CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
PhotonXGBoostProducer Class Reference
Inheritance diagram for PhotonXGBoostProducer:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PhotonXGBoostProducer (edm::ParameterSet const &)
 
 ~PhotonXGBoostProducer ()=default
 
- Public Member Functions inherited from edm::global::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
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
bool wantsStreamLuminosityBlocks () const noexcept final
 
bool wantsStreamRuns () const noexcept final
 
- Public Member Functions inherited from edm::global::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::global::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Member Functions

void produce (edm::StreamID, edm::Event &, edm::EventSetup const &) const override
 

Private Attributes

const edm::EDGetTokenT< reco::RecoEcalCandidateCollectioncandToken_
 
const std::unique_ptr< const PhotonXGBoostEstimatormvaEstimatorB_
 
const std::unique_ptr< const PhotonXGBoostEstimatormvaEstimatorE_
 
const edm::FileInPath mvaFileXgbB_
 
const edm::FileInPath mvaFileXgbE_
 
const unsigned mvaNTreeLimitB_
 
const unsigned mvaNTreeLimitE_
 
const double mvaThresholdEt_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMaptokenE2x2_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMaptokenHoE_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMaptokenIso_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMaptokenR9_
 
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMaptokenSigmaiEtaiEta_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 20 of file PhotonXGBoostProducer.cc.

Constructor & Destructor Documentation

◆ PhotonXGBoostProducer()

PhotonXGBoostProducer::PhotonXGBoostProducer ( edm::ParameterSet const &  config)
explicit

Definition at line 45 of file PhotonXGBoostProducer.cc.

References mvaFileXgbB_, and mvaNTreeLimitB_.

46  : candToken_(consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("candTag"))),
47  tokenR9_(consumes<reco::RecoEcalCandidateIsolationMap>(config.getParameter<edm::InputTag>("inputTagR9"))),
48  tokenHoE_(consumes<reco::RecoEcalCandidateIsolationMap>(config.getParameter<edm::InputTag>("inputTagHoE"))),
50  consumes<reco::RecoEcalCandidateIsolationMap>(config.getParameter<edm::InputTag>("inputTagSigmaiEtaiEta"))),
51  tokenE2x2_(consumes<reco::RecoEcalCandidateIsolationMap>(config.getParameter<edm::InputTag>("inputTagE2x2"))),
52  tokenIso_(consumes<reco::RecoEcalCandidateIsolationMap>(config.getParameter<edm::InputTag>("inputTagIso"))),
53  mvaFileXgbB_(config.getParameter<edm::FileInPath>("mvaFileXgbB")),
54  mvaFileXgbE_(config.getParameter<edm::FileInPath>("mvaFileXgbE")),
55  mvaNTreeLimitB_(config.getParameter<unsigned int>("mvaNTreeLimitB")),
56  mvaNTreeLimitE_(config.getParameter<unsigned int>("mvaNTreeLimitE")),
57  mvaThresholdEt_(config.getParameter<double>("mvaThresholdEt")),
58  mvaEstimatorB_{std::make_unique<const PhotonXGBoostEstimator>(mvaFileXgbB_, mvaNTreeLimitB_)},
59  mvaEstimatorE_{std::make_unique<const PhotonXGBoostEstimator>(mvaFileXgbE_, mvaNTreeLimitE_)} {
60  produces<reco::RecoEcalCandidateIsolationMap>();
61 }
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenR9_
const edm::FileInPath mvaFileXgbB_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenSigmaiEtaiEta_
const edm::FileInPath mvaFileXgbE_
Definition: config.py:1
const std::unique_ptr< const PhotonXGBoostEstimator > mvaEstimatorE_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenE2x2_
const std::unique_ptr< const PhotonXGBoostEstimator > mvaEstimatorB_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenIso_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > candToken_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenHoE_

◆ ~PhotonXGBoostProducer()

PhotonXGBoostProducer::~PhotonXGBoostProducer ( )
default

Member Function Documentation

◆ fillDescriptions()

void PhotonXGBoostProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 63 of file PhotonXGBoostProducer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

63  {
65  desc.add<edm::InputTag>("candTag", edm::InputTag("hltEgammaCandidatesUnseeded"));
66  desc.add<edm::InputTag>("inputTagR9", edm::InputTag("hltEgammaR9IDUnseeded", "r95x5"));
67  desc.add<edm::InputTag>("inputTagHoE", edm::InputTag("hltEgammaHoverEUnseeded"));
68  desc.add<edm::InputTag>("inputTagSigmaiEtaiEta",
69  edm::InputTag("hltEgammaClusterShapeUnseeded", "sigmaIEtaIEta5x5NoiseCleaned"));
70  desc.add<edm::InputTag>("inputTagE2x2", edm::InputTag("hltEgammaClusterShapeUnseeded", "e2x2"));
71  desc.add<edm::InputTag>("inputTagIso", edm::InputTag("hltEgammaEcalPFClusterIsoUnseeded"));
72  desc.add<edm::FileInPath>(
73  "mvaFileXgbB", edm::FileInPath("RecoEgamma/PhotonIdentification/data/XGBoost/Photon_NTL_168_Barrel_v1.bin"));
74  desc.add<edm::FileInPath>(
75  "mvaFileXgbE", edm::FileInPath("RecoEgamma/PhotonIdentification/data/XGBoost/Photon_NTL_158_Endcap_v1.bin"));
76  desc.add<unsigned int>("mvaNTreeLimitB", 168);
77  desc.add<unsigned int>("mvaNTreeLimitE", 158);
78  desc.add<double>("mvaThresholdEt", 0);
79  descriptions.addWithDefaultLabel(desc);
80 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ produce()

void PhotonXGBoostProducer::produce ( edm::StreamID  ,
edm::Event event,
edm::EventSetup const &  setup 
) const
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 82 of file PhotonXGBoostProducer.cc.

References funct::abs(), candToken_, electrons_cff::hoe, mps_fire::i, edm::AssociationMap< Tag >::insert(), genparticles_cff::iso, mvaEstimatorB_, mvaEstimatorE_, mvaThresholdEt_, electrons_cff::r9, HLT_2024v14_cff::r9Map, egamma_custom_cff::rawEnergy, photons_cff::s4, tokenE2x2_, tokenHoE_, tokenIso_, tokenR9_, and tokenSigmaiEtaiEta_.

82  {
83  const auto& recCollection = event.getHandle(candToken_);
84 
85  //get hold of r9 association map
86  const auto& r9Map = event.getHandle(tokenR9_);
87 
88  //get hold of HoE association map
89  const auto& hoEMap = event.getHandle(tokenHoE_);
90 
91  //get hold of isolated association map
92  const auto& sigmaiEtaiEtaMap = event.getHandle(tokenSigmaiEtaiEta_);
93 
94  //get hold of e2x2 (s4) association map
95  const auto& e2x2Map = event.getHandle(tokenE2x2_);
96 
97  //get hold of Ecal isolation association map
98  const auto& isoMap = event.getHandle(tokenIso_);
99 
100  //output
101  reco::RecoEcalCandidateIsolationMap mvaScoreMap(recCollection);
102 
103  for (size_t i = 0; i < recCollection->size(); i++) {
105 
106  float etaSC = ref->eta();
107 
108  float scEnergy = ref->superCluster()->energy();
109  float r9 = (*r9Map).find(ref)->val;
110  float hoe = (*hoEMap).find(ref)->val / scEnergy;
111  float siEtaiEta = (*sigmaiEtaiEtaMap).find(ref)->val;
112  float e2x2 = (*e2x2Map).find(ref)->val;
113  float s4 = e2x2 / scEnergy;
114  float iso = (*isoMap).find(ref)->val;
115 
116  float rawEnergy = ref->superCluster()->rawEnergy();
117  float etaW = ref->superCluster()->etaWidth();
118  float phiW = ref->superCluster()->phiWidth();
119 
120  float scEt = scEnergy / cosh(etaSC);
121  if (scEt < 0.)
122  scEt = 0.; /* first and second order terms assume non-negative energies */
123 
124  float xgbScore = -100.;
125  //compute only above threshold used for training and cand filter, else store negative value into the association map.
126  if (scEt >= mvaThresholdEt_) {
127  if (std::abs(etaSC) < 1.5)
128  xgbScore = mvaEstimatorB_->computeMva(rawEnergy, r9, siEtaiEta, etaW, phiW, s4, etaSC, hoe, iso);
129  else
130  xgbScore = mvaEstimatorE_->computeMva(rawEnergy, r9, siEtaiEta, etaW, phiW, s4, etaSC, hoe, iso);
131  }
132  mvaScoreMap.insert(ref, xgbScore);
133  }
134  event.put(std::make_unique<reco::RecoEcalCandidateIsolationMap>(mvaScoreMap));
135 }
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenR9_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenSigmaiEtaiEta_
const std::unique_ptr< const PhotonXGBoostEstimator > mvaEstimatorE_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenE2x2_
const std::unique_ptr< const PhotonXGBoostEstimator > mvaEstimatorB_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenIso_
const edm::EDGetTokenT< reco::RecoEcalCandidateCollection > candToken_
const edm::EDGetTokenT< reco::RecoEcalCandidateIsolationMap > tokenHoE_

Member Data Documentation

◆ candToken_

const edm::EDGetTokenT<reco::RecoEcalCandidateCollection> PhotonXGBoostProducer::candToken_
private

Definition at line 30 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ mvaEstimatorB_

const std::unique_ptr<const PhotonXGBoostEstimator> PhotonXGBoostProducer::mvaEstimatorB_
private

Definition at line 41 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ mvaEstimatorE_

const std::unique_ptr<const PhotonXGBoostEstimator> PhotonXGBoostProducer::mvaEstimatorE_
private

Definition at line 42 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ mvaFileXgbB_

const edm::FileInPath PhotonXGBoostProducer::mvaFileXgbB_
private

Definition at line 36 of file PhotonXGBoostProducer.cc.

Referenced by PhotonXGBoostProducer().

◆ mvaFileXgbE_

const edm::FileInPath PhotonXGBoostProducer::mvaFileXgbE_
private

Definition at line 37 of file PhotonXGBoostProducer.cc.

◆ mvaNTreeLimitB_

const unsigned PhotonXGBoostProducer::mvaNTreeLimitB_
private

Definition at line 38 of file PhotonXGBoostProducer.cc.

Referenced by PhotonXGBoostProducer().

◆ mvaNTreeLimitE_

const unsigned PhotonXGBoostProducer::mvaNTreeLimitE_
private

Definition at line 39 of file PhotonXGBoostProducer.cc.

◆ mvaThresholdEt_

const double PhotonXGBoostProducer::mvaThresholdEt_
private

Definition at line 40 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ tokenE2x2_

const edm::EDGetTokenT<reco::RecoEcalCandidateIsolationMap> PhotonXGBoostProducer::tokenE2x2_
private

Definition at line 34 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ tokenHoE_

const edm::EDGetTokenT<reco::RecoEcalCandidateIsolationMap> PhotonXGBoostProducer::tokenHoE_
private

Definition at line 32 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ tokenIso_

const edm::EDGetTokenT<reco::RecoEcalCandidateIsolationMap> PhotonXGBoostProducer::tokenIso_
private

Definition at line 35 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ tokenR9_

const edm::EDGetTokenT<reco::RecoEcalCandidateIsolationMap> PhotonXGBoostProducer::tokenR9_
private

Definition at line 31 of file PhotonXGBoostProducer.cc.

Referenced by produce().

◆ tokenSigmaiEtaiEta_

const edm::EDGetTokenT<reco::RecoEcalCandidateIsolationMap> PhotonXGBoostProducer::tokenSigmaiEtaiEta_
private

Definition at line 33 of file PhotonXGBoostProducer.cc.

Referenced by produce().