CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void produce (edm::Event &, const edm::EventSetup &)
 
 RegressionEnergyPatElectronProducer (const edm::ParameterSet &)
 
virtual ~RegressionEnergyPatElectronProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

const CaloGeometrycaloGeometry_
 
bool debug_
 
const CaloTopologyecalTopology_
 
uint32_t energyRegressionType_
 
bool geomInitialized_
 
uint32_t inputCollectionType_
 
edm::EDGetTokenT
< reco::GsfElectronCollection
inputGsfElectronsToken_
 
edm::EDGetTokenT
< pat::ElectronCollection
inputPatElectronsToken_
 
std::string nameEnergyErrorReg_
 
std::string nameEnergyReg_
 
unsigned nElectrons_
 
bool producePatElectrons_
 
bool produceValueMaps_
 
edm::EDGetTokenT
< EcalRecHitCollection
recHitCollectionEBToken_
 
edm::EDGetTokenT
< EcalRecHitCollection
recHitCollectionEEToken_
 
ElectronEnergyRegressionEvaluateregressionEvaluator_
 
std::string regressionInputFile_
 
edm::EDGetTokenT< double > rhoInputToken_
 
bool useReducedRecHits_
 
edm::EDGetTokenT
< reco::VertexCollection
verticesInputToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
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)
 
- 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 23 of file RegressionEnergyPatElectronProducer.cc.

References gather_cfg::cout, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), ElectronEnergyRegressionEvaluate::kNoTrkVar, ElectronEnergyRegressionEvaluate::kWithSubCluVar, ElectronEnergyRegressionEvaluate::kWithTrkVar, and AlCaHLTBitMon_QueryRunRegistry::string.

24 {
25 
26  inputGsfElectronsToken_ = mayConsume<GsfElectronCollection>(cfg.getParameter<edm::InputTag>("inputElectronsTag"));
27  inputPatElectronsToken_ = mayConsume<ElectronCollection>(cfg.getParameter<edm::InputTag>("inputElectronsTag"));
28  inputCollectionType_ = cfg.getParameter<uint32_t>("inputCollectionType");
29  rhoInputToken_ = consumes<double>(cfg.getParameter<edm::InputTag>("rhoCollection"));
30  verticesInputToken_ = consumes<VertexCollection>(cfg.getParameter<edm::InputTag>("vertexCollection"));
31  energyRegressionType_ = cfg.getParameter<uint32_t>("energyRegressionType");
32  regressionInputFile_ = cfg.getParameter<std::string>("regressionInputFile");
33  recHitCollectionEBToken_ = mayConsume<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitCollectionEB"));
34  recHitCollectionEEToken_ = mayConsume<EcalRecHitCollection>(cfg.getParameter<edm::InputTag>("recHitCollectionEE"));
35  nameEnergyReg_ = cfg.getParameter<std::string>("nameEnergyReg");
36  nameEnergyErrorReg_ = cfg.getParameter<std::string>("nameEnergyErrorReg");
37  debug_ = cfg.getUntrackedParameter<bool>("debug");
38  useReducedRecHits_ = cfg.getParameter<bool>("useRecHitCollections");
39  produceValueMaps_ = cfg.getParameter<bool>("produceValueMaps");
40 
41  // if Gsf Electrons; useReducedRecHits should be used)
43  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;
44  }
45 
47  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;
48  }
49 
50  if (inputCollectionType_ == 0) {
51  // do nothing
52  } else if (inputCollectionType_ == 1) {
53  produces<ElectronCollection>();
54  } else {
55  throw cms::Exception("InconsistentParameters") << " inputCollectionType should be either 0 (GsfElectrons) or 1 (pat::Electrons) " << std::endl;
56  }
57 
58 
59  //set regression type
64 
65  //load weights and initialize
68 
69  if(produceValueMaps_) {
70  produces<edm::ValueMap<double> >(nameEnergyReg_);
71  produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
72  }
73 
74 
75  //****************************************************************************************
76  //set up regression calculator
77  //****************************************************************************************
78 
79  geomInitialized_ = false;
80 
81  std::cout << " Finished initialization " << std::endl;
82 
83 }
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_
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< pat::ElectronCollection > inputPatElectronsToken_
RegressionEnergyPatElectronProducer::~RegressionEnergyPatElectronProducer ( )
virtual

Definition at line 85 of file RegressionEnergyPatElectronProducer.cc.

86 {
87  delete regressionEvaluator_;
88 
89 }
ElectronEnergyRegressionEvaluate * regressionEvaluator_

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 91 of file RegressionEnergyPatElectronProducer.cc.

References assert(), reco::LeafCandidate::charge(), SuperClusterHelper::clustersSize(), reco::GsfElectron::correctEcalEnergy(), reco::GsfElectron::correctMomentum(), gather_cfg::cout, SuperClusterHelper::e2nd(), SuperClusterHelper::e2x5Bottom(), SuperClusterHelper::e2x5Left(), SuperClusterHelper::e2x5Max(), SuperClusterHelper::e2x5Right(), SuperClusterHelper::e2x5Top(), SuperClusterHelper::e3x3(), SuperClusterHelper::e5x5(), SuperClusterHelper::eBottom(), reco::GsfElectron::ecalDrivenSeed(), SuperClusterHelper::eESClusters(), SuperClusterHelper::eLeft(), SuperClusterHelper::eMax(), 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(), edm::EventSetup::get(), SuperClusterHelper::hadronicOverEm(), SuperClusterHelper::ietaSeed(), edm::helper::Filler< Map >::insert(), SuperClusterHelper::iphiSeed(), reco::GsfElectron::isEB(), reco::GsfElectron::isEBEtaGap(), reco::GsfElectron::isEBPhiGap(), reco::GsfElectron::isEEDeeGap(), SuperClusterHelper::nPreshowerClusters(), reco::LeafCandidate::p(), reco::GsfElectron::p4(), electronProducer_cfi::patElectrons, SuperClusterHelper::phi(), reco::LeafCandidate::phi(), SuperClusterHelper::phiCrySeed(), SuperClusterHelper::phiWidth(), SuperClusterHelper::preshowerEnergy(), SuperClusterHelper::preshowerEnergyOverRaw(), edm::Handle< T >::product(), reco::LeafCandidate::pt(), SuperClusterHelper::r9(), SuperClusterHelper::rawEnergy(), HLT_FULL_cff::recHits, rho, 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(), and reco::GsfElectron::trackMomentumError().

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

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

Member Data Documentation

const CaloGeometry* RegressionEnergyPatElectronProducer::caloGeometry_
private

Definition at line 56 of file RegressionEnergyPatElectronProducer.h.

bool RegressionEnergyPatElectronProducer::debug_
private

Definition at line 48 of file RegressionEnergyPatElectronProducer.h.

const CaloTopology* RegressionEnergyPatElectronProducer::ecalTopology_
private

Definition at line 55 of file RegressionEnergyPatElectronProducer.h.

uint32_t RegressionEnergyPatElectronProducer::energyRegressionType_
private

Definition at line 45 of file RegressionEnergyPatElectronProducer.h.

bool RegressionEnergyPatElectronProducer::geomInitialized_
private

Definition at line 50 of file RegressionEnergyPatElectronProducer.h.

uint32_t RegressionEnergyPatElectronProducer::inputCollectionType_
private

Definition at line 46 of file RegressionEnergyPatElectronProducer.h.

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

Definition at line 30 of file RegressionEnergyPatElectronProducer.h.

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

Definition at line 31 of file RegressionEnergyPatElectronProducer.h.

std::string RegressionEnergyPatElectronProducer::nameEnergyErrorReg_
private

Definition at line 43 of file RegressionEnergyPatElectronProducer.h.

std::string RegressionEnergyPatElectronProducer::nameEnergyReg_
private

Definition at line 42 of file RegressionEnergyPatElectronProducer.h.

unsigned RegressionEnergyPatElectronProducer::nElectrons_
private

Definition at line 57 of file RegressionEnergyPatElectronProducer.h.

bool RegressionEnergyPatElectronProducer::producePatElectrons_
private

Definition at line 51 of file RegressionEnergyPatElectronProducer.h.

bool RegressionEnergyPatElectronProducer::produceValueMaps_
private

Definition at line 52 of file RegressionEnergyPatElectronProducer.h.

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

Definition at line 34 of file RegressionEnergyPatElectronProducer.h.

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

Definition at line 35 of file RegressionEnergyPatElectronProducer.h.

ElectronEnergyRegressionEvaluate* RegressionEnergyPatElectronProducer::regressionEvaluator_
private

Definition at line 49 of file RegressionEnergyPatElectronProducer.h.

std::string RegressionEnergyPatElectronProducer::regressionInputFile_
private

Definition at line 47 of file RegressionEnergyPatElectronProducer.h.

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

Definition at line 32 of file RegressionEnergyPatElectronProducer.h.

bool RegressionEnergyPatElectronProducer::useReducedRecHits_
private

Definition at line 38 of file RegressionEnergyPatElectronProducer.h.

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

Definition at line 33 of file RegressionEnergyPatElectronProducer.h.