CMS 3D CMS Logo

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

#include <RegressionEnergyPatElectronProducer.h>

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

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 RegressionEnergyPatElectronProducer (const edm::ParameterSet &)
 
 ~RegressionEnergyPatElectronProducer () 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
 

Private Attributes

const CaloGeometrycaloGeometry_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeomToken_
 
bool debug_
 
const CaloTopologyecalTopology_
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordecalTopoToken_
 
uint32_t energyRegressionType_
 
bool geomInitialized_
 
uint32_t inputCollectionType_
 
edm::EDGetTokenT< reco::GsfElectronCollectioninputGsfElectronsToken_
 
edm::EDGetTokenT< pat::ElectronCollectioninputPatElectronsToken_
 
std::string nameEnergyErrorReg_
 
std::string nameEnergyReg_
 
unsigned nElectrons_
 
bool producePatElectrons_
 
bool produceValueMaps_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitCollectionEBToken_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitCollectionEEToken_
 
ElectronEnergyRegressionEvaluateregressionEvaluator_
 
std::string regressionInputFile_
 
edm::EDGetTokenT< double > rhoInputToken_
 
bool useReducedRecHits_
 
edm::EDGetTokenT< reco::VertexCollectionverticesInputToken_
 

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

Definition at line 20 of file RegressionEnergyPatElectronProducer.h.

Constructor & Destructor Documentation

◆ RegressionEnergyPatElectronProducer()

RegressionEnergyPatElectronProducer::RegressionEnergyPatElectronProducer ( const edm::ParameterSet cfg)
explicit

Definition at line 17 of file RegressionEnergyPatElectronProducer.cc.

References caloGeomToken_, looper::cfg, debug_, ecalTopoToken_, energyRegressionType_, deDxTools::esConsumes(), Exception, geomInitialized_, ElectronEnergyRegressionEvaluate::initialize(), inputCollectionType_, inputGsfElectronsToken_, inputPatElectronsToken_, ElectronEnergyRegressionEvaluate::kNoTrkVar, ElectronEnergyRegressionEvaluate::kWithSubCluVar, ElectronEnergyRegressionEvaluate::kWithTrkVar, nameEnergyErrorReg_, nameEnergyReg_, produceValueMaps_, recHitCollectionEBToken_, recHitCollectionEEToken_, regressionEvaluator_, regressionInputFile_, rhoInputToken_, AlCaHLTBitMon_QueryRunRegistry::string, useReducedRecHits_, and verticesInputToken_.

17  {
19  mayConsume<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("inputElectronsTag"));
20  inputPatElectronsToken_ = mayConsume<pat::ElectronCollection>(cfg.getParameter<edm::InputTag>("inputElectronsTag"));
21  inputCollectionType_ = cfg.getParameter<uint32_t>("inputCollectionType");
22  rhoInputToken_ = consumes<double>(cfg.getParameter<edm::InputTag>("rhoCollection"));
23  verticesInputToken_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertexCollection"));
24  energyRegressionType_ = cfg.getParameter<uint32_t>("energyRegressionType");
25  regressionInputFile_ = cfg.getParameter<std::string>("regressionInputFile");
26  recHitCollectionEBToken_ = mayConsume<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitCollectionEB"));
27  recHitCollectionEEToken_ = mayConsume<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitCollectionEE"));
30  nameEnergyReg_ = cfg.getParameter<std::string>("nameEnergyReg");
31  nameEnergyErrorReg_ = cfg.getParameter<std::string>("nameEnergyErrorReg");
32  debug_ = cfg.getUntrackedParameter<bool>("debug");
33  useReducedRecHits_ = cfg.getParameter<bool>("useRecHitCollections");
34  produceValueMaps_ = cfg.getParameter<bool>("produceValueMaps");
35 
36  // if Gsf Electrons; useReducedRecHits should be used)
38  throw cms::Exception("InconsistentParameters")
39  << " *** Inconsistent configuration : if you read GsfElectrons, you should set useRecHitCollections to true "
40  "and provide the correcte values to recHitCollectionEB and recHitCollectionEE (most probably "
41  "reducedEcalRecHitsEB and reducedEcalRecHitsEE )"
42  << std::endl;
43  }
44 
46  edm::LogPrint("RegressionEnergyPatElectronProducer")
47  << " You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the results. "
48  "In that case, it does not nothing !! ";
49  }
50 
51  if (inputCollectionType_ == 0) {
52  // do nothing
53  } else if (inputCollectionType_ == 1) {
54  produces<pat::ElectronCollection>();
55  } else {
56  throw cms::Exception("InconsistentParameters")
57  << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) ";
58  }
59 
60  //set regression type
62  if (energyRegressionType_ == 1)
64  else if (energyRegressionType_ == 2)
66  else if (energyRegressionType_ == 3)
68 
69  //load weights and initialize
72 
73  if (produceValueMaps_) {
74  produces<edm::ValueMap<double> >(nameEnergyReg_);
75  produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
76  }
77 
78  //****************************************************************************************
79  //set up regression calculator
80  //****************************************************************************************
81 
82  geomInitialized_ = false;
83 
84  edm::LogPrint("RegressionEnergyPatElectronProducer") << " Finished initialization ";
85 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopoToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
edm::EDGetTokenT< reco::VertexCollection > verticesInputToken_
void initialize(std::string weightsFile, ElectronEnergyRegressionEvaluate::ElectronEnergyRegressionType type)
Log< level::Warning, true > LogPrint
ElectronEnergyRegressionEvaluate * regressionEvaluator_
edm::EDGetTokenT< reco::GsfElectronCollection > inputGsfElectronsToken_
edm::EDGetTokenT< pat::ElectronCollection > inputPatElectronsToken_

◆ ~RegressionEnergyPatElectronProducer()

RegressionEnergyPatElectronProducer::~RegressionEnergyPatElectronProducer ( )
override

Definition at line 87 of file RegressionEnergyPatElectronProducer.cc.

References regressionEvaluator_.

87 { delete regressionEvaluator_; }
ElectronEnergyRegressionEvaluate * regressionEvaluator_

Member Function Documentation

◆ produce()

void RegressionEnergyPatElectronProducer::produce ( edm::Event event,
const edm::EventSetup setup 
)
override

Definition at line 89 of file RegressionEnergyPatElectronProducer.cc.

References cms::cuda::assert(), caloGeometry_, caloGeomToken_, reco::LeafCandidate::charge(), SuperClusterHelper::clustersSize(), reco::GsfElectron::correctEcalEnergy(), reco::GsfElectron::correctMomentum(), debug_, SuperClusterHelper::e2nd(), SuperClusterHelper::e2x5Bottom(), SuperClusterHelper::e2x5Left(), SuperClusterHelper::e2x5Max(), SuperClusterHelper::e2x5Right(), SuperClusterHelper::e2x5Top(), SuperClusterHelper::e3x3(), SuperClusterHelper::e5x5(), SuperClusterHelper::eBottom(), reco::GsfElectron::ecalDrivenSeed(), ecalTopology_, ecalTopoToken_, SuperClusterHelper::eESClusters(), SuperClusterHelper::eLeft(), SuperClusterHelper::eMax(), energyRegressionType_, SuperClusterHelper::eRight(), SuperClusterHelper::esClusterEnergy(), SuperClusterHelper::esClusterEta(), SuperClusterHelper::esClusterPhi(), SuperClusterHelper::eSubClusters(), reco::GsfElectron::eSuperClusterOverP(), SuperClusterHelper::eta(), reco::LeafCandidate::eta(), SuperClusterHelper::etaCrySeed(), SuperClusterHelper::etaWidth(), SuperClusterHelper::eTop(), reco::GsfElectron::fbrem(), edm::helper::Filler< Map >::fill(), geomInitialized_, SuperClusterHelper::hadronicOverEm(), SuperClusterHelper::ietaSeed(), inputCollectionType_, inputGsfElectronsToken_, inputPatElectronsToken_, edm::helper::Filler< Map >::insert(), SuperClusterHelper::iphiSeed(), reco::GsfElectron::isEB(), reco::GsfElectron::isEBEtaGap(), reco::GsfElectron::isEBPhiGap(), reco::GsfElectron::isEEDeeGap(), ElectronEnergyRegressionEvaluate::isInitialized(), eostools::move(), nameEnergyErrorReg_, nameEnergyReg_, nElectrons_, SuperClusterHelper::nPreshowerClusters(), reco::LeafCandidate::p(), reco::GsfElectron::p4(), patElectronEAIsoCorrectionProducer_cfi::patElectrons, SuperClusterHelper::phi(), reco::LeafCandidate::phi(), SuperClusterHelper::phiCrySeed(), SuperClusterHelper::phiWidth(), SuperClusterHelper::preshowerEnergy(), SuperClusterHelper::preshowerEnergyOverRaw(), produceValueMaps_, edm::Handle< T >::product(), reco::LeafCandidate::pt(), SuperClusterHelper::r9(), SuperClusterHelper::rawEnergy(), recHitCollectionEBToken_, recHitCollectionEEToken_, FastTrackerRecHitMaskProducer_cfi::recHits, regressionEvaluator_, ElectronEnergyRegressionEvaluate::regressionUncertaintyNoTrkVar(), ElectronEnergyRegressionEvaluate::regressionUncertaintyWithSubClusters(), ElectronEnergyRegressionEvaluate::regressionUncertaintyWithTrkVar(), ElectronEnergyRegressionEvaluate::regressionValueNoTrkVar(), ElectronEnergyRegressionEvaluate::regressionValueWithSubClusters(), ElectronEnergyRegressionEvaluate::regressionValueWithTrkVar(), rho, rhoInputToken_, SuperClusterHelper::seedEnergy(), SuperClusterHelper::seedEta(), SuperClusterHelper::seedPhi(), SuperClusterHelper::sep(), pat::Electron::setEcalRegressionEnergy(), singleTopDQM_cfi::setup, SuperClusterHelper::sigmaIetaIeta(), SuperClusterHelper::spp(), SuperClusterHelper::subClusterE3x3(), SuperClusterHelper::subClusterEmax(), SuperClusterHelper::subClusterEnergy(), SuperClusterHelper::subClusterEta(), SuperClusterHelper::subClusterPhi(), reco::GsfElectron::trackMomentumAtVtx(), reco::GsfElectron::trackMomentumError(), useReducedRecHits_, and verticesInputToken_.

89  {
91  if (!geomInitialized_) {
94  geomInitialized_ = true;
95  }
96 
97  //**************************************************************************
98  //Get Number of Vertices
99  //**************************************************************************
101  event.getByToken(verticesInputToken_, hVertexProduct);
102  const reco::VertexCollection inVertices = *(hVertexProduct.product());
103 
104  // loop through all vertices
105  Int_t nvertices = 0;
106  for (reco::VertexCollection::const_iterator inV = inVertices.begin(); inV != inVertices.end(); ++inV) {
107  //pass these vertex cuts
108  if (inV->ndof() >= 4 && inV->position().Rho() <= 2.0 && fabs(inV->z()) <= 24.0) {
109  nvertices++;
110  }
111  }
112 
113  //**************************************************************************
114  //Get Rho
115  //**************************************************************************
116  double rho = 0;
117  edm::Handle<double> hRhoKt6PFJets;
118  event.getByToken(rhoInputToken_, hRhoKt6PFJets);
119  rho = (*hRhoKt6PFJets);
120 
121  //*************************************************************************
122  // Get the RecHits
123  //************************************************************************
124 
127  if (useReducedRecHits_) {
128  event.getByToken(recHitCollectionEBToken_, pEBRecHits);
129  event.getByToken(recHitCollectionEEToken_, pEERecHits);
130  }
131 
134  if (inputCollectionType_ == 0) {
135  event.getByToken(inputGsfElectronsToken_, gsfCollectionH);
136  nElectrons_ = gsfCollectionH->size();
137  }
138  if (inputCollectionType_ == 1) {
139  event.getByToken(inputPatElectronsToken_, patCollectionH);
140  nElectrons_ = patCollectionH->size();
141  }
142 
143  // prepare the two even if only one is used
144  std::unique_ptr<pat::ElectronCollection> patElectrons(new pat::ElectronCollection);
145 
146  // Fillers for ValueMaps:
147  std::unique_ptr<edm::ValueMap<double> > regrEnergyMap(new edm::ValueMap<double>());
148  edm::ValueMap<double>::Filler energyFiller(*regrEnergyMap);
149 
150  std::unique_ptr<edm::ValueMap<double> > regrEnergyErrorMap(new edm::ValueMap<double>());
151  edm::ValueMap<double>::Filler energyErrorFiller(*regrEnergyErrorMap);
152 
153  // Reserve the vectors with outputs
154  std::vector<double> energyValues;
155  std::vector<double> energyErrorValues;
156  energyValues.reserve(nElectrons_);
157  energyErrorValues.reserve(nElectrons_);
158 
159  for (unsigned iele = 0; iele < nElectrons_; ++iele) {
160  const reco::GsfElectron* ele = (inputCollectionType_ == 0) ? &(*gsfCollectionH)[iele] : &(*patCollectionH)[iele];
161  if (debug_) {
162  edm::LogPrint("RegressionEnergyPatElectronProducer")
163  << "***********************************************************************\n";
164  edm::LogPrint("RegressionEnergyPatElectronProducer")
165  << "Run Lumi Event: " << event.id().run() << " " << event.luminosityBlock() << " " << event.id().event()
166  << "\n";
167  edm::LogPrint("RegressionEnergyPatElectronProducer")
168  << "Pat Electron : " << ele->pt() << " " << ele->eta() << " " << ele->phi() << "\n";
169  }
170 
171  pat::Electron* myPatElectron = (inputCollectionType_ == 0) ? nullptr : new pat::Electron((*patCollectionH)[iele]);
172  // Get RecHit Collection
173  const EcalRecHitCollection* recHits = nullptr;
174  if (useReducedRecHits_) {
175  if (ele->isEB()) {
176  recHits = pEBRecHits.product();
177  } else
178  recHits = pEERecHits.product();
179  } else {
180  recHits = (*patCollectionH)[iele].recHits();
181  }
182 
183  SuperClusterHelper* mySCHelper = nullptr;
184  if (inputCollectionType_ == 0) {
185  mySCHelper = new SuperClusterHelper(&(*ele), recHits, ecalTopology_, caloGeometry_);
186  } else if (inputCollectionType_ == 1) {
187  mySCHelper = new SuperClusterHelper(&(*patCollectionH)[iele], recHits, ecalTopology_, caloGeometry_);
188  }
189 
190  // apply regression energy
191  Double_t FinalMomentum = 0;
192  Double_t FinalMomentumError = 0;
193  Double_t RegressionMomentum = 0;
194  Double_t RegressionMomentumError = 0;
195 
196  if (energyRegressionType_ == 1) {
197  RegressionMomentum = regressionEvaluator_->regressionValueNoTrkVar(mySCHelper->rawEnergy(),
198  mySCHelper->eta(),
199  mySCHelper->phi(),
200  mySCHelper->r9(),
201  mySCHelper->etaWidth(),
202  mySCHelper->phiWidth(),
203  mySCHelper->clustersSize(),
204  mySCHelper->hadronicOverEm(),
205  rho,
206  nvertices,
207  mySCHelper->seedEta(),
208  mySCHelper->seedPhi(),
209  mySCHelper->seedEnergy(),
210  mySCHelper->e3x3(),
211  mySCHelper->e5x5(),
212  mySCHelper->sigmaIetaIeta(),
213  mySCHelper->spp(),
214  mySCHelper->sep(),
215  mySCHelper->eMax(),
216  mySCHelper->e2nd(),
217  mySCHelper->eTop(),
218  mySCHelper->eBottom(),
219  mySCHelper->eLeft(),
220  mySCHelper->eRight(),
221  mySCHelper->e2x5Max(),
222  mySCHelper->e2x5Top(),
223  mySCHelper->e2x5Bottom(),
224  mySCHelper->e2x5Left(),
225  mySCHelper->e2x5Right(),
226  mySCHelper->ietaSeed(),
227  mySCHelper->iphiSeed(),
228  mySCHelper->etaCrySeed(),
229  mySCHelper->phiCrySeed(),
230  mySCHelper->preshowerEnergyOverRaw(),
231  debug_);
232  RegressionMomentumError =
234  mySCHelper->eta(),
235  mySCHelper->phi(),
236  mySCHelper->r9(),
237  mySCHelper->etaWidth(),
238  mySCHelper->phiWidth(),
239  mySCHelper->clustersSize(),
240  mySCHelper->hadronicOverEm(),
241  rho,
242  nvertices,
243  mySCHelper->seedEta(),
244  mySCHelper->seedPhi(),
245  mySCHelper->seedEnergy(),
246  mySCHelper->e3x3(),
247  mySCHelper->e5x5(),
248  mySCHelper->sigmaIetaIeta(),
249  mySCHelper->spp(),
250  mySCHelper->sep(),
251  mySCHelper->eMax(),
252  mySCHelper->e2nd(),
253  mySCHelper->eTop(),
254  mySCHelper->eBottom(),
255  mySCHelper->eLeft(),
256  mySCHelper->eRight(),
257  mySCHelper->e2x5Max(),
258  mySCHelper->e2x5Top(),
259  mySCHelper->e2x5Bottom(),
260  mySCHelper->e2x5Left(),
261  mySCHelper->e2x5Right(),
262  mySCHelper->ietaSeed(),
263  mySCHelper->iphiSeed(),
264  mySCHelper->etaCrySeed(),
265  mySCHelper->phiCrySeed(),
266  mySCHelper->preshowerEnergyOverRaw(),
267  debug_);
268 
269  // PAT method
270  if (inputCollectionType_ == 1) {
271  myPatElectron->setEcalRegressionEnergy(RegressionMomentum, RegressionMomentumError);
272  }
273  energyValues.push_back(RegressionMomentum);
274  energyErrorValues.push_back(RegressionMomentumError);
275 
276  } else if (energyRegressionType_ == 2) { // ECAL regression with subcluster information
277  RegressionMomentum = regressionEvaluator_->regressionValueWithSubClusters(mySCHelper->rawEnergy(),
278  mySCHelper->eta(),
279  mySCHelper->phi(),
280  mySCHelper->r9(),
281  mySCHelper->etaWidth(),
282  mySCHelper->phiWidth(),
283  mySCHelper->clustersSize(),
284  mySCHelper->hadronicOverEm(),
285  rho,
286  nvertices,
287  mySCHelper->seedEta(),
288  mySCHelper->seedPhi(),
289  mySCHelper->seedEnergy(),
290  mySCHelper->e3x3(),
291  mySCHelper->e5x5(),
292  mySCHelper->sigmaIetaIeta(),
293  mySCHelper->spp(),
294  mySCHelper->sep(),
295  mySCHelper->eMax(),
296  mySCHelper->e2nd(),
297  mySCHelper->eTop(),
298  mySCHelper->eBottom(),
299  mySCHelper->eLeft(),
300  mySCHelper->eRight(),
301  mySCHelper->e2x5Max(),
302  mySCHelper->e2x5Top(),
303  mySCHelper->e2x5Bottom(),
304  mySCHelper->e2x5Left(),
305  mySCHelper->e2x5Right(),
306  mySCHelper->ietaSeed(),
307  mySCHelper->iphiSeed(),
308  mySCHelper->etaCrySeed(),
309  mySCHelper->phiCrySeed(),
310  mySCHelper->preshowerEnergyOverRaw(),
311  ele->ecalDrivenSeed(),
312  ele->isEBEtaGap(),
313  ele->isEBPhiGap(),
314  ele->isEEDeeGap(),
315  mySCHelper->eSubClusters(),
316  mySCHelper->subClusterEnergy(1),
317  mySCHelper->subClusterEta(1),
318  mySCHelper->subClusterPhi(1),
319  mySCHelper->subClusterEmax(1),
320  mySCHelper->subClusterE3x3(1),
321  mySCHelper->subClusterEnergy(2),
322  mySCHelper->subClusterEta(2),
323  mySCHelper->subClusterPhi(2),
324  mySCHelper->subClusterEmax(2),
325  mySCHelper->subClusterE3x3(2),
326  mySCHelper->subClusterEnergy(3),
327  mySCHelper->subClusterEta(3),
328  mySCHelper->subClusterPhi(3),
329  mySCHelper->subClusterEmax(3),
330  mySCHelper->subClusterE3x3(3),
331  mySCHelper->nPreshowerClusters(),
332  mySCHelper->eESClusters(),
333  mySCHelper->esClusterEnergy(0),
334  mySCHelper->esClusterEta(0),
335  mySCHelper->esClusterPhi(0),
336  mySCHelper->esClusterEnergy(1),
337  mySCHelper->esClusterEta(1),
338  mySCHelper->esClusterPhi(1),
339  mySCHelper->esClusterEnergy(2),
340  mySCHelper->esClusterEta(2),
341  mySCHelper->esClusterPhi(2),
342  ele->isEB(),
343  debug_);
344  RegressionMomentumError =
346  mySCHelper->eta(),
347  mySCHelper->phi(),
348  mySCHelper->r9(),
349  mySCHelper->etaWidth(),
350  mySCHelper->phiWidth(),
351  mySCHelper->clustersSize(),
352  mySCHelper->hadronicOverEm(),
353  rho,
354  nvertices,
355  mySCHelper->seedEta(),
356  mySCHelper->seedPhi(),
357  mySCHelper->seedEnergy(),
358  mySCHelper->e3x3(),
359  mySCHelper->e5x5(),
360  mySCHelper->sigmaIetaIeta(),
361  mySCHelper->spp(),
362  mySCHelper->sep(),
363  mySCHelper->eMax(),
364  mySCHelper->e2nd(),
365  mySCHelper->eTop(),
366  mySCHelper->eBottom(),
367  mySCHelper->eLeft(),
368  mySCHelper->eRight(),
369  mySCHelper->e2x5Max(),
370  mySCHelper->e2x5Top(),
371  mySCHelper->e2x5Bottom(),
372  mySCHelper->e2x5Left(),
373  mySCHelper->e2x5Right(),
374  mySCHelper->ietaSeed(),
375  mySCHelper->iphiSeed(),
376  mySCHelper->etaCrySeed(),
377  mySCHelper->phiCrySeed(),
378  mySCHelper->preshowerEnergyOverRaw(),
379  ele->ecalDrivenSeed(),
380  ele->isEBEtaGap(),
381  ele->isEBPhiGap(),
382  ele->isEEDeeGap(),
383  mySCHelper->eSubClusters(),
384  mySCHelper->subClusterEnergy(1),
385  mySCHelper->subClusterEta(1),
386  mySCHelper->subClusterPhi(1),
387  mySCHelper->subClusterEmax(1),
388  mySCHelper->subClusterE3x3(1),
389  mySCHelper->subClusterEnergy(2),
390  mySCHelper->subClusterEta(2),
391  mySCHelper->subClusterPhi(2),
392  mySCHelper->subClusterEmax(2),
393  mySCHelper->subClusterE3x3(2),
394  mySCHelper->subClusterEnergy(3),
395  mySCHelper->subClusterEta(3),
396  mySCHelper->subClusterPhi(3),
397  mySCHelper->subClusterEmax(3),
398  mySCHelper->subClusterE3x3(3),
399  mySCHelper->nPreshowerClusters(),
400  mySCHelper->eESClusters(),
401  mySCHelper->esClusterEnergy(0),
402  mySCHelper->esClusterEta(0),
403  mySCHelper->esClusterPhi(0),
404  mySCHelper->esClusterEnergy(1),
405  mySCHelper->esClusterEta(1),
406  mySCHelper->esClusterPhi(1),
407  mySCHelper->esClusterEnergy(2),
408  mySCHelper->esClusterEta(2),
409  mySCHelper->esClusterPhi(2),
410  ele->isEB(),
411  debug_);
412 
413  // PAT method
414  if (inputCollectionType_ == 1) {
415  myPatElectron->setEcalRegressionEnergy(RegressionMomentum, RegressionMomentumError);
416  }
417  energyValues.push_back(RegressionMomentum);
418  energyErrorValues.push_back(RegressionMomentumError);
419 
420  }
421 
422  else if (energyRegressionType_ == 3) {
423  RegressionMomentum = regressionEvaluator_->regressionValueWithTrkVar(ele->p(),
424  mySCHelper->rawEnergy(),
425  mySCHelper->eta(),
426  mySCHelper->phi(),
427  mySCHelper->etaWidth(),
428  mySCHelper->phiWidth(),
429  mySCHelper->clustersSize(),
430  mySCHelper->hadronicOverEm(),
431  mySCHelper->r9(),
432  rho,
433  nvertices,
434  mySCHelper->seedEta(),
435  mySCHelper->seedPhi(),
436  mySCHelper->seedEnergy(),
437  mySCHelper->e3x3(),
438  mySCHelper->e5x5(),
439  mySCHelper->sigmaIetaIeta(),
440  mySCHelper->spp(),
441  mySCHelper->sep(),
442  mySCHelper->eMax(),
443  mySCHelper->e2nd(),
444  mySCHelper->eTop(),
445  mySCHelper->eBottom(),
446  mySCHelper->eLeft(),
447  mySCHelper->eRight(),
448  mySCHelper->e2x5Max(),
449  mySCHelper->e2x5Top(),
450  mySCHelper->e2x5Bottom(),
451  mySCHelper->e2x5Left(),
452  mySCHelper->e2x5Right(),
453  ele->pt(),
454  ele->trackMomentumAtVtx().R(),
455  ele->fbrem(),
456  ele->charge(),
457  ele->eSuperClusterOverP(),
458  mySCHelper->ietaSeed(),
459  mySCHelper->iphiSeed(),
460  mySCHelper->etaCrySeed(),
461  mySCHelper->phiCrySeed(),
462  mySCHelper->preshowerEnergy(),
463  debug_);
464  RegressionMomentumError = regressionEvaluator_->regressionUncertaintyWithTrkVar(ele->p(),
465  mySCHelper->rawEnergy(),
466  mySCHelper->eta(),
467  mySCHelper->phi(),
468  mySCHelper->etaWidth(),
469  mySCHelper->phiWidth(),
470  mySCHelper->clustersSize(),
471  mySCHelper->hadronicOverEm(),
472  mySCHelper->r9(),
473  rho,
474  nvertices,
475  mySCHelper->seedEta(),
476  mySCHelper->seedPhi(),
477  mySCHelper->seedEnergy(),
478  mySCHelper->e3x3(),
479  mySCHelper->e5x5(),
480  mySCHelper->sigmaIetaIeta(),
481  mySCHelper->spp(),
482  mySCHelper->sep(),
483  mySCHelper->eMax(),
484  mySCHelper->e2nd(),
485  mySCHelper->eTop(),
486  mySCHelper->eBottom(),
487  mySCHelper->eLeft(),
488  mySCHelper->eRight(),
489  mySCHelper->e2x5Max(),
490  mySCHelper->e2x5Top(),
491  mySCHelper->e2x5Bottom(),
492  mySCHelper->e2x5Left(),
493  mySCHelper->e2x5Right(),
494  ele->pt(),
495  ele->trackMomentumAtVtx().R(),
496  ele->fbrem(),
497  ele->charge(),
498  ele->eSuperClusterOverP(),
499  mySCHelper->ietaSeed(),
500  mySCHelper->iphiSeed(),
501  mySCHelper->etaCrySeed(),
502  mySCHelper->phiCrySeed(),
503  mySCHelper->preshowerEnergy(),
504  debug_);
505  FinalMomentum = RegressionMomentum;
506  FinalMomentumError = RegressionMomentumError;
507  const math::XYZTLorentzVector& oldMomentum = ele->p4();
508  math::XYZTLorentzVector newMomentum = math::XYZTLorentzVector(oldMomentum.x() * FinalMomentum / oldMomentum.t(),
509  oldMomentum.y() * FinalMomentum / oldMomentum.t(),
510  oldMomentum.z() * FinalMomentum / oldMomentum.t(),
511  FinalMomentum);
512 
513  myPatElectron->correctEcalEnergy(RegressionMomentum, RegressionMomentumError);
514  myPatElectron->correctMomentum(newMomentum, ele->trackMomentumError(), FinalMomentumError);
515 
516  energyValues.push_back(RegressionMomentum);
517  energyErrorValues.push_back(RegressionMomentumError);
518  } else {
519  edm::LogPrint("RegressionEnergyPatElectronProducer")
520  << "Error: RegressionType = " << energyRegressionType_ << " is not supported.\n";
521  }
522 
523  if (inputCollectionType_ == 1) {
524  patElectrons->push_back(*myPatElectron);
525  }
526  if (myPatElectron)
527  delete myPatElectron;
528  if (mySCHelper)
529  delete mySCHelper;
530  } // loop on electrons
531 
532  // Write the new collection in the event (AOD case)
533  if (inputCollectionType_ == 1) {
534  event.put(std::move(patElectrons));
535  }
536 
537  // now AOD case: write ValueMaps
538  if (produceValueMaps_) {
539  if (inputCollectionType_ == 0) {
540  energyFiller.insert(gsfCollectionH, energyValues.begin(), energyValues.end());
541  energyErrorFiller.insert(gsfCollectionH, energyErrorValues.begin(), energyErrorValues.end());
542  } else if (inputCollectionType_ == 1) {
543  energyFiller.insert(patCollectionH, energyValues.begin(), energyValues.end());
544  energyErrorFiller.insert(patCollectionH, energyErrorValues.begin(), energyErrorValues.end());
545  }
546 
547  energyFiller.fill();
548  energyErrorFiller.fill();
549  event.put(std::move(regrEnergyMap), nameEnergyReg_);
550  event.put(std::move(regrEnergyErrorMap), nameEnergyErrorReg_);
551  }
552 }
float subClusterPhi(unsigned i) const
float subClusterEnergy(unsigned i) const
float preshowerEnergy() const
double pt() const final
transverse momentum
bool ecalDrivenSeed() const
Definition: GsfElectron.h:158
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopoToken_
bool isEBPhiGap() const
Definition: GsfElectron.h:334
float trackMomentumError() const
Definition: GsfElectron.h:884
void correctMomentum(const LorentzVector &p4, float trackMomentumError, float p4Error)
Definition: GsfElectron.h:905
T const * product() const
Definition: Handle.h:70
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
float e2x5Left() const
double regressionValueWithTrkVar(double electronP, double SCRawEnergy, double scEta, double scPhi, double R9, double etawidth, double phiwidth, double NClusters, double HoE, double rho, double vertices, double EtaSeed, double PhiSeed, double ESeed, double E3x3Seed, double E5x5Seed, double see, double spp, double sep, double EMaxSeed, double E2ndSeed, double ETopSeed, double EBottomSeed, double ELeftSeed, double ERightSeed, double E2x5MaxSeed, double E2x5TopSeed, double E2x5BottomSeed, double E2x5LeftSeed, double E2x5RightSeed, double pt, double GsfTrackPIn, double fbrem, double Charge, double EoP, double IEtaSeed, double IPhiSeed, double EtaCrySeed, double PhiCrySeed, double PreShowerOverRaw, bool printDebug=false)
double regressionUncertaintyNoTrkVar(double SCRawEnergy, double scEta, double scPhi, double R9, double etawidth, double phiwidth, double NClusters, double HoE, double rho, double vertices, double EtaSeed, double PhiSeed, double ESeed, double E3x3Seed, double E5x5Seed, double see, double spp, double sep, double EMaxSeed, double E2ndSeed, double ETopSeed, double EBottomSeed, double ELeftSeed, double ERightSeed, double E2x5MaxSeed, double E2x5TopSeed, double E2x5BottomSeed, double E2x5LeftSeed, double E2x5RightSeed, double IEtaSeed, double IPhiSeed, double EtaCrySeed, double PhiCrySeed, double PreShowerOverRaw, bool printDebug=false)
assert(be >=bs)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
double regressionValueWithSubClusters(double SCRawEnergy, double scEta, double scPhi, double R9, double etawidth, double phiwidth, double NClusters, double HoE, double rho, double vertices, double EtaSeed, double PhiSeed, double ESeed, double E3x3Seed, double E5x5Seed, double see, double spp, double sep, double EMaxSeed, double E2ndSeed, double ETopSeed, double EBottomSeed, double ELeftSeed, double ERightSeed, double E2x5MaxSeed, double E2x5TopSeed, double E2x5BottomSeed, double E2x5LeftSeed, double E2x5RightSeed, double IEtaSeed, double IPhiSeed, double EtaCrySeed, double PhiCrySeed, double PreShowerOverRaw, double isEcalDriven, double isEtaGap, double isPhiGap, double isDeeGap, double ESubs, double ESub1, double EtaSub1, double PhiSub1, double EMaxSub1, double E3x3Sub1, double ESub2, double EtaSub2, double PhiSub2, double EMaxSub2, double E3x3Sub2, double ESub3, double EtaSub3, double PhiSub3, double EMaxSub3, double E3x3Sub3, double NPshwClusters, double EPshwSubs, double EPshwSub1, double EtaPshwSub1, double PhiPshwSub1, double EPshwSub2, double EtaPshwSub2, double PhiPshwSub2, double EPshwSub3, double EtaPshwSub3, double PhiPshwSub3, bool isEB, bool printDebug=false)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
float sigmaIetaIeta() const
bool isEBEtaGap() const
Definition: GsfElectron.h:333
float eSuperClusterOverP() const
Definition: GsfElectron.h:221
bool isEB() const
Definition: GsfElectron.h:328
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
float seedEnergy() const
float hadronicOverEm() const
float esClusterPhi(unsigned i) const
double p() const final
magnitude of momentum vector
std::vector< Electron > ElectronCollection
Definition: Electron.h:36
edm::EDGetTokenT< reco::VertexCollection > verticesInputToken_
double regressionValueNoTrkVar(double SCRawEnergy, double scEta, double scPhi, double R9, double etawidth, double phiwidth, double NClusters, double HoE, double rho, double vertices, double EtaSeed, double PhiSeed, double ESeed, double E3x3Seed, double E5x5Seed, double see, double spp, double sep, double EMaxSeed, double E2ndSeed, double ETopSeed, double EBottomSeed, double ELeftSeed, double ERightSeed, double E2x5MaxSeed, double E2x5TopSeed, double E2x5BottomSeed, double E2x5LeftSeed, double E2x5RightSeed, double IEtaSeed, double IPhiSeed, double EtaCrySeed, double PhiCrySeed, double PreShowerOverRaw, bool printDebug=false)
float nPreshowerClusters() const
float esClusterEnergy(unsigned i) const
math::XYZVectorF trackMomentumAtVtx() const
Definition: GsfElectron.h:268
bool isEEDeeGap() const
Definition: GsfElectron.h:336
float preshowerEnergyOverRaw() const
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:217
float etaWidth() const
Log< level::Warning, true > LogPrint
float esClusterEta(unsigned i) const
void correctEcalEnergy(float newEnergy, float newEnergyError, bool corrEovP=true)
Definition: GsfElectron.h:901
ElectronEnergyRegressionEvaluate * regressionEvaluator_
float clustersSize() const
float eSubClusters() const
double regressionUncertaintyWithTrkVar(double electronP, double SCRawEnergy, double scEta, double scPhi, double R9, double etawidth, double phiwidth, double NClusters, double HoE, double rho, double vertices, double EtaSeed, double PhiSeed, double ESeed, double E3x3Seed, double E5x5Seed, double see, double spp, double sep, double EMaxSeed, double E2ndSeed, double ETopSeed, double EBottomSeed, double ELeftSeed, double ERightSeed, double E2x5MaxSeed, double E2x5TopSeed, double E2x5BottomSeed, double E2x5LeftSeed, double E2x5RightSeed, double pt, double GsfTrackPIn, double fbrem, double Charge, double EoP, double IEtaSeed, double IPhiSeed, double EtaCrySeed, double PhiCrySeed, double PreShowerOverRaw, bool printDebug=false)
float rawEnergy() const
Analysis-level electron class.
Definition: Electron.h:51
float phiWidth() const
float fbrem() const
Definition: GsfElectron.h:809
float eESClusters() const
float subClusterE3x3(unsigned i) const
edm::EDGetTokenT< reco::GsfElectronCollection > inputGsfElectronsToken_
float e2x5Right() const
double regressionUncertaintyWithSubClusters(double SCRawEnergy, double scEta, double scPhi, double R9, double etawidth, double phiwidth, double NClusters, double HoE, double rho, double vertices, double EtaSeed, double PhiSeed, double ESeed, double E3x3Seed, double E5x5Seed, double see, double spp, double sep, double EMaxSeed, double E2ndSeed, double ETopSeed, double EBottomSeed, double ELeftSeed, double ERightSeed, double E2x5MaxSeed, double E2x5TopSeed, double E2x5BottomSeed, double E2x5LeftSeed, double E2x5RightSeed, double IEtaSeed, double IPhiSeed, double EtaCrySeed, double PhiCrySeed, double PreShowerOverRaw, double isEcalDriven, double isEtaGap, double isPhiGap, double isDeeGap, double ESubs, double ESub1, double EtaSub1, double PhiSub1, double EMaxSub1, double E3x3Sub1, double ESub2, double EtaSub2, double PhiSub2, double EMaxSub2, double E3x3Sub2, double ESub3, double EtaSub3, double PhiSub3, double EMaxSub3, double E3x3Sub3, double NPshwClusters, double EPshwSubs, double EPshwSub1, double EtaPshwSub1, double PhiPshwSub1, double EPshwSub2, double EtaPshwSub2, double PhiPshwSub2, double EPshwSub3, double EtaPshwSub3, double PhiPshwSub3, bool isEB, bool printDebug=false)
double phi() const final
momentum azimuthal angle
void setEcalRegressionEnergy(double val, double err)
set regression1
Definition: Electron.h:230
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< pat::ElectronCollection > inputPatElectronsToken_
float subClusterEmax(unsigned i) const
int charge() const final
electric charge
float subClusterEta(unsigned i) const
float e2x5Bottom() const
double eta() const final
momentum pseudorapidity

Member Data Documentation

◆ caloGeometry_

const CaloGeometry* RegressionEnergyPatElectronProducer::caloGeometry_
private

Definition at line 55 of file RegressionEnergyPatElectronProducer.h.

Referenced by produce().

◆ caloGeomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> RegressionEnergyPatElectronProducer::caloGeomToken_
private

◆ debug_

bool RegressionEnergyPatElectronProducer::debug_
private

◆ ecalTopology_

const CaloTopology* RegressionEnergyPatElectronProducer::ecalTopology_
private

Definition at line 54 of file RegressionEnergyPatElectronProducer.h.

Referenced by produce().

◆ ecalTopoToken_

edm::ESGetToken<CaloTopology, CaloTopologyRecord> RegressionEnergyPatElectronProducer::ecalTopoToken_
private

◆ energyRegressionType_

uint32_t RegressionEnergyPatElectronProducer::energyRegressionType_
private

◆ geomInitialized_

bool RegressionEnergyPatElectronProducer::geomInitialized_
private

◆ inputCollectionType_

uint32_t RegressionEnergyPatElectronProducer::inputCollectionType_
private

◆ inputGsfElectronsToken_

edm::EDGetTokenT<reco::GsfElectronCollection> RegressionEnergyPatElectronProducer::inputGsfElectronsToken_
private

◆ inputPatElectronsToken_

edm::EDGetTokenT<pat::ElectronCollection> RegressionEnergyPatElectronProducer::inputPatElectronsToken_
private

◆ nameEnergyErrorReg_

std::string RegressionEnergyPatElectronProducer::nameEnergyErrorReg_
private

◆ nameEnergyReg_

std::string RegressionEnergyPatElectronProducer::nameEnergyReg_
private

◆ nElectrons_

unsigned RegressionEnergyPatElectronProducer::nElectrons_
private

Definition at line 56 of file RegressionEnergyPatElectronProducer.h.

Referenced by produce().

◆ producePatElectrons_

bool RegressionEnergyPatElectronProducer::producePatElectrons_
private

Definition at line 51 of file RegressionEnergyPatElectronProducer.h.

◆ produceValueMaps_

bool RegressionEnergyPatElectronProducer::produceValueMaps_
private

◆ recHitCollectionEBToken_

edm::EDGetTokenT<EcalRecHitCollection> RegressionEnergyPatElectronProducer::recHitCollectionEBToken_
private

◆ recHitCollectionEEToken_

edm::EDGetTokenT<EcalRecHitCollection> RegressionEnergyPatElectronProducer::recHitCollectionEEToken_
private

◆ regressionEvaluator_

ElectronEnergyRegressionEvaluate* RegressionEnergyPatElectronProducer::regressionEvaluator_
private

◆ regressionInputFile_

std::string RegressionEnergyPatElectronProducer::regressionInputFile_
private

◆ rhoInputToken_

edm::EDGetTokenT<double> RegressionEnergyPatElectronProducer::rhoInputToken_
private

◆ useReducedRecHits_

bool RegressionEnergyPatElectronProducer::useReducedRecHits_
private

◆ verticesInputToken_

edm::EDGetTokenT<reco::VertexCollection> RegressionEnergyPatElectronProducer::verticesInputToken_
private