CMS 3D CMS Logo

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

Public Member Functions

 ElectronRegressionEnergyProducer (const edm::ParameterSet &)
 
 ~ElectronRegressionEnergyProducer () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () 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
 
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)
 
 ~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
 
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::vector< ModuleDescription const * > &modules, 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
 
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_
 
const CaloTopologyecalTopology_
 
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::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 30 of file ElectronRegressionEnergyProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 62 of file ElectronRegressionEnergyProducer.cc.

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

62  {
63  printDebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
64  electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
65 
66  regressionInputFile_ = iConfig.getParameter<std::string>("regressionInputFile");
67  energyRegressionType_ = iConfig.getParameter<uint32_t>("energyRegressionType");
68 
69  nameEnergyReg_ = iConfig.getParameter<std::string>("nameEnergyReg");
70  nameEnergyErrorReg_ = iConfig.getParameter<std::string>("nameEnergyErrorReg");
71 
72  recHitCollectionEBToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitCollectionEB"));
73  recHitCollectionEEToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitCollectionEE"));
74 
75  hVertexToken_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
76  hRhoKt6PFJetsToken_ = consumes<double>(edm::InputTag("kt6PFJets", "rho"));
77 
78  produces<edm::ValueMap<double> >(nameEnergyReg_);
79  produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
80 
82 
83  //set regression type
85  if (energyRegressionType_ == 1)
87  else if (energyRegressionType_ == 2)
89  else if (energyRegressionType_ == 3)
91  else if (energyRegressionType_ == 4)
93 
94  //load weights and initialize
96 
97  geomInitialized_ = false;
98 }
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ElectronEnergyRegressionEvaluate * regressionEvaluator
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
edm::EDGetTokenT< reco::VertexCollection > hVertexToken_
void initialize(std::string weightsFile, ElectronEnergyRegressionEvaluate::ElectronEnergyRegressionType type)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
ElectronRegressionEnergyProducer::~ElectronRegressionEnergyProducer ( )
override

Definition at line 100 of file ElectronRegressionEnergyProducer.cc.

References regressionEvaluator.

100 { delete regressionEvaluator; }
ElectronEnergyRegressionEvaluate * regressionEvaluator

Member Function Documentation

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

Definition at line 103 of file ElectronRegressionEnergyProducer.cc.

References ElectronEnergyRegressionEvaluate::calculateRegressionEnergy(), ElectronEnergyRegressionEvaluate::calculateRegressionEnergyUncertainty(), caloGeometry_, DEFINE_FWK_MODULE, ecalTopology_, electronToken_, HCALHighEnergyHPDFilter_cfi::energy, relativeConstraints::error, edm::helper::Filler< Map >::fill(), geomInitialized_, edm::EventSetup::get(), edm::Event::getByToken(), hRhoKt6PFJetsToken_, hVertexToken_, edm::helper::Filler< Map >::insert(), ElectronEnergyRegressionEvaluate::isInitialized(), eostools::move(), nameEnergyErrorReg_, nameEnergyReg_, printDebug_, edm::Handle< T >::product(), edm::Event::put(), recHitCollectionEBToken_, recHitCollectionEEToken_, FastTrackerRecHitMaskProducer_cfi::recHits, regressionEvaluator, and rho.

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

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

Member Data Documentation

const CaloGeometry* ElectronRegressionEnergyProducer::caloGeometry_
private

Definition at line 51 of file ElectronRegressionEnergyProducer.cc.

Referenced by filter().

const CaloTopology* ElectronRegressionEnergyProducer::ecalTopology_
private

Definition at line 50 of file ElectronRegressionEnergyProducer.cc.

Referenced by filter().

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

Definition at line 40 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

uint32_t ElectronRegressionEnergyProducer::energyRegressionType_
private
bool ElectronRegressionEnergyProducer::geomInitialized_
private

Definition at line 48 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 59 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 58 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

std::string ElectronRegressionEnergyProducer::nameEnergyErrorReg_
private

Definition at line 46 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

std::string ElectronRegressionEnergyProducer::nameEnergyReg_
private

Definition at line 45 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

bool ElectronRegressionEnergyProducer::printDebug_
private

Definition at line 39 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 53 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 54 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

ElectronEnergyRegressionEvaluate* ElectronRegressionEnergyProducer::regressionEvaluator
private
std::string ElectronRegressionEnergyProducer::regressionInputFile_
private