CMS 3D CMS Logo

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

#include <PhotonProducer.h>

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

Public Member Functions

 PhotonProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Member Functions

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 edm::Handle< CaloTowerCollection > &hcalTowersHandle, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC, const EcalSeverityLevelAlgo *sevLv)
 

Private Attributes

edm::EDGetTokenT< EcalRecHitCollectionbarrelEcalHits_
 
std::string candidateP4type_
 
edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHits_
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
edm::EDGetTokenT< CaloTowerCollectionhcalTowers_
 
double highEt_
 
double hOverEConeSize_
 
double maxHOverE_
 
double minR9Barrel_
 
double minR9Endcap_
 
double minSCEt_
 
std::string PhotonCollection_
 
edm::EDGetTokenT< reco::PhotonCoreCollectionphotonCoreProducer_
 
PhotonEnergyCorrector photonEnergyCorrector_
 
PhotonIsolationCalculator photonIsolationCalculator_
 
PhotonMIPHaloTagger photonMIPHaloTagger_
 
PositionCalc posCalculator_
 
std::vector< double > preselCutValuesBarrel_
 
std::vector< double > preselCutValuesEndcap_
 
bool runMIPTagger_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 
bool usePrimaryVertex_
 
bool validConversions_
 
bool validPixelSeeds_
 
edm::EDGetTokenT< reco::VertexCollectionvertexProducer_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 35 of file PhotonProducer.h.

Constructor & Destructor Documentation

PhotonProducer::PhotonProducer ( const edm::ParameterSet ps)

Definition at line 33 of file PhotonProducer.cc.

References barrelEcalHits_, candidateP4type_, endcapEcalHits_, flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), hcalTowers_, highEt_, hOverEConeSize_, gedPhotons_cfi::isolationSumsCalculatorSet, minR9Barrel_, minR9Endcap_, gedPhotons_cfi::mipVariableSet, PhotonCollection_, photonCoreProducer_, photonIsolationCalculator_, photonMIPHaloTagger_, MonitorAlCaEcalPi0_cfi::posCalcParameters, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, runMIPTagger_, PhotonMIPHaloTagger::setup(), PhotonIsolationCalculator::setup(), severitiesexclEB_, severitiesexclEE_, AlCaHLTBitMon_QueryRunRegistry::string, usePrimaryVertex_, and vertexProducer_.

33  : photonEnergyCorrector_(config, consumesCollector()) {
34  // use onfiguration file to setup input/output collection names
35 
36  photonCoreProducer_ = consumes<reco::PhotonCoreCollection>(config.getParameter<edm::InputTag>("photonCoreProducer"));
37  barrelEcalHits_ = consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("barrelEcalHits"));
38  endcapEcalHits_ = consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("endcapEcalHits"));
39  vertexProducer_ = consumes<reco::VertexCollection>(config.getParameter<edm::InputTag>("primaryVertexProducer"));
40  hcalTowers_ = consumes<CaloTowerCollection>(config.getParameter<edm::InputTag>("hcalTowers"));
41  hOverEConeSize_ = config.getParameter<double>("hOverEConeSize");
42  highEt_ = config.getParameter<double>("highEt");
43  // R9 value to decide converted/unconverted
44  minR9Barrel_ = config.getParameter<double>("minR9Barrel");
45  minR9Endcap_ = config.getParameter<double>("minR9Endcap");
46  usePrimaryVertex_ = config.getParameter<bool>("usePrimaryVertex");
47  runMIPTagger_ = config.getParameter<bool>("runMIPTagger");
48 
49  candidateP4type_ = config.getParameter<std::string>("candidateP4type");
50 
51  edm::ParameterSet posCalcParameters = config.getParameter<edm::ParameterSet>("posCalcParameters");
53 
54  //AA
55  //Flags and Severities to be excluded from photon calculations
56  const std::vector<std::string> flagnamesEB =
57  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEB");
58 
59  const std::vector<std::string> flagnamesEE =
60  config.getParameter<std::vector<std::string> >("RecHitFlagToBeExcludedEE");
61 
62  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
63 
64  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
65 
66  const std::vector<std::string> severitynamesEB =
67  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEB");
68 
69  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
70 
71  const std::vector<std::string> severitynamesEE =
72  config.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcludedEE");
73 
74  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
75 
76  //AA
77 
78  //
79 
80  // Parameters for the position calculation:
81  // std::map<std::string,double> providedParameters;
82  // providedParameters.insert(std::make_pair("LogWeighted",config.getParameter<bool>("posCalc_logweight")));
83  //providedParameters.insert(std::make_pair("T0_barl",config.getParameter<double>("posCalc_t0_barl")));
84  //providedParameters.insert(std::make_pair("T0_endc",config.getParameter<double>("posCalc_t0_endc")));
85  //providedParameters.insert(std::make_pair("T0_endcPresh",config.getParameter<double>("posCalc_t0_endcPresh")));
86  //providedParameters.insert(std::make_pair("W0",config.getParameter<double>("posCalc_w0")));
87  //providedParameters.insert(std::make_pair("X0",config.getParameter<double>("posCalc_x0")));
88  //posCalculator_ = PositionCalc(providedParameters);
89  // cut values for pre-selection
90  preselCutValuesBarrel_.push_back(config.getParameter<double>("minSCEtBarrel"));
91  preselCutValuesBarrel_.push_back(config.getParameter<double>("maxHoverEBarrel"));
92  preselCutValuesBarrel_.push_back(config.getParameter<double>("ecalRecHitSumEtOffsetBarrel"));
93  preselCutValuesBarrel_.push_back(config.getParameter<double>("ecalRecHitSumEtSlopeBarrel"));
94  preselCutValuesBarrel_.push_back(config.getParameter<double>("hcalTowerSumEtOffsetBarrel"));
95  preselCutValuesBarrel_.push_back(config.getParameter<double>("hcalTowerSumEtSlopeBarrel"));
96  preselCutValuesBarrel_.push_back(config.getParameter<double>("nTrackSolidConeBarrel"));
97  preselCutValuesBarrel_.push_back(config.getParameter<double>("nTrackHollowConeBarrel"));
98  preselCutValuesBarrel_.push_back(config.getParameter<double>("trackPtSumSolidConeBarrel"));
99  preselCutValuesBarrel_.push_back(config.getParameter<double>("trackPtSumHollowConeBarrel"));
100  preselCutValuesBarrel_.push_back(config.getParameter<double>("sigmaIetaIetaCutBarrel"));
101  //
102  preselCutValuesEndcap_.push_back(config.getParameter<double>("minSCEtEndcap"));
103  preselCutValuesEndcap_.push_back(config.getParameter<double>("maxHoverEEndcap"));
104  preselCutValuesEndcap_.push_back(config.getParameter<double>("ecalRecHitSumEtOffsetEndcap"));
105  preselCutValuesEndcap_.push_back(config.getParameter<double>("ecalRecHitSumEtSlopeEndcap"));
106  preselCutValuesEndcap_.push_back(config.getParameter<double>("hcalTowerSumEtOffsetEndcap"));
107  preselCutValuesEndcap_.push_back(config.getParameter<double>("hcalTowerSumEtSlopeEndcap"));
108  preselCutValuesEndcap_.push_back(config.getParameter<double>("nTrackSolidConeEndcap"));
109  preselCutValuesEndcap_.push_back(config.getParameter<double>("nTrackHollowConeEndcap"));
110  preselCutValuesEndcap_.push_back(config.getParameter<double>("trackPtSumSolidConeEndcap"));
111  preselCutValuesEndcap_.push_back(config.getParameter<double>("trackPtSumHollowConeEndcap"));
112  preselCutValuesEndcap_.push_back(config.getParameter<double>("sigmaIetaIetaCutEndcap"));
113  //
114 
115  edm::ParameterSet isolationSumsCalculatorSet = config.getParameter<edm::ParameterSet>("isolationSumsCalculatorSet");
117  isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_, consumesCollector());
118 
119  edm::ParameterSet mipVariableSet = config.getParameter<edm::ParameterSet>("mipVariableSet");
120  photonMIPHaloTagger_.setup(mipVariableSet, consumesCollector());
121 
122  // Register the product
123  produces<reco::PhotonCollection>(PhotonCollection_);
124 }
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
std::vector< double > preselCutValuesEndcap_
PositionCalc posCalculator_
Definition: config.py:1
PhotonEnergyCorrector photonEnergyCorrector_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
PhotonMIPHaloTagger photonMIPHaloTagger_
double hOverEConeSize_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
PhotonIsolationCalculator photonIsolationCalculator_
std::vector< int > flagsexclEB_
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)
std::vector< int > flagsexclEE_
std::string candidateP4type_
std::vector< int > severitiesexclEE_
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
std::vector< int > severitiesexclEB_
std::string PhotonCollection_
std::vector< double > preselCutValuesBarrel_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_

Member Function Documentation

void PhotonProducer::fillPhotonCollection ( edm::Event evt,
edm::EventSetup const &  es,
const edm::Handle< reco::PhotonCoreCollection > &  photonCoreHandle,
const CaloTopology topology,
const EcalRecHitCollection ecalBarrelHits,
const EcalRecHitCollection ecalEndcapHits,
const edm::Handle< CaloTowerCollection > &  hcalTowersHandle,
reco::VertexCollection pvVertices,
reco::PhotonCollection outputCollection,
int &  iSC,
const EcalSeverityLevelAlgo sevLv 
)
private

fill shower shape block

fill full5x5 shower shape block

get ecal photon specific corrected energy plus values from regressions and store them in the Photon

Pre-selection loose isolation cuts

Definition at line 214 of file PhotonProducer.cc.

References PhotonIsolationCalculator::calculate(), PhotonEnergyCorrector::calculate(), PositionCalc::Calculate_Location(), candidateP4type_, EcalClusterToolsT< noZS >::covariances(), EgHLTOffHistBins_cfi::e1x5, EcalClusterToolsT< noZS >::e1x5(), reco::Photon::ShowerShape::e1x5, EgHLTOffHistBins_cfi::e2x5, reco::Photon::ShowerShape::e2x5, EcalClusterToolsT< noZS >::e2x5Max(), EcalClusterToolsT< noZS >::e3x3(), reco::Photon::ShowerShape::e3x3, EcalClusterToolsT< noZS >::e5x5(), reco::Photon::ShowerShape::e5x5, DetId::Ecal, reco::Photon::ecal_photons, EcalBarrel, EcalEndcap, EcalPreshower, cosmicPhotonAnalyzer_cfi::eMax, EcalClusterToolsT< noZS >::eMax(), flagsexclEB_, flagsexclEE_, HLT_2018_cff::full5x5_sigmaIetaIeta, geometry, edm::EventSetup::get(), EgammaHadTower::getDepth1HcalESum(), EgammaHadTower::getDepth2HcalESum(), CaloGeometry::getSubdetectorGeometry(), EgammaTowerIsolation::getTowerESum(), reco::Photon::ShowerShape::hcalDepth1OverEcal, reco::Photon::ShowerShape::hcalDepth1OverEcalBc, reco::Photon::ShowerShape::hcalDepth2OverEcal, reco::Photon::ShowerShape::hcalDepth2OverEcalBc, reco::Photon::ShowerShape::hcalTowersBehindClusters, highEt_, hfClusterShapes_cfi::hits, hOverEConeSize_, PhotonEnergyCorrector::init(), createfilelist::int, EcalClusterToolsT< noZS >::localCovariances(), reco::Photon::ShowerShape::maxEnergyXtal, EgHLTOffEleSelection_cfi::minR9, minR9Barrel_, minR9Endcap_, PhotonMIPHaloTagger::MIPcalculate(), p4, MaterialEffects_cfi::photonEnergy, photonEnergyCorrector_, photonIsolationCalculator_, photonMIPHaloTagger_, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), electrons_cff::r9, reco::Photon::regression1, runMIPTagger_, EgammaHadTower::setTowerCollection(), severitiesexclEB_, severitiesexclEE_, electronIdCutBasedExt_cfi::sigmaEtaEta, reco::Photon::ShowerShape::sigmaEtaEta, reco::Photon::ShowerShape::sigmaIetaIeta, mathSSE::sqrt(), EgammaHadTower::towersOf(), and badGlobalMuonTaggersAOD_cff::vtx.

Referenced by produce().

224  {
225  // get the geometry from the event setup:
226  edm::ESHandle<CaloGeometry> caloGeomHandle;
227  es.get<CaloGeometryRecord>().get(caloGeomHandle);
228 
229  const CaloGeometry* geometry = caloGeomHandle.product();
230  const CaloSubdetectorGeometry* subDetGeometry = nullptr;
231  const CaloSubdetectorGeometry* geometryES = caloGeomHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
232  const EcalRecHitCollection* hits = nullptr;
233  std::vector<double> preselCutValues;
234  float minR9 = 0;
235 
237 
238  std::vector<int> flags_, severitiesexcl_;
239 
240  for (unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
241  reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC));
242  reco::SuperClusterRef scRef = coreRef->superCluster();
243  iSC++;
244 
245  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
246  subDetGeometry = caloGeomHandle->getSubdetectorGeometry(DetId::Ecal, subdet);
247 
248  if (subdet == EcalBarrel) {
249  preselCutValues = preselCutValuesBarrel_;
250  minR9 = minR9Barrel_;
251  hits = ecalBarrelHits;
252  flags_ = flagsexclEB_;
253  severitiesexcl_ = severitiesexclEB_;
254  } else if (subdet == EcalEndcap) {
255  preselCutValues = preselCutValuesEndcap_;
256  minR9 = minR9Endcap_;
257  hits = ecalEndcapHits;
258  flags_ = flagsexclEE_;
259  severitiesexcl_ = severitiesexclEE_;
260  } else {
261  edm::LogWarning("") << "PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
262  }
263  if (hits == nullptr)
264  continue;
265 
266  // SC energy preselection
267  if (scRef->energy() / cosh(scRef->eta()) <= preselCutValues[0])
268  continue;
269  // calculate HoE
270 
271  const CaloTowerCollection* hcalTowersColl = hcalTowersHandle.product();
272  EgammaTowerIsolation towerIso1(hOverEConeSize_, 0., 0., 1, hcalTowersColl);
273  EgammaTowerIsolation towerIso2(hOverEConeSize_, 0., 0., 2, hcalTowersColl);
274  double HoE1 = towerIso1.getTowerESum(&(*scRef)) / scRef->energy();
275  double HoE2 = towerIso2.getTowerESum(&(*scRef)) / scRef->energy();
276 
277  EgammaHadTower towerIsoBehindClus(es);
278  towerIsoBehindClus.setTowerCollection(hcalTowersHandle.product());
279  std::vector<CaloTowerDetId> TowersBehindClus = towerIsoBehindClus.towersOf(*scRef);
280  float hcalDepth1OverEcalBc = towerIsoBehindClus.getDepth1HcalESum(TowersBehindClus) / scRef->energy();
281  float hcalDepth2OverEcalBc = towerIsoBehindClus.getDepth2HcalESum(TowersBehindClus) / scRef->energy();
282 
283  // recalculate position of seed BasicCluster taking shower depth for unconverted photon
284  math::XYZPoint unconvPos =
285  posCalculator_.Calculate_Location(scRef->seed()->hitsAndFractions(), hits, subDetGeometry, geometryES);
286 
287  float maxXtal = EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
288  //AA
289  //Change these to consider severity level of hits
290  float e1x5 = EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
291  float e2x5 = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
292  float e3x3 = EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
293  float e5x5 = EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
294  std::vector<float> cov = EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology), geometry);
295  std::vector<float> locCov = EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
296 
297  float sigmaEtaEta = sqrt(cov[0]);
298  float sigmaIetaIeta = sqrt(locCov[0]);
299  float r9 = e3x3 / (scRef->rawEnergy());
300 
301  float full5x5_maxXtal = noZS::EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
302  //AA
303  //Change these to consider severity level of hits
304  float full5x5_e1x5 = noZS::EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
305  float full5x5_e2x5 = noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
306  float full5x5_e3x3 = noZS::EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
307  float full5x5_e5x5 = noZS::EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
308  std::vector<float> full5x5_cov =
309  noZS::EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology), geometry);
310  std::vector<float> full5x5_locCov =
311  noZS::EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
312 
313  float full5x5_sigmaEtaEta = sqrt(full5x5_cov[0]);
314  float full5x5_sigmaIetaIeta = sqrt(full5x5_locCov[0]);
315 
316  // compute position of ECAL shower
317  math::XYZPoint caloPosition;
318  if (r9 > minR9) {
319  caloPosition = unconvPos;
320  } else {
321  caloPosition = scRef->position();
322  }
323 
325  double photonEnergy = 1.;
326  math::XYZPoint vtx(0., 0., 0.);
327  if (!vertexCollection.empty())
328  vtx = vertexCollection.begin()->position();
329  // compute momentum vector of photon from primary vertex and cluster position
330  math::XYZVector direction = caloPosition - vtx;
331  math::XYZVector momentum = direction.unit();
332 
333  // Create dummy candidate with unit momentum and zero energy to allow setting of all variables. The energy is set for last.
334  math::XYZTLorentzVectorD p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy);
335  reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
336 
337  // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator
338  reco::Photon::FiducialFlags fiducialFlags;
339  reco::Photon::IsolationVariables isolVarR03, isolVarR04;
340  photonIsolationCalculator_.calculate(&newCandidate, evt, es, fiducialFlags, isolVarR04, isolVarR03);
341  newCandidate.setFiducialVolumeFlags(fiducialFlags);
342  newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
343 
345  reco::Photon::ShowerShape showerShape;
346  showerShape.e1x5 = e1x5;
347  showerShape.e2x5 = e2x5;
348  showerShape.e3x3 = e3x3;
349  showerShape.e5x5 = e5x5;
350  showerShape.maxEnergyXtal = maxXtal;
351  showerShape.sigmaEtaEta = sigmaEtaEta;
352  showerShape.sigmaIetaIeta = sigmaIetaIeta;
353  showerShape.hcalDepth1OverEcal = HoE1;
354  showerShape.hcalDepth2OverEcal = HoE2;
355  showerShape.hcalDepth1OverEcalBc = hcalDepth1OverEcalBc;
356  showerShape.hcalDepth2OverEcalBc = hcalDepth2OverEcalBc;
357  showerShape.hcalTowersBehindClusters = TowersBehindClus;
358  newCandidate.setShowerShapeVariables(showerShape);
359 
361  reco::Photon::ShowerShape full5x5_showerShape;
362  full5x5_showerShape.e1x5 = full5x5_e1x5;
363  full5x5_showerShape.e2x5 = full5x5_e2x5;
364  full5x5_showerShape.e3x3 = full5x5_e3x3;
365  full5x5_showerShape.e5x5 = full5x5_e5x5;
366  full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
367  full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
368  full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
369  newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
370 
373  // Photon candidate takes by default (set in photons_cfi.py) a 4-momentum derived from the ecal photon-specific corrections.
374  photonEnergyCorrector_.calculate(evt, newCandidate, subdet, vertexCollection, es);
375  if (candidateP4type_ == "fromEcalEnergy") {
376  newCandidate.setP4(newCandidate.p4(reco::Photon::ecal_photons));
377  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
378  } else if (candidateP4type_ == "fromRegression") {
379  newCandidate.setP4(newCandidate.p4(reco::Photon::regression1));
380  newCandidate.setCandidateP4type(reco::Photon::regression1);
381  }
382 
383  // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger
385  if (subdet == EcalBarrel && runMIPTagger_) {
386  photonMIPHaloTagger_.MIPcalculate(&newCandidate, evt, es, mipVar);
387  newCandidate.setMIPVariables(mipVar);
388  }
389 
391  bool isLooseEM = true;
392  if (newCandidate.pt() < highEt_) {
393  if (newCandidate.hadronicOverEm() >= preselCutValues[1])
394  isLooseEM = false;
395  if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
396  isLooseEM = false;
397  if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
398  isLooseEM = false;
399  if (newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]))
400  isLooseEM = false;
401  if (newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]))
402  isLooseEM = false;
403  if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
404  isLooseEM = false;
405  if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
406  isLooseEM = false;
407  if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
408  isLooseEM = false;
409  }
410 
411  if (isLooseEM)
412  outputPhotonCollection.push_back(newCandidate);
413  }
414 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
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
std::vector< double > preselCutValuesEndcap_
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
static std::vector< float > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
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)
PositionCalc posCalculator_
PhotonEnergyCorrector photonEnergyCorrector_
PhotonMIPHaloTagger photonMIPHaloTagger_
double hOverEConeSize_
PhotonIsolationCalculator photonIsolationCalculator_
std::vector< int > flagsexclEB_
T sqrt(T t)
Definition: SSEVec.h:19
double p4[4]
Definition: TauolaWrapper.h:92
std::vector< int > flagsexclEE_
std::string candidateP4type_
std::vector< int > severitiesexclEE_
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void init(const edm::EventSetup &theEventSetup)
std::vector< int > severitiesexclEB_
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
T const * product() const
Definition: Handle.h:69
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
std::vector< double > preselCutValuesBarrel_
ESHandle< TrackerGeometry > geometry
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=0)
Definition: PositionCalc.h:65
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
T const * product() const
Definition: ESHandle.h:86
static std::vector< float > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=4.7)
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
void PhotonProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 126 of file PhotonProducer.cc.

References barrelEcalHits_, HLT_2018_cff::barrelRecHits, endcapEcalHits_, HLT_2018_cff::endcapRecHits, fillPhotonCollection(), edm::EventSetup::get(), edm::Event::getByToken(), hcalTowers_, edm::HandleBase::isValid(), eostools::move(), gedPhotons_cfi::outputPhotonCollection, PhotonCollection_, photonCoreProducer_, edm::Handle< T >::product(), edm::ESHandle< T >::product(), edm::Event::put(), ecaldqm::topology(), usePrimaryVertex_, spclusmultinvestigator_cfi::vertexCollection, and vertexProducer_.

126  {
127  using namespace edm;
128  // nEvt_++;
129 
131  auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
132 
133  // Get the PhotonCore collection
134  bool validPhotonCoreHandle = true;
135  Handle<reco::PhotonCoreCollection> photonCoreHandle;
136  theEvent.getByToken(photonCoreProducer_, photonCoreHandle);
137  if (!photonCoreHandle.isValid()) {
138  edm::LogError("PhotonProducer") << "Error! Can't get the photonCoreProducer";
139  validPhotonCoreHandle = false;
140  }
141 
142  // Get EcalRecHits
143  bool validEcalRecHits = true;
144  Handle<EcalRecHitCollection> barrelHitHandle;
146  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
147  if (!barrelHitHandle.isValid()) {
148  edm::LogError("PhotonProducer") << "Error! Can't get the barrelEcalHits";
149  validEcalRecHits = false;
150  }
151  if (validEcalRecHits)
152  barrelRecHits = *(barrelHitHandle.product());
153 
154  Handle<EcalRecHitCollection> endcapHitHandle;
155  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
157  if (!endcapHitHandle.isValid()) {
158  edm::LogError("PhotonProducer") << "Error! Can't get the endcapEcalHits";
159  validEcalRecHits = false;
160  }
161  if (validEcalRecHits)
162  endcapRecHits = *(endcapHitHandle.product());
163 
164  //AA
165  //Get the severity level object
167  theEventSetup.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
168  //
169 
170  // get Hcal towers collection
171  Handle<CaloTowerCollection> hcalTowersHandle;
172  theEvent.getByToken(hcalTowers_, hcalTowersHandle);
173 
174  edm::ESHandle<CaloTopology> pTopology;
175  theEventSetup.get<CaloTopologyRecord>().get(pTopology);
176  const CaloTopology* topology = pTopology.product();
177 
178  // Get the primary event vertex
179  Handle<reco::VertexCollection> vertexHandle;
181  bool validVertex = true;
182  if (usePrimaryVertex_) {
183  theEvent.getByToken(vertexProducer_, vertexHandle);
184  if (!vertexHandle.isValid()) {
185  edm::LogWarning("PhotonProducer") << "Error! Can't get the product primary Vertex Collection "
186  << "\n";
187  validVertex = false;
188  }
189  if (validVertex)
190  vertexCollection = *(vertexHandle.product());
191  }
192 
193  int iSC = 0; // index in photon collection
194  // Loop over barrel and endcap SC collections and fill the photon collection
195  if (validPhotonCoreHandle)
196  fillPhotonCollection(theEvent,
197  theEventSetup,
198  photonCoreHandle,
199  topology,
200  &barrelRecHits,
201  &endcapRecHits,
202  hcalTowersHandle,
203  vertexCollection,
204  outputPhotonCollection,
205  iSC,
206  sevLv.product());
207 
208  // put the product in the event
209  edm::LogInfo("PhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n";
210  outputPhotonCollection_p->assign(outputPhotonCollection.begin(), outputPhotonCollection.end());
211  theEvent.put(std::move(outputPhotonCollection_p), PhotonCollection_);
212 }
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< CaloTowerCollection > hcalTowers_
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 edm::Handle< CaloTowerCollection > &hcalTowersHandle, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC, const EcalSeverityLevelAlgo *sevLv)
CaloTopology const * topology(0)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
bool isValid() const
Definition: HandleBase.h:70
std::string PhotonCollection_
T const * product() const
Definition: Handle.h:69
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
HLT enums.
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<EcalRecHitCollection> PhotonProducer::barrelEcalHits_
private

Definition at line 57 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

std::string PhotonProducer::candidateP4type_
private

Definition at line 94 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::EDGetTokenT<EcalRecHitCollection> PhotonProducer::endcapEcalHits_
private

Definition at line 58 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

std::vector<int> PhotonProducer::flagsexclEB_
private

Definition at line 65 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<int> PhotonProducer::flagsexclEE_
private

Definition at line 66 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::EDGetTokenT<CaloTowerCollection> PhotonProducer::hcalTowers_
private

Definition at line 59 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

double PhotonProducer::highEt_
private

Definition at line 73 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::hOverEConeSize_
private

Definition at line 70 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::maxHOverE_
private

Definition at line 71 of file PhotonProducer.h.

double PhotonProducer::minR9Barrel_
private

Definition at line 74 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minR9Endcap_
private

Definition at line 75 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minSCEt_
private

Definition at line 72 of file PhotonProducer.h.

std::string PhotonProducer::PhotonCollection_
private

Definition at line 55 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

edm::EDGetTokenT<reco::PhotonCoreCollection> PhotonProducer::photonCoreProducer_
private

Definition at line 56 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

PhotonEnergyCorrector PhotonProducer::photonEnergyCorrector_
private

Definition at line 93 of file PhotonProducer.h.

Referenced by fillPhotonCollection().

PhotonIsolationCalculator PhotonProducer::photonIsolationCalculator_
private

Definition at line 85 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

PhotonMIPHaloTagger PhotonProducer::photonMIPHaloTagger_
private

Definition at line 88 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

PositionCalc PhotonProducer::posCalculator_
private

Definition at line 82 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<double> PhotonProducer::preselCutValuesBarrel_
private

Definition at line 90 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<double> PhotonProducer::preselCutValuesEndcap_
private

Definition at line 91 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

bool PhotonProducer::runMIPTagger_
private

Definition at line 76 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<int> PhotonProducer::severitiesexclEB_
private

Definition at line 67 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::vector<int> PhotonProducer::severitiesexclEE_
private

Definition at line 68 of file PhotonProducer.h.

Referenced by fillPhotonCollection(), and PhotonProducer().

bool PhotonProducer::usePrimaryVertex_
private

Definition at line 80 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().

bool PhotonProducer::validConversions_
private

Definition at line 78 of file PhotonProducer.h.

bool PhotonProducer::validPixelSeeds_
private

Definition at line 84 of file PhotonProducer.h.

edm::EDGetTokenT<reco::VertexCollection> PhotonProducer::vertexProducer_
private

Definition at line 60 of file PhotonProducer.h.

Referenced by PhotonProducer(), and produce().