CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
PhotonProducer Class Reference
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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, ElectronHcalHelper const &hcalHelperCone, ElectronHcalHelper const &hcalHelperBc, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
 

Private Attributes

edm::EDGetTokenT
< EcalRecHitCollection
barrelEcalHits_
 
const edm::ESGetToken
< CaloGeometry,
CaloGeometryRecord
caloGeomToken_
 
std::string candidateP4type_
 
edm::EDGetTokenT
< EcalRecHitCollection
endcapEcalHits_
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
edm::EDGetTokenT
< HBHERecHitCollection
hbheRecHits_
 
std::unique_ptr
< ElectronHcalHelper
hcalHelperBc_
 
std::unique_ptr
< ElectronHcalHelper
hcalHelperCone_
 
bool hcalRun2EffDepth_
 
double highEt_
 
double hOverEConeSize_
 
double minR9Barrel_
 
double minR9Endcap_
 
std::string PhotonCollection_
 
edm::EDGetTokenT
< reco::PhotonCoreCollection
photonCoreProducer_
 
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_
 
const edm::ESGetToken
< CaloTopology,
CaloTopologyRecord
topologyToken_
 
bool usePrimaryVertex_
 
bool validConversions_
 
bool validPixelSeeds_
 
edm::EDGetTokenT
< reco::VertexCollection
vertexProducer_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Author
Nancy Marinelli, U. of Notre Dame, US

Definition at line 44 of file PhotonProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 114 of file PhotonProducer.cc.

References barrelEcalHits_, candidateP4type_, endcapEcalHits_, flagsexclEB_, flagsexclEE_, edm::ParameterSet::getParameter(), hbheRecHits_, hcalHelperBc_, hcalHelperCone_, hcalRun2EffDepth_, highEt_, ElectronHcalHelper::Configuration::hOverEConeSize, hOverEConeSize_, minR9Barrel_, minR9Endcap_, PhotonCollection_, photonCoreProducer_, photonIsolationCalculator_, photonMIPHaloTagger_, HLT_FULL_cff::posCalcParameters, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, runMIPTagger_, PhotonMIPHaloTagger::setup(), PhotonIsolationCalculator::setup(), severitiesexclEB_, severitiesexclEE_, AlCaHLTBitMon_QueryRunRegistry::string, usePrimaryVertex_, and vertexProducer_.

116  // use configuration file to setup input/output collection names
117 
118  photonCoreProducer_ = consumes<reco::PhotonCoreCollection>(config.getParameter<edm::InputTag>("photonCoreProducer"));
119  barrelEcalHits_ = consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("barrelEcalHits"));
120  endcapEcalHits_ = consumes<EcalRecHitCollection>(config.getParameter<edm::InputTag>("endcapEcalHits"));
121  vertexProducer_ = consumes<reco::VertexCollection>(config.getParameter<edm::InputTag>("primaryVertexProducer"));
122  hbheRecHits_ = consumes<HBHERecHitCollection>(config.getParameter<edm::InputTag>("hbheRecHits"));
123  hOverEConeSize_ = config.getParameter<double>("hOverEConeSize");
124  highEt_ = config.getParameter<double>("highEt");
125  // R9 value to decide converted/unconverted
126  minR9Barrel_ = config.getParameter<double>("minR9Barrel");
127  minR9Endcap_ = config.getParameter<double>("minR9Endcap");
128  usePrimaryVertex_ = config.getParameter<bool>("usePrimaryVertex");
129  runMIPTagger_ = config.getParameter<bool>("runMIPTagger");
130 
131  candidateP4type_ = config.getParameter<std::string>("candidateP4type");
132 
133  edm::ParameterSet posCalcParameters = config.getParameter<edm::ParameterSet>("posCalcParameters");
135 
136  //AA
137  //Flags and Severities to be excluded from photon calculations
138  const std::vector<std::string> flagnamesEB =
139  config.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEB");
140 
141  const std::vector<std::string> flagnamesEE =
142  config.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEE");
143 
144  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
145 
146  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
147 
148  const std::vector<std::string> severitynamesEB =
149  config.getParameter<std::vector<std::string>>("RecHitSeverityToBeExcludedEB");
150 
151  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
152 
153  const std::vector<std::string> severitynamesEE =
154  config.getParameter<std::vector<std::string>>("RecHitSeverityToBeExcludedEE");
155 
156  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
157 
158  ElectronHcalHelper::Configuration cfgCone, cfgBc;
160  if (cfgCone.hOverEConeSize > 0) {
161  cfgCone.onlyBehindCluster = false;
162  cfgCone.checkHcalStatus = false;
163 
164  cfgCone.hbheRecHits = hbheRecHits_;
165 
166  cfgCone.eThresHB = config.getParameter<EgammaHcalIsolation::arrayHB>("recHitEThresholdHB");
167  cfgCone.maxSeverityHB = config.getParameter<int>("maxHcalRecHitSeverity");
168  cfgCone.eThresHE = config.getParameter<EgammaHcalIsolation::arrayHE>("recHitEThresholdHE");
169  cfgCone.maxSeverityHE = cfgCone.maxSeverityHB;
170  }
171 
172  cfgBc.hOverEConeSize = 0.;
173  cfgBc.onlyBehindCluster = true;
174  cfgBc.checkHcalStatus = false;
175 
176  cfgBc.hbheRecHits = hbheRecHits_;
177 
178  cfgBc.eThresHB = config.getParameter<EgammaHcalIsolation::arrayHB>("recHitEThresholdHB");
179  cfgBc.maxSeverityHB = config.getParameter<int>("maxHcalRecHitSeverity");
180  cfgBc.eThresHE = config.getParameter<EgammaHcalIsolation::arrayHE>("recHitEThresholdHE");
181  cfgBc.maxSeverityHE = cfgBc.maxSeverityHB;
182 
183  hcalHelperCone_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
184  hcalHelperBc_ = std::make_unique<ElectronHcalHelper>(cfgBc, consumesCollector());
185 
186  hcalRun2EffDepth_ = config.getParameter<bool>("hcalRun2EffDepth");
187 
188  //AA
189 
190  //
191 
192  // Parameters for the position calculation:
193  // std::map<std::string,double> providedParameters;
194  // providedParameters.insert(std::make_pair("LogWeighted",config.getParameter<bool>("posCalc_logweight")));
195  //providedParameters.insert(std::make_pair("T0_barl",config.getParameter<double>("posCalc_t0_barl")));
196  //providedParameters.insert(std::make_pair("T0_endc",config.getParameter<double>("posCalc_t0_endc")));
197  //providedParameters.insert(std::make_pair("T0_endcPresh",config.getParameter<double>("posCalc_t0_endcPresh")));
198  //providedParameters.insert(std::make_pair("W0",config.getParameter<double>("posCalc_w0")));
199  //providedParameters.insert(std::make_pair("X0",config.getParameter<double>("posCalc_x0")));
200  //posCalculator_ = PositionCalc(providedParameters);
201  // cut values for pre-selection
202  preselCutValuesBarrel_.push_back(config.getParameter<double>("minSCEtBarrel"));
203  preselCutValuesBarrel_.push_back(config.getParameter<double>("maxHoverEBarrel"));
204  preselCutValuesBarrel_.push_back(config.getParameter<double>("ecalRecHitSumEtOffsetBarrel"));
205  preselCutValuesBarrel_.push_back(config.getParameter<double>("ecalRecHitSumEtSlopeBarrel"));
206  preselCutValuesBarrel_.push_back(config.getParameter<double>("hcalRecHitSumEtOffsetBarrel"));
207  preselCutValuesBarrel_.push_back(config.getParameter<double>("hcalRecHitSumEtSlopeBarrel"));
208  preselCutValuesBarrel_.push_back(config.getParameter<double>("nTrackSolidConeBarrel"));
209  preselCutValuesBarrel_.push_back(config.getParameter<double>("nTrackHollowConeBarrel"));
210  preselCutValuesBarrel_.push_back(config.getParameter<double>("trackPtSumSolidConeBarrel"));
211  preselCutValuesBarrel_.push_back(config.getParameter<double>("trackPtSumHollowConeBarrel"));
212  preselCutValuesBarrel_.push_back(config.getParameter<double>("sigmaIetaIetaCutBarrel"));
213  //
214  preselCutValuesEndcap_.push_back(config.getParameter<double>("minSCEtEndcap"));
215  preselCutValuesEndcap_.push_back(config.getParameter<double>("maxHoverEEndcap"));
216  preselCutValuesEndcap_.push_back(config.getParameter<double>("ecalRecHitSumEtOffsetEndcap"));
217  preselCutValuesEndcap_.push_back(config.getParameter<double>("ecalRecHitSumEtSlopeEndcap"));
218  preselCutValuesEndcap_.push_back(config.getParameter<double>("hcalRecHitSumEtOffsetEndcap"));
219  preselCutValuesEndcap_.push_back(config.getParameter<double>("hcalRecHitSumEtSlopeEndcap"));
220  preselCutValuesEndcap_.push_back(config.getParameter<double>("nTrackSolidConeEndcap"));
221  preselCutValuesEndcap_.push_back(config.getParameter<double>("nTrackHollowConeEndcap"));
222  preselCutValuesEndcap_.push_back(config.getParameter<double>("trackPtSumSolidConeEndcap"));
223  preselCutValuesEndcap_.push_back(config.getParameter<double>("trackPtSumHollowConeEndcap"));
224  preselCutValuesEndcap_.push_back(config.getParameter<double>("sigmaIetaIetaCutEndcap"));
225  //
226 
227  edm::ParameterSet isolationSumsCalculatorSet = config.getParameter<edm::ParameterSet>("isolationSumsCalculatorSet");
229  isolationSumsCalculatorSet, flagsexclEB_, flagsexclEE_, severitiesexclEB_, severitiesexclEE_, consumesCollector());
230 
231  edm::ParameterSet mipVariableSet = config.getParameter<edm::ParameterSet>("mipVariableSet");
232  photonMIPHaloTagger_.setup(mipVariableSet, consumesCollector());
233 
234  // Register the product
235  produces<reco::PhotonCollection>(PhotonCollection_);
236 }
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
std::vector< double > preselCutValuesEndcap_
std::unique_ptr< ElectronHcalHelper > hcalHelperCone_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
PositionCalc posCalculator_
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > topologyToken_
PhotonEnergyCorrector photonEnergyCorrector_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
PhotonMIPHaloTagger photonMIPHaloTagger_
double hOverEConeSize_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
PhotonIsolationCalculator photonIsolationCalculator_
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
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_
tuple posCalcParameters
void setup(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
std::vector< int > severitiesexclEB_
std::string PhotonCollection_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
std::vector< double > preselCutValuesBarrel_
tuple config
parse the configuration file
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
std::array< double, 4 > arrayHB
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::array< double, 7 > arrayHE

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,
ElectronHcalHelper const &  hcalHelperCone,
ElectronHcalHelper const &  hcalHelperBc,
reco::VertexCollection pvVertices,
reco::PhotonCollection outputCollection,
int &  iSC 
)
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 325 of file PhotonProducer.cc.

References PhotonEnergyCorrector::calculate(), PhotonIsolationCalculator::calculate(), PositionCalc::Calculate_Location(), caloGeomToken_, candidateP4type_, EcalClusterToolsT< noZS >::covariances(), EcalClusterToolsT< noZS >::e1x5(), reco::Photon::ShowerShape::e1x5, 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, EcalClusterToolsT< noZS >::eMax(), flagsexclEB_, flagsexclEE_, relativeConstraints::geometry, edm::EventSetup::getData(), CaloGeometry::getSubdetectorGeometry(), ElectronHcalHelper::hcalESum(), reco::Photon::ShowerShape::hcalOverEcal, reco::Photon::ShowerShape::hcalOverEcalBc, ElectronHcalHelper::hcalTowersBehindClusters(), reco::Photon::ShowerShape::hcalTowersBehindClusters, highEt_, gpuClustering::id, PhotonEnergyCorrector::init(), EcalClusterToolsT< noZS >::localCovariances(), reco::Photon::ShowerShape::maxEnergyXtal, minR9Barrel_, minR9Endcap_, PhotonMIPHaloTagger::MIPcalculate(), photonEnergyCorrector_, photonIsolationCalculator_, photonMIPHaloTagger_, posCalculator_, reco::Photon::ShowerShape::pre7DepthHcal, preselCutValuesBarrel_, preselCutValuesEndcap_, reco::Photon::regression1, runMIPTagger_, severitiesexclEB_, severitiesexclEE_, reco::Photon::ShowerShape::sigmaEtaEta, reco::Photon::ShowerShape::sigmaIetaIeta, mathSSE::sqrt(), and parallelization::uint().

Referenced by produce().

335  {
336  // get the geometry from the event setup:
337  const CaloGeometry* geometry = &es.getData(caloGeomToken_);
338  const CaloSubdetectorGeometry* subDetGeometry = nullptr;
340  const EcalRecHitCollection* hits = nullptr;
341  std::vector<double> preselCutValues;
342  float minR9 = 0;
343 
345 
346  std::vector<int> flags_, severitiesexcl_;
347 
348  for (unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
349  reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC));
350  reco::SuperClusterRef scRef = coreRef->superCluster();
351  iSC++;
352 
353  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
354  subDetGeometry = geometry->getSubdetectorGeometry(DetId::Ecal, subdet);
355 
356  if (subdet == EcalBarrel) {
357  preselCutValues = preselCutValuesBarrel_;
358  minR9 = minR9Barrel_;
359  hits = ecalBarrelHits;
360  flags_ = flagsexclEB_;
361  severitiesexcl_ = severitiesexclEB_;
362  } else if (subdet == EcalEndcap) {
363  preselCutValues = preselCutValuesEndcap_;
364  minR9 = minR9Endcap_;
365  hits = ecalEndcapHits;
366  flags_ = flagsexclEE_;
367  severitiesexcl_ = severitiesexclEE_;
368  } else {
369  edm::LogWarning("") << "PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
370  }
371  if (hits == nullptr)
372  continue;
373 
374  // SC energy preselection
375  if (scRef->energy() / cosh(scRef->eta()) <= preselCutValues[0])
376  continue;
377 
378  // recalculate position of seed BasicCluster taking shower depth for unconverted photon
379  math::XYZPoint unconvPos =
380  posCalculator_.Calculate_Location(scRef->seed()->hitsAndFractions(), hits, subDetGeometry, geometryES);
381 
382  float maxXtal = EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
383  //AA
384  //Change these to consider severity level of hits
385  float e1x5 = EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
386  float e2x5 = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
387  float e3x3 = EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
388  float e5x5 = EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
389  const auto& cov = EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology), geometry);
390  const auto& locCov = EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
391 
392  float sigmaEtaEta = sqrt(cov[0]);
393  float sigmaIetaIeta = sqrt(locCov[0]);
394  float r9 = e3x3 / (scRef->rawEnergy());
395 
396  float full5x5_maxXtal = noZS::EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
397  //AA
398  //Change these to consider severity level of hits
399  float full5x5_e1x5 = noZS::EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
400  float full5x5_e2x5 = noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
401  float full5x5_e3x3 = noZS::EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
402  float full5x5_e5x5 = noZS::EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
403  const auto& full5x5_cov = noZS::EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology), geometry);
404  const auto& full5x5_locCov = noZS::EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
405 
406  float full5x5_sigmaEtaEta = sqrt(full5x5_cov[0]);
407  float full5x5_sigmaIetaIeta = sqrt(full5x5_locCov[0]);
408 
409  // compute position of ECAL shower
410  math::XYZPoint caloPosition;
411  if (r9 > minR9) {
412  caloPosition = unconvPos;
413  } else {
414  caloPosition = scRef->position();
415  }
416 
418  double photonEnergy = 1.;
419  math::XYZPoint vtx(0., 0., 0.);
420  if (!vertexCollection.empty())
421  vtx = vertexCollection.begin()->position();
422  // compute momentum vector of photon from primary vertex and cluster position
423  math::XYZVector direction = caloPosition - vtx;
424  math::XYZVector momentum = direction.unit();
425 
426  // Create dummy candidate with unit momentum and zero energy to allow setting of all variables. The energy is set for last.
427  math::XYZTLorentzVectorD p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy);
428  reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
429 
430  // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator
431  reco::Photon::FiducialFlags fiducialFlags;
432  reco::Photon::IsolationVariables isolVarR03, isolVarR04;
433  photonIsolationCalculator_.calculate(&newCandidate, evt, es, fiducialFlags, isolVarR04, isolVarR03);
434  newCandidate.setFiducialVolumeFlags(fiducialFlags);
435  newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
436 
438  reco::Photon::ShowerShape showerShape;
439  showerShape.e1x5 = e1x5;
440  showerShape.e2x5 = e2x5;
441  showerShape.e3x3 = e3x3;
442  showerShape.e5x5 = e5x5;
443  showerShape.maxEnergyXtal = maxXtal;
444  showerShape.sigmaEtaEta = sigmaEtaEta;
445  showerShape.sigmaIetaIeta = sigmaIetaIeta;
446  for (uint id = 0; id < showerShape.hcalOverEcal.size(); ++id) {
447  showerShape.hcalOverEcal[id] = hcalHelperCone.hcalESum(*scRef, id + 1) / scRef->energy();
448  showerShape.hcalOverEcalBc[id] = hcalHelperBc.hcalESum(*scRef, id + 1) / scRef->energy();
449  }
450  showerShape.hcalTowersBehindClusters = hcalHelperBc.hcalTowersBehindClusters(*scRef);
451  showerShape.pre7DepthHcal = false;
452  newCandidate.setShowerShapeVariables(showerShape);
453 
455  reco::Photon::ShowerShape full5x5_showerShape;
456  full5x5_showerShape.e1x5 = full5x5_e1x5;
457  full5x5_showerShape.e2x5 = full5x5_e2x5;
458  full5x5_showerShape.e3x3 = full5x5_e3x3;
459  full5x5_showerShape.e5x5 = full5x5_e5x5;
460  full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
461  full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
462  full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
463  for (uint id = 0; id < full5x5_showerShape.hcalOverEcal.size(); ++id) {
464  full5x5_showerShape.hcalOverEcal[id] = hcalHelperCone.hcalESum(*scRef, id + 1) / full5x5_e5x5;
465  full5x5_showerShape.hcalOverEcalBc[id] = hcalHelperBc.hcalESum(*scRef, id + 1) / full5x5_e5x5;
466  }
467  full5x5_showerShape.hcalTowersBehindClusters = hcalHelperBc.hcalTowersBehindClusters(*scRef);
468  full5x5_showerShape.pre7DepthHcal = false;
469  newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
470 
473  // Photon candidate takes by default (set in photons_cfi.py) a 4-momentum derived from the ecal photon-specific corrections.
474  photonEnergyCorrector_.calculate(evt, newCandidate, subdet, vertexCollection, es);
475  if (candidateP4type_ == "fromEcalEnergy") {
476  newCandidate.setP4(newCandidate.p4(reco::Photon::ecal_photons));
477  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
478  } else if (candidateP4type_ == "fromRegression") {
479  newCandidate.setP4(newCandidate.p4(reco::Photon::regression1));
480  newCandidate.setCandidateP4type(reco::Photon::regression1);
481  }
482 
483  // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger
485  if (subdet == EcalBarrel && runMIPTagger_) {
486  photonMIPHaloTagger_.MIPcalculate(&newCandidate, evt, es, mipVar);
487  newCandidate.setMIPVariables(mipVar);
488  }
489 
491  bool isLooseEM = true;
492  if (newCandidate.pt() < highEt_) {
493  if (newCandidate.hadronicOverEm() >= preselCutValues[1])
494  isLooseEM = false;
495  if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
496  isLooseEM = false;
497  if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
498  isLooseEM = false;
499  if (newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]))
500  isLooseEM = false;
501  if (newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]))
502  isLooseEM = false;
503  if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
504  isLooseEM = false;
505  if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
506  isLooseEM = false;
507  if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
508  isLooseEM = false;
509  }
510 
511  if (isLooseEM)
512  outputPhotonCollection.push_back(newCandidate);
513  }
514 }
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:153
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
uint16_t *__restrict__ id
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_
std::array< float, 7 > hcalOverEcalBc
Definition: Photon.h:152
PhotonEnergyCorrector photonEnergyCorrector_
tuple vertexCollection
PhotonMIPHaloTagger photonMIPHaloTagger_
static std::array< float, 3 > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
PhotonIsolationCalculator photonIsolationCalculator_
static std::array< float, 3 > localCovariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, float w0=EgammaLocalCovParamDefaults::kRelEnCut, const EcalPFRecHitThresholds *thresholds=nullptr, float multEB=0.0, float multEE=0.0)
std::vector< int > flagsexclEB_
T sqrt(T t)
Definition: SSEVec.h:19
std::vector< int > flagsexclEE_
std::string candidateP4type_
std::vector< int > severitiesexclEE_
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=nullptr)
Definition: PositionCalc.h:65
void init(const edm::EventSetup &theEventSetup)
std::vector< int > severitiesexclEB_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
void calculate(edm::Event &evt, reco::Photon &, int subdet, const reco::VertexCollection &vtxcol, const edm::EventSetup &iSetup)
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::array< float, 7 > hcalOverEcal
Definition: Photon.h:150
std::vector< double > preselCutValuesBarrel_
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Log< level::Warning, false > LogWarning
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 238 of file PhotonProducer.cc.

References barrelEcalHits_, HLT_FULL_cff::barrelRecHits, endcapEcalHits_, HLT_FULL_cff::endcapRecHits, fillPhotonCollection(), edm::Event::getByToken(), edm::EventSetup::getData(), hcalHelperBc_, hcalHelperCone_, hcalRun2EffDepth_, eostools::move(), PhotonCollection_, photonCoreProducer_, edm::Event::put(), topologyToken_, usePrimaryVertex_, GoodVertex_cfg::vertexCollection, and vertexProducer_.

238  {
239  using namespace edm;
240  // nEvt_++;
241 
242  reco::PhotonCollection outputPhotonCollection;
243  auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
244 
245  // Get the PhotonCore collection
246  bool validPhotonCoreHandle = true;
247  Handle<reco::PhotonCoreCollection> photonCoreHandle;
248  theEvent.getByToken(photonCoreProducer_, photonCoreHandle);
249  if (!photonCoreHandle.isValid()) {
250  edm::LogError("PhotonProducer") << "Error! Can't get the photonCoreProducer";
251  validPhotonCoreHandle = false;
252  }
253 
254  // Get EcalRecHits
255  bool validEcalRecHits = true;
256  Handle<EcalRecHitCollection> barrelHitHandle;
258  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
259  if (!barrelHitHandle.isValid()) {
260  edm::LogError("PhotonProducer") << "Error! Can't get the barrelEcalHits";
261  validEcalRecHits = false;
262  }
263  if (validEcalRecHits)
264  barrelRecHits = *(barrelHitHandle.product());
265 
266  Handle<EcalRecHitCollection> endcapHitHandle;
267  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
269  if (!endcapHitHandle.isValid()) {
270  edm::LogError("PhotonProducer") << "Error! Can't get the endcapEcalHits";
271  validEcalRecHits = false;
272  }
273  if (validEcalRecHits)
274  endcapRecHits = *(endcapHitHandle.product());
275 
276  const CaloTopology* topology = &theEventSetup.getData(topologyToken_);
277 
278  // prepare access to hcal data
279  hcalHelperCone_->beginEvent(theEvent, theEventSetup);
280  hcalHelperBc_->beginEvent(theEvent, theEventSetup);
281 
282  // Get the primary event vertex
283  Handle<reco::VertexCollection> vertexHandle;
285  bool validVertex = true;
286  if (usePrimaryVertex_) {
287  theEvent.getByToken(vertexProducer_, vertexHandle);
288  if (!vertexHandle.isValid()) {
289  edm::LogWarning("PhotonProducer") << "Error! Can't get the product primary Vertex Collection "
290  << "\n";
291  validVertex = false;
292  }
293  if (validVertex)
294  vertexCollection = *(vertexHandle.product());
295  }
296 
297  int iSC = 0; // index in photon collection
298  // Loop over barrel and endcap SC collections and fill the photon collection
299  if (validPhotonCoreHandle)
300  fillPhotonCollection(theEvent,
301  theEventSetup,
302  photonCoreHandle,
303  topology,
304  &barrelRecHits,
305  &endcapRecHits,
307  *hcalHelperBc_,
309  outputPhotonCollection,
310  iSC);
311 
312  // put the product in the event
313  edm::LogInfo("PhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n";
314  outputPhotonCollection_p->assign(outputPhotonCollection.begin(), outputPhotonCollection.end());
315 
316  // go back to run2-like 2 effective depths if desired - depth 1 is the normal depth 1, depth 2 is the sum over the rest
317  if (hcalRun2EffDepth_) {
318  for (auto& pho : *outputPhotonCollection_p)
319  pho.hcalToRun2EffDepth();
320  }
321 
322  theEvent.put(std::move(outputPhotonCollection_p), PhotonCollection_);
323 }
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
std::unique_ptr< ElectronHcalHelper > hcalHelperCone_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > topologyToken_
Log< level::Error, false > LogError
tuple vertexCollection
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
def move
Definition: eostools.py:511
std::string PhotonCollection_
Log< level::Info, false > LogInfo
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCoreCollection > &photonCoreHandle, const CaloTopology *topology, const EcalRecHitCollection *ecalBarrelHits, const EcalRecHitCollection *ecalEndcapHits, ElectronHcalHelper const &hcalHelperCone, ElectronHcalHelper const &hcalHelperBc, reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC)
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
Log< level::Warning, false > LogWarning

Member Data Documentation

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

Definition at line 66 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> PhotonProducer::caloGeomToken_
private

Definition at line 70 of file PhotonProducer.cc.

Referenced by fillPhotonCollection().

std::string PhotonProducer::candidateP4type_
private

Definition at line 103 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 67 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

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

Definition at line 76 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 77 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

edm::EDGetTokenT<HBHERecHitCollection> PhotonProducer::hbheRecHits_
private

Definition at line 68 of file PhotonProducer.cc.

Referenced by PhotonProducer().

std::unique_ptr<ElectronHcalHelper> PhotonProducer::hcalHelperBc_
private

Definition at line 107 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

std::unique_ptr<ElectronHcalHelper> PhotonProducer::hcalHelperCone_
private

Definition at line 106 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

bool PhotonProducer::hcalRun2EffDepth_
private

Definition at line 108 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

double PhotonProducer::highEt_
private

Definition at line 82 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::hOverEConeSize_
private

Definition at line 81 of file PhotonProducer.cc.

Referenced by PhotonProducer().

double PhotonProducer::minR9Barrel_
private

Definition at line 83 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

double PhotonProducer::minR9Endcap_
private

Definition at line 84 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

std::string PhotonProducer::PhotonCollection_
private

Definition at line 64 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

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

Definition at line 65 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

PhotonEnergyCorrector PhotonProducer::photonEnergyCorrector_
private

Definition at line 102 of file PhotonProducer.cc.

Referenced by fillPhotonCollection().

PhotonIsolationCalculator PhotonProducer::photonIsolationCalculator_
private

Definition at line 94 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

PhotonMIPHaloTagger PhotonProducer::photonMIPHaloTagger_
private

Definition at line 97 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

PositionCalc PhotonProducer::posCalculator_
private

Definition at line 91 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 99 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 100 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

bool PhotonProducer::runMIPTagger_
private

Definition at line 85 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 78 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

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

Definition at line 79 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

const edm::ESGetToken<CaloTopology, CaloTopologyRecord> PhotonProducer::topologyToken_
private

Definition at line 71 of file PhotonProducer.cc.

Referenced by produce().

bool PhotonProducer::usePrimaryVertex_
private

Definition at line 89 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

bool PhotonProducer::validConversions_
private

Definition at line 87 of file PhotonProducer.cc.

bool PhotonProducer::validPixelSeeds_
private

Definition at line 93 of file PhotonProducer.cc.

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

Definition at line 69 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().