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
 
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)
 
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::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 ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, 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 63 of file ElectronRegressionEnergyProducer.cc.

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

63  {
64  printDebug_ = iConfig.getUntrackedParameter<bool>("printDebug", false);
65  electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter<edm::InputTag>("electronTag"));
66 
67  regressionInputFile_ = iConfig.getParameter<std::string>("regressionInputFile");
68  energyRegressionType_ = iConfig.getParameter<uint32_t>("energyRegressionType");
69 
70  nameEnergyReg_ = iConfig.getParameter<std::string>("nameEnergyReg");
71  nameEnergyErrorReg_ = iConfig.getParameter<std::string>("nameEnergyErrorReg");
72 
73  recHitCollectionEBToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitCollectionEB"));
74  recHitCollectionEEToken_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitCollectionEE"));
75 
76  hVertexToken_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
77  hRhoKt6PFJetsToken_ = consumes<double>(edm::InputTag("kt6PFJets","rho"));
78 
79  produces<edm::ValueMap<double> >(nameEnergyReg_);
80  produces<edm::ValueMap<double> >(nameEnergyErrorReg_);
81 
83 
84  //set regression type
90 
91  //load weights and initialize
93 
94  geomInitialized_ = false;
95 
96 }
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 99 of file ElectronRegressionEnergyProducer.cc.

References regressionEvaluator.

100 {
101  delete regressionEvaluator;
102 }
ElectronEnergyRegressionEvaluate * regressionEvaluator

Member Function Documentation

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

Definition at line 105 of file ElectronRegressionEnergyProducer.cc.

References ElectronEnergyRegressionEvaluate::calculateRegressionEnergy(), ElectronEnergyRegressionEvaluate::calculateRegressionEnergyUncertainty(), caloGeometry_, DEFINE_FWK_MODULE, ecalTopology_, electronToken_, 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_, 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().

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

Member Data Documentation

const CaloGeometry* ElectronRegressionEnergyProducer::caloGeometry_
private

Definition at line 50 of file ElectronRegressionEnergyProducer.cc.

Referenced by filter().

const CaloTopology* ElectronRegressionEnergyProducer::ecalTopology_
private

Definition at line 49 of file ElectronRegressionEnergyProducer.cc.

Referenced by filter().

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

Definition at line 39 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 47 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 58 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 57 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

std::string ElectronRegressionEnergyProducer::nameEnergyErrorReg_
private

Definition at line 45 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

std::string ElectronRegressionEnergyProducer::nameEnergyReg_
private

Definition at line 44 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

bool ElectronRegressionEnergyProducer::printDebug_
private

Definition at line 38 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 52 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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

Definition at line 53 of file ElectronRegressionEnergyProducer.cc.

Referenced by ElectronRegressionEnergyProducer(), and filter().

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