From f11c106a21676b2b09afe22e052a0cd5203e5859 Mon Sep 17 00:00:00 2001
From: "W. David Dagenhart" <wdd@fnal.gov>
Date: Tue, 25 Oct 2022 21:07:42 +0200
Subject: [PATCH] Remove deprecated JetPartonCorrector

---
 JetMETCorrections/JetParton/BuildFile.xml     |   8 -
 .../data/PartonScale_IterativeCone0.5.txt     |  19 --
 .../data/PartonScale_IterativeCone0.7.txt     |  19 --
 .../JetParton/interface/JetPartonCorrector.h  |  39 ---
 .../python/JetPartonCorrections_cff.py        |  37 ---
 .../JetParton/src/JetPartonCorrector.cc       | 229 ------------------
 6 files changed, 351 deletions(-)
 delete mode 100644 JetMETCorrections/JetParton/BuildFile.xml
 delete mode 100644 JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.5.txt
 delete mode 100644 JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.7.txt
 delete mode 100644 JetMETCorrections/JetParton/interface/JetPartonCorrector.h
 delete mode 100644 JetMETCorrections/JetParton/python/JetPartonCorrections_cff.py
 delete mode 100644 JetMETCorrections/JetParton/src/JetPartonCorrector.cc

diff --git a/JetMETCorrections/JetParton/BuildFile.xml b/JetMETCorrections/JetParton/BuildFile.xml
deleted file mode 100644
index 55e5ee0d88f8a..0000000000000
--- a/JetMETCorrections/JetParton/BuildFile.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<use name="clhep"/>
-<use name="DataFormats/Common"/>
-<use name="JetMETCorrections/Objects"/>
-<use name="FWCore/Framework"/>
-<use name="FWCore/ParameterSet"/>
-<export>
-  <lib name="1"/>
-</export>
diff --git a/JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.5.txt b/JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.5.txt
deleted file mode 100644
index cb62b1ac0fdd5..0000000000000
--- a/JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.5.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# light q: type = 1, gluon:type = 2, QCD mixture: type = 3
-0.250 1 1.0000  0.60  5.00
-0.990 1 1.0000  0.60  5.00
-1.740 1 1.0000  0.60  5.00
-2.240 1 1.0000  0.60  5.00
-2.910 1 1.0000  0.60  5.50
-3.840 1 0.9975  0.60  6.00
-0.250 2 1.0015  2.50  3.00
-0.990 2 1.0015  2.50  3.00
-1.740 2 1.0015  2.50  3.00
-2.240 2 1.0015  2.50  3.10
-2.910 2 1.0015  2.50  3.50
-3.840 2 1.0015  2.50  4.00
-0.250 3 1.0025  1.88  5.00
-0.990 3 1.0025  1.88  5.00
-1.740 3 1.0025  1.85  5.00
-2.240 3 1.0025  1.80  5.10
-2.910 3 1.0025  1.65  5.50
-3.840 3 1.0025  1.35  6.50
diff --git a/JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.7.txt b/JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.7.txt
deleted file mode 100644
index 50e64812f494d..0000000000000
--- a/JetMETCorrections/JetParton/data/PartonScale_IterativeCone0.7.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# light q: type = 1, gluon:type = 2, QCD mixture: type = 3
-0.250 1 1.0020  0.00  1.00
-0.990 1 1.0020  0.00  1.00
-1.740 1 1.0020  0.00  1.00
-2.240 1 1.0020  0.00  1.00
-2.910 1 1.0020  0.00  1.00
-3.840 1 1.0010  0.00  1.00
-0.250 2 1.0010  0.70  5.00
-0.990 2 1.0010  0.65  5.00
-1.740 2 1.0010  0.64  5.00
-2.240 2 1.0010  0.65  5.00
-2.910 2 1.0010  0.70  5.00
-3.840 2 1.0010  0.80  5.00
-0.250 3 1.0035  0.40  8.00
-0.990 3 1.0035  0.35  8.50
-1.740 3 1.0035  0.30  9.25
-2.240 3 1.0035  0.26 10.00
-2.910 3 1.0035  0.26 10.00
-3.840 3 1.0035  0.26 10.00
diff --git a/JetMETCorrections/JetParton/interface/JetPartonCorrector.h b/JetMETCorrections/JetParton/interface/JetPartonCorrector.h
deleted file mode 100644
index 644de9f5c3f5e..0000000000000
--- a/JetMETCorrections/JetParton/interface/JetPartonCorrector.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef JetPartonCorrector_h
-#define JetPartonCorrector_h
-
-///
-/// jet parton energy corrections
-///
-
-#include <map>
-#include <string>
-#include <vector>
-#include "JetMETCorrections/Objects/interface/JetCorrector.h"
-namespace edm {
-  class ParameterSet;
-}
-
-namespace JetPartonNamespace {
-  class ParametrizationJetParton;
-  class UserPartonMixture;
-}  // namespace JetPartonNamespace
-
-class JetPartonCorrector : public JetCorrector {
-public:
-  JetPartonCorrector(const edm::ParameterSet& fConfig);
-  ~JetPartonCorrector() override;
-
-  double correction(const LorentzVector& fJet) const override;
-
-  void setParameters(std::string aCalibrationType, double aJetFinderRadius, int aPartonMixture);
-
-  /// if correction needs event information
-  bool eventRequired() const override { return false; }
-
-private:
-  typedef std::map<double, JetPartonNamespace::ParametrizationJetParton*> ParametersMap;
-  ParametersMap parametrization;
-  int thePartonMixture;
-  double theJetFinderRadius;
-};
-#endif
diff --git a/JetMETCorrections/JetParton/python/JetPartonCorrections_cff.py b/JetMETCorrections/JetParton/python/JetPartonCorrections_cff.py
deleted file mode 100644
index 6957af9baf239..0000000000000
--- a/JetMETCorrections/JetParton/python/JetPartonCorrections_cff.py
+++ /dev/null
@@ -1,37 +0,0 @@
-import FWCore.ParameterSet.Config as cms
-
-# File: JetCorrections.cff
-# Author: O. Kodolova
-# Date: 1/24/07
-#
-# JetParton corrections for the icone5, icone7 jets. (ORCA derived)
-# 
-JetPartonCorrectorIcone5 = cms.ESSource("JetPartonCorrectionService",
-    MixtureType = cms.int32(3),
-    Radius = cms.double(0.5),
-    tagName = cms.string('PartonScale_IterativeCone0.5.txt'),
-    label = cms.string('JetPartonCorrectorIcone5')
-)
-
-es_prefer_JetPartonCorrectorIcone5 = cms.ESPrefer("JetPartonCorrectionService","JetPartonCorrectorIcone5")
-JetPartonCorrectorIcone7 = cms.ESSource("JetPartonCorrectionService",
-    MixtureType = cms.int32(3),
-    Radius = cms.double(0.7),
-    tagName = cms.string('PartonScale_IterativeCone0.7.txt'),
-    label = cms.string('JetPartonCorrectorIcone7')
-)
-
-JetPartonCorJetIcone5 = cms.EDProducer("JetCorrectionProducer",
-    src = cms.InputTag("iterativeCone5CaloJets"),
-    correctors = cms.vstring('JetPartonCorrectorIcone5'),
-    alias = cms.untracked.string('JetPartonCorJetIcone5')
-)
-
-JetPartonCorJetIcone7 = cms.EDProducer("JetCorrectionProducer",
-    src = cms.InputTag("iterativeCone7CaloJets"),
-    correctors = cms.vstring('JetPartonCorrectorIcone7'),
-    alias = cms.untracked.string('JetPartonCorJetIcone7')
-)
-
-JetPartonCorrections = cms.Sequence(JetPartonCorJetIcone5*JetPartonCorJetIcone7)
-
diff --git a/JetMETCorrections/JetParton/src/JetPartonCorrector.cc b/JetMETCorrections/JetParton/src/JetPartonCorrector.cc
deleted file mode 100644
index aca8b882e626e..0000000000000
--- a/JetMETCorrections/JetParton/src/JetPartonCorrector.cc
+++ /dev/null
@@ -1,229 +0,0 @@
-#include "JetMETCorrections/JetParton/interface/JetPartonCorrector.h"
-#include "FWCore/ParameterSet/interface/FileInPath.h"
-#include "FWCore/Framework/interface/Event.h"
-#include "DataFormats/Common/interface/Handle.h"
-#include "FWCore/Framework/interface/EventSetup.h"
-#include "FWCore/ParameterSet/interface/ParameterSet.h"
-#include "FWCore/MessageLogger/interface/MessageLogger.h"
-#include <vector>
-#include <fstream>
-#include <sstream>
-using namespace std;
-
-namespace JetPartonNamespace {
-  class UserPartonMixture {
-  public:
-    UserPartonMixture() {}
-    virtual ~UserPartonMixture() {}
-    virtual double mixt(double et, double eta) {
-      // The mixture of quark and gluons corresponds to QCD jets.
-      double f = 0.2 + et / 1000. * (1. + .13 * exp(eta));
-      return f;
-    }
-  };
-
-  class ParametrizationJetParton {
-  public:
-    ParametrizationJetParton(int thePartonMixture,
-                             const vector<double>& x,
-                             const vector<double>& y,
-                             const vector<double>& z) {
-      type = thePartonMixture;
-      pq = x;
-      pg = y;
-      pqcd = z;
-    }
-
-    double value(double arg1, double arg2) const;
-
-  private:
-    int type;
-    std::vector<double> pq;
-    std::vector<double> pg;
-    std::vector<double> pqcd;
-  };
-
-  double ParametrizationJetParton::value(double e, double eta) const {
-    double enew(e);
-    double x = e;
-    double y = eta;
-
-    if (abs(x - pq[2]) < pq[1] / pq[0] || abs(x - pg[2]) < pg[1] / pg[0] || abs(x - pqcd[2]) < pqcd[1] / pqcd[0]) {
-      return enew;
-    }
-
-    double kjetq = pq[0] - pq[1] / (x - pq[2]);
-    double kjetg = pg[0] - pg[1] / (x - pg[2]);
-    double kjetqcd = pqcd[0] - pqcd[1] / (x - pqcd[2]);
-
-    switch (type) {
-      case 1: {
-        if (abs(kjetq) > 0.0001)
-          enew = e / kjetq;
-        break;
-      }
-      case 2: {
-        if (abs(kjetg) > 0.0001)
-          enew = e / kjetg;
-        break;
-      }
-      case 3: {
-        if (abs(kjetqcd) > 0.0001)
-          enew = e / kjetqcd;
-        break;
-      }
-      case 4: {
-        cout << "[Jets] JetPartonCorrector: Warning! Calibration to b-quark - does not implemented yet. Light quark "
-                "calibration is used instead "
-             << endl;
-        if (abs(kjetq) > 0.0001)
-          enew = e / kjetq;
-        break;
-      }
-      case 100: {
-        UserPartonMixture upm;
-        double f = upm.mixt(x, y);
-        double kjet = (f * kjetq + kjetg) / (f + 1);
-        if (abs(kjet) > 0.0001)
-          enew = e / kjet;
-        break;
-      }
-
-      default:
-        cerr << "[Jets] JetPartonCorrector: Error! unknown parametrization type = " << type
-             << " No correction applied ..." << endl;
-        break;
-    }
-    return enew;
-  }
-
-  class JetPartonCalibrationParameterSet {
-  public:
-    JetPartonCalibrationParameterSet(string tag);
-    int neta() { return etavector.size(); }
-    double eta(int ieta) { return etavector[ieta]; }
-    int type(int ieta) { return typevector[ieta]; }
-    const vector<double>& parameters(int ieta) { return pars[ieta]; }
-    bool valid() { return !etavector.empty(); }
-
-  private:
-    vector<double> etavector;
-    vector<int> typevector;
-    vector<vector<double> > pars;
-  };
-
-  JetPartonCalibrationParameterSet::JetPartonCalibrationParameterSet(string tag) {
-    std::string file = "JetMETCorrections/JetParton/data/" + tag + ".txt";
-
-    edm::FileInPath f1(file);
-
-    std::ifstream in((f1.fullPath()).c_str());
-
-    //  if ( f1.isLocal() ){
-    string line;
-    while (std::getline(in, line)) {
-      if (line.empty() || line[0] == '#')
-        continue;
-      istringstream linestream(line);
-      double par;
-      int type;
-      linestream >> par >> type;
-      etavector.push_back(par);
-      typevector.push_back(type);
-      pars.push_back(vector<double>());
-      while (linestream >> par)
-        pars.back().push_back(par);
-    }
-    //  }
-    //  else
-    //    if (tag!="no") { cout<<"The file \""<<file<<"\" was not found in path \""<<f1.fullPath()<<"\"."<<endl; }
-  }
-}  // namespace JetPartonNamespace
-
-JetPartonCorrector::JetPartonCorrector(const edm::ParameterSet& fConfig) {
-  thePartonMixture = fConfig.getParameter<int>("MixtureType");
-  theJetFinderRadius = fConfig.getParameter<double>("Radius");
-  setParameters(fConfig.getParameter<std::string>("tagName"), theJetFinderRadius, thePartonMixture);
-}
-
-JetPartonCorrector::~JetPartonCorrector() {
-  for (ParametersMap::iterator ip = parametrization.begin(); ip != parametrization.end(); ip++)
-    delete ip->second;
-}
-
-void JetPartonCorrector::setParameters(std::string aCalibrationType, double aJetFinderRadius, int aPartonMixture) {
-  theJetFinderRadius = aJetFinderRadius;
-  thePartonMixture = aPartonMixture;
-
-  JetPartonNamespace::JetPartonCalibrationParameterSet pset(aCalibrationType);
-
-  if ((!pset.valid()) && (aCalibrationType != "no")) {
-    edm::LogError("JetPartonCorrector: Jet Corrections not found ")
-        << aCalibrationType
-        << " not found! Cannot apply any correction ... For JetPlusTrack calibration only radii 0.5 and 0.7 are "
-           "included for JetParton"
-        << endl;
-    return;
-  }
-  if (aCalibrationType == "no")
-    return;
-
-  map<int, vector<double> > pq;
-  map<int, vector<double> > pg;
-  map<int, vector<double> > pqcd;
-  int iq = 0;
-  int ig = 0;
-  int iqcd = 0;
-  for (int ieta = 0; ieta < pset.neta(); ieta++) {
-    if (pset.type(ieta) == 1) {
-      pq[iq] = pset.parameters(ieta);
-      iq++;
-    };
-    if (pset.type(ieta) == 2) {
-      pg[ig] = pset.parameters(ieta);
-      ig++;
-    };
-    if (pset.type(ieta) == 3) {
-      pqcd[iqcd] = pset.parameters(ieta);
-      iqcd++;
-    };
-  }
-
-  for (int ieta = 0; ieta < iq; ieta++) {
-    parametrization[pset.eta(ieta)] = new JetPartonNamespace::ParametrizationJetParton(
-        thePartonMixture, (*pq.find(ieta)).second, (*pg.find(ieta)).second, (*pqcd.find(ieta)).second);
-  }
-}
-double JetPartonCorrector::correction(const LorentzVector& fJet) const {
-  if (parametrization.empty()) {
-    return 1.;
-  }
-
-  double et = fJet.Et();
-  double eta = fabs(fJet.Eta());
-
-  //if(eta<10) { eta=abs(fJet.getY()); }
-
-  double etnew;
-  std::map<double, JetPartonNamespace::ParametrizationJetParton*>::const_iterator ip = parametrization.upper_bound(eta);
-  if (ip == parametrization.begin()) {
-    etnew = ip->second->value(et, eta);
-  } else if (ip == parametrization.end()) {
-    etnew = (--ip)->second->value(et, eta);
-  } else {
-    double eta2 = ip->first;
-    double et2 = ip->second->value(et, eta);
-    ip--;
-    double eta1 = ip->first;
-    double et1 = ip->second->value(et, eta);
-
-    etnew = (eta2 * et1 - eta1 * et2 + eta * et2 - eta * et1) / (eta2 - eta1);
-  }
-  cout << " JetParton::The new energy found " << etnew << " " << et << endl;
-  float mScale = 1000.;
-
-  if (et > 0.001)
-    mScale = etnew / et;
-
-  return mScale;
-}