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