CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
GEDPhotonProducer Class Reference
Inheritance diagram for GEDPhotonProducer:
edm::stream::EDProducer< edm::GlobalCache< CacheData > >

Classes

class  RecoStepInfo
 

Public Member Functions

void endStream () override
 
 GEDPhotonProducer (const edm::ParameterSet &ps, const CacheData *gcache)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< CacheData > >
 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
 

Static Public Member Functions

static void globalEndJob (const CacheData *)
 
static std::unique_ptr< CacheDatainitializeGlobalCache (const edm::ParameterSet &)
 

Private Types

typedef EcalPFClusterIsolation< reco::PhotonPhotonEcalPFClusterIsolation
 
typedef HcalPFClusterIsolation< reco::PhotonPhotonHcalPFClusterIsolation
 

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 EcalRecHitCollection *preshowerHits, const ElectronHcalHelper *hcalHelperCone, const ElectronHcalHelper *hcalHelperBc, const reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC, EcalPFRecHitThresholds const &thresholds)
 
void fillPhotonCollection (edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCollection > &photonHandle, const edm::Handle< reco::PFCandidateCollection > pfCandidateHandle, const edm::Handle< reco::PFCandidateCollection > pfEGCandidateHandle, reco::VertexCollection const &pvVertices, reco::PhotonCollection &outputCollection, int &iSC, const edm::Handle< edm::ValueMap< float >> &chargedHadrons, const edm::Handle< edm::ValueMap< float >> &neutralHadrons, const edm::Handle< edm::ValueMap< float >> &photons, const edm::Handle< edm::ValueMap< float >> &chargedHadronsWorstVtx, const edm::Handle< edm::ValueMap< float >> &chargedHadronsWorstVtxGeomVeto, const edm::Handle< edm::ValueMap< float >> &chargedHadronsPFPV, const edm::Handle< edm::ValueMap< float >> &pfEcalClusters, const edm::Handle< edm::ValueMap< float >> &pfHcalClusters)
 

Private Attributes

edm::EDGetTokenT< EcalRecHitCollectionbarrelEcalHits_
 
CaloGeometry const * caloGeom_ = nullptr
 
const edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeometryToken_
 
const edm::ESGetToken< CaloTopology, CaloTopologyRecordcaloTopologyToken_
 
std::string candidateP4type_
 
bool checkHcalStatus_
 
bool dnnPFidEnabled_
 
const EcalClusterLazyTools::ESGetTokens ecalClusterESGetTokens_
 
double ecaldrMax_
 
double ecaldrVetoBarrel_
 
double ecaldrVetoEndcap_
 
double ecalenergyBarrel_
 
double ecalenergyEndcap_
 
double ecaletaStripBarrel_
 
double ecaletaStripEndcap_
 
std::unique_ptr< PhotonEcalPFClusterIsolationecalisoAlgo = nullptr
 
const edm::ESGetToken< EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcdecalPFRechitThresholdsToken_
 
edm::EDGetTokenT< EcalRecHitCollectionendcapEcalHits_
 
std::vector< int > flagsexclEB_
 
std::vector< int > flagsexclEE_
 
edm::EDGetTokenT< HBHERecHitCollectionhbheRecHits_
 
double hcaldrMax_
 
double hcaldrVetoBarrel_
 
double hcaldrVetoEndcap_
 
double hcalenergyBarrel_
 
double hcalenergyEndcap_
 
double hcaletaStripBarrel_
 
double hcaletaStripEndcap_
 
std::unique_ptr< ElectronHcalHelperhcalHelperBc_
 
std::unique_ptr< ElectronHcalHelperhcalHelperCone_
 
std::unique_ptr< PhotonHcalPFClusterIsolationhcalisoAlgo = nullptr
 
bool hcalRun2EffDepth_
 
double hcaluseEt_
 
double highEt_
 
double hOverEConeSize_
 
double minR9Barrel_
 
double minR9Endcap_
 
double multThresEB_
 
double multThresEE_
 
edm::EDGetTokenT< edm::ValueMap< std::vector< reco::PFCandidateRef > > > particleBasedIsolationToken
 
edm::EDGetTokenT< reco::PFCandidateCollectionpfCandidates_
 
edm::EDGetTokenT< reco::PFClusterCollectionpfClusterProducer_
 
edm::EDGetTokenT< reco::PFClusterCollectionpfClusterProducerHCAL_
 
edm::EDGetTokenT< reco::PFClusterCollectionpfClusterProducerHFEM_
 
edm::EDGetTokenT< reco::PFClusterCollectionpfClusterProducerHFHAD_
 
edm::EDGetTokenT< reco::PFCandidateCollectionpfEgammaCandidates_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedIsolationToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedPFPVIsoToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxGeomVetoIsoToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxIsoToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoNeutralHadronIsolationToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoPFECALClusIsolationToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoPFHCALClusIsolationToken_
 
edm::EDGetTokenT< edm::ValueMap< float > > phoPhotonIsolationToken_
 
std::string photonCollection_
 
edm::EDGetTokenT< reco::PhotonCoreCollectionphotonCoreProducerT_
 
std::unique_ptr< PhotonEnergyCorrectorphotonEnergyCorrector_ = nullptr
 
std::unique_ptr< PhotonIsolationCalculatorphotonIsoCalculator_ = nullptr
 
std::unique_ptr< PhotonMIPHaloTaggerphotonMIPHaloTagger_ = nullptr
 
std::unique_ptr< PhotonMVABasedHaloTaggerphotonMVABasedHaloTagger_ = nullptr
 
const edm::InputTag photonProducer_
 
edm::EDGetTokenT< reco::PhotonCollectionphotonProducerT_
 
std::vector< double > preselCutValuesBarrel_
 
std::vector< double > preselCutValuesEndcap_
 
edm::EDGetTokenT< EcalRecHitCollectionpreshowerHits_
 
RecoStepInfo recoStep_
 
bool runMIPTagger_
 
bool runMVABasedHaloTagger_
 
std::vector< int > severitiesexclEB_
 
std::vector< int > severitiesexclEE_
 
std::vector< tensorflow::Session * > tfSessions_
 
bool useHF_
 
bool usePrimaryVertex_
 
std::string valueMapPFCandPhoton_
 
edm::EDGetTokenT< reco::VertexCollectionvertexProducer_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< CacheData > >
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 85 of file GEDPhotonProducer.cc.

Member Typedef Documentation

◆ PhotonEcalPFClusterIsolation

Definition at line 227 of file GEDPhotonProducer.cc.

◆ PhotonHcalPFClusterIsolation

Definition at line 245 of file GEDPhotonProducer.cc.

Constructor & Destructor Documentation

◆ GEDPhotonProducer()

GEDPhotonProducer::GEDPhotonProducer ( const edm::ParameterSet ps,
const CacheData gcache 
)

Get the set for PF cluster isolation calculator

Definition at line 274 of file GEDPhotonProducer.cc.

275  : photonProducer_{config.getParameter<edm::InputTag>("photonProducer")},
276  ecalClusterESGetTokens_{consumesCollector()},
277  recoStep_(config.getParameter<std::string>("reconstructionStep")),
281  hcalHelperCone_(nullptr),
282  hcalHelperBc_(nullptr) {
283  if (recoStep_.isFinal()) {
284  photonProducerT_ = consumes(photonProducer_);
285  pfCandidates_ = consumes(config.getParameter<edm::InputTag>("pfCandidates"));
286 
287  const edm::ParameterSet& pfIsolCfg = config.getParameter<edm::ParameterSet>("pfIsolCfg");
288  auto getVMToken = [&pfIsolCfg, this](const std::string& name) {
289  return consumes(pfIsolCfg.getParameter<edm::InputTag>(name));
290  };
291  phoChargedIsolationToken_ = getVMToken("chargedHadronIso");
292  phoNeutralHadronIsolationToken_ = getVMToken("neutralHadronIso");
293  phoPhotonIsolationToken_ = getVMToken("photonIso");
294  phoChargedWorstVtxIsoToken_ = getVMToken("chargedHadronWorstVtxIso");
295  phoChargedWorstVtxGeomVetoIsoToken_ = getVMToken("chargedHadronWorstVtxGeomVetoIso");
296  phoChargedPFPVIsoToken_ = getVMToken("chargedHadronPFPVIso");
297 
298  //OOT photons in legacy 80X re-miniAOD do not have PF cluster embeded into the reco object
299  //to preserve 80X behaviour
300  if (config.exists("pfECALClusIsolation")) {
301  phoPFECALClusIsolationToken_ = consumes(config.getParameter<edm::InputTag>("pfECALClusIsolation"));
302  }
303  if (config.exists("pfHCALClusIsolation")) {
304  phoPFHCALClusIsolationToken_ = consumes(config.getParameter<edm::InputTag>("pfHCALClusIsolation"));
305  }
306 
307  } else {
309  }
310 
311  auto pfEg = config.getParameter<edm::InputTag>("pfEgammaCandidates");
312  if (not pfEg.label().empty()) {
313  pfEgammaCandidates_ = consumes(pfEg);
314  }
315  barrelEcalHits_ = consumes(config.getParameter<edm::InputTag>("barrelEcalHits"));
316  endcapEcalHits_ = consumes(config.getParameter<edm::InputTag>("endcapEcalHits"));
317  preshowerHits_ = consumes(config.getParameter<edm::InputTag>("preshowerHits"));
318  vertexProducer_ = consumes(config.getParameter<edm::InputTag>("primaryVertexProducer"));
319 
320  auto hbhetag = config.getParameter<edm::InputTag>("hbheRecHits");
321  if (not hbhetag.label().empty())
322  hbheRecHits_ = consumes<HBHERecHitCollection>(hbhetag);
323 
324  //
325  photonCollection_ = config.getParameter<std::string>("outputPhotonCollection");
326  multThresEB_ = config.getParameter<double>("multThresEB");
327  multThresEE_ = config.getParameter<double>("multThresEE");
328  hOverEConeSize_ = config.getParameter<double>("hOverEConeSize");
329  highEt_ = config.getParameter<double>("highEt");
330  // R9 value to decide converted/unconverted
331  minR9Barrel_ = config.getParameter<double>("minR9Barrel");
332  minR9Endcap_ = config.getParameter<double>("minR9Endcap");
333  usePrimaryVertex_ = config.getParameter<bool>("usePrimaryVertex");
334  runMIPTagger_ = config.getParameter<bool>("runMIPTagger");
335  runMVABasedHaloTagger_ = config.getParameter<bool>("runMVABasedHaloTagger");
336 
337  candidateP4type_ = config.getParameter<std::string>("candidateP4type");
338  valueMapPFCandPhoton_ = config.getParameter<std::string>("valueMapPhotons");
339 
340  //AA
341  //Flags and Severities to be excluded from photon calculations
342  auto const& flagnamesEB = config.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEB");
343  auto const& flagnamesEE = config.getParameter<std::vector<std::string>>("RecHitFlagToBeExcludedEE");
344 
345  flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
346  flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
347 
348  auto const& severitynamesEB = config.getParameter<std::vector<std::string>>("RecHitSeverityToBeExcludedEB");
349  auto const& severitynamesEE = config.getParameter<std::vector<std::string>>("RecHitSeverityToBeExcludedEE");
350 
351  severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
352  severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
353 
354  photonEnergyCorrector_ = std::make_unique<PhotonEnergyCorrector>(config, consumesCollector());
355 
356  checkHcalStatus_ = config.getParameter<bool>("checkHcalStatus");
357  if (not hbheRecHits_.isUninitialized()) {
358  ElectronHcalHelper::Configuration cfgCone, cfgBc;
360  if (cfgCone.hOverEConeSize > 0) {
361  cfgCone.onlyBehindCluster = false;
363 
364  cfgCone.hbheRecHits = hbheRecHits_;
365 
366  cfgCone.eThresHB = config.getParameter<EgammaHcalIsolation::arrayHB>("recHitEThresholdHB");
367  cfgCone.maxSeverityHB = config.getParameter<int>("maxHcalRecHitSeverity");
368  cfgCone.eThresHE = config.getParameter<EgammaHcalIsolation::arrayHE>("recHitEThresholdHE");
369  cfgCone.maxSeverityHE = cfgCone.maxSeverityHB;
370  }
371  cfgBc.hOverEConeSize = 0.;
372  cfgBc.onlyBehindCluster = true;
374 
375  cfgBc.hbheRecHits = hbheRecHits_;
376 
377  cfgBc.eThresHB = config.getParameter<EgammaHcalIsolation::arrayHB>("recHitEThresholdHB");
378  cfgBc.maxSeverityHB = config.getParameter<int>("maxHcalRecHitSeverity");
379  cfgBc.eThresHE = config.getParameter<EgammaHcalIsolation::arrayHE>("recHitEThresholdHE");
380  cfgBc.maxSeverityHE = cfgBc.maxSeverityHB;
381 
382  hcalHelperCone_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
383  hcalHelperBc_ = std::make_unique<ElectronHcalHelper>(cfgBc, consumesCollector());
384  }
385 
386  hcalRun2EffDepth_ = config.getParameter<bool>("hcalRun2EffDepth");
387 
388  // cut values for pre-selection
389  preselCutValuesBarrel_ = {config.getParameter<double>("minSCEtBarrel"),
390  config.getParameter<double>("maxHoverEBarrel"),
391  config.getParameter<double>("ecalRecHitSumEtOffsetBarrel"),
392  config.getParameter<double>("ecalRecHitSumEtSlopeBarrel"),
393  config.getParameter<double>("hcalRecHitSumEtOffsetBarrel"),
394  config.getParameter<double>("hcalRecHitSumEtSlopeBarrel"),
395  config.getParameter<double>("nTrackSolidConeBarrel"),
396  config.getParameter<double>("nTrackHollowConeBarrel"),
397  config.getParameter<double>("trackPtSumSolidConeBarrel"),
398  config.getParameter<double>("trackPtSumHollowConeBarrel"),
399  config.getParameter<double>("sigmaIetaIetaCutBarrel")};
400  //
401  preselCutValuesEndcap_ = {config.getParameter<double>("minSCEtEndcap"),
402  config.getParameter<double>("maxHoverEEndcap"),
403  config.getParameter<double>("ecalRecHitSumEtOffsetEndcap"),
404  config.getParameter<double>("ecalRecHitSumEtSlopeEndcap"),
405  config.getParameter<double>("hcalRecHitSumEtOffsetEndcap"),
406  config.getParameter<double>("hcalRecHitSumEtSlopeEndcap"),
407  config.getParameter<double>("nTrackSolidConeEndcap"),
408  config.getParameter<double>("nTrackHollowConeEndcap"),
409  config.getParameter<double>("trackPtSumSolidConeEndcap"),
410  config.getParameter<double>("trackPtSumHollowConeEndcap"),
411  config.getParameter<double>("sigmaIetaIetaCutEndcap")};
412  //
413 
414  //moved from beginRun to here, I dont see how this could cause harm as its just reading in the exactly same parameters each run
415  if (!recoStep_.isFinal()) {
416  photonIsoCalculator_ = std::make_unique<PhotonIsolationCalculator>();
417  edm::ParameterSet isolationSumsCalculatorSet = config.getParameter<edm::ParameterSet>("isolationSumsCalculatorSet");
419  flagsexclEB_,
420  flagsexclEE_,
423  consumesCollector());
424  photonMIPHaloTagger_ = std::make_unique<PhotonMIPHaloTagger>();
425  edm::ParameterSet mipVariableSet = config.getParameter<edm::ParameterSet>("mipVariableSet");
426  photonMIPHaloTagger_->setup(mipVariableSet, consumesCollector());
427  }
428 
430  edm::ParameterSet mvaBasedHaloVariableSet = config.getParameter<edm::ParameterSet>("mvaBasedHaloVariableSet");
432  std::make_unique<PhotonMVABasedHaloTagger>(mvaBasedHaloVariableSet, consumesCollector());
433  }
434 
436  const edm::ParameterSet& pfECALClusIsolCfg = config.getParameter<edm::ParameterSet>("pfECALClusIsolCfg");
438  consumes<reco::PFClusterCollection>(pfECALClusIsolCfg.getParameter<edm::InputTag>("pfClusterProducer"));
439  ecaldrMax_ = pfECALClusIsolCfg.getParameter<double>("drMax");
440  ecaldrVetoBarrel_ = pfECALClusIsolCfg.getParameter<double>("drVetoBarrel");
441  ecaldrVetoEndcap_ = pfECALClusIsolCfg.getParameter<double>("drVetoEndcap");
442  ecaletaStripBarrel_ = pfECALClusIsolCfg.getParameter<double>("etaStripBarrel");
443  ecaletaStripEndcap_ = pfECALClusIsolCfg.getParameter<double>("etaStripEndcap");
444  ecalenergyBarrel_ = pfECALClusIsolCfg.getParameter<double>("energyBarrel");
445  ecalenergyEndcap_ = pfECALClusIsolCfg.getParameter<double>("energyEndcap");
446 
447  const edm::ParameterSet& pfHCALClusIsolCfg = config.getParameter<edm::ParameterSet>("pfHCALClusIsolCfg");
448  pfClusterProducerHCAL_ = consumes(pfHCALClusIsolCfg.getParameter<edm::InputTag>("pfClusterProducerHCAL"));
449  pfClusterProducerHFEM_ = consumes(pfHCALClusIsolCfg.getParameter<edm::InputTag>("pfClusterProducerHFEM"));
450  pfClusterProducerHFHAD_ = consumes(pfHCALClusIsolCfg.getParameter<edm::InputTag>("pfClusterProducerHFHAD"));
451  useHF_ = pfHCALClusIsolCfg.getParameter<bool>("useHF");
452  hcaldrMax_ = pfHCALClusIsolCfg.getParameter<double>("drMax");
453  hcaldrVetoBarrel_ = pfHCALClusIsolCfg.getParameter<double>("drVetoBarrel");
454  hcaldrVetoEndcap_ = pfHCALClusIsolCfg.getParameter<double>("drVetoEndcap");
455  hcaletaStripBarrel_ = pfHCALClusIsolCfg.getParameter<double>("etaStripBarrel");
456  hcaletaStripEndcap_ = pfHCALClusIsolCfg.getParameter<double>("etaStripEndcap");
457  hcalenergyBarrel_ = pfHCALClusIsolCfg.getParameter<double>("energyBarrel");
458  hcalenergyEndcap_ = pfHCALClusIsolCfg.getParameter<double>("energyEndcap");
459  hcaluseEt_ = pfHCALClusIsolCfg.getParameter<bool>("useEt");
460 
461  // Register the product
462  produces<reco::PhotonCollection>(photonCollection_);
464  produces<edm::ValueMap<reco::PhotonRef>>(valueMapPFCandPhoton_);
465  }
466 
467  const auto& pset_dnn = config.getParameter<edm::ParameterSet>("PhotonDNNPFid");
468  dnnPFidEnabled_ = pset_dnn.getParameter<bool>("enabled");
469  if (dnnPFidEnabled_) {
470  tfSessions_ = gcache->photonDNNEstimator->getSessions();
471  }
472 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
const edm::ESGetToken< EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd > ecalPFRechitThresholdsToken_
std::unique_ptr< PhotonMVABasedHaloTagger > photonMVABasedHaloTagger_
std::unique_ptr< PhotonEnergyCorrector > photonEnergyCorrector_
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHFEM_
std::vector< int > flagsexclEB_
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
Definition: config.py:1
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::vector< int > severitiesexclEE_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits
std::string photonCollection_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedPFPVIsoToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxGeomVetoIsoToken_
std::unique_ptr< ElectronHcalHelper > hcalHelperCone_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedIsolationToken_
std::unique_ptr< PhotonIsolationCalculator > photonIsoCalculator_
std::vector< int > flagsexclEE_
std::unique_ptr< const PhotonDNNEstimator > photonDNNEstimator
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducerT_
std::vector< tensorflow::Session * > tfSessions_
edm::EDGetTokenT< edm::ValueMap< float > > phoPFHCALClusIsolationToken_
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
std::vector< int > severitiesexclEB_
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHFHAD_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHits_
edm::EDGetTokenT< edm::ValueMap< float > > phoNeutralHadronIsolationToken_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxIsoToken_
std::vector< double > preselCutValuesBarrel_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
std::vector< double > preselCutValuesEndcap_
config
parse the configuration file
const EcalClusterLazyTools::ESGetTokens ecalClusterESGetTokens_
const edm::InputTag photonProducer_
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
std::string candidateP4type_
edm::EDGetTokenT< edm::ValueMap< float > > phoPhotonIsolationToken_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducer_
edm::EDGetTokenT< edm::ValueMap< float > > phoPFECALClusIsolationToken_
EgammaHcalIsolation::arrayHB eThresHB
EgammaHcalIsolation::arrayHE eThresHE
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
std::array< double, 4 > arrayHB
std::unique_ptr< PhotonMIPHaloTagger > photonMIPHaloTagger_
edm::EDGetTokenT< EcalRecHitCollection > preshowerHits_
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHCAL_
std::string valueMapPFCandPhoton_
std::array< double, 7 > arrayHE

Member Function Documentation

◆ endStream()

void GEDPhotonProducer::endStream ( )
override

Definition at line 479 of file GEDPhotonProducer.cc.

References tensorflow::closeSession(), and tfSessions_.

479  {
480  for (auto session : tfSessions_) {
481  tensorflow::closeSession(session);
482  }
483 }
bool closeSession(Session *&session)
Definition: TensorFlow.cc:198
std::vector< tensorflow::Session * > tfSessions_

◆ fillPhotonCollection() [1/2]

void GEDPhotonProducer::fillPhotonCollection ( edm::Event evt,
edm::EventSetup const &  es,
const edm::Handle< reco::PhotonCoreCollection > &  photonCoreHandle,
const CaloTopology topology,
const EcalRecHitCollection ecalBarrelHits,
const EcalRecHitCollection ecalEndcapHits,
const EcalRecHitCollection preshowerHits,
const ElectronHcalHelper hcalHelperCone,
const ElectronHcalHelper hcalHelperBc,
const reco::VertexCollection pvVertices,
reco::PhotonCollection outputCollection,
int &  iSC,
EcalPFRecHitThresholds const &  thresholds 
)
private

fill shower shape block

fill extra shower shapes

fill full5x5 shower shape block

fill extra full5x5 shower shapes

get ecal photon specific corrected energy plus values from regressions and store them in the Photon
Pre-selection loose isolation cuts

Definition at line 682 of file GEDPhotonProducer.cc.

References Cluster2ndMoments::alpha, barrelEcalHits_, caloGeom_, candidateP4type_, EcalClusterToolsT< noZS >::cluster2ndMoments(), EcalClusterToolsT< noZS >::covariances(), reco::Photon::PflowIDVariables::dnn, dnnPFidEnabled_, EcalClusterToolsT< noZS >::e1x3(), reco::Photon::ShowerShape::e1x3, EgHLTOffHistBins_cfi::e1x5, EcalClusterToolsT< noZS >::e1x5(), reco::Photon::ShowerShape::e1x5, reco::Photon::ShowerShape::e2nd, EcalClusterToolsT< noZS >::e2nd(), EcalClusterToolsT< noZS >::e2x2(), reco::Photon::ShowerShape::e2x2, EgHLTOffHistBins_cfi::e2x5, reco::Photon::ShowerShape::e2x5, EcalClusterToolsT< noZS >::e2x5Bottom(), reco::Photon::ShowerShape::e2x5Bottom, EcalClusterToolsT< noZS >::e2x5Left(), reco::Photon::ShowerShape::e2x5Left, EcalClusterToolsT< noZS >::e2x5Max(), reco::Photon::ShowerShape::e2x5Max, EcalClusterToolsT< noZS >::e2x5Right(), reco::Photon::ShowerShape::e2x5Right, EcalClusterToolsT< noZS >::e2x5Top(), reco::Photon::ShowerShape::e2x5Top, EcalClusterToolsT< noZS >::e3x3(), reco::Photon::ShowerShape::e3x3, EcalClusterToolsT< noZS >::e5x5(), reco::Photon::ShowerShape::e5x5, EcalClusterToolsT< noZS >::eBottom(), reco::Photon::ShowerShape::eBottom, reco::Photon::ecal_photons, EcalBarrel, ecalClusterESGetTokens_, EcalEndcap, ecalisoAlgo, ecalRecHit_cfi::ecalRecHit, reco::Photon::ShowerShape::effSigmaRR, EcalClusterToolsT< noZS >::eLeft(), reco::Photon::ShowerShape::eLeft, cosmicPhotonAnalyzer_cfi::eMax, EcalClusterToolsT< noZS >::eMax(), endcapEcalHits_, EcalClusterToolsT< noZS >::eRight(), reco::Photon::ShowerShape::eRight, EcalClusterToolsT< noZS >::eTop(), reco::Photon::ShowerShape::eTop, flagsexclEB_, flagsexclEE_, HLT_2022v11_cff::full5x5_sigmaIetaIeta, EcalClusterLazyToolsBase::ESGetTokens::get(), edm::Event::getHandle(), ElectronHcalHelper::hasActiveHcal(), ElectronHcalHelper::hcalESum(), hcalisoAlgo, reco::Photon::ShowerShape::hcalOverEcal, reco::Photon::ShowerShape::hcalOverEcalBc, ElectronHcalHelper::hcalTowersBehindClusters(), reco::Photon::ShowerShape::hcalTowersBehindClusters, highEt_, hfClusterShapes_cfi::hits, triggerObjects_cff::id, createfilelist::int, reco::Photon::ShowerShape::invalidHcal, reco::Photon::FiducialFlags::isEE, edm::isFinite(), EcalTools::isHGCalDet(), edm::Ref< C, T, F >::isNonnull(), reco::Photon::SaturationInfo::isSeedSaturated, EgammaLocalCovParamDefaults::kRelEnCut, EcalClusterToolsT< noZS >::localCovariances(), LogDebug, reco::Photon::ShowerShape::maxEnergyXtal, multThresEB_, multThresEE_, reco::Photon::SaturationInfo::nSaturatedXtals, gedPhotons_cfi::outputPhotonCollection, pfClusterProducer_, pfClusterProducerHCAL_, pfClusterProducerHFEM_, pfClusterProducerHFHAD_, displacedMuons_cfi::photon, MaterialEffects_cfi::photonEnergy, photonEnergyCorrector_, photonIsoCalculator_, photonMIPHaloTagger_, reco::Photon::ShowerShape::pre7DepthHcal, preselCutValuesBarrel_, preselCutValuesEndcap_, preshowerHits_, ptFast(), reco::Photon::regression1, reco::Photon::regression2, runMIPTagger_, reco::CaloCluster::seed(), severitiesexclEB_, severitiesexclEE_, reco::Photon::ShowerShape::sigmaEtaEta, HLT_FULL_cff::sigmaEtaEta, reco::Photon::ShowerShape::sigmaIetaIeta, reco::Photon::ShowerShape::sigmaIetaIphi, reco::Photon::ShowerShape::sigmaIphiIphi, Cluster2ndMoments::sMaj, reco::Photon::ShowerShape::smAlpha, Cluster2ndMoments::sMin, reco::Photon::ShowerShape::smMajor, reco::Photon::ShowerShape::smMinor, mathSSE::sqrt(), reco::Photon::PflowIsolationVariables::sumEcalClusterEt, reco::Photon::PflowIsolationVariables::sumHcalClusterEt, tfSessions_, particleFlowZeroSuppressionECAL_cff::thresholds, parallelization::uint, useHF_, contentValuesCheck::values, spclusmultinvestigator_cfi::vertexCollection, and extraflags_cff::vtx.

Referenced by produce().

694  {
695  const EcalRecHitCollection* hits = nullptr;
696  std::vector<double> preselCutValues;
697  std::vector<int> flags_, severitiesexcl_;
698 
699  for (unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
700  reco::PhotonCoreRef coreRef(reco::PhotonCoreRef(photonCoreHandle, lSC));
701  reco::SuperClusterRef parentSCRef = coreRef->parentSuperCluster();
702  reco::SuperClusterRef scRef = coreRef->superCluster();
703 
704  // const reco::SuperCluster* pClus=&(*scRef);
705  iSC++;
706 
707  DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
708  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
709  if (subdet == EcalBarrel) {
710  preselCutValues = preselCutValuesBarrel_;
711  hits = ecalBarrelHits;
712  flags_ = flagsexclEB_;
713  severitiesexcl_ = severitiesexclEB_;
714  } else if (subdet == EcalEndcap) {
715  preselCutValues = preselCutValuesEndcap_;
716  hits = ecalEndcapHits;
717  flags_ = flagsexclEE_;
718  severitiesexcl_ = severitiesexclEE_;
719  } else if (EcalTools::isHGCalDet(thedet)) {
720  preselCutValues = preselCutValuesEndcap_;
721  hits = nullptr;
722  flags_ = flagsexclEE_;
723  severitiesexcl_ = severitiesexclEE_;
724  } else {
725  edm::LogWarning("") << "GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster: " << thedet
726  << ' ' << subdet;
727  }
728 
729  // SC energy preselection
730  if (parentSCRef.isNonnull() &&
731  ptFast(parentSCRef->energy(), parentSCRef->position(), {0, 0, 0}) <= preselCutValues[0])
732  continue;
733 
734  float maxXtal = (hits != nullptr ? EcalClusterTools::eMax(*(scRef->seed()), hits) : 0.f);
735 
736  //AA
737  //Change these to consider severity level of hits
738  float e1x5 = (hits != nullptr ? EcalClusterTools::e1x5(*(scRef->seed()), hits, topology) : 0.f);
739  float e2x5 = (hits != nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), hits, topology) : 0.f);
740  float e3x3 = (hits != nullptr ? EcalClusterTools::e3x3(*(scRef->seed()), hits, topology) : 0.f);
741  float e5x5 = (hits != nullptr ? EcalClusterTools::e5x5(*(scRef->seed()), hits, topology) : 0.f);
742  const auto& cov = (hits != nullptr ? EcalClusterTools::covariances(*(scRef->seed()), hits, topology, caloGeom_)
743  : std::array<float, 3>({{0.f, 0.f, 0.f}}));
744  // fractional local covariances
745  const auto& locCov = (hits != nullptr ? EcalClusterTools::localCovariances(*(scRef->seed()), hits, topology)
746  : std::array<float, 3>({{0.f, 0.f, 0.f}}));
747 
748  float sigmaEtaEta = std::sqrt(cov[0]);
749  float sigmaIetaIeta = std::sqrt(locCov[0]);
750 
751  float full5x5_maxXtal = (hits != nullptr ? noZS::EcalClusterTools::eMax(*(scRef->seed()), hits) : 0.f);
752  //AA
753  //Change these to consider severity level of hits
754  float full5x5_e1x5 = (hits != nullptr ? noZS::EcalClusterTools::e1x5(*(scRef->seed()), hits, topology) : 0.f);
755  float full5x5_e2x5 = (hits != nullptr ? noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), hits, topology) : 0.f);
756  float full5x5_e3x3 = (hits != nullptr ? noZS::EcalClusterTools::e3x3(*(scRef->seed()), hits, topology) : 0.f);
757  float full5x5_e5x5 = (hits != nullptr ? noZS::EcalClusterTools::e5x5(*(scRef->seed()), hits, topology) : 0.f);
758  const auto& full5x5_cov =
759  (hits != nullptr ? noZS::EcalClusterTools::covariances(*(scRef->seed()), hits, topology, caloGeom_)
760  : std::array<float, 3>({{0.f, 0.f, 0.f}}));
761  // for full5x5 local covariances, do noise-cleaning
762  // by passing per crystal PF recHit thresholds and mult values.
763  // mult values for EB and EE were obtained by dedicated studies.
764  const auto& full5x5_locCov =
765  (hits != nullptr ? noZS::EcalClusterTools::localCovariances(*(scRef->seed()),
766  hits,
767  topology,
769  &thresholds,
770  multThresEB_,
771  multThresEE_)
772  : std::array<float, 3>({{0.f, 0.f, 0.f}}));
773 
774  float full5x5_sigmaEtaEta = sqrt(full5x5_cov[0]);
775  float full5x5_sigmaIetaIeta = sqrt(full5x5_locCov[0]);
776  float full5x5_sigmaIetaIphi = full5x5_locCov[1];
777 
778  // compute position of ECAL shower
779  math::XYZPoint caloPosition = scRef->position();
780 
782  double photonEnergy = 1.;
783  math::XYZPoint vtx(0., 0., 0.);
784  if (!vertexCollection.empty())
785  vtx = vertexCollection.begin()->position();
786  // compute momentum vector of photon from primary vertex and cluster position
787  math::XYZVector direction = caloPosition - vtx;
788  //math::XYZVector momentum = direction.unit() * photonEnergy ;
789  math::XYZVector momentum = direction.unit();
790 
791  // Create dummy candidate with unit momentum and zero energy to allow setting of all variables. The energy is set for last.
792  math::XYZTLorentzVectorD p4(momentum.x(), momentum.y(), momentum.z(), photonEnergy);
793  reco::Photon newCandidate(p4, caloPosition, coreRef, vtx);
794 
795  //std::cout << " standard p4 before " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
796  //std::cout << " type " <<newCandidate.getCandidateP4type() << " standard p4 after " << newCandidate.p4() << " energy " << newCandidate.energy() << std::endl;
797 
798  // Calculate fiducial flags and isolation variable. Blocked are filled from the isolationCalculator
799  reco::Photon::FiducialFlags fiducialFlags;
800  reco::Photon::IsolationVariables isolVarR03, isolVarR04;
801  if (!EcalTools::isHGCalDet(thedet)) {
802  photonIsoCalculator_->calculate(&newCandidate, evt, es, fiducialFlags, isolVarR04, isolVarR03);
803  }
804  newCandidate.setFiducialVolumeFlags(fiducialFlags);
805  newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
806 
808  reco::Photon::ShowerShape showerShape;
809  showerShape.e1x5 = e1x5;
810  showerShape.e2x5 = e2x5;
811  showerShape.e3x3 = e3x3;
812  showerShape.e5x5 = e5x5;
813  showerShape.maxEnergyXtal = maxXtal;
814  showerShape.sigmaEtaEta = sigmaEtaEta;
815  showerShape.sigmaIetaIeta = sigmaIetaIeta;
816  for (uint id = 0; id < showerShape.hcalOverEcal.size(); ++id) {
817  showerShape.hcalOverEcal[id] =
818  (hcalHelperCone != nullptr) ? hcalHelperCone->hcalESum(*scRef, id + 1) / scRef->energy() : 0.f;
819 
820  showerShape.hcalOverEcalBc[id] =
821  (hcalHelperBc != nullptr) ? hcalHelperBc->hcalESum(*scRef, id + 1) / scRef->energy() : 0.f;
822  }
823  showerShape.invalidHcal = (hcalHelperBc != nullptr) ? !hcalHelperBc->hasActiveHcal(*scRef) : false;
824  if (hcalHelperBc != nullptr)
825  showerShape.hcalTowersBehindClusters = hcalHelperBc->hcalTowersBehindClusters(*scRef);
826  showerShape.pre7DepthHcal = false;
827 
829  const float spp = (!edm::isFinite(locCov[2]) ? 0. : sqrt(locCov[2]));
830  const float sep = locCov[1];
831  showerShape.sigmaIetaIphi = sep;
832  showerShape.sigmaIphiIphi = spp;
833  showerShape.e2nd = (hits != nullptr ? EcalClusterTools::e2nd(*(scRef->seed()), hits) : 0.f);
834  showerShape.eTop = (hits != nullptr ? EcalClusterTools::eTop(*(scRef->seed()), hits, topology) : 0.f);
835  showerShape.eLeft = (hits != nullptr ? EcalClusterTools::eLeft(*(scRef->seed()), hits, topology) : 0.f);
836  showerShape.eRight = (hits != nullptr ? EcalClusterTools::eRight(*(scRef->seed()), hits, topology) : 0.f);
837  showerShape.eBottom = (hits != nullptr ? EcalClusterTools::eBottom(*(scRef->seed()), hits, topology) : 0.f);
838  showerShape.e1x3 = (hits != nullptr ? EcalClusterTools::e1x3(*(scRef->seed()), hits, topology) : 0.f);
839  showerShape.e2x2 = (hits != nullptr ? EcalClusterTools::e2x2(*(scRef->seed()), hits, topology) : 0.f);
840  showerShape.e2x5Max = (hits != nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), hits, topology) : 0.f);
841  showerShape.e2x5Left = (hits != nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()), hits, topology) : 0.f);
842  showerShape.e2x5Right = (hits != nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()), hits, topology) : 0.f);
843  showerShape.e2x5Top = (hits != nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()), hits, topology) : 0.f);
844  showerShape.e2x5Bottom = (hits != nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()), hits, topology) : 0.f);
845  if (hits) {
846  Cluster2ndMoments clus2ndMoments = EcalClusterTools::cluster2ndMoments(*(scRef->seed()), *hits);
847  showerShape.smMajor = clus2ndMoments.sMaj;
848  showerShape.smMinor = clus2ndMoments.sMin;
849  showerShape.smAlpha = clus2ndMoments.alpha;
850  } else {
851  showerShape.smMajor = 0.f;
852  showerShape.smMinor = 0.f;
853  showerShape.smAlpha = 0.f;
854  }
855 
856  // fill preshower shapes
857  EcalClusterLazyTools toolsforES(
858  evt, ecalClusterESGetTokens_.get(es), barrelEcalHits_, endcapEcalHits_, preshowerHits_);
859  const float sigmaRR = toolsforES.eseffsirir(*scRef);
860  showerShape.effSigmaRR = sigmaRR;
861  newCandidate.setShowerShapeVariables(showerShape);
862 
863  const reco::CaloCluster& seedCluster = *(scRef->seed());
864  DetId seedXtalId = seedCluster.seed();
865  int nSaturatedXtals = 0;
866  bool isSeedSaturated = false;
867  if (hits != nullptr) {
868  const auto hitsAndFractions = scRef->hitsAndFractions();
869  for (auto const& hitFractionPair : hitsAndFractions) {
870  auto&& ecalRecHit = hits->find(hitFractionPair.first);
871  if (ecalRecHit == hits->end())
872  continue;
873  if (ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
874  nSaturatedXtals++;
875  if (seedXtalId == ecalRecHit->detid())
876  isSeedSaturated = true;
877  }
878  }
879  }
880  reco::Photon::SaturationInfo saturationInfo;
881  saturationInfo.nSaturatedXtals = nSaturatedXtals;
882  saturationInfo.isSeedSaturated = isSeedSaturated;
883  newCandidate.setSaturationInfo(saturationInfo);
884 
886  reco::Photon::ShowerShape full5x5_showerShape;
887  full5x5_showerShape.e1x5 = full5x5_e1x5;
888  full5x5_showerShape.e2x5 = full5x5_e2x5;
889  full5x5_showerShape.e3x3 = full5x5_e3x3;
890  full5x5_showerShape.e5x5 = full5x5_e5x5;
891  full5x5_showerShape.maxEnergyXtal = full5x5_maxXtal;
892  full5x5_showerShape.sigmaEtaEta = full5x5_sigmaEtaEta;
893  full5x5_showerShape.sigmaIetaIeta = full5x5_sigmaIetaIeta;
895  const float full5x5_spp = (!edm::isFinite(full5x5_locCov[2]) ? 0. : std::sqrt(full5x5_locCov[2]));
896  const float full5x5_sep = full5x5_sigmaIetaIphi;
897  full5x5_showerShape.sigmaIetaIphi = full5x5_sep;
898  full5x5_showerShape.sigmaIphiIphi = full5x5_spp;
899  full5x5_showerShape.e2nd = (hits != nullptr ? noZS::EcalClusterTools::e2nd(*(scRef->seed()), hits) : 0.f);
900  full5x5_showerShape.eTop = (hits != nullptr ? noZS::EcalClusterTools::eTop(*(scRef->seed()), hits, topology) : 0.f);
901  full5x5_showerShape.eLeft =
902  (hits != nullptr ? noZS::EcalClusterTools::eLeft(*(scRef->seed()), hits, topology) : 0.f);
903  full5x5_showerShape.eRight =
904  (hits != nullptr ? noZS::EcalClusterTools::eRight(*(scRef->seed()), hits, topology) : 0.f);
905  full5x5_showerShape.eBottom =
906  (hits != nullptr ? noZS::EcalClusterTools::eBottom(*(scRef->seed()), hits, topology) : 0.f);
907  full5x5_showerShape.e1x3 = (hits != nullptr ? noZS::EcalClusterTools::e1x3(*(scRef->seed()), hits, topology) : 0.f);
908  full5x5_showerShape.e2x2 = (hits != nullptr ? noZS::EcalClusterTools::e2x2(*(scRef->seed()), hits, topology) : 0.f);
909  full5x5_showerShape.e2x5Max =
910  (hits != nullptr ? noZS::EcalClusterTools::e2x5Max(*(scRef->seed()), hits, topology) : 0.f);
911  full5x5_showerShape.e2x5Left =
912  (hits != nullptr ? noZS::EcalClusterTools::e2x5Left(*(scRef->seed()), hits, topology) : 0.f);
913  full5x5_showerShape.e2x5Right =
914  (hits != nullptr ? noZS::EcalClusterTools::e2x5Right(*(scRef->seed()), hits, topology) : 0.f);
915  full5x5_showerShape.e2x5Top =
916  (hits != nullptr ? noZS::EcalClusterTools::e2x5Top(*(scRef->seed()), hits, topology) : 0.f);
917  full5x5_showerShape.e2x5Bottom =
918  (hits != nullptr ? noZS::EcalClusterTools::e2x5Bottom(*(scRef->seed()), hits, topology) : 0.f);
919  if (hits) {
920  Cluster2ndMoments clus2ndMoments = noZS::EcalClusterTools::cluster2ndMoments(*(scRef->seed()), *hits);
921  full5x5_showerShape.smMajor = clus2ndMoments.sMaj;
922  full5x5_showerShape.smMinor = clus2ndMoments.sMin;
923  full5x5_showerShape.smAlpha = clus2ndMoments.alpha;
924  } else {
925  full5x5_showerShape.smMajor = 0.f;
926  full5x5_showerShape.smMinor = 0.f;
927  full5x5_showerShape.smAlpha = 0.f;
928  }
929  // fill preshower shapes
930  full5x5_showerShape.effSigmaRR = sigmaRR;
931  for (uint id = 0; id < full5x5_showerShape.hcalOverEcal.size(); ++id) {
932  full5x5_showerShape.hcalOverEcal[id] =
933  (hcalHelperCone != nullptr) ? hcalHelperCone->hcalESum(*scRef, id + 1) / full5x5_e5x5 : 0.f;
934  full5x5_showerShape.hcalOverEcalBc[id] =
935  (hcalHelperBc != nullptr) ? hcalHelperBc->hcalESum(*scRef, id + 1) / full5x5_e5x5 : 0.f;
936  }
937  full5x5_showerShape.pre7DepthHcal = false;
938  newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
939 
940  //get the pointer for the photon object
941  edm::Ptr<reco::PhotonCore> photonPtr(photonCoreHandle, lSC);
942 
943  // New in CMSSW_12_1_0 for PFID with DNNs
944  // The PFIso values are computed in the first loop on gedPhotonsTmp to make them available as DNN inputs.
945  // They are computed with the same inputs and algo as the final PFiso variables computed in the second loop after PF.
946  // Get PFClusters for PFID only if the PFID DNN evaluation is enabled
947  if (dnnPFidEnabled_) {
948  auto clusterHandle = evt.getHandle(pfClusterProducer_);
949  std::vector<edm::Handle<reco::PFClusterCollection>> clusterHandles{evt.getHandle(pfClusterProducerHCAL_)};
950  if (useHF_) {
951  clusterHandles.push_back(evt.getHandle(pfClusterProducerHFEM_));
952  clusterHandles.push_back(evt.getHandle(pfClusterProducerHFHAD_));
953  }
955  pfIso.sumEcalClusterEt = ecalisoAlgo->getSum(newCandidate, clusterHandle);
956  pfIso.sumHcalClusterEt = hcalisoAlgo->getSum(newCandidate, clusterHandles);
957 
958  newCandidate.setPflowIsolationVariables(pfIso);
959  }
960 
963  // Photon candidate takes by default (set in photons_cfi.py)
964  // a 4-momentum derived from the ecal photon-specific corrections.
965  if (!EcalTools::isHGCalDet(thedet)) {
966  photonEnergyCorrector_->calculate(evt, newCandidate, subdet, vertexCollection, es);
967  if (candidateP4type_ == "fromEcalEnergy") {
968  newCandidate.setP4(newCandidate.p4(reco::Photon::ecal_photons));
969  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
970  newCandidate.setMass(0.0);
971  } else if (candidateP4type_ == "fromRegression1") {
972  newCandidate.setP4(newCandidate.p4(reco::Photon::regression1));
973  newCandidate.setCandidateP4type(reco::Photon::regression1);
974  newCandidate.setMass(0.0);
975  } else if (candidateP4type_ == "fromRegression2") {
976  newCandidate.setP4(newCandidate.p4(reco::Photon::regression2));
977  newCandidate.setCandidateP4type(reco::Photon::regression2);
978  newCandidate.setMass(0.0);
979  } else if (candidateP4type_ == "fromRefinedSCRegression") {
980  newCandidate.setP4(newCandidate.p4(reco::Photon::regression2));
981  newCandidate.setCandidateP4type(reco::Photon::regression2);
982  newCandidate.setMass(0.0);
983  }
984  } else {
985  math::XYZVector gamma_momentum = direction.unit() * scRef->energy();
986  math::PtEtaPhiMLorentzVector p4(gamma_momentum.rho(), gamma_momentum.eta(), gamma_momentum.phi(), 0.0);
987  newCandidate.setP4(p4);
988  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
989  // Make it an EE photon
990  reco::Photon::FiducialFlags fiducialFlags;
991  fiducialFlags.isEE = true;
992  newCandidate.setFiducialVolumeFlags(fiducialFlags);
993  }
994 
995  // fill MIP Vairables for Halo: Block for MIP are filled from PhotonMIPHaloTagger
997  if (subdet == EcalBarrel && runMIPTagger_) {
998  photonMIPHaloTagger_->MIPcalculate(&newCandidate, evt, es, mipVar);
999  newCandidate.setMIPVariables(mipVar);
1000  }
1001 
1003  bool isLooseEM = true;
1004  if (newCandidate.pt() < highEt_) {
1005  if (newCandidate.hadronicOverEm() >= preselCutValues[1])
1006  isLooseEM = false;
1007  if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
1008  isLooseEM = false;
1009  if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
1010  isLooseEM = false;
1011  if (newCandidate.nTrkSolidConeDR04() > int(preselCutValues[6]))
1012  isLooseEM = false;
1013  if (newCandidate.nTrkHollowConeDR04() > int(preselCutValues[7]))
1014  isLooseEM = false;
1015  if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
1016  isLooseEM = false;
1017  if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
1018  isLooseEM = false;
1019  if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
1020  isLooseEM = false;
1021  }
1022 
1023  if (isLooseEM)
1024  outputPhotonCollection.push_back(newCandidate);
1025  }
1026 
1027  if (dnnPFidEnabled_) {
1028  // Here send the list of photons to the PhotonDNNEstimator and get back the values for all the photons in one go
1029  LogDebug("GEDPhotonProducer") << "Getting DNN PFId for photons";
1030  const auto& dnn_photon_pfid = globalCache()->photonDNNEstimator->evaluate(outputPhotonCollection, tfSessions_);
1031  size_t ipho = 0;
1032  for (auto& photon : outputPhotonCollection) {
1033  const auto& values = dnn_photon_pfid[ipho];
1035  pfID.dnn = values[0];
1036  photon.setPflowIDVariables(pfID);
1037  ipho++;
1038  }
1039  }
1040 }
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:49
static float e2x5Bottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
std::vector< CaloTowerDetId > hcalTowersBehindClusters
Definition: Photon.h:156
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
bool hasActiveHcal(const reco::SuperCluster &sc) const
static float eMax(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:219
CaloGeometry const * caloGeom_
std::vector< int > flagsexclEB_
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
std::array< float, 7 > hcalOverEcalBc
Definition: Photon.h:155
constexpr bool isFinite(T x)
std::vector< int > severitiesexclEE_
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
static float e2x5Top(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double hcalESum(const reco::SuperCluster &, int depth) const
static std::array< float, 3 > covariances(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology, const CaloGeometry *geometry, float w0=4.7)
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)
static float e2x2(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
T sqrt(T t)
Definition: SSEVec.h:19
static float e2nd(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits)
std::vector< int > flagsexclEE_
static float e2x5Max(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
double f[11][100]
static float eBottom(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e2x5Right(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
std::vector< int > severitiesexclEB_
static Cluster2ndMoments cluster2ndMoments(const reco::BasicCluster &basicCluster, const EcalRecHitCollection &recHits, double phiCorrectionFactor=0.8, double w0=4.7, bool useLogWeights=true)
static float eTop(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Definition: DetId.h:17
std::vector< double > preselCutValuesBarrel_
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:153
Detector
Definition: DetId.h:24
std::vector< double > preselCutValuesEndcap_
static float e2x5Left(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
auto hcalTowersBehindClusters(const reco::SuperCluster &sc) const
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
static float eRight(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e3x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e1x3(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
Log< level::Warning, false > LogWarning
static float eLeft(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
static float e1x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)
#define LogDebug(id)
static float e5x5(const reco::BasicCluster &cluster, const EcalRecHitCollection *recHits, const CaloTopology *topology)

◆ fillPhotonCollection() [2/2]

void GEDPhotonProducer::fillPhotonCollection ( edm::Event evt,
edm::EventSetup const &  es,
const edm::Handle< reco::PhotonCollection > &  photonHandle,
const edm::Handle< reco::PFCandidateCollection pfCandidateHandle,
const edm::Handle< reco::PFCandidateCollection pfEGCandidateHandle,
reco::VertexCollection const &  pvVertices,
reco::PhotonCollection outputCollection,
int &  iSC,
const edm::Handle< edm::ValueMap< float >> &  chargedHadrons,
const edm::Handle< edm::ValueMap< float >> &  neutralHadrons,
const edm::Handle< edm::ValueMap< float >> &  photons,
const edm::Handle< edm::ValueMap< float >> &  chargedHadronsWorstVtx,
const edm::Handle< edm::ValueMap< float >> &  chargedHadronsWorstVtxGeomVeto,
const edm::Handle< edm::ValueMap< float >> &  chargedHadronsPFPV,
const edm::Handle< edm::ValueMap< float >> &  pfEcalClusters,
const edm::Handle< edm::ValueMap< float >> &  pfHcalClusters 
)
private

sets values only for EE, for EB it always returns 1

Definition at line 1042 of file GEDPhotonProducer.cc.

References candidateP4type_, reco::Photon::PflowIsolationVariables::chargedHadronIso, reco::Photon::PflowIsolationVariables::chargedHadronPFPVIso, reco::Photon::PflowIsolationVariables::chargedHadronWorstVtxGeomVetoIso, reco::Photon::PflowIsolationVariables::chargedHadronWorstVtxIso, reco::Photon::ecal_photons, EcalBarrel, EcalEndcap, reco::LeafCandidate::get(), EcalTools::isHGCalDet(), edm::Ref< C, T, F >::isNonnull(), GEDPhotonProducer::RecoStepInfo::isOOT(), edm::EDGetTokenT< T >::isUninitialized(), reco::Photon::PflowIsolationVariables::neutralHadronIso, gedPhotons_cfi::outputPhotonCollection, reco::Photon::p4(), phoPFECALClusIsolationToken_, phoPFHCALClusIsolationToken_, photonEnergyCorrector_, reco::Photon::PflowIsolationVariables::photonIso, photonMVABasedHaloTagger_, preselCutValuesBarrel_, preselCutValuesEndcap_, ptFast(), recoStep_, reco::Photon::regression1, reco::Photon::regression2, runMVABasedHaloTagger_, reco::Photon::setCandidateP4type(), reco::Photon::setHaloTaggerMVAVal(), reco::LeafCandidate::setMass(), reco::Photon::setP4(), reco::Photon::setPflowIsolationVariables(), reco::Photon::PflowIsolationVariables::sumEcalClusterEt, reco::Photon::PflowIsolationVariables::sumHcalClusterEt, and spclusmultinvestigator_cfi::vertexCollection.

1057  {
1058  std::vector<double> preselCutValues;
1059 
1060  for (unsigned int lSC = 0; lSC < photonHandle->size(); lSC++) {
1061  reco::PhotonRef phoRef(reco::PhotonRef(photonHandle, lSC));
1062  reco::SuperClusterRef parentSCRef = phoRef->parentSuperCluster();
1063  reco::SuperClusterRef scRef = phoRef->superCluster();
1064  DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
1065  int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
1066  if (subdet == EcalBarrel) {
1067  preselCutValues = preselCutValuesBarrel_;
1068  } else if (subdet == EcalEndcap) {
1069  preselCutValues = preselCutValuesEndcap_;
1070  } else if (EcalTools::isHGCalDet(thedet)) {
1071  preselCutValues = preselCutValuesEndcap_;
1072  } else {
1073  edm::LogWarning("") << "GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet << ' '
1074  << subdet;
1075  }
1076 
1077  // SC energy preselection
1078  if (parentSCRef.isNonnull() &&
1079  ptFast(parentSCRef->energy(), parentSCRef->position(), {0, 0, 0}) <= preselCutValues[0])
1080  continue;
1081 
1082  reco::Photon newCandidate(*phoRef);
1083  iSC++;
1084 
1085  if (runMVABasedHaloTagger_) {
1086  float BHmva = photonMVABasedHaloTagger_->calculateMVA(&newCandidate, globalCache()->haloTaggerGBR.get(), evt, es);
1087  newCandidate.setHaloTaggerMVAVal(BHmva);
1088  }
1089 
1090  // Calculate the PF isolation
1092  // The PFID are not recomputed since they have been already computed in the first loop with the DNN
1093 
1094  //get the pointer for the photon object
1095  edm::Ptr<reco::Photon> photonPtr(photonHandle, lSC);
1096 
1097  if (!recoStep_.isOOT()) { //out of time photons do not have PF info so skip in this case
1098  pfIso.chargedHadronIso = (*chargedHadrons)[photonPtr];
1099  pfIso.neutralHadronIso = (*neutralHadrons)[photonPtr];
1100  pfIso.photonIso = (*photons)[photonPtr];
1101  pfIso.chargedHadronWorstVtxIso = (*chargedHadronsWorstVtx)[photonPtr];
1102  pfIso.chargedHadronWorstVtxGeomVetoIso = (*chargedHadronsWorstVtxGeomVeto)[photonPtr];
1103  pfIso.chargedHadronPFPVIso = (*chargedHadronsPFPV)[photonPtr];
1104  }
1105 
1106  //OOT photons in legacy 80X reminiAOD workflow dont have pf cluster isolation embeded into them at this stage
1107  // They have been already computed in the first loop on gedPhotonsTmp but better to compute them again here.
1108  pfIso.sumEcalClusterEt = !phoPFECALClusIsolationToken_.isUninitialized() ? (*pfEcalClusters)[photonPtr] : 0.;
1109  pfIso.sumHcalClusterEt = !phoPFHCALClusIsolationToken_.isUninitialized() ? (*pfHcalClusters)[photonPtr] : 0.;
1110  newCandidate.setPflowIsolationVariables(pfIso);
1111 
1112  // do the regression
1113  photonEnergyCorrector_->calculate(evt, newCandidate, subdet, vertexCollection, es);
1114  if (candidateP4type_ == "fromEcalEnergy") {
1115  newCandidate.setP4(newCandidate.p4(reco::Photon::ecal_photons));
1116  newCandidate.setCandidateP4type(reco::Photon::ecal_photons);
1117  newCandidate.setMass(0.0);
1118  } else if (candidateP4type_ == "fromRegression1") {
1119  newCandidate.setP4(newCandidate.p4(reco::Photon::regression1));
1120  newCandidate.setCandidateP4type(reco::Photon::regression1);
1121  newCandidate.setMass(0.0);
1122  } else if (candidateP4type_ == "fromRegression2") {
1123  newCandidate.setP4(newCandidate.p4(reco::Photon::regression2));
1124  newCandidate.setCandidateP4type(reco::Photon::regression2);
1125  newCandidate.setMass(0.0);
1126  } else if (candidateP4type_ == "fromRefinedSCRegression") {
1127  newCandidate.setP4(newCandidate.p4(reco::Photon::regression2));
1128  newCandidate.setCandidateP4type(reco::Photon::regression2);
1129  newCandidate.setMass(0.0);
1130  }
1131 
1132  outputPhotonCollection.push_back(newCandidate);
1133  }
1134 }
static bool isHGCalDet(DetId::Detector thedet)
identify HGCal cells
Definition: EcalTools.h:49
std::unique_ptr< PhotonMVABasedHaloTagger > photonMVABasedHaloTagger_
std::unique_ptr< PhotonEnergyCorrector > photonEnergyCorrector_
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
edm::EDGetTokenT< edm::ValueMap< float > > phoPFHCALClusIsolationToken_
std::vector< double > preselCutValuesBarrel_
Detector
Definition: DetId.h:24
std::vector< double > preselCutValuesEndcap_
std::string candidateP4type_
edm::EDGetTokenT< edm::ValueMap< float > > phoPFECALClusIsolationToken_
Log< level::Warning, false > LogWarning

◆ globalEndJob()

static void GEDPhotonProducer::globalEndJob ( const CacheData )
inlinestatic

Definition at line 92 of file GEDPhotonProducer.cc.

92 {};

◆ initializeGlobalCache()

std::unique_ptr< CacheData > GEDPhotonProducer::initializeGlobalCache ( const edm::ParameterSet config)
static

Definition at line 474 of file GEDPhotonProducer.cc.

References submitPVResolutionJobs::config.

474  {
475  // this method is supposed to create, initialize and return a CacheData instance
476  return std::make_unique<CacheData>(config);
477 }
config
parse the configuration file

◆ produce()

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

PF ECAL cluster based isolations

Definition at line 485 of file GEDPhotonProducer.cc.

References barrelEcalHits_, HLT_2022v11_cff::barrelRecHits, caloGeom_, caloGeometryToken_, caloTopologyToken_, ecaldrMax_, ecaldrVetoBarrel_, ecaldrVetoEndcap_, ecalenergyBarrel_, ecalenergyEndcap_, ecaletaStripBarrel_, ecaletaStripEndcap_, ecalisoAlgo, ecalPFRechitThresholdsToken_, endcapEcalHits_, HLT_2022v11_cff::endcapRecHits, options_cfi::eventSetup, Exception, trigObjTnPSource_cfi::filler, fillPhotonCollection(), edm::Event::get(), edm::Event::getByToken(), hcaldrMax_, hcaldrVetoBarrel_, hcaldrVetoEndcap_, hcalenergyBarrel_, hcalenergyEndcap_, hcaletaStripBarrel_, hcaletaStripEndcap_, hcalHelperBc_, hcalHelperCone_, hcalisoAlgo, hcalRun2EffDepth_, hcaluseEt_, GEDPhotonProducer::RecoStepInfo::isFinal(), GEDPhotonProducer::RecoStepInfo::isOOT(), edm::EDGetTokenT< T >::isUninitialized(), edm::HandleBase::isValid(), edm::InputTag::label(), eostools::move(), pfCandidates_, pfEgammaCandidates_, phoChargedIsolationToken_, phoChargedPFPVIsoToken_, phoChargedWorstVtxGeomVetoIsoToken_, phoChargedWorstVtxIsoToken_, phoNeutralHadronIsolationToken_, phoPFECALClusIsolationToken_, phoPFHCALClusIsolationToken_, phoPhotonIsolationToken_, photonCollection_, photonCoreProducerT_, photonEnergyCorrector_, photonProducer_, photonProducerT_, preshowerHits_, edm::Event::put(), recoStep_, particleFlowZeroSuppressionECAL_cff::thresholds, usePrimaryVertex_, valueMapPFCandPhoton_, contentValuesCheck::values, spclusmultinvestigator_cfi::vertexCollection, and vertexProducer_.

485  {
486  using namespace edm;
487 
488  auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
489  edm::ValueMap<reco::PhotonRef> pfEGCandToPhotonMap;
490 
491  // Get the PhotonCore collection
492  bool validPhotonCoreHandle = false;
493  Handle<reco::PhotonCoreCollection> photonCoreHandle;
494  bool validPhotonHandle = false;
495  Handle<reco::PhotonCollection> photonHandle;
496  //value maps for isolation
497  edm::Handle<edm::ValueMap<float>> phoChargedIsolationMap;
498  edm::Handle<edm::ValueMap<float>> phoNeutralHadronIsolationMap;
499  edm::Handle<edm::ValueMap<float>> phoPhotonIsolationMap;
500  edm::Handle<edm::ValueMap<float>> phoChargedWorstVtxIsoMap;
501  edm::Handle<edm::ValueMap<float>> phoChargedWorstVtxGeomVetoIsoMap;
502  edm::Handle<edm::ValueMap<float>> phoChargedPFPVIsoMap;
503 
504  edm::Handle<edm::ValueMap<float>> phoPFECALClusIsolationMap;
505  edm::Handle<edm::ValueMap<float>> phoPFHCALClusIsolationMap;
506 
507  if (recoStep_.isFinal()) {
508  theEvent.getByToken(photonProducerT_, photonHandle);
509  //get isolation objects
510  theEvent.getByToken(phoChargedIsolationToken_, phoChargedIsolationMap);
511  theEvent.getByToken(phoNeutralHadronIsolationToken_, phoNeutralHadronIsolationMap);
512  theEvent.getByToken(phoPhotonIsolationToken_, phoPhotonIsolationMap);
513  theEvent.getByToken(phoChargedWorstVtxIsoToken_, phoChargedWorstVtxIsoMap);
514  theEvent.getByToken(phoChargedWorstVtxGeomVetoIsoToken_, phoChargedWorstVtxGeomVetoIsoMap);
515  theEvent.getByToken(phoChargedPFPVIsoToken_, phoChargedPFPVIsoMap);
516 
517  //OOT photons in legacy 80X re-miniAOD workflow dont have cluster isolation embed in them
519  theEvent.getByToken(phoPFECALClusIsolationToken_, phoPFECALClusIsolationMap);
520  }
522  theEvent.getByToken(phoPFHCALClusIsolationToken_, phoPFHCALClusIsolationMap);
523  }
524 
525  if (photonHandle.isValid()) {
526  validPhotonHandle = true;
527  } else {
528  throw cms::Exception("GEDPhotonProducer") << "Error! Can't get the product " << photonProducer_.label() << "\n";
529  }
530  } else {
531  theEvent.getByToken(photonCoreProducerT_, photonCoreHandle);
532  if (photonCoreHandle.isValid()) {
533  validPhotonCoreHandle = true;
534  } else {
535  throw cms::Exception("GEDPhotonProducer")
536  << "Error! Can't get the photonCoreProducer " << photonProducer_.label() << "\n";
537  }
538  }
539 
540  // Get EcalRecHits
541  auto const& barrelRecHits = theEvent.get(barrelEcalHits_);
542  auto const& endcapRecHits = theEvent.get(endcapEcalHits_);
543  auto const& preshowerRecHits = theEvent.get(preshowerHits_);
544 
545  Handle<reco::PFCandidateCollection> pfEGCandidateHandle;
546  // Get the PF refined cluster collection
548  theEvent.getByToken(pfEgammaCandidates_, pfEGCandidateHandle);
549  if (!pfEGCandidateHandle.isValid()) {
550  throw cms::Exception("GEDPhotonProducer") << "Error! Can't get the pfEgammaCandidates";
551  }
552  }
553 
554  Handle<reco::PFCandidateCollection> pfCandidateHandle;
555 
556  if (recoStep_.isFinal()) {
557  // Get the PF candidates collection
558  theEvent.getByToken(pfCandidates_, pfCandidateHandle);
559  //OOT photons have no PF candidates so its not an error in this case
560  if (!pfCandidateHandle.isValid() && !recoStep_.isOOT()) {
561  throw cms::Exception("GEDPhotonProducer") << "Error! Can't get the pfCandidates";
562  }
563  }
564 
565  // get the geometry from the event setup:
567 
568  // prepare access to hcal data
569  if (hcalHelperCone_ != nullptr and hcalHelperBc_ != nullptr) {
570  hcalHelperCone_->beginEvent(theEvent, eventSetup);
571  hcalHelperBc_->beginEvent(theEvent, eventSetup);
572  }
573 
574  auto const& topology = eventSetup.getData(caloTopologyToken_);
575  auto const& thresholds = eventSetup.getData(ecalPFRechitThresholdsToken_);
576 
577  // Get the primary event vertex
578  const reco::VertexCollection dummyVC;
579  auto const& vertexCollection{usePrimaryVertex_ ? theEvent.get(vertexProducer_) : dummyVC};
580 
581  // math::XYZPoint vtx(0.,0.,0.);
582  //if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
583 
584  // get the regression calculator ready
586  if (photonEnergyCorrector_->gedRegression()) {
587  photonEnergyCorrector_->gedRegression()->setEvent(theEvent);
588  photonEnergyCorrector_->gedRegression()->setEventContent(eventSetup);
589  }
590 
592  ecalisoAlgo = std::make_unique<PhotonEcalPFClusterIsolation>(ecaldrMax_,
599 
600  hcalisoAlgo = std::make_unique<PhotonHcalPFClusterIsolation>(hcaldrMax_,
607  hcaluseEt_);
608 
609  int iSC = 0; // index in photon collection
610  // Loop over barrel and endcap SC collections and fill the photon collection
611  if (validPhotonCoreHandle)
612  fillPhotonCollection(theEvent,
613  eventSetup,
614  photonCoreHandle,
615  &topology,
616  &barrelRecHits,
617  &endcapRecHits,
618  &preshowerRecHits,
619  hcalHelperCone_.get(),
620  hcalHelperBc_.get(),
621  //vtx,
623  *outputPhotonCollection_p,
624  iSC,
625  thresholds);
626 
627  iSC = 0;
628  if (validPhotonHandle && recoStep_.isFinal())
629  fillPhotonCollection(theEvent,
630  eventSetup,
631  photonHandle,
632  pfCandidateHandle,
633  pfEGCandidateHandle,
634  theEvent.get(vertexProducer_),
635  *outputPhotonCollection_p,
636  iSC,
637  phoChargedIsolationMap,
638  phoNeutralHadronIsolationMap,
639  phoPhotonIsolationMap,
640  phoChargedWorstVtxIsoMap,
641  phoChargedWorstVtxGeomVetoIsoMap,
642  phoChargedPFPVIsoMap,
643  phoPFECALClusIsolationMap,
644  phoPFHCALClusIsolationMap);
645 
646  // put the product in the event
647  edm::LogInfo("GEDPhotonProducer") << " Put in the event " << iSC << " Photon Candidates \n";
648 
649  // 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
650  if (hcalRun2EffDepth_) {
651  for (auto& pho : *outputPhotonCollection_p)
652  pho.hcalToRun2EffDepth();
653  }
654  const auto photonOrphHandle = theEvent.put(std::move(outputPhotonCollection_p), photonCollection_);
655 
658  auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
659  edm::ValueMap<reco::PhotonRef>::Filler filler(*pfEGCandToPhotonMap_p);
660  unsigned nObj = pfEGCandidateHandle->size();
661  std::vector<reco::PhotonRef> values(nObj);
663  for (unsigned int lCand = 0; lCand < nObj; lCand++) {
664  reco::PFCandidateRef pfCandRef(reco::PFCandidateRef(pfEGCandidateHandle, lCand));
665  reco::SuperClusterRef pfScRef = pfCandRef->superClusterRef();
666 
667  for (unsigned int lSC = 0; lSC < photonOrphHandle->size(); lSC++) {
668  reco::PhotonRef photonRef(reco::PhotonRef(photonOrphHandle, lSC));
669  reco::SuperClusterRef scRef = photonRef->superCluster();
670  if (pfScRef != scRef)
671  continue;
672  values[lCand] = photonRef;
673  }
674  }
675 
676  filler.insert(pfEGCandidateHandle, values.begin(), values.end());
677  filler.fill();
678  theEvent.put(std::move(pfEGCandToPhotonMap_p), valueMapPFCandPhoton_);
679  }
680 }
std::unique_ptr< PhotonHcalPFClusterIsolation > hcalisoAlgo
edm::EDGetTokenT< reco::PFCandidateCollection > pfCandidates_
void fillPhotonCollection(edm::Event &evt, edm::EventSetup const &es, const edm::Handle< reco::PhotonCoreCollection > &photonCoreHandle, const CaloTopology *topology, const EcalRecHitCollection *ecalBarrelHits, const EcalRecHitCollection *ecalEndcapHits, const EcalRecHitCollection *preshowerHits, const ElectronHcalHelper *hcalHelperCone, const ElectronHcalHelper *hcalHelperBc, const reco::VertexCollection &pvVertices, reco::PhotonCollection &outputCollection, int &iSC, EcalPFRecHitThresholds const &thresholds)
const edm::ESGetToken< EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd > ecalPFRechitThresholdsToken_
std::unique_ptr< PhotonEnergyCorrector > photonEnergyCorrector_
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
CaloGeometry const * caloGeom_
std::unique_ptr< PhotonEcalPFClusterIsolation > ecalisoAlgo
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapEcalHits_
std::string const & label() const
Definition: InputTag.h:36
std::string photonCollection_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedPFPVIsoToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelEcalHits_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxGeomVetoIsoToken_
std::unique_ptr< ElectronHcalHelper > hcalHelperCone_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedIsolationToken_
edm::EDGetTokenT< reco::PhotonCoreCollection > photonCoreProducerT_
edm::EDGetTokenT< edm::ValueMap< float > > phoPFHCALClusIsolationToken_
edm::EDGetTokenT< reco::PFCandidateCollection > pfEgammaCandidates_
Log< level::Info, false > LogInfo
edm::EDGetTokenT< edm::ValueMap< float > > phoNeutralHadronIsolationToken_
edm::EDGetTokenT< edm::ValueMap< float > > phoChargedWorstVtxIsoToken_
edm::EDGetTokenT< reco::PhotonCollection > photonProducerT_
const edm::InputTag photonProducer_
std::unique_ptr< ElectronHcalHelper > hcalHelperBc_
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< edm::ValueMap< float > > phoPhotonIsolationToken_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
HLT enums.
edm::EDGetTokenT< edm::ValueMap< float > > phoPFECALClusIsolationToken_
edm::EDGetTokenT< reco::VertexCollection > vertexProducer_
edm::EDGetTokenT< EcalRecHitCollection > preshowerHits_
def move(src, dest)
Definition: eostools.py:511
std::string valueMapPFCandPhoton_

Member Data Documentation

◆ barrelEcalHits_

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

Definition at line 146 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ caloGeom_

CaloGeometry const* GEDPhotonProducer::caloGeom_ = nullptr
private

Definition at line 194 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ caloGeometryToken_

const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> GEDPhotonProducer::caloGeometryToken_
private

Definition at line 208 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ caloTopologyToken_

const edm::ESGetToken<CaloTopology, CaloTopologyRecord> GEDPhotonProducer::caloTopologyToken_
private

Definition at line 207 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ candidateP4type_

std::string GEDPhotonProducer::candidateP4type_
private

Definition at line 205 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ checkHcalStatus_

bool GEDPhotonProducer::checkHcalStatus_
private

Definition at line 183 of file GEDPhotonProducer.cc.

◆ dnnPFidEnabled_

bool GEDPhotonProducer::dnnPFidEnabled_
private

Definition at line 217 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ ecalClusterESGetTokens_

const EcalClusterLazyTools::ESGetTokens GEDPhotonProducer::ecalClusterESGetTokens_
private

Definition at line 166 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ ecaldrMax_

double GEDPhotonProducer::ecaldrMax_
private

Definition at line 220 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecaldrVetoBarrel_

double GEDPhotonProducer::ecaldrVetoBarrel_
private

Definition at line 221 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecaldrVetoEndcap_

double GEDPhotonProducer::ecaldrVetoEndcap_
private

Definition at line 222 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecalenergyBarrel_

double GEDPhotonProducer::ecalenergyBarrel_
private

Definition at line 225 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecalenergyEndcap_

double GEDPhotonProducer::ecalenergyEndcap_
private

Definition at line 226 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecaletaStripBarrel_

double GEDPhotonProducer::ecaletaStripBarrel_
private

Definition at line 223 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecaletaStripEndcap_

double GEDPhotonProducer::ecaletaStripEndcap_
private

Definition at line 224 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ ecalisoAlgo

std::unique_ptr<PhotonEcalPFClusterIsolation> GEDPhotonProducer::ecalisoAlgo = nullptr
private

Definition at line 228 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ ecalPFRechitThresholdsToken_

const edm::ESGetToken<EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd> GEDPhotonProducer::ecalPFRechitThresholdsToken_
private

Definition at line 209 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ endcapEcalHits_

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

Definition at line 147 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ flagsexclEB_

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

Definition at line 175 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ flagsexclEE_

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

Definition at line 176 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ hbheRecHits_

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

Definition at line 151 of file GEDPhotonProducer.cc.

◆ hcaldrMax_

double GEDPhotonProducer::hcaldrMax_
private

Definition at line 232 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcaldrVetoBarrel_

double GEDPhotonProducer::hcaldrVetoBarrel_
private

Definition at line 233 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcaldrVetoEndcap_

double GEDPhotonProducer::hcaldrVetoEndcap_
private

Definition at line 234 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcalenergyBarrel_

double GEDPhotonProducer::hcalenergyBarrel_
private

Definition at line 237 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcalenergyEndcap_

double GEDPhotonProducer::hcalenergyEndcap_
private

Definition at line 238 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcaletaStripBarrel_

double GEDPhotonProducer::hcaletaStripBarrel_
private

Definition at line 235 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcaletaStripEndcap_

double GEDPhotonProducer::hcaletaStripEndcap_
private

Definition at line 236 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcalHelperBc_

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

Definition at line 213 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcalHelperCone_

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

Definition at line 212 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcalisoAlgo

std::unique_ptr<PhotonHcalPFClusterIsolation> GEDPhotonProducer::hcalisoAlgo = nullptr
private

Definition at line 246 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ hcalRun2EffDepth_

bool GEDPhotonProducer::hcalRun2EffDepth_
private

Definition at line 214 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ hcaluseEt_

double GEDPhotonProducer::hcaluseEt_
private

Definition at line 239 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ highEt_

double GEDPhotonProducer::highEt_
private

Definition at line 184 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ hOverEConeSize_

double GEDPhotonProducer::hOverEConeSize_
private

Definition at line 182 of file GEDPhotonProducer.cc.

◆ minR9Barrel_

double GEDPhotonProducer::minR9Barrel_
private

Definition at line 185 of file GEDPhotonProducer.cc.

◆ minR9Endcap_

double GEDPhotonProducer::minR9Endcap_
private

Definition at line 186 of file GEDPhotonProducer.cc.

◆ multThresEB_

double GEDPhotonProducer::multThresEB_
private

Definition at line 180 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ multThresEE_

double GEDPhotonProducer::multThresEE_
private

Definition at line 181 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ particleBasedIsolationToken

edm::EDGetTokenT<edm::ValueMap<std::vector<reco::PFCandidateRef> > > GEDPhotonProducer::particleBasedIsolationToken
private

Definition at line 154 of file GEDPhotonProducer.cc.

◆ pfCandidates_

edm::EDGetTokenT<reco::PFCandidateCollection> GEDPhotonProducer::pfCandidates_
private

Definition at line 150 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ pfClusterProducer_

edm::EDGetTokenT<reco::PFClusterCollection> GEDPhotonProducer::pfClusterProducer_
private

Definition at line 229 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ pfClusterProducerHCAL_

edm::EDGetTokenT<reco::PFClusterCollection> GEDPhotonProducer::pfClusterProducerHCAL_
private

Definition at line 241 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ pfClusterProducerHFEM_

edm::EDGetTokenT<reco::PFClusterCollection> GEDPhotonProducer::pfClusterProducerHFEM_
private

Definition at line 242 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ pfClusterProducerHFHAD_

edm::EDGetTokenT<reco::PFClusterCollection> GEDPhotonProducer::pfClusterProducerHFHAD_
private

Definition at line 243 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ pfEgammaCandidates_

edm::EDGetTokenT<reco::PFCandidateCollection> GEDPhotonProducer::pfEgammaCandidates_
private

Definition at line 149 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ phoChargedIsolationToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoChargedIsolationToken_
private

Definition at line 156 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ phoChargedPFPVIsoToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoChargedPFPVIsoToken_
private

Definition at line 161 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ phoChargedWorstVtxGeomVetoIsoToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoChargedWorstVtxGeomVetoIsoToken_
private

Definition at line 160 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ phoChargedWorstVtxIsoToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoChargedWorstVtxIsoToken_
private

Definition at line 159 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ phoNeutralHadronIsolationToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoNeutralHadronIsolationToken_
private

Definition at line 157 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ phoPFECALClusIsolationToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoPFECALClusIsolationToken_
private

Definition at line 163 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ phoPFHCALClusIsolationToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoPFHCALClusIsolationToken_
private

Definition at line 164 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ phoPhotonIsolationToken_

edm::EDGetTokenT<edm::ValueMap<float> > GEDPhotonProducer::phoPhotonIsolationToken_
private

Definition at line 158 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ photonCollection_

std::string GEDPhotonProducer::photonCollection_
private

Definition at line 141 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ photonCoreProducerT_

edm::EDGetTokenT<reco::PhotonCoreCollection> GEDPhotonProducer::photonCoreProducerT_
private

Definition at line 144 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ photonEnergyCorrector_

std::unique_ptr<PhotonEnergyCorrector> GEDPhotonProducer::photonEnergyCorrector_ = nullptr
private

Definition at line 204 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ photonIsoCalculator_

std::unique_ptr<PhotonIsolationCalculator> GEDPhotonProducer::photonIsoCalculator_ = nullptr
private

Definition at line 170 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ photonMIPHaloTagger_

std::unique_ptr<PhotonMIPHaloTagger> GEDPhotonProducer::photonMIPHaloTagger_ = nullptr
private

Definition at line 197 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ photonMVABasedHaloTagger_

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

Definition at line 199 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ photonProducer_

const edm::InputTag GEDPhotonProducer::photonProducer_
private

Definition at line 142 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ photonProducerT_

edm::EDGetTokenT<reco::PhotonCollection> GEDPhotonProducer::photonProducerT_
private

Definition at line 145 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ preselCutValuesBarrel_

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

Definition at line 201 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ preselCutValuesEndcap_

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

Definition at line 202 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ preshowerHits_

edm::EDGetTokenT<EcalRecHitCollection> GEDPhotonProducer::preshowerHits_
private

Definition at line 148 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ recoStep_

RecoStepInfo GEDPhotonProducer::recoStep_
private

Definition at line 190 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection(), and produce().

◆ runMIPTagger_

bool GEDPhotonProducer::runMIPTagger_
private

Definition at line 187 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ runMVABasedHaloTagger_

bool GEDPhotonProducer::runMVABasedHaloTagger_
private

Definition at line 188 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ severitiesexclEB_

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

Definition at line 177 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ severitiesexclEE_

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

Definition at line 178 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ tfSessions_

std::vector<tensorflow::Session*> GEDPhotonProducer::tfSessions_
private

Definition at line 218 of file GEDPhotonProducer.cc.

Referenced by endStream(), and fillPhotonCollection().

◆ useHF_

bool GEDPhotonProducer::useHF_
private

Definition at line 231 of file GEDPhotonProducer.cc.

Referenced by fillPhotonCollection().

◆ usePrimaryVertex_

bool GEDPhotonProducer::usePrimaryVertex_
private

Definition at line 192 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ valueMapPFCandPhoton_

std::string GEDPhotonProducer::valueMapPFCandPhoton_
private

Definition at line 168 of file GEDPhotonProducer.cc.

Referenced by produce().

◆ vertexProducer_

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

Definition at line 152 of file GEDPhotonProducer.cc.

Referenced by produce().