CMS 3D CMS Logo

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

#include <RegressionEnergyPatElectronProducer.h>

Inheritance diagram for RegressionEnergyPatElectronProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 RegressionEnergyPatElectronProducer (const edm::ParameterSet &)
 
 ~RegressionEnergyPatElectronProducer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

const CaloGeometrycaloGeometry_
 
bool debug_
 
const CaloTopologyecalTopology_
 
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::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 19 of file RegressionEnergyPatElectronProducer.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file RegressionEnergyPatElectronProducer.cc.

References gather_cfg::cout, debug_, energyRegressionType_, Exception, geomInitialized_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), 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_.

18 {
19 
20  inputGsfElectronsToken_ = mayConsume<reco::GsfElectronCollection>(cfg.getParameter<edm::InputTag>("inputElectronsTag"));
21  inputPatElectronsToken_ = mayConsume<pat::ElectronCollection>(cfg.getParameter<edm::InputTag>("inputElectronsTag"));
22  inputCollectionType_ = cfg.getParameter<uint32_t>("inputCollectionType");
23  rhoInputToken_ = consumes<double>(cfg.getParameter<edm::InputTag>("rhoCollection"));
24  verticesInputToken_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("vertexCollection"));
25  energyRegressionType_ = cfg.getParameter<uint32_t>("energyRegressionType");
26  regressionInputFile_ = cfg.getParameter<std::string>("regressionInputFile");
27  recHitCollectionEBToken_ = mayConsume<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitCollectionEB"));
28  recHitCollectionEEToken_ = mayConsume<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitCollectionEE"));
29  nameEnergyReg_ = cfg.getParameter<std::string>("nameEnergyReg");
30  nameEnergyErrorReg_ = cfg.getParameter<std::string>("nameEnergyErrorReg");
31  debug_ = cfg.getUntrackedParameter<bool>("debug");
32  useReducedRecHits_ = cfg.getParameter<bool>("useRecHitCollections");
33  produceValueMaps_ = cfg.getParameter<bool>("produceValueMaps");
34 
35  // if Gsf Electrons; useReducedRecHits should be used)
37  throw cms::Exception("InconsistentParameters") << " *** Inconsistent configuration : if you read GsfElectrons, you should set useRecHitCollections to true and provide the correcte values to recHitCollectionEB and recHitCollectionEE (most probably reducedEcalRecHitsEB and reducedEcalRecHitsEE )" << std::endl;
38  }
39 
41  std::cout << " You are running on GsfElectrons and the producer is not configured to produce ValueMaps with the results. In that case, it does not nothing !! " << std::endl;
42  }
43 
44  if (inputCollectionType_ == 0) {
45  // do nothing
46  } else if (inputCollectionType_ == 1) {
47  produces<pat::ElectronCollection>();
48  } else {
49  throw cms::Exception("InconsistentParameters") << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " << std::endl;
50  }
51 
52 
53  //set regression type
58 
59  //load weights and initialize
62 
63  if(produceValueMaps_) {
64  produces<edm::ValueMap<double> >(nameEnergyReg_);
65  produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
66  }
67 
68 
69  //****************************************************************************************
70  //set up regression calculator
71  //****************************************************************************************
72 
73  geomInitialized_ = false;
74 
75  std::cout << " Finished initialization " << std::endl;
76 
77 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
edm::EDGetTokenT< reco::VertexCollection > verticesInputToken_
void initialize(std::string weightsFile, ElectronEnergyRegressionEvaluate::ElectronEnergyRegressionType type)
ElectronEnergyRegressionEvaluate * regressionEvaluator_
edm::EDGetTokenT< reco::GsfElectronCollection > inputGsfElectronsToken_
edm::EDGetTokenT< pat::ElectronCollection > inputPatElectronsToken_
RegressionEnergyPatElectronProducer::~RegressionEnergyPatElectronProducer ( )
override

Definition at line 79 of file RegressionEnergyPatElectronProducer.cc.

References regressionEvaluator_.

80 {
81  delete regressionEvaluator_;
82 
83 }
ElectronEnergyRegressionEvaluate * regressionEvaluator_

Member Function Documentation

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

Definition at line 85 of file RegressionEnergyPatElectronProducer.cc.

References caloGeometry_, reco::LeafCandidate::charge(), SuperClusterHelper::clustersSize(), reco::GsfElectron::correctEcalEnergy(), reco::GsfElectron::correctMomentum(), gather_cfg::cout, debug_, DEFINE_FWK_MODULE, SuperClusterHelper::e2nd(), SuperClusterHelper::e2x5Bottom(), SuperClusterHelper::e2x5Left(), SuperClusterHelper::e2x5Max(), SuperClusterHelper::e2x5Right(), SuperClusterHelper::e2x5Top(), SuperClusterHelper::e3x3(), SuperClusterHelper::e5x5(), SuperClusterHelper::eBottom(), reco::GsfElectron::ecalDrivenSeed(), ecalTopology_, 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_, edm::EventSetup::get(), 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(), nullptr, reco::LeafCandidate::p(), reco::GsfElectron::p4(), electronProducer_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_, 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(), SuperClusterHelper::sigmaIetaIeta(), SuperClusterHelper::spp(), SuperClusterHelper::subClusterE3x3(), SuperClusterHelper::subClusterEmax(), SuperClusterHelper::subClusterEnergy(), SuperClusterHelper::subClusterEta(), SuperClusterHelper::subClusterPhi(), reco::GsfElectron::trackMomentumAtVtx(), reco::GsfElectron::trackMomentumError(), useReducedRecHits_, and verticesInputToken_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

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

Member Data Documentation

const CaloGeometry* RegressionEnergyPatElectronProducer::caloGeometry_
private

Definition at line 56 of file RegressionEnergyPatElectronProducer.h.

Referenced by produce().

bool RegressionEnergyPatElectronProducer::debug_
private
const CaloTopology* RegressionEnergyPatElectronProducer::ecalTopology_
private

Definition at line 55 of file RegressionEnergyPatElectronProducer.h.

Referenced by produce().

uint32_t RegressionEnergyPatElectronProducer::energyRegressionType_
private
bool RegressionEnergyPatElectronProducer::geomInitialized_
private
uint32_t RegressionEnergyPatElectronProducer::inputCollectionType_
private
edm::EDGetTokenT<reco::GsfElectronCollection> RegressionEnergyPatElectronProducer::inputGsfElectronsToken_
private
edm::EDGetTokenT<pat::ElectronCollection> RegressionEnergyPatElectronProducer::inputPatElectronsToken_
private
std::string RegressionEnergyPatElectronProducer::nameEnergyErrorReg_
private
std::string RegressionEnergyPatElectronProducer::nameEnergyReg_
private
unsigned RegressionEnergyPatElectronProducer::nElectrons_
private

Definition at line 57 of file RegressionEnergyPatElectronProducer.h.

Referenced by produce().

bool RegressionEnergyPatElectronProducer::producePatElectrons_
private

Definition at line 51 of file RegressionEnergyPatElectronProducer.h.

bool RegressionEnergyPatElectronProducer::produceValueMaps_
private
edm::EDGetTokenT<EcalRecHitCollection> RegressionEnergyPatElectronProducer::recHitCollectionEBToken_
private
edm::EDGetTokenT<EcalRecHitCollection> RegressionEnergyPatElectronProducer::recHitCollectionEEToken_
private
ElectronEnergyRegressionEvaluate* RegressionEnergyPatElectronProducer::regressionEvaluator_
private
std::string RegressionEnergyPatElectronProducer::regressionInputFile_
private
edm::EDGetTokenT<double> RegressionEnergyPatElectronProducer::rhoInputToken_
private
bool RegressionEnergyPatElectronProducer::useReducedRecHits_
private
edm::EDGetTokenT<reco::VertexCollection> RegressionEnergyPatElectronProducer::verticesInputToken_
private