CMS 3D CMS Logo

GEDPhotonProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
5 // Framework
9 
11 
16 
17 
29 
31 
34 
37 
40 
46 
47 namespace {
48  inline double ptFast( const double energy,
49  const math::XYZPoint& position,
50  const math::XYZPoint& origin ) {
51  const auto v = position - origin;
52  return energy*std::sqrt(v.perp2()/v.mag2());
53  }
54 }
55 
57  flags_(0)
58 {
59  if(step=="final") flags_ = kFinal;
60  else if(step=="oot") flags_ = kOOT;
61  else if(step=="ootfinal") flags_ = (kOOT|kFinal);
62  else if(step=="tmp") flags_ = 0;
63  else{
64  throw cms::Exception("InvalidConfig") <<" reconstructStep "<<step<<" is invalid, the options are: tmp, final,oot or ootfinal"<<std::endl;
65  }
66 }
67 
69  recoStep_(config.getParameter<std::string>("reconstructionStep")),
70  conf_(config)
71 {
72 
73  // use configuration file to setup input/output collection names
74  //
75  photonProducer_ = conf_.getParameter<edm::InputTag>("photonProducer");
76 
77  if ( recoStep_.isFinal() ) {
79  consumes<reco::PhotonCollection>(photonProducer_);
80  pfCandidates_ =
81  consumes<reco::PFCandidateCollection>(conf_.getParameter<edm::InputTag>("pfCandidates"));
82 
84  auto getVMToken = [&pfIsolCfg,this](const std::string& name){
85  return consumes<edm::ValueMap<float> >(pfIsolCfg.getParameter<edm::InputTag>(name));
86  };
87  phoChargedIsolationToken_ = getVMToken("chargedHadronIso");
88  phoNeutralHadronIsolationToken_ = getVMToken("neutralHadronIso");
89  phoPhotonIsolationToken_ = getVMToken("photonIso");
90  phoChargedWorstVtxIsoToken_ = getVMToken("chargedHadronWorstVtxIso");
91  phoChargedWorstVtxGeomVetoIsoToken_ = getVMToken("chargedHadronWorstVtxGeomVetoIso");
92  phoChargedPFPVIsoToken_ = getVMToken("chargedHadronPFPVIso");
93 
94  //OOT photons in legacy 80X re-miniAOD do not have PF cluster embeded into the reco object
95  //to preserve 80X behaviour
96  if(conf_.exists("pfECALClusIsolation")){
98  consumes<edm::ValueMap<float>>(conf_.getParameter<edm::InputTag>("pfECALClusIsolation"));
99  }
100  if(conf_.exists("pfHCALClusIsolation")){
102  consumes<edm::ValueMap<float>>(conf_.getParameter<edm::InputTag>("pfHCALClusIsolation"));
103  }
104  } else {
105 
107  consumes<reco::PhotonCoreCollection>(photonProducer_);
108 
109  }
110 
111  auto pfEg = conf_.getParameter<edm::InputTag>("pfEgammaCandidates");
112  if (not pfEg.label().empty())
114  consumes<reco::PFCandidateCollection>(pfEg);
115  barrelEcalHits_ =
116  consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("barrelEcalHits"));
117  endcapEcalHits_ =
118  consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("endcapEcalHits"));
119  preshowerHits_ =
120  consumes<EcalRecHitCollection>(conf_.getParameter<edm::InputTag>("preshowerHits"));
121  vertexProducer_ =
122  consumes<reco::VertexCollection>(conf_.getParameter<edm::InputTag>("primaryVertexProducer"));
123 
124  auto hcTow = conf_.getParameter<edm::InputTag>("hcalTowers");
125  if (not hcTow.label().empty())
126  hcalTowers_ =
127  consumes<CaloTowerCollection>(hcTow);
128  //
129  photonCollection_ = conf_.getParameter<std::string>("outputPhotonCollection");
130  hOverEConeSize_ = conf_.getParameter<double>("hOverEConeSize");
131  highEt_ = conf_.getParameter<double>("highEt");
132  // R9 value to decide converted/unconverted
133  minR9Barrel_ = conf_.getParameter<double>("minR9Barrel");
134  minR9Endcap_ = conf_.getParameter<double>("minR9Endcap");
135  usePrimaryVertex_ = conf_.getParameter<bool>("usePrimaryVertex");
136  runMIPTagger_ = conf_.getParameter<bool>("runMIPTagger");
137 
138  candidateP4type_ = config.getParameter<std::string>("candidateP4type") ;
139  valueMapPFCandPhoton_ = config.getParameter<std::string>("valueMapPhotons");
140 
141 
143  config.getParameter<edm::ParameterSet>("posCalcParameters");
144  posCalculator_ = PositionCalc(posCalcParameters);
145 
146 
147  //AA
148  //Flags and Severities to be excluded from photon calculations
149  const std::vector<std::string> flagnamesEB =
150  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
151 
152  const std::vector<std::string> flagnamesEE =
153  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
154 
155  flagsexclEB_=
156  StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
157 
158  flagsexclEE_=
159  StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
160 
161  const std::vector<std::string> severitynamesEB =
162  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
163 
165  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
166 
167  const std::vector<std::string> severitynamesEE =
168  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
169 
171  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
172 
174  new PhotonEnergyCorrector(conf_, consumesCollector());
175 
176  //AA
177 
178  //
179 
180  // Parameters for the position calculation:
181  // std::map<std::string,double> providedParameters;
182  // providedParameters.insert(std::make_pair("LogWeighted",conf_.getParameter<bool>("posCalc_logweight")));
183  //providedParameters.insert(std::make_pair("T0_barl",conf_.getParameter<double>("posCalc_t0_barl")));
184  //providedParameters.insert(std::make_pair("T0_endc",conf_.getParameter<double>("posCalc_t0_endc")));
185  //providedParameters.insert(std::make_pair("T0_endcPresh",conf_.getParameter<double>("posCalc_t0_endcPresh")));
186  //providedParameters.insert(std::make_pair("W0",conf_.getParameter<double>("posCalc_w0")));
187  //providedParameters.insert(std::make_pair("X0",conf_.getParameter<double>("posCalc_x0")));
188  //posCalculator_ = PositionCalc(providedParameters);
189  // cut values for pre-selection
190  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("minSCEtBarrel"));
191  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("maxHoverEBarrel"));
192  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("ecalRecHitSumEtOffsetBarrel"));
193  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("ecalRecHitSumEtSlopeBarrel"));
194  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("hcalTowerSumEtOffsetBarrel"));
195  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("hcalTowerSumEtSlopeBarrel"));
196  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("nTrackSolidConeBarrel"));
197  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("nTrackHollowConeBarrel"));
198  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("trackPtSumSolidConeBarrel"));
199  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("trackPtSumHollowConeBarrel"));
200  preselCutValuesBarrel_.push_back(conf_.getParameter<double>("sigmaIetaIetaCutBarrel"));
201  //
202  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("minSCEtEndcap"));
203  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("maxHoverEEndcap"));
204  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("ecalRecHitSumEtOffsetEndcap"));
205  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("ecalRecHitSumEtSlopeEndcap"));
206  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("hcalTowerSumEtOffsetEndcap"));
207  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("hcalTowerSumEtSlopeEndcap"));
208  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("nTrackSolidConeEndcap"));
209  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("nTrackHollowConeEndcap"));
210  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("trackPtSumSolidConeEndcap"));
211  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("trackPtSumHollowConeEndcap"));
212  preselCutValuesEndcap_.push_back(conf_.getParameter<double>("sigmaIetaIetaCutEndcap"));
213  //
214 
215  //moved from beginRun to here, I dont see how this could cause harm as its just reading in the exactly same parameters each run
216  if ( !recoStep_.isFinal()){
219  thePhotonIsolationCalculator_->setup(isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_,consumesCollector());
222  thePhotonMIPHaloTagger_->setup(mipVariableSet,consumesCollector());
223 
224  }else{
226  thePhotonMIPHaloTagger_=nullptr;
227  }
228 
229  checkHcalStatus_ = conf_.getParameter<bool>("checkHcalStatus");
230 
231  // Register the product
232  produces< reco::PhotonCollection >(photonCollection_);
234  produces< edm::ValueMap<reco::PhotonRef> > (valueMapPFCandPhoton_);
235 
236 
237 }
238 
240 {
244  //delete energyCorrectionF;
245 }
246 
247 
248 
249 void GEDPhotonProducer::beginRun (edm::Run const& r, edm::EventSetup const & theEventSetup) {
250 
251  if ( !recoStep_.isFinal() ) {
252  thePhotonEnergyCorrector_ -> init(theEventSetup);
253  }
254 
255 }
256 
257 void GEDPhotonProducer::endRun (edm::Run const& r, edm::EventSetup const & theEventSetup) {
258 }
259 
260 
261 void GEDPhotonProducer::produce(edm::Event& theEvent, const edm::EventSetup& theEventSetup) {
262 
263  using namespace edm;
264  // nEvt_++;
265 
267  auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
268  edm::ValueMap<reco::PhotonRef> pfEGCandToPhotonMap;
269 
270 
271  // Get the PhotonCore collection
272  bool validPhotonCoreHandle=false;
273  Handle<reco::PhotonCoreCollection> photonCoreHandle;
274  bool validPhotonHandle= false;
275  Handle<reco::PhotonCollection> photonHandle;
276  //value maps for isolation
277  edm::Handle<edm::ValueMap<float> > phoChargedIsolationMap;
278  edm::Handle<edm::ValueMap<float> > phoNeutralHadronIsolationMap;
279  edm::Handle<edm::ValueMap<float> > phoPhotonIsolationMap;
280  edm::Handle<edm::ValueMap<float> > phoChargedWorstVtxIsoMap;
281  edm::Handle<edm::ValueMap<float> > phoChargedWorstVtxGeomVetoIsoMap;
282  edm::Handle<edm::ValueMap<float> > phoChargedPFPVIsoMap;
283 
284  edm::Handle<edm::ValueMap<float> > phoPFECALClusIsolationMap;
285  edm::Handle<edm::ValueMap<float> > phoPFHCALClusIsolationMap;
286 
287  if ( recoStep_.isFinal() ) {
288  theEvent.getByToken(photonProducerT_,photonHandle);
289  //get isolation objects
290  theEvent.getByToken(phoChargedIsolationToken_,phoChargedIsolationMap);
291  theEvent.getByToken(phoNeutralHadronIsolationToken_,phoNeutralHadronIsolationMap);
292  theEvent.getByToken(phoPhotonIsolationToken_,phoPhotonIsolationMap);
293  theEvent.getByToken(phoChargedWorstVtxIsoToken_,phoChargedWorstVtxIsoMap);
294  theEvent.getByToken(phoChargedWorstVtxGeomVetoIsoToken_,phoChargedWorstVtxGeomVetoIsoMap);
295  theEvent.getByToken(phoChargedPFPVIsoToken_,phoChargedPFPVIsoMap);
296 
297  //OOT photons in legacy 80X re-miniAOD workflow dont have cluster isolation embed in them
299  theEvent.getByToken(phoPFECALClusIsolationToken_,phoPFECALClusIsolationMap);
300  }
302  theEvent.getByToken(phoPFHCALClusIsolationToken_,phoPFHCALClusIsolationMap);
303  }
304 
305  if ( photonHandle.isValid()) {
306  validPhotonHandle=true;
307  } else {
308  throw cms::Exception("GEDPhotonProducer") << "Error! Can't get the product " << photonProducer_.label() << "\n";
309  }
310  } else {
311 
312  theEvent.getByToken(photonCoreProducerT_,photonCoreHandle);
313  if (photonCoreHandle.isValid()) {
314  validPhotonCoreHandle=true;
315  } else {
316  throw cms::Exception("GEDPhotonProducer")
317  << "Error! Can't get the photonCoreProducer " << photonProducer_.label() << "\n";
318  }
319  }
320 
321  // Get EcalRecHits
322  bool validEcalRecHits=true;
323  Handle<EcalRecHitCollection> barrelHitHandle;
324  const EcalRecHitCollection dummyEB;
325  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
326  if (!barrelHitHandle.isValid()) {
327  throw cms::Exception("GEDPhotonProducer")
328  << "Error! Can't get the barrelEcalHits";
329  }
330  const EcalRecHitCollection& barrelRecHits(validEcalRecHits ? *(barrelHitHandle.product()) : dummyEB);
331 
332  Handle<EcalRecHitCollection> endcapHitHandle;
333  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
334  const EcalRecHitCollection dummyEE;
335  if (!endcapHitHandle.isValid()) {
336  throw cms::Exception("GEDPhotonProducer")
337  << "Error! Can't get the endcapEcalHits";
338  }
339  const EcalRecHitCollection& endcapRecHits(validEcalRecHits ? *(endcapHitHandle.product()) : dummyEE);
340 
341  bool validPreshowerRecHits=true;
342  Handle<EcalRecHitCollection> preshowerHitHandle;
343  theEvent.getByToken(preshowerHits_, preshowerHitHandle);
344  EcalRecHitCollection preshowerRecHits;
345  if (!preshowerHitHandle.isValid()) {
346  throw cms::Exception("GEDPhotonProducer")
347  << "Error! Can't get the preshowerEcalHits";
348  }
349  if( validPreshowerRecHits ) preshowerRecHits = *(preshowerHitHandle.product());
350 
351 
352 
353  Handle<reco::PFCandidateCollection> pfEGCandidateHandle;
354  // Get the PF refined cluster collection
356  theEvent.getByToken(pfEgammaCandidates_,pfEGCandidateHandle);
357  if (!pfEGCandidateHandle.isValid()) {
358  throw cms::Exception("GEDPhotonProducer")
359  << "Error! Can't get the pfEgammaCandidates";
360  }
361  }
362 
363  Handle<reco::PFCandidateCollection> pfCandidateHandle;
364 
365  if ( recoStep_.isFinal() ) {
366  // Get the PF candidates collection
367  theEvent.getByToken(pfCandidates_,pfCandidateHandle);
368  //OOT photons have no PF candidates so its not an error in this case
369  if (!pfCandidateHandle.isValid() && !recoStep_.isOOT()) {
370  throw cms::Exception("GEDPhotonProducer")
371  << "Error! Can't get the pfCandidates";
372  }
373  }
374 
375  //AA
376  //Get the severity level object
378  theEventSetup.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
379  //
380 
381 
382 // get Hcal towers collection
383  Handle<CaloTowerCollection> hcalTowersHandle;
384  if (not hcalTowers_.isUninitialized()){
385  theEvent.getByToken(hcalTowers_, hcalTowersHandle);
386  }
387 
388  // get the geometry from the event setup:
389  theEventSetup.get<CaloGeometryRecord>().get(theCaloGeom_);
390 
391  //
392  // update energy correction function
393  // energyCorrectionF->init(theEventSetup);
394 
395  edm::ESHandle<CaloTopology> pTopology;
396  theEventSetup.get<CaloTopologyRecord>().get(theCaloTopo_);
398 
399  // Get the primary event vertex
400  Handle<reco::VertexCollection> vertexHandle;
401  const reco::VertexCollection dummyVC;
402  bool validVertex=true;
403  if ( usePrimaryVertex_ ) {
404  theEvent.getByToken(vertexProducer_, vertexHandle);
405  if (!vertexHandle.isValid()) {
406  throw cms::Exception("GEDPhotonProducer")
407  << "Error! Can't get the product primary Vertex Collection";
408  }
409  }
410  const reco::VertexCollection& vertexCollection(usePrimaryVertex_ && validVertex ? *(vertexHandle.product()) : dummyVC);
411 
412  // math::XYZPoint vtx(0.,0.,0.);
413  //if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
414 
415  // get the regression calculator ready
416  thePhotonEnergyCorrector_->init(theEventSetup);
418  thePhotonEnergyCorrector_->gedRegression()->setEvent(theEvent);
419  thePhotonEnergyCorrector_->gedRegression()->setEventContent(theEventSetup);
420  }
421 
422 
423  int iSC=0; // index in photon collection
424  // Loop over barrel and endcap SC collections and fill the photon collection
425  if ( validPhotonCoreHandle)
426  fillPhotonCollection(theEvent,
427  theEventSetup,
428  photonCoreHandle,
429  topology,
430  &barrelRecHits,
431  &endcapRecHits,
432  &preshowerRecHits,
433  hcalTowersHandle,
434  //vtx,
435  vertexCollection,
436  outputPhotonCollection,
437  iSC);
438 
439  iSC=0;
440  if ( validPhotonHandle && recoStep_.isFinal() )
441  fillPhotonCollection(theEvent,
442  theEventSetup,
443  photonHandle,
444  pfCandidateHandle,
445  pfEGCandidateHandle,
446  pfEGCandToPhotonMap,
447  vertexHandle,
448  outputPhotonCollection,
449  iSC,
450  phoChargedIsolationMap,
451  phoNeutralHadronIsolationMap,
452  phoPhotonIsolationMap,
453  phoChargedWorstVtxIsoMap,
454  phoChargedWorstVtxGeomVetoIsoMap,
455  phoChargedPFPVIsoMap,
456  phoPFECALClusIsolationMap,
457  phoPFHCALClusIsolationMap);
458 
459 
460 
461  // put the product in the event
462  edm::LogInfo("GEDPhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n";
463  outputPhotonCollection_p->assign(outputPhotonCollection.begin(),outputPhotonCollection.end());
464  const edm::OrphanHandle<reco::PhotonCollection> photonOrphHandle = theEvent.put(std::move(outputPhotonCollection_p), photonCollection_);
465 
466 
469  auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
470  edm::ValueMap<reco::PhotonRef>::Filler filler(*pfEGCandToPhotonMap_p);
471  unsigned nObj = pfEGCandidateHandle->size();
472  std::vector<reco::PhotonRef> values(nObj);
474  for(unsigned int lCand=0; lCand < nObj; lCand++) {
475  reco::PFCandidateRef pfCandRef (reco::PFCandidateRef(pfEGCandidateHandle,lCand));
476  reco::SuperClusterRef pfScRef = pfCandRef -> superClusterRef();
477 
478  for(unsigned int lSC=0; lSC < photonOrphHandle->size(); lSC++) {
479  reco::PhotonRef photonRef(reco::PhotonRef(photonOrphHandle, lSC));
480  reco::SuperClusterRef scRef=photonRef->superCluster();
481  if ( pfScRef != scRef ) continue;
482  values[lCand] = photonRef;
483  }
484  }
485 
486 
487  filler.insert(pfEGCandidateHandle,values.begin(),values.end());
488  filler.fill();
489  theEvent.put(std::move(pfEGCandToPhotonMap_p),valueMapPFCandPhoton_);
490 
491 
492  }
493 
494 
495 
496 
497 
498 
499 }
500 
502  edm::EventSetup const & es,
503  const edm::Handle<reco::PhotonCoreCollection> & photonCoreHandle,
504  const CaloTopology* topology,
505  const EcalRecHitCollection* ecalBarrelHits,
506  const EcalRecHitCollection* ecalEndcapHits,
508  const edm::Handle<CaloTowerCollection> & hcalTowersHandle,
511 
512 
515  std::vector<double> preselCutValues;
516  std::vector<int> flags_, severitiesexcl_;
517 
518  for(unsigned int lSC=0; lSC < photonCoreHandle->size(); lSC++) {
519 
520  reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC));
521  reco::SuperClusterRef parentSCRef = coreRef->parentSuperCluster();
522  reco::SuperClusterRef scRef=coreRef->superCluster();
523 
524 
525 
526  // const reco::SuperCluster* pClus=&(*scRef);
527  iSC++;
528 
529  DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
530  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
531  if (subdet==EcalBarrel) {
532  preselCutValues = preselCutValuesBarrel_;
533  hits = ecalBarrelHits;
534  flags_ = flagsexclEB_;
535  severitiesexcl_ = severitiesexclEB_;
536  } else if (subdet==EcalEndcap) {
537  preselCutValues = preselCutValuesEndcap_;
538  hits = ecalEndcapHits;
539  flags_ = flagsexclEE_;
540  severitiesexcl_ = severitiesexclEE_;
541  } else if ( EcalTools::isHGCalDet(thedet) ) {
542  preselCutValues = preselCutValuesEndcap_;
543  hits = nullptr;
544  flags_ = flagsexclEE_;
545  severitiesexcl_ = severitiesexclEE_;
546  } else {
547  edm::LogWarning("")<<"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster: " << thedet << ' ' << subdet;
548  }
549 
550 
551 
552 
553  // SC energy preselection
554  if (parentSCRef.isNonnull() &&
555  ptFast(parentSCRef->energy(),parentSCRef->position(),math::XYZPoint(0,0,0)) <= preselCutValues[0] ) continue;
556  // calculate HoE
557 
558  double HoE1,HoE2;
559  HoE1=HoE2=0.;
560 
561  std::vector<CaloTowerDetId> TowersBehindClus;
562  float hcalDepth1OverEcalBc,hcalDepth2OverEcalBc;
563  hcalDepth1OverEcalBc=hcalDepth2OverEcalBc=0.f;
564  bool invalidHcal = false;
565 
566  if (not hcalTowers_.isUninitialized()) {
567  const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product();
568  EgammaTowerIsolation towerIso1(hOverEConeSize_,0.,0.,1,hcalTowersColl) ;
569  EgammaTowerIsolation towerIso2(hOverEConeSize_,0.,0.,2,hcalTowersColl) ;
570  HoE1=towerIso1.getTowerESum(&(*scRef))/scRef->energy();
571  HoE2=towerIso2.getTowerESum(&(*scRef))/scRef->energy();
572 
573  EgammaHadTower towerIsoBehindClus(es);
574  towerIsoBehindClus.setTowerCollection(hcalTowersHandle.product());
575  TowersBehindClus = towerIsoBehindClus.towersOf(*scRef);
576  hcalDepth1OverEcalBc = towerIsoBehindClus.getDepth1HcalESum(TowersBehindClus)/scRef->energy();
577  hcalDepth2OverEcalBc = towerIsoBehindClus.getDepth2HcalESum(TowersBehindClus)/scRef->energy();
578 
579  if (checkHcalStatus_ && hcalDepth1OverEcalBc == 0 && hcalDepth2OverEcalBc == 0) {
580  invalidHcal = !towerIsoBehindClus.hasActiveHcal(TowersBehindClus);
581  }
582  }
583 
584  // std::cout << " GEDPhotonProducer calculation of HoE with towers in a cone " << HoE1 << " " << HoE2 << std::endl;
585  //std::cout << " GEDPhotonProducer calcualtion of HoE with towers behind the BCs " << hcalDepth1OverEcalBc << " " << hcalDepth2OverEcalBc << std::endl;
586 
587  float maxXtal = ( hits != nullptr ? EcalClusterTools::eMax( *(scRef->seed()), &(*hits) ) : 0.f );
588  //AA
589  //Change these to consider severity level of hits
590  float e1x5 = ( hits != nullptr ? EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
591  float e2x5 = ( hits != nullptr ? EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
592  float e3x3 = ( hits != nullptr ? EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
593  float e5x5 = ( hits != nullptr ? EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
594  std::vector<float> cov = ( hits != nullptr ? EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology), geometry) : std::vector<float>( {0.f,0.f,0.f} ) );
595  std::vector<float> locCov = ( hits != nullptr ? EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology)) : std::vector<float>( {0.f,0.f,0.f} ) );
596 
597  float sigmaEtaEta = sqrt(cov[0]);
598  float sigmaIetaIeta = sqrt(locCov[0]);
599 
600  float full5x5_maxXtal = ( hits != nullptr ? noZS::EcalClusterTools::eMax( *(scRef->seed()), &(*hits) ) : 0.f );
601  //AA
602  //Change these to consider severity level of hits
603  float full5x5_e1x5 = ( hits != nullptr ? noZS::EcalClusterTools::e1x5( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
604  float full5x5_e2x5 = ( hits != nullptr ? noZS::EcalClusterTools::e2x5Max( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
605  float full5x5_e3x3 = ( hits != nullptr ? noZS::EcalClusterTools::e3x3( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
606  float full5x5_e5x5 = ( hits != nullptr ? noZS::EcalClusterTools::e5x5( *(scRef->seed()), &(*hits), &(*topology)) : 0.f );
607  std::vector<float> full5x5_cov = ( hits != nullptr ? noZS::EcalClusterTools::covariances( *(scRef->seed()), &(*hits), &(*topology), geometry) : std::vector<float>( {0.f,0.f,0.f} ) );
608  std::vector<float> full5x5_locCov = ( hits != nullptr ? noZS::EcalClusterTools::localCovariances( *(scRef->seed()), &(*hits), &(*topology)) : std::vector<float>( {0.f,0.f,0.f} ) );
609 
610  float full5x5_sigmaEtaEta = sqrt(full5x5_cov[0]);
611  float full5x5_sigmaIetaIeta = sqrt(full5x5_locCov[0]);
612 
613  // compute position of ECAL shower
614  math::XYZPoint caloPosition = scRef->position();
615 
616 
618  double photonEnergy=1.;
619  math::XYZPoint vtx(0.,0.,0.);
620  if (!vertexCollection.empty()) vtx = vertexCollection.begin()->position();
621  // compute momentum vector of photon from primary vertex and cluster position
622  math::XYZVector direction = caloPosition - vtx;
623  //math::XYZVector momentum = direction.unit() * photonEnergy ;
624  math::XYZVector momentum = direction.unit() ;
625 
626  // Create dummy candidate with unit momentum and zero energy to allow setting of all variables. The energy is set for last.
627  math::XYZTLorentzVectorD p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy );
628  reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
629 
630  //std::cout << " standard p4 before " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
631  //std::cout << " type " <<newCandidate.getCandidateP4type() << " standard p4 after " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
632 
633  // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator
634  reco::Photon::FiducialFlags fiducialFlags;
635  reco::Photon::IsolationVariables isolVarR03, isolVarR04;
636  if( !EcalTools::isHGCalDet(thedet) ) {
637  thePhotonIsolationCalculator_->calculate( &newCandidate,evt,es,fiducialFlags,isolVarR04, isolVarR03);
638  }
639  newCandidate.setFiducialVolumeFlags( fiducialFlags );
640  newCandidate.setIsolationVariables(isolVarR04, isolVarR03 );
641 
642 
644  reco::Photon::ShowerShape showerShape;
645  showerShape.e1x5= e1x5;
646  showerShape.e2x5= e2x5;
647  showerShape.e3x3= e3x3;
648  showerShape.e5x5= e5x5;
649  showerShape.maxEnergyXtal = maxXtal;
650  showerShape.sigmaEtaEta = sigmaEtaEta;
651  showerShape.sigmaIetaIeta = sigmaIetaIeta;
652  showerShape.hcalDepth1OverEcal = HoE1;
653  showerShape.hcalDepth2OverEcal = HoE2;
654  showerShape.hcalDepth1OverEcalBc = hcalDepth1OverEcalBc;
655  showerShape.hcalDepth2OverEcalBc = hcalDepth2OverEcalBc;
656  showerShape.hcalTowersBehindClusters = TowersBehindClus;
657  showerShape.invalidHcal = invalidHcal;
659  const float spp = (!edm::isFinite(locCov[2]) ? 0. : sqrt(locCov[2]));
660  const float sep = locCov[1];
661  showerShape.sigmaIetaIphi = sep;
662  showerShape.sigmaIphiIphi = spp;
663  showerShape.e2nd = ( hits != nullptr ? EcalClusterTools::e2nd(*(scRef->seed()),&(*hits)) : 0.f );
664  showerShape.eTop = ( hits != nullptr ? EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
665  showerShape.eLeft = ( hits != nullptr ? EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
666  showerShape.eRight = ( hits != nullptr ? EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
667  showerShape.eBottom = ( hits != nullptr ? EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
668  showerShape.e1x3 = ( hits != nullptr ? EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
669  showerShape.e2x2 = ( hits != nullptr ? EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
670  showerShape.e2x5Max = ( hits != nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
671  showerShape.e2x5Left = ( hits != nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
672  showerShape.e2x5Right = ( hits != nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
673  showerShape.e2x5Top = ( hits != nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
674  showerShape.e2x5Bottom = ( hits != nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
675  if(hits){
676  Cluster2ndMoments clus2ndMoments = EcalClusterTools::cluster2ndMoments(*(scRef->seed()),*hits);
677  showerShape.smMajor = clus2ndMoments.sMaj;
678  showerShape.smMinor = clus2ndMoments.sMin;
679  showerShape.smAlpha = clus2ndMoments.alpha;
680  }else{
681  showerShape.smMajor = 0.f;
682  showerShape.smMinor = 0.f;
683  showerShape.smAlpha = 0.f;
684  }
685 
686 
687  // fill preshower shapes
689  const float sigmaRR = toolsforES.eseffsirir( *scRef );
690  showerShape.effSigmaRR = sigmaRR;
691  newCandidate.setShowerShapeVariables ( showerShape );
692 
693  reco::Photon::SaturationInfo saturationInfo;
694  const reco::CaloCluster& seedCluster = *(scRef->seed()) ;
695  DetId seedXtalId = seedCluster.seed();
696  int nSaturatedXtals = 0;
697  bool isSeedSaturated = false;
698  if (hits != nullptr) {
699  const auto hitsAndFractions = scRef->hitsAndFractions();
700  for (auto&& hitFractionPair : hitsAndFractions) {
701  auto&& ecalRecHit = hits->find(hitFractionPair.first);
702  if (ecalRecHit == hits->end()) continue;
703  if (ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
704  nSaturatedXtals++;
705  if (seedXtalId == ecalRecHit->detid())
706  isSeedSaturated = true;
707  }
708  }
709  }
710  saturationInfo.nSaturatedXtals = nSaturatedXtals;
711  saturationInfo.isSeedSaturated = isSeedSaturated;
712  newCandidate.setSaturationInfo(saturationInfo);
713 
715  reco::Photon::ShowerShape full5x5_showerShape;
716  full5x5_showerShape.e1x5= full5x5_e1x5;
717  full5x5_showerShape.e2x5= full5x5_e2x5;
718  full5x5_showerShape.e3x3= full5x5_e3x3;
719  full5x5_showerShape.e5x5= full5x5_e5x5;
720  full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
721  full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
722  full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
724  const float full5x5_spp = (!edm::isFinite(full5x5_locCov[2]) ? 0. : sqrt(full5x5_locCov[2]));
725  const float full5x5_sep = full5x5_locCov[1];
726  full5x5_showerShape.sigmaIetaIphi = full5x5_sep;
727  full5x5_showerShape.sigmaIphiIphi = full5x5_spp;
728  full5x5_showerShape.e2nd = ( hits != nullptr ? noZS::EcalClusterTools::e2nd(*(scRef->seed()),&(*hits)) : 0.f );
729  full5x5_showerShape.eTop = ( hits != nullptr ? noZS::EcalClusterTools::eTop(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
730  full5x5_showerShape.eLeft = ( hits != nullptr ? noZS::EcalClusterTools::eLeft(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
731  full5x5_showerShape.eRight = ( hits != nullptr ? noZS::EcalClusterTools::eRight(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
732  full5x5_showerShape.eBottom = ( hits != nullptr ? noZS::EcalClusterTools::eBottom(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
733  full5x5_showerShape.e1x3 = ( hits != nullptr ? noZS::EcalClusterTools::e1x3(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
734  full5x5_showerShape.e2x2 = ( hits != nullptr ? noZS::EcalClusterTools::e2x2(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
735  full5x5_showerShape.e2x5Max = ( hits != nullptr ? noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
736  full5x5_showerShape.e2x5Left = ( hits != nullptr ? noZS::EcalClusterTools::e2x5Left(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
737  full5x5_showerShape.e2x5Right = ( hits != nullptr ? noZS::EcalClusterTools::e2x5Right(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
738  full5x5_showerShape.e2x5Top = ( hits != nullptr ? noZS::EcalClusterTools::e2x5Top(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
739  full5x5_showerShape.e2x5Bottom = ( hits != nullptr ? noZS::EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*hits), &(*topology)) : 0.f );
740  if(hits){
741  Cluster2ndMoments clus2ndMoments = noZS::EcalClusterTools::cluster2ndMoments(*(scRef->seed()),*hits);
742  full5x5_showerShape.smMajor = clus2ndMoments.sMaj;
743  full5x5_showerShape.smMinor = clus2ndMoments.sMin;
744  full5x5_showerShape.smAlpha = clus2ndMoments.alpha;
745  }else{
746  full5x5_showerShape.smMajor = 0.f;
747  full5x5_showerShape.smMinor = 0.f;
748  full5x5_showerShape.smAlpha = 0.f;
749  }
750  // fill preshower shapes
751  full5x5_showerShape.effSigmaRR = sigmaRR;
752  newCandidate.full5x5_setShowerShapeVariables ( full5x5_showerShape );
753 
754 
755 
758  // Photon candidate takes by default (set in photons_cfi.py)
759  // a 4-momentum derived from the ecal photon-specific corrections.
760  if( !EcalTools::isHGCalDet(thedet) ) {
761  thePhotonEnergyCorrector_->calculate(evt, newCandidate, subdet, vertexCollection, es);
762  if ( candidateP4type_ == "fromEcalEnergy") {
763  newCandidate.setP4( newCandidate.p4(reco::Photon::ecal_photons) );
764  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
765  } else if ( candidateP4type_ == "fromRegression1") {
766  newCandidate.setP4( newCandidate.p4(reco::Photon::regression1) );
767  newCandidate.setCandidateP4type(reco::Photon::regression1);
768  } else if ( candidateP4type_ == "fromRegression2") {
769  newCandidate.setP4( newCandidate.p4(reco::Photon::regression2) );
770  newCandidate.setCandidateP4type(reco::Photon::regression2);
771  } else if ( candidateP4type_ == "fromRefinedSCRegression" ) {
772  newCandidate.setP4( newCandidate.p4(reco::Photon::regression2) );
773  newCandidate.setCandidateP4type(reco::Photon::regression2);
774  }
775  } else {
776  math::XYZVector gamma_momentum = direction.unit() * scRef->energy();
777  math::XYZTLorentzVectorD p4(gamma_momentum.x(),
778  gamma_momentum.y(),
779  gamma_momentum.z(),
780  scRef->energy());
781  newCandidate.setP4(p4);
782  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
783  // Make it an EE photon
784  reco::Photon::FiducialFlags fiducialFlags;
785  fiducialFlags.isEE = true;
786  newCandidate.setFiducialVolumeFlags(fiducialFlags);
787  }
788 
789  // std::cout << " final p4 " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
790 
791 
792  // std::cout << " GEDPhotonProducer from candidate HoE with towers in a cone " << newCandidate.hadronicOverEm() << " " << newCandidate.hadronicDepth1OverEm() << " " << newCandidate.hadronicDepth2OverEm() << std::endl;
793  // std::cout << " GEDPhotonProducer from candidate of HoE with towers behind the BCs " << newCandidate.hadTowOverEm() << " " << newCandidate.hadTowDepth1OverEm() << " " << newCandidate.hadTowDepth2OverEm() << std::endl;
794 
795 
796  // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger
798  if(subdet==EcalBarrel && runMIPTagger_ )
799  {
800 
801  thePhotonMIPHaloTagger_-> MIPcalculate( &newCandidate,evt,es,mipVar);
802  newCandidate.setMIPVariables(mipVar);
803  }
804 
805 
806 
808  bool isLooseEM=true;
809  if ( newCandidate.pt() < highEt_) {
810  if ( newCandidate.hadronicOverEm() >= preselCutValues[1] ) isLooseEM=false;
811  if ( newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2]+ preselCutValues[3]*newCandidate.pt() ) isLooseEM=false;
812  if ( newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4]+ preselCutValues[5]*newCandidate.pt() ) isLooseEM=false;
813  if ( newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]) ) isLooseEM=false;
814  if ( newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]) ) isLooseEM=false;
815  if ( newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8] ) isLooseEM=false;
816  if ( newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9] ) isLooseEM=false;
817  if ( newCandidate.sigmaIetaIeta() > preselCutValues[10] ) isLooseEM=false;
818  }
819 
820 
821 
822  if ( isLooseEM)
823  outputPhotonCollection.push_back(newCandidate);
824 
825 
826  }
827 }
828 
829 
830 
831 
833  edm::EventSetup const & es,
834  const edm::Handle<reco::PhotonCollection> & photonHandle,
835  const edm::Handle<reco::PFCandidateCollection> pfCandidateHandle,
836  const edm::Handle<reco::PFCandidateCollection> pfEGCandidateHandle,
837  edm::ValueMap<reco::PhotonRef> pfEGCandToPhotonMap,
840  const edm::Handle<edm::ValueMap<float>>& chargedHadrons,
841  const edm::Handle<edm::ValueMap<float>>& neutralHadrons,
843  const edm::Handle<edm::ValueMap<float>>& chargedHadronsWorstVtx,
844  const edm::Handle<edm::ValueMap<float>>& chargedHadronsWorstVtxGeomVeto,
845  const edm::Handle<edm::ValueMap<float>>& chargedHadronsPFPV,
846  const edm::Handle<edm::ValueMap<float>>& pfEcalClusters,
847  const edm::Handle<edm::ValueMap<float>>& pfHcalClusters){
848 
849 
850 
851  std::vector<double> preselCutValues;
852 
853 
854  for(unsigned int lSC=0; lSC < photonHandle->size(); lSC++) {
855  reco::PhotonRef phoRef(reco::PhotonRef(photonHandle, lSC));
856  reco::SuperClusterRef parentSCRef = phoRef->parentSuperCluster();
857  reco::SuperClusterRef scRef=phoRef->superCluster();
858  DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
859  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
860  if (subdet==EcalBarrel) {
861  preselCutValues = preselCutValuesBarrel_;
862  } else if (subdet==EcalEndcap) {
863  preselCutValues = preselCutValuesEndcap_;
864  } else if (EcalTools::isHGCalDet(thedet)) {
865  preselCutValues = preselCutValuesEndcap_;
866  } else {
867  edm::LogWarning("")<<"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet << ' ' << subdet;
868  }
869 
870 
871 
872  // SC energy preselection
873  if (parentSCRef.isNonnull() &&
874  ptFast(parentSCRef->energy(),parentSCRef->position(),math::XYZPoint(0,0,0)) <= preselCutValues[0] ) continue;
875  reco::Photon newCandidate(*phoRef);
876  iSC++;
877 
878 
879  // Calculate the PF isolation and ID - for the time being there is no calculation. Only the setting
882 
883  //get the pointer for the photon object
884  edm::Ptr<reco::Photon> photonPtr(photonHandle, lSC);
885 
886  if(!recoStep_.isOOT()){ //out of time photons do not have PF info so skip in this case
887  pfIso.chargedHadronIso = (*chargedHadrons)[photonPtr] ;
888  pfIso.neutralHadronIso = (*neutralHadrons)[photonPtr];
889  pfIso.photonIso = (*photons)[photonPtr];
890  pfIso.chargedHadronWorstVtxIso = (*chargedHadronsWorstVtx)[photonPtr];
891  pfIso.chargedHadronWorstVtxGeomVetoIso = (*chargedHadronsWorstVtxGeomVeto)[photonPtr];
892  pfIso.chargedHadronPFPVIso = (*chargedHadronsPFPV)[photonPtr];
893  }
894 
895  //OOT photons in legacy 80X reminiAOD workflow dont have pf cluster isolation embeded into them at this stage
897  pfIso.sumEcalClusterEt = (*pfEcalClusters)[photonPtr];
898  }else pfIso.sumEcalClusterEt = 0.;
899 
901  pfIso.sumHcalClusterEt = (*pfHcalClusters)[photonPtr];
902  }else pfIso.sumHcalClusterEt = 0.;
903 
904  newCandidate.setPflowIsolationVariables(pfIso);
905  newCandidate.setPflowIDVariables(pfID);
906 
907  // do the regression
908  thePhotonEnergyCorrector_->calculate(evt, newCandidate, subdet, *vertexHandle, es);
909  if ( candidateP4type_ == "fromEcalEnergy") {
910  newCandidate.setP4( newCandidate.p4(reco::Photon::ecal_photons) );
912  } else if ( candidateP4type_ == "fromRegression1") {
913  newCandidate.setP4( newCandidate.p4(reco::Photon::regression1) );
915  } else if ( candidateP4type_ == "fromRegression2") {
916  newCandidate.setP4( newCandidate.p4(reco::Photon::regression2) );
918  } else if ( candidateP4type_ == "fromRefinedSCRegression" ) {
919  newCandidate.setP4( newCandidate.p4(reco::Photon::regression2) );
921  }
922 
923  // std::cout << " GEDPhotonProducer pf based isolation chargedHadron " << newCandidate.chargedHadronIso() << " neutralHadron " << newCandidate.neutralHadronIso() << " Photon " << newCandidate.photonIso() << std::endl;
924  //std::cout << " GEDPhotonProducer from candidate HoE with towers in a cone " << newCandidate.hadronicOverEm() << " " << newCandidate.hadronicDepth1OverEm() << " " << newCandidate.hadronicDepth2OverEm() << std::endl;
925  //std::cout << " GEDPhotonProducer from candidate of HoE with towers behind the BCs " << newCandidate.hadTowOverEm() << " " << newCandidate.hadTowDepth1OverEm() << " " << newCandidate.hadTowDepth2OverEm() << std::endl;
926  //std::cout << " standard p4 before " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
927  //std::cout << " type " <<newCandidate.getCandidateP4type() << " standard p4 after " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
928  //std::cout << " final p4 " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
929 
930  outputPhotonCollection.push_back(newCandidate);
931 
932  }
933 
934 }
edm::InputTag photonProducer_
void setPflowIsolationVariables(const PflowIsolationVariables &pfisol)
Set Particle Flow Isolation variables.
Definition: Photon.h:509
T getParameter(std::string const &) const
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:54
PhotonEnergyCorrector * thePhotonEnergyCorrector_
PhotonMIPHaloTagger * thePhotonMIPHaloTagger_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
void calculate(const reco::Photon *, const edm::Event &, const edm::EventSetup &es, reco::Photon::FiducialFlags &phofid, reco::Photon::IsolationVariables &phoisolR03, reco::Photon::IsolationVariables &phoisolR04) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
edm::ESHandle< CaloGeometry > theCaloGeom_
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: Photon.h:152
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
void setCandidateP4type(const P4type type)
Definition: Photon.h:314
void beginRun(edm::Run const &r, edm::EventSetup const &es) final
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
CaloTopology const * topology(0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
static float eMax(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
void produce(edm::Event &evt, const edm::EventSetup &es) override
~GEDPhotonProducer() override
#define nullptr
int init
Definition: HydjetWrapper.h:67
RecoStepInfo recoStep_
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::vector< int > flagsexclEB_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
Definition: config.py:1
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
constexpr bool isFinite(T x)
PhotonIsolationCalculator * thePhotonIsolationCalculator_
std::vector< int > severitiesexclEE_
std::unique_ptr< ModifyObjectValueBase > & gedRegression()
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
std::string photonCollection_
bool hasActiveHcal(const reco::SuperCluster &sc) const
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
RecoStepInfo(const std::string &recoStep)
edm::ESHandle< CaloTopology > theCaloTopo_
void setTowerCollection(const CaloTowerCollection *towercollection)
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedPFPVIsoToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
PositionCalc posCalculator_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxGeomVetoIsoToken_
double getDepth1HcalESum(const reco::SuperCluster &sc) const
static float e2x2(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedIsolationToken_
T sqrt(T t)
Definition: SSEVec.h:18
double p4[4]
Definition: TauolaWrapper.h:92
void setup(const edm::ParameterSet &conf, std::vector< int > const &flagsEB_, std::vector< int > const &flagsEE_, std::vector< int > const &severitiesEB_, std::vector< int > const &severitiesEE_, edm::ConsumesCollector &&iC)
void setPflowIDVariables(const PflowIDVariables &pfid)
Definition: Photon.h:532
static float e2nd(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
std::vector< int > flagsexclEE_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducerT_
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double f[11][100]
static float eBottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< edm::ValueMap< float > > phoPFHCALClusIsolationToken_
void init(const edm::EventSetup &theEventSetup)
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
bool isValid() const
Definition: HandleBase.h:74
double getTowerESum(const reco::Candidate *cand, const std::vector< CaloTowerDetId > *detIdToExclude=0) const
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
std::vector< int > severitiesexclEB_
const_iterator end() const
static Cluster2ndMoments cluster2ndMoments(const reco::BasicCluster &basicCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
static float eTop(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: DetId.h:18
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
edm::EDGetTokenT< edm::ValueMap< float > > phoNeutralHadronIsolationToken_
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:207
GEDPhotonProducer(const edm::ParameterSet &ps)
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxIsoToken_
T const * product() const
Definition: Handle.h:74
std::vector< double > preselCutValuesBarrel_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Detector
Definition: DetId.h:26
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
std::vector< double > preselCutValuesEndcap_
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
const LorentzVector & p4(P4type type) const
std::string candidateP4type_
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCoreCollection > &photonCoreHandle, const CaloTopology *topology, const EcalRecHitCollection *ecalBarrelHits, const EcalRecHitCollection *ecalEndcapHits, const EcalRecHitCollection *preshowerHits, const edm::Handle< CaloTowerCollection > &hcalTowersHandle, const reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
edm::EDGetTokenT< edm::ValueMap< float > > phoPhotonIsolationToken_
void endRun(edm::Run const &, edm::EventSetup const &) final
std::string const & label() const
Definition: InputTag.h:36
std::vector< CaloTowerDetId > towersOf(const reco::SuperCluster &sc) const
double getDepth2HcalESum(const reco::SuperCluster &sc) const
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
HLT enums.
static int position[264][3]
Definition: ReadPGInfo.cc:509
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< edm::ValueMap< float > > phoPFECALClusIsolationToken_
edm::ParameterSet conf_
static float eRight(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
bool isUninitialized() const
Definition: EDGetToken.h:70
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
step
Definition: StallMonitor.cc:94
static float e1x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
T const * product() const
Definition: ESHandle.h:86
static float eLeft(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
edm::EDGetTokenT< EcalRecHitCollection > preshowerHits_
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
void setP4(P4type type, const LorentzVector &p4, float p4Error, bool setToRecoCandidate)
std::string valueMapPFCandPhoton_
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)