CMS 3D CMS Logo

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

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 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< EcalRecHitCollectionbarrelEcalHits_
 
const edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeomToken_
 
std::string candidateP4type_
 
bool cutsFromDB
 
edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHits_
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
edm::EDGetTokenT< HBHERecHitCollectionhbheRecHits_
 
HcalPFCuts const * hcalCuts = nullptr
 
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcdhcalCutsToken_
 
std::unique_ptr< ElectronHcalHelperhcalHelperBc_
 
std::unique_ptr< ElectronHcalHelperhcalHelperCone_
 
bool hcalRun2EffDepth_
 
double highEt_
 
double hOverEConeSize_
 
double minR9Barrel_
 
double minR9Endcap_
 
std::string PhotonCollection_
 
edm::EDGetTokenT< reco::PhotonCoreCollectionphotonCoreProducer_
 
PhotonEnergyCorrector photonEnergyCorrector_
 
PhotonIsolationCalculator photonIsolationCalculator_
 
PhotonMIPHaloTagger photonMIPHaloTagger_
 
std::unique_ptr< PhotonMVABasedHaloTaggerphotonMVABasedHaloTagger_ = nullptr
 
PositionCalc posCalculator_
 
std::vector< double > preselCutValuesBarrel_
 
std::vector< double > preselCutValuesEndcap_
 
bool runMIPTagger_
 
bool runMVABasedHaloTagger_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 
const edm::ESGetToken< CaloTopology, CaloTopologyRecordtopologyToken_
 
bool usePrimaryVertex_
 
bool validConversions_
 
bool validPixelSeeds_
 
edm::EDGetTokenT< reco::VertexCollectionvertexProducer_
 

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 48 of file PhotonProducer.cc.

Constructor & Destructor Documentation

◆ PhotonProducer()

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

Definition at line 126 of file PhotonProducer.cc.

References barrelEcalHits_, candidateP4type_, cutsFromDB, endcapEcalHits_, flagsexclEB_, flagsexclEE_, hbheRecHits_, hcalCutsToken_, hcalHelperBc_, hcalHelperCone_, hcalRun2EffDepth_, highEt_, ElectronHcalHelper::Configuration::hOverEConeSize, hOverEConeSize_, gedPhotons_cfi::isolationSumsCalculatorSet, minR9Barrel_, minR9Endcap_, gedPhotons_cfi::mipVariableSet, PhotonCollection_, photonCoreProducer_, photonIsolationCalculator_, photonMIPHaloTagger_, ecalPiZeroTask_cfi::posCalcParameters, posCalculator_, preselCutValuesBarrel_, preselCutValuesEndcap_, runMIPTagger_, runMVABasedHaloTagger_, PhotonMIPHaloTagger::setup(), PhotonIsolationCalculator::setup(), severitiesexclEB_, severitiesexclEE_, AlCaHLTBitMon_QueryRunRegistry::string, usePrimaryVertex_, and vertexProducer_.

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

Member Function Documentation

◆ beginRun()

void PhotonProducer::beginRun ( const edm::Run run,
const edm::EventSetup theEventSetup 
)
override

Definition at line 257 of file PhotonProducer.cc.

References cutsFromDB, edm::EventSetup::getData(), hcalCuts, and hcalCutsToken_.

257  {
258  if (cutsFromDB) {
259  hcalCuts = &theEventSetup.getData(hcalCutsToken_);
260  }
261 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
HcalPFCuts const * hcalCuts

◆ fillPhotonCollection()

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 350 of file PhotonProducer.cc.

References PhotonEnergyCorrector::calculate(), PhotonIsolationCalculator::calculate(), PositionCalc::Calculate_Location(), caloGeomToken_, 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_2023v12_cff::full5x5_sigmaIetaIeta, relativeConstraints::geometry, edm::EventSetup::getData(), hcalCuts, ElectronHcalHelper::hcalESum(), reco::Photon::ShowerShape::hcalOverEcal, reco::Photon::ShowerShape::hcalOverEcalBc, ElectronHcalHelper::hcalTowersBehindClusters(), reco::Photon::ShowerShape::hcalTowersBehindClusters, highEt_, hfClusterShapes_cfi::hits, l1ctLayer2EG_cff::id, PhotonEnergyCorrector::init(), createfilelist::int, EcalClusterToolsT< noZS >::localCovariances(), reco::Photon::ShowerShape::maxEnergyXtal, EgHLTOffEleSelection_cfi::minR9, minR9Barrel_, minR9Endcap_, PhotonMIPHaloTagger::MIPcalculate(), gedPhotons_cfi::outputPhotonCollection, MaterialEffects_cfi::photonEnergy, photonEnergyCorrector_, photonIsolationCalculator_, photonMIPHaloTagger_, posCalculator_, reco::Photon::ShowerShape::pre7DepthHcal, preselCutValuesBarrel_, preselCutValuesEndcap_, electrons_cff::r9, reco::Photon::regression1, runMIPTagger_, severitiesexclEB_, severitiesexclEE_, reco::Photon::ShowerShape::sigmaEtaEta, HLT_2023v12_cff::sigmaEtaEta, run3scouting_cff::sigmaIetaIeta, reco::Photon::ShowerShape::sigmaIetaIeta, mathSSE::sqrt(), parallelization::uint, spclusmultinvestigator_cfi::vertexCollection, and L1BJetProducer_cff::vtx.

Referenced by produce().

360  {
361  // get the geometry from the event setup:
362  const CaloGeometry* geometry = &es.getData(caloGeomToken_);
363  const CaloSubdetectorGeometry* subDetGeometry = nullptr;
364  const CaloSubdetectorGeometry* geometryES = geometry->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
365  const EcalRecHitCollection* hits = nullptr;
366  std::vector<double> preselCutValues;
367  float minR9 = 0;
368 
370 
371  std::vector<int> flags_, severitiesexcl_;
372 
373  for (unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
374  reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC));
375  reco::SuperClusterRef scRef = coreRef->superCluster();
376  iSC++;
377 
378  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
379  subDetGeometry = geometry->getSubdetectorGeometry(DetId::Ecal, subdet);
380 
381  if (subdet == EcalBarrel) {
382  preselCutValues = preselCutValuesBarrel_;
384  hits = ecalBarrelHits;
385  flags_ = flagsexclEB_;
386  severitiesexcl_ = severitiesexclEB_;
387  } else if (subdet == EcalEndcap) {
388  preselCutValues = preselCutValuesEndcap_;
390  hits = ecalEndcapHits;
391  flags_ = flagsexclEE_;
392  severitiesexcl_ = severitiesexclEE_;
393  } else {
394  edm::LogWarning("") << "PhotonProducer: do not know if it is a barrel or endcap SuperCluster";
395  }
396  if (hits == nullptr)
397  continue;
398 
399  // SC energy preselection
400  if (scRef->energy() / cosh(scRef->eta()) <= preselCutValues[0])
401  continue;
402 
403  // recalculate position of seed BasicCluster taking shower depth for unconverted photon
404  math::XYZPoint unconvPos =
405  posCalculator_.Calculate_Location(scRef->seed()->hitsAndFractions(), hits, subDetGeometry, geometryES);
406 
407  float maxXtal = EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
408  //AA
409  //Change these to consider severity level of hits
410  float e1x5 = EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
411  float e2x5 = EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
412  float e3x3 = EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
413  float e5x5 = EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
414  const auto& cov = EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology), geometry);
415  const auto& locCov = EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
416 
417  float sigmaEtaEta = sqrt(cov[0]);
418  float sigmaIetaIeta = sqrt(locCov[0]);
419  float r9 = e3x3 / (scRef->rawEnergy());
420 
421  float full5x5_maxXtal = noZS::EcalClusterTools::eMax(*(scRef->seed()), &(*hits));
422  //AA
423  //Change these to consider severity level of hits
424  float full5x5_e1x5 = noZS::EcalClusterTools::e1x5(*(scRef->seed()), &(*hits), &(*topology));
425  float full5x5_e2x5 = noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), &(*hits), &(*topology));
426  float full5x5_e3x3 = noZS::EcalClusterTools::e3x3(*(scRef->seed()), &(*hits), &(*topology));
427  float full5x5_e5x5 = noZS::EcalClusterTools::e5x5(*(scRef->seed()), &(*hits), &(*topology));
428  const auto& full5x5_cov = noZS::EcalClusterTools::covariances(*(scRef->seed()), &(*hits), &(*topology), geometry);
429  const auto& full5x5_locCov = noZS::EcalClusterTools::localCovariances(*(scRef->seed()), &(*hits), &(*topology));
430 
431  float full5x5_sigmaEtaEta = sqrt(full5x5_cov[0]);
432  float full5x5_sigmaIetaIeta = sqrt(full5x5_locCov[0]);
433 
434  // compute position of ECAL shower
435  math::XYZPoint caloPosition;
436  if (r9 > minR9) {
437  caloPosition = unconvPos;
438  } else {
439  caloPosition = scRef->position();
440  }
441 
443  double photonEnergy = 1.;
444  math::XYZPoint vtx(0., 0., 0.);
445  if (!vertexCollection.empty())
446  vtx = vertexCollection.begin()->position();
447  // compute momentum vector of photon from primary vertex and cluster position
448  math::XYZVector direction = caloPosition - vtx;
449  math::XYZVector momentum = direction.unit();
450 
451  // Create dummy candidate with unit momentum and zero energy to allow setting of all variables. The energy is set for last.
452  math::XYZTLorentzVectorD p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy);
453  reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
454 
455  // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator
456  reco::Photon::FiducialFlags fiducialFlags;
457  reco::Photon::IsolationVariables isolVarR03, isolVarR04;
458  photonIsolationCalculator_.calculate(&newCandidate, evt, es, fiducialFlags, isolVarR04, isolVarR03, hcalCuts);
459  newCandidate.setFiducialVolumeFlags(fiducialFlags);
460  newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
461 
463  reco::Photon::ShowerShape showerShape;
464  showerShape.e1x5 = e1x5;
465  showerShape.e2x5 = e2x5;
466  showerShape.e3x3 = e3x3;
467  showerShape.e5x5 = e5x5;
468  showerShape.maxEnergyXtal = maxXtal;
469  showerShape.sigmaEtaEta = sigmaEtaEta;
470  showerShape.sigmaIetaIeta = sigmaIetaIeta;
471  for (uint id = 0; id < showerShape.hcalOverEcal.size(); ++id) {
472  showerShape.hcalOverEcal[id] = hcalHelperCone.hcalESum(*scRef, id + 1, hcalCuts) / scRef->energy();
473  showerShape.hcalOverEcalBc[id] = hcalHelperBc.hcalESum(*scRef, id + 1, hcalCuts) / scRef->energy();
474  }
475  showerShape.hcalTowersBehindClusters = hcalHelperBc.hcalTowersBehindClusters(*scRef);
476  showerShape.pre7DepthHcal = false;
477  newCandidate.setShowerShapeVariables(showerShape);
478 
480  reco::Photon::ShowerShape full5x5_showerShape;
481  full5x5_showerShape.e1x5 = full5x5_e1x5;
482  full5x5_showerShape.e2x5 = full5x5_e2x5;
483  full5x5_showerShape.e3x3 = full5x5_e3x3;
484  full5x5_showerShape.e5x5 = full5x5_e5x5;
485  full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
486  full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
487  full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
488  for (uint id = 0; id < full5x5_showerShape.hcalOverEcal.size(); ++id) {
489  full5x5_showerShape.hcalOverEcal[id] = hcalHelperCone.hcalESum(*scRef, id + 1, hcalCuts) / full5x5_e5x5;
490  full5x5_showerShape.hcalOverEcalBc[id] = hcalHelperBc.hcalESum(*scRef, id + 1, hcalCuts) / full5x5_e5x5;
491  }
492  full5x5_showerShape.hcalTowersBehindClusters = hcalHelperBc.hcalTowersBehindClusters(*scRef);
493  full5x5_showerShape.pre7DepthHcal = false;
494  newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
495 
498  // Photon candidate takes by default (set in photons_cfi.py) a 4-momentum derived from the ecal photon-specific corrections.
499  photonEnergyCorrector_.calculate(evt, newCandidate, subdet, vertexCollection, es);
500  if (candidateP4type_ == "fromEcalEnergy") {
501  newCandidate.setP4(newCandidate.p4(reco::Photon::ecal_photons));
502  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
503  } else if (candidateP4type_ == "fromRegression") {
504  newCandidate.setP4(newCandidate.p4(reco::Photon::regression1));
505  newCandidate.setCandidateP4type(reco::Photon::regression1);
506  }
507 
508  // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger
510  if (subdet == EcalBarrel && runMIPTagger_) {
511  photonMIPHaloTagger_.MIPcalculate(&newCandidate, evt, es, mipVar);
512  newCandidate.setMIPVariables(mipVar);
513  }
514 
516  bool isLooseEM = true;
517  if (newCandidate.pt() < highEt_) {
518  if (newCandidate.hadronicOverEm() >= preselCutValues[1])
519  isLooseEM = false;
520  if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
521  isLooseEM = false;
522  if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
523  isLooseEM = false;
524  if (newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]))
525  isLooseEM = false;
526  if (newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]))
527  isLooseEM = false;
528  if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
529  isLooseEM = false;
530  if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
531  isLooseEM = false;
532  if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
533  isLooseEM = false;
534  }
535 
536  if (isLooseEM)
537  outputPhotonCollection.push_back(newCandidate);
538  }
539 }
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 HcalPFCuts *hcalCuts) const
std::vector< double > preselCutValuesEndcap_
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: Photon.h:159
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
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:158
PhotonEnergyCorrector photonEnergyCorrector_
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:156
std::vector< double > preselCutValuesBarrel_
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Log< level::Warning, false > LogWarning
HcalPFCuts const * hcalCuts
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)

◆ produce()

void PhotonProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 263 of file PhotonProducer.cc.

References barrelEcalHits_, HLT_2023v12_cff::barrelRecHits, endcapEcalHits_, HLT_2023v12_cff::endcapRecHits, fillPhotonCollection(), edm::Event::getByToken(), edm::EventSetup::getData(), hcalHelperBc_, hcalHelperCone_, hcalRun2EffDepth_, edm::HandleBase::isValid(), eostools::move(), gedPhotons_cfi::outputPhotonCollection, PhotonCollection_, photonCoreProducer_, edm::Handle< T >::product(), edm::Event::put(), pfClusterHBHEAlpaka_cff::topology, topologyToken_, usePrimaryVertex_, spclusmultinvestigator_cfi::vertexCollection, and vertexProducer_.

263  {
264  using namespace edm;
265  // nEvt_++;
266 
268  auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
269 
270  // Get the PhotonCore collection
271  bool validPhotonCoreHandle = true;
272  Handle<reco::PhotonCoreCollection> photonCoreHandle;
273  theEvent.getByToken(photonCoreProducer_, photonCoreHandle);
274  if (!photonCoreHandle.isValid()) {
275  edm::LogError("PhotonProducer") << "Error! Can't get the photonCoreProducer";
276  validPhotonCoreHandle = false;
277  }
278 
279  // Get EcalRecHits
280  bool validEcalRecHits = true;
281  Handle<EcalRecHitCollection> barrelHitHandle;
283  theEvent.getByToken(barrelEcalHits_, barrelHitHandle);
284  if (!barrelHitHandle.isValid()) {
285  edm::LogError("PhotonProducer") << "Error! Can't get the barrelEcalHits";
286  validEcalRecHits = false;
287  }
288  if (validEcalRecHits)
289  barrelRecHits = *(barrelHitHandle.product());
290 
291  Handle<EcalRecHitCollection> endcapHitHandle;
292  theEvent.getByToken(endcapEcalHits_, endcapHitHandle);
294  if (!endcapHitHandle.isValid()) {
295  edm::LogError("PhotonProducer") << "Error! Can't get the endcapEcalHits";
296  validEcalRecHits = false;
297  }
298  if (validEcalRecHits)
299  endcapRecHits = *(endcapHitHandle.product());
300 
301  const CaloTopology* topology = &theEventSetup.getData(topologyToken_);
302 
303  // prepare access to hcal data
304  hcalHelperCone_->beginEvent(theEvent, theEventSetup);
305  hcalHelperBc_->beginEvent(theEvent, theEventSetup);
306 
307  // Get the primary event vertex
308  Handle<reco::VertexCollection> vertexHandle;
310  bool validVertex = true;
311  if (usePrimaryVertex_) {
312  theEvent.getByToken(vertexProducer_, vertexHandle);
313  if (!vertexHandle.isValid()) {
314  edm::LogWarning("PhotonProducer") << "Error! Can't get the product primary Vertex Collection "
315  << "\n";
316  validVertex = false;
317  }
318  if (validVertex)
319  vertexCollection = *(vertexHandle.product());
320  }
321 
322  int iSC = 0; // index in photon collection
323  // Loop over barrel and endcap SC collections and fill the photon collection
324  if (validPhotonCoreHandle)
325  fillPhotonCollection(theEvent,
326  theEventSetup,
327  photonCoreHandle,
328  topology,
329  &barrelRecHits,
330  &endcapRecHits,
332  *hcalHelperBc_,
335  iSC);
336 
337  // put the product in the event
338  edm::LogInfo("PhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n";
339  outputPhotonCollection_p->assign(outputPhotonCollection.begin(), outputPhotonCollection.end());
340 
341  // 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
342  if (hcalRun2EffDepth_) {
343  for (auto& pho : *outputPhotonCollection_p)
344  pho.hcalToRun2EffDepth();
345  }
346 
347  theEvent.put(std::move(outputPhotonCollection_p), PhotonCollection_);
348 }
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
T const * product() const
Definition: Handle.h:70
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
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducer_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
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)
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
Log< level::Warning, false > LogWarning
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ barrelEcalHits_

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

Definition at line 71 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ caloGeomToken_

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

Definition at line 75 of file PhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ candidateP4type_

std::string PhotonProducer::candidateP4type_
private

Definition at line 111 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ cutsFromDB

bool PhotonProducer::cutsFromDB
private

Definition at line 119 of file PhotonProducer.cc.

Referenced by beginRun(), and PhotonProducer().

◆ endcapEcalHits_

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

Definition at line 72 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ flagsexclEB_

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

Definition at line 81 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ flagsexclEE_

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

Definition at line 82 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ hbheRecHits_

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

Definition at line 73 of file PhotonProducer.cc.

Referenced by PhotonProducer().

◆ hcalCuts

HcalPFCuts const* PhotonProducer::hcalCuts = nullptr
private

Definition at line 120 of file PhotonProducer.cc.

Referenced by beginRun(), and fillPhotonCollection().

◆ hcalCutsToken_

edm::ESGetToken<HcalPFCuts, HcalPFCutsRcd> PhotonProducer::hcalCutsToken_
private

Definition at line 118 of file PhotonProducer.cc.

Referenced by beginRun(), and PhotonProducer().

◆ hcalHelperBc_

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

Definition at line 115 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ hcalHelperCone_

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

Definition at line 114 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ hcalRun2EffDepth_

bool PhotonProducer::hcalRun2EffDepth_
private

Definition at line 116 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ highEt_

double PhotonProducer::highEt_
private

Definition at line 87 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ hOverEConeSize_

double PhotonProducer::hOverEConeSize_
private

Definition at line 86 of file PhotonProducer.cc.

Referenced by PhotonProducer().

◆ minR9Barrel_

double PhotonProducer::minR9Barrel_
private

Definition at line 88 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ minR9Endcap_

double PhotonProducer::minR9Endcap_
private

Definition at line 89 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ PhotonCollection_

std::string PhotonProducer::PhotonCollection_
private

Definition at line 69 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ photonCoreProducer_

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

Definition at line 70 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ photonEnergyCorrector_

PhotonEnergyCorrector PhotonProducer::photonEnergyCorrector_
private

Definition at line 110 of file PhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ photonIsolationCalculator_

PhotonIsolationCalculator PhotonProducer::photonIsolationCalculator_
private

Definition at line 100 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ photonMIPHaloTagger_

PhotonMIPHaloTagger PhotonProducer::photonMIPHaloTagger_
private

Definition at line 103 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ photonMVABasedHaloTagger_

std::unique_ptr<PhotonMVABasedHaloTagger> PhotonProducer::photonMVABasedHaloTagger_ = nullptr
private

Definition at line 105 of file PhotonProducer.cc.

◆ posCalculator_

PositionCalc PhotonProducer::posCalculator_
private

Definition at line 97 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ preselCutValuesBarrel_

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

Definition at line 107 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ preselCutValuesEndcap_

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

Definition at line 108 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ runMIPTagger_

bool PhotonProducer::runMIPTagger_
private

Definition at line 90 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ runMVABasedHaloTagger_

bool PhotonProducer::runMVABasedHaloTagger_
private

Definition at line 91 of file PhotonProducer.cc.

Referenced by PhotonProducer().

◆ severitiesexclEB_

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

Definition at line 83 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ severitiesexclEE_

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

Definition at line 84 of file PhotonProducer.cc.

Referenced by fillPhotonCollection(), and PhotonProducer().

◆ topologyToken_

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

Definition at line 76 of file PhotonProducer.cc.

Referenced by produce().

◆ usePrimaryVertex_

bool PhotonProducer::usePrimaryVertex_
private

Definition at line 95 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().

◆ validConversions_

bool PhotonProducer::validConversions_
private

Definition at line 93 of file PhotonProducer.cc.

◆ validPixelSeeds_

bool PhotonProducer::validPixelSeeds_
private

Definition at line 99 of file PhotonProducer.cc.

◆ vertexProducer_

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

Definition at line 74 of file PhotonProducer.cc.

Referenced by PhotonProducer(), and produce().