CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ElectronRegressionEnergyProducer Class Reference
Inheritance diagram for ElectronRegressionEnergyProducer:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ElectronRegressionEnergyProducer (const edm::ParameterSet &)
 
 ~ElectronRegressionEnergyProducer () override
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
 EDFilter (const EDFilter &)=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 EDFilteroperator= (const EDFilter &)=delete
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
 EDFilterBase (const EDFilterBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDFilterBaseoperator= (const EDFilterBase &)=delete
 
 ~EDFilterBase () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const CaloGeometrycaloGeometry_
 
edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeomToken_
 
const CaloTopologyecalTopology_
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordecalTopoToken_
 
edm::EDGetTokenT< reco::GsfElectronCollectionelectronToken_
 
uint32_t energyRegressionType_
 
bool geomInitialized_
 
edm::EDGetTokenT< double > hRhoKt6PFJetsToken_
 
edm::EDGetTokenT< reco::VertexCollectionhVertexToken_
 
std::string nameEnergyErrorReg_
 
std::string nameEnergyReg_
 
bool printDebug_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitCollectionEBToken_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitCollectionEEToken_
 
ElectronEnergyRegressionEvaluateregressionEvaluator
 
std::string regressionInputFile_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
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
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase 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
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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 30 of file ElectronRegressionEnergyProducer.cc.

Constructor & Destructor Documentation

◆ ElectronRegressionEnergyProducer()

ElectronRegressionEnergyProducer::ElectronRegressionEnergyProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 65 of file ElectronRegressionEnergyProducer.cc.

References caloGeomToken_, ecalTopoToken_, electronToken_, energyRegressionType_, edm::EDConsumerBase::esConsumes(), geomInitialized_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hRhoKt6PFJetsToken_, hVertexToken_, ElectronEnergyRegressionEvaluate::initialize(), HLT_2022v15_cff::InputTag, ElectronEnergyRegressionEvaluate::kNoTrkVar, ElectronEnergyRegressionEvaluate::kWithSubCluVar, ElectronEnergyRegressionEvaluate::kWithTrkVarV1, ElectronEnergyRegressionEvaluate::kWithTrkVarV2, nameEnergyErrorReg_, nameEnergyReg_, printDebug_, recHitCollectionEBToken_, recHitCollectionEEToken_, regressionEvaluator, regressionInputFile_, and AlCaHLTBitMon_QueryRunRegistry::string.

65  {
66  printDebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
67  electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
68 
69  regressionInputFile_ = iConfig.getParameter<std::string>("regressionInputFile");
70  energyRegressionType_ = iConfig.getParameter<uint32_t>("energyRegressionType");
71 
72  nameEnergyReg_ = iConfig.getParameter<std::string>("nameEnergyReg");
73  nameEnergyErrorReg_ = iConfig.getParameter<std::string>("nameEnergyErrorReg");
74 
75  recHitCollectionEBToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitCollectionEB"));
76  recHitCollectionEEToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitCollectionEE"));
77 
78  hVertexToken_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
79  hRhoKt6PFJetsToken_ = consumes<double>(edm::InputTag("kt6PFJets", "rho"));
80 
83 
84  produces<edm::ValueMap<double> >(nameEnergyReg_);
85  produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
86 
88 
89  //set regression type
91  if (energyRegressionType_ == 1)
93  else if (energyRegressionType_ == 2)
95  else if (energyRegressionType_ == 3)
97  else if (energyRegressionType_ == 4)
99 
100  //load weights and initialize
102 
103  geomInitialized_ = false;
104 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ElectronEnergyRegressionEvaluate * regressionEvaluator
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
T getUntrackedParameter(std::string const &, T const &) const
edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopoToken_
edm::EDGetTokenT< reco::VertexCollection > hVertexToken_
void initialize(std::string weightsFile, ElectronEnergyRegressionEvaluate::ElectronEnergyRegressionType type)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_

◆ ~ElectronRegressionEnergyProducer()

ElectronRegressionEnergyProducer::~ElectronRegressionEnergyProducer ( )
override

Definition at line 106 of file ElectronRegressionEnergyProducer.cc.

References regressionEvaluator.

106 { delete regressionEvaluator; }
ElectronEnergyRegressionEvaluate * regressionEvaluator

Member Function Documentation

◆ filter()

bool ElectronRegressionEnergyProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::stream::EDFilterBase.

Definition at line 109 of file ElectronRegressionEnergyProducer.cc.

References cms::cuda::assert(), ElectronEnergyRegressionEvaluate::calculateRegressionEnergy(), ElectronEnergyRegressionEvaluate::calculateRegressionEnergyUncertainty(), caloGeometry_, caloGeomToken_, ecalTopology_, ecalTopoToken_, electronToken_, HCALHighEnergyHPDFilter_cfi::energy, relativeConstraints::error, edm::helper::Filler< Map >::fill(), geomInitialized_, edm::EventSetup::getData(), hRhoKt6PFJetsToken_, hVertexToken_, iEvent, edm::helper::Filler< Map >::insert(), ElectronEnergyRegressionEvaluate::isInitialized(), eostools::move(), nameEnergyErrorReg_, nameEnergyReg_, printDebug_, edm::Handle< T >::product(), recHitCollectionEBToken_, recHitCollectionEEToken_, FastTrackerRecHitMaskProducer_cfi::recHits, regressionEvaluator, and rho.

109  {
111 
112  if (!geomInitialized_) {
113  ecalTopology_ = &(iSetup.getData(ecalTopoToken_));
114  caloGeometry_ = &(iSetup.getData(caloGeomToken_));
115  geomInitialized_ = true;
116  }
117 
118  std::unique_ptr<edm::ValueMap<double> > regrEnergyMap(new edm::ValueMap<double>());
119  edm::ValueMap<double>::Filler energyFiller(*regrEnergyMap);
120 
121  std::unique_ptr<edm::ValueMap<double> > regrEnergyErrorMap(new edm::ValueMap<double>());
122  edm::ValueMap<double>::Filler energyErrorFiller(*regrEnergyErrorMap);
123 
125  iEvent.getByToken(electronToken_, egCollection);
126  const reco::GsfElectronCollection egCandidates = (*egCollection.product());
127 
128  std::vector<double> energyValues;
129  std::vector<double> energyErrorValues;
130  energyValues.reserve(egCollection->size());
131  energyErrorValues.reserve(egCollection->size());
132  //
133  //**************************************************************************
134  // Rechits
135  //**************************************************************************
138  iEvent.getByToken(recHitCollectionEBToken_, pEBRecHits);
139  iEvent.getByToken(recHitCollectionEEToken_, pEERecHits);
140 
141  //**************************************************************************
142  //Get Number of Vertices
143  //**************************************************************************
145  iEvent.getByToken(hVertexToken_, hVertexProduct);
146  const reco::VertexCollection inVertices = *(hVertexProduct.product());
147 
148  // loop through all vertices
149  Int_t nvertices = 0;
150  for (reco::VertexCollection::const_iterator inV = inVertices.begin(); inV != inVertices.end(); ++inV) {
151  // pass these vertex cuts
152  if (inV->ndof() >= 4 && inV->position().Rho() <= 2.0 && fabs(inV->z()) <= 24.0) {
153  nvertices++;
154  }
155  }
156 
157  //**************************************************************************
158  //Get Rho
159  //**************************************************************************
160  double rho = 0;
161  edm::Handle<double> hRhoKt6PFJets;
162  iEvent.getByToken(hRhoKt6PFJetsToken_, hRhoKt6PFJets);
163  rho = (*hRhoKt6PFJets);
164 
165  for (reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin(); egIter != egCandidates.end();
166  ++egIter) {
167  const EcalRecHitCollection* recHits = nullptr;
168  if (egIter->isEB())
169  recHits = pEBRecHits.product();
170  else
171  recHits = pEERecHits.product();
172 
173  SuperClusterHelper mySCHelper(&(*egIter), recHits, ecalTopology_, caloGeometry_);
174 
175  double energy = regressionEvaluator->calculateRegressionEnergy(&(*egIter), mySCHelper, rho, nvertices, printDebug_);
176 
177  double error =
178  regressionEvaluator->calculateRegressionEnergyUncertainty(&(*egIter), mySCHelper, rho, nvertices, printDebug_);
179 
180  energyValues.push_back(energy);
181  energyErrorValues.push_back(error);
182  }
183 
184  energyFiller.insert(egCollection, energyValues.begin(), energyValues.end());
185  energyFiller.fill();
186 
187  energyErrorFiller.insert(egCollection, energyErrorValues.begin(), energyErrorValues.end());
188  energyErrorFiller.fill();
189 
190  iEvent.put(std::move(regrEnergyMap), nameEnergyReg_);
191  iEvent.put(std::move(regrEnergyErrorMap), nameEnergyErrorReg_);
192 
193  return true;
194 }
ElectronEnergyRegressionEvaluate * regressionEvaluator
T const * product() const
Definition: Handle.h:70
double calculateRegressionEnergy(const reco::GsfElectron *ele, SuperClusterHelper &mySCHelper, double rho, double nvertices, bool printDebug=false)
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
assert(be >=bs)
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
edm::ESGetToken< CaloTopology, CaloTopologyRecord > ecalTopoToken_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::VertexCollection > hVertexToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
double calculateRegressionEnergyUncertainty(const reco::GsfElectron *ele, SuperClusterHelper &mySCHelper, double rho, double nvertices, bool printDebug=false)
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ caloGeometry_

const CaloGeometry* ElectronRegressionEnergyProducer::caloGeometry_
private

Definition at line 51 of file ElectronRegressionEnergyProducer.cc.

Referenced by filter().

◆ caloGeomToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> ElectronRegressionEnergyProducer::caloGeomToken_
private

Definition at line 62 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ ecalTopology_

const CaloTopology* ElectronRegressionEnergyProducer::ecalTopology_
private

Definition at line 50 of file ElectronRegressionEnergyProducer.cc.

Referenced by filter().

◆ ecalTopoToken_

edm::ESGetToken<CaloTopology, CaloTopologyRecord> ElectronRegressionEnergyProducer::ecalTopoToken_
private

Definition at line 61 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ electronToken_

edm::EDGetTokenT<reco::GsfElectronCollection> ElectronRegressionEnergyProducer::electronToken_
private

Definition at line 40 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ energyRegressionType_

uint32_t ElectronRegressionEnergyProducer::energyRegressionType_
private

◆ geomInitialized_

bool ElectronRegressionEnergyProducer::geomInitialized_
private

Definition at line 48 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ hRhoKt6PFJetsToken_

edm::EDGetTokenT<double> ElectronRegressionEnergyProducer::hRhoKt6PFJetsToken_
private

Definition at line 59 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ hVertexToken_

edm::EDGetTokenT<reco::VertexCollection> ElectronRegressionEnergyProducer::hVertexToken_
private

Definition at line 58 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ nameEnergyErrorReg_

std::string ElectronRegressionEnergyProducer::nameEnergyErrorReg_
private

Definition at line 46 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ nameEnergyReg_

std::string ElectronRegressionEnergyProducer::nameEnergyReg_
private

Definition at line 45 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ printDebug_

bool ElectronRegressionEnergyProducer::printDebug_
private

Definition at line 39 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ recHitCollectionEBToken_

edm::EDGetTokenT<EcalRecHitCollection> ElectronRegressionEnergyProducer::recHitCollectionEBToken_
private

Definition at line 53 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ recHitCollectionEEToken_

edm::EDGetTokenT<EcalRecHitCollection> ElectronRegressionEnergyProducer::recHitCollectionEEToken_
private

Definition at line 54 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

◆ regressionEvaluator

ElectronEnergyRegressionEvaluate* ElectronRegressionEnergyProducer::regressionEvaluator
private

◆ regressionInputFile_

std::string ElectronRegressionEnergyProducer::regressionInputFile_
private