CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Phase1L1TJetCalibrator Class Reference

#include <Phase1L1TJetCalibrator.cc>

Inheritance diagram for Phase1L1TJetCalibrator:
edm::stream::EDProducer<>

Public Member Functions

 Phase1L1TJetCalibrator (const edm::ParameterSet &)
 
 ~Phase1L1TJetCalibrator () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::vector< std::vector< double > > _jetCalibrationFactorsPtBins
 
std::vector< double > absEtaBinning_
 
std::vector< edm::ParameterSetcalibration_
 
edm::EDGetTokenT< std::vector< reco::CaloJet > > inputCollectionTag_
 
std::vector< std::vector< double > > jetCalibrationFactorsBinnedInEta_
 
size_t nBinsEta_
 
std::string outputCollectionName_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Description: Applies calibrations to reco::calojets

INPUT PARAMETERS ***
inputCollectionTag, InputTag, collection of reco calojet to calibrate
absEtaBinning, vdouble with eta bins, allows for non-homogeneous binning
calibration, VPSet with calibration factors
outputCollectionName, string, output collection tag name

Definition at line 43 of file Phase1L1TJetCalibrator.cc.

Constructor & Destructor Documentation

◆ Phase1L1TJetCalibrator()

Phase1L1TJetCalibrator::Phase1L1TJetCalibrator ( const edm::ParameterSet iConfig)
explicit

Definition at line 76 of file Phase1L1TJetCalibrator.cc.

References _jetCalibrationFactorsPtBins, calibration_, jetCalibrationFactorsBinnedInEta_, outputCollectionName_, and muonDTDigis_cfi::pset.

77  : inputCollectionTag_(edm::EDGetTokenT<std::vector<reco::CaloJet>>(
78  consumes<std::vector<reco::CaloJet>>(iConfig.getParameter<edm::InputTag>("inputCollectionTag")))),
79  absEtaBinning_(iConfig.getParameter<std::vector<double>>("absEtaBinning")),
80  nBinsEta_(absEtaBinning_.size() - 1),
81  calibration_(iConfig.getParameter<std::vector<edm::ParameterSet>>("calibration")),
82  outputCollectionName_(iConfig.getParameter<std::string>("outputCollectionName"))
83 
84 {
85  for (const auto& pset : calibration_) {
86  _jetCalibrationFactorsPtBins.emplace_back(pset.getParameter<std::vector<double>>("l1tPtBins"));
87  jetCalibrationFactorsBinnedInEta_.emplace_back(pset.getParameter<std::vector<double>>("l1tCalibrationFactors"));
88  }
89 
90  produces<std::vector<reco::CaloJet>>(outputCollectionName_).setBranchAlias(outputCollectionName_);
91 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< edm::ParameterSet > calibration_
std::vector< std::vector< double > > _jetCalibrationFactorsPtBins
std::vector< double > absEtaBinning_
std::vector< std::vector< double > > jetCalibrationFactorsBinnedInEta_
edm::EDGetTokenT< std::vector< reco::CaloJet > > inputCollectionTag_

◆ ~Phase1L1TJetCalibrator()

Phase1L1TJetCalibrator::~Phase1L1TJetCalibrator ( )
override

Definition at line 93 of file Phase1L1TJetCalibrator.cc.

93 {}

Member Function Documentation

◆ fillDescriptions()

void Phase1L1TJetCalibrator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 169 of file Phase1L1TJetCalibrator.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, HLT_2022v12_cff::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

169  {
171  desc.add<edm::InputTag>("inputCollectionTag",
172  edm::InputTag("Phase1L1TJetProducer", "UncalibratedPhase1L1TJetFromPfCandidates"));
173  desc.add<std::vector<double>>("absEtaBinning");
174  std::vector<edm::ParameterSet> vDefaults;
176  validator.add<double>("etaMax");
177  validator.add<double>("etaMin");
178  validator.add<std::vector<double>>("l1tCalibrationFactors");
179  validator.add<std::vector<double>>("l1tPtBins");
180  desc.addVPSet("calibration", validator, vDefaults);
181  desc.add<std::string>("outputCollectionName", "Phase1L1TJetFromPfCandidates");
182  descriptions.add("Phase1L1TJetCalibrator", desc);
183 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void Phase1L1TJetCalibrator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 100 of file Phase1L1TJetCalibrator.cc.

References _jetCalibrationFactorsPtBins, absEtaBinning_, PVValHelper::eta, etaBin(), iEvent, inputCollectionTag_, jetCalibrationFactorsBinnedInEta_, l1tSlwPFPuppiJetsCorrected_cfi::l1tCalibrationFactors, l1tSlwPFPuppiJetsCorrected_cfi::l1tPtBins, LogDebug, eostools::move(), outputCollectionName_, DiDispStaMuonMonitor_cfi::pt, reco::LeafCandidate::pt(), muonRecoAnalyzer_cfi::ptBin, jetUpdater_cfi::sort, and pfDeepBoostedJetPreprocessParams_cfi::upper_bound.

100  {
101  edm::Handle<std::vector<reco::CaloJet>> inputCollectionHandle;
102  iEvent.getByToken(inputCollectionTag_, inputCollectionHandle);
103 
104  auto calibratedCollectionPtr = std::make_unique<std::vector<reco::CaloJet>>();
105 
106  // for each candidate:
107  // 1 get pt and eta
108  // 2 run a dicotomic search on the eta vector to find the eta index
109  // 3 fetch the corresponding calibration elements
110  // 4 run a dicotomic search on the pt binning to find the pt index
111  // 5 fetch the calibration factor
112  // 6 update the candidate pt by applying the calibration factor
113  // 7 store calibrated candidate in a new collection
114 
115  calibratedCollectionPtr->reserve(inputCollectionHandle->size());
116 
117  for (const auto& candidate : *inputCollectionHandle) {
118  // 1
119  float pt = candidate.pt();
120  float eta = candidate.eta();
121 
122  //2
123  auto etaBin = upper_bound(absEtaBinning_.begin(), absEtaBinning_.end(), fabs(eta));
124  int etaIndex = etaBin - absEtaBinning_.begin() - 1;
125 
126  //3
127  const std::vector<double>& l1tPtBins = _jetCalibrationFactorsPtBins[etaIndex];
128  const std::vector<double>& l1tCalibrationFactors = jetCalibrationFactorsBinnedInEta_[etaIndex];
129 
130  //4
131  auto ptBin = upper_bound(l1tPtBins.begin(), l1tPtBins.end(), pt);
132  int ptBinIndex = ptBin - l1tPtBins.begin() - 1;
133 
134  //5
135  const double& l1tCalibrationFactor = l1tCalibrationFactors[ptBinIndex];
136 
137  //6 and 7
138  reco::Candidate::PolarLorentzVector candidateP4(candidate.polarP4());
139  candidateP4.SetPt(candidateP4.pt() * l1tCalibrationFactor);
140  calibratedCollectionPtr->emplace_back(candidate);
141  calibratedCollectionPtr->back().setP4(candidateP4);
142 
143 #ifdef DEBUG
144  if (newCandidate->pt() < 0) {
145  LogDebug("Phase1L1TJetCalibrator") << "######################" << std::endl;
146  LogDebug("Phase1L1TJetCalibrator") << "PRE-CALIBRATION " << std::endl;
147  LogDebug("Phase1L1TJetCalibrator") << "\t Jet properties (pt, eta, phi, pile-up): " << candidate.pt() << "\t"
148  << candidate.eta() << "\t" LogDebug("Phase1L1TJetCalibrator")
149  << candidate.phi() << "\t" << candidate.pileup() << std::endl;
150  LogDebug("Phase1L1TJetCalibrator") << "CALIBRATION " << std::endl;
151  LogDebug("Phase1L1TJetCalibrator") << "\t Using eta - pt - factor " << *etaBin << " - " << *ptBin << " - "
152  << l1tCalibrationFactor LogDebug("Phase1L1TJetCalibrator") << std::endl;
153  LogDebug("Phase1L1TJetCalibrator") << "POST-CALIBRATION " << std::endl;
154  LogDebug("Phase1L1TJetCalibrator") << "\t Jet properties (pt, eta, phi, pile-up): " << newCandidate->pt() << "\t"
155  << newCandidate->eta() << "\t" << newCandidate->phi() << "\t"
156  << newCandidate->pileup() << std::endl;
157  }
158 #endif
159  }
160 
161  // finally, sort the collection by pt
162  std::sort(calibratedCollectionPtr->begin(),
163  calibratedCollectionPtr->end(),
164  [](const reco::CaloJet& jet1, const reco::CaloJet& jet2) { return jet1.pt() > jet2.pt(); });
165 
166  iEvent.put(std::move(calibratedCollectionPtr), outputCollectionName_);
167 }
Jets made from CaloTowers.
Definition: CaloJet.h:27
double pt() const final
transverse momentum
int iEvent
Definition: GenABIO.cc:224
std::vector< std::vector< double > > _jetCalibrationFactorsPtBins
std::vector< double > absEtaBinning_
std::vector< std::vector< double > > jetCalibrationFactorsBinnedInEta_
edm::EDGetTokenT< std::vector< reco::CaloJet > > inputCollectionTag_
int etaBin(const l1t::HGCalMulticluster *cl)
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

Member Data Documentation

◆ _jetCalibrationFactorsPtBins

std::vector<std::vector<double> > Phase1L1TJetCalibrator::_jetCalibrationFactorsPtBins
private

Definition at line 60 of file Phase1L1TJetCalibrator.cc.

Referenced by Phase1L1TJetCalibrator(), and produce().

◆ absEtaBinning_

std::vector<double> Phase1L1TJetCalibrator::absEtaBinning_
private

Definition at line 54 of file Phase1L1TJetCalibrator.cc.

Referenced by produce().

◆ calibration_

std::vector<edm::ParameterSet> Phase1L1TJetCalibrator::calibration_
private

Definition at line 56 of file Phase1L1TJetCalibrator.cc.

Referenced by Phase1L1TJetCalibrator().

◆ inputCollectionTag_

edm::EDGetTokenT<std::vector<reco::CaloJet> > Phase1L1TJetCalibrator::inputCollectionTag_
private

Definition at line 53 of file Phase1L1TJetCalibrator.cc.

Referenced by produce().

◆ jetCalibrationFactorsBinnedInEta_

std::vector<std::vector<double> > Phase1L1TJetCalibrator::jetCalibrationFactorsBinnedInEta_
private

Definition at line 59 of file Phase1L1TJetCalibrator.cc.

Referenced by Phase1L1TJetCalibrator(), and produce().

◆ nBinsEta_

size_t Phase1L1TJetCalibrator::nBinsEta_
private

Definition at line 55 of file Phase1L1TJetCalibrator.cc.

◆ outputCollectionName_

std::string Phase1L1TJetCalibrator::outputCollectionName_
private

Definition at line 57 of file Phase1L1TJetCalibrator.cc.

Referenced by Phase1L1TJetCalibrator(), and produce().