CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
CalibratedElectronProducerT< T > Class Template Reference
Inheritance diagram for CalibratedElectronProducerT< T >:
edm::stream::EDProducer<>

Public Member Functions

 CalibratedElectronProducerT (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~CalibratedElectronProducerT () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void setSemiDetRandomSeed (const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
 

Private Attributes

edm::EDGetTokenT< edm::View< T > > electronToken_
 
ElectronEnergyCalibrator energyCorrector_
 
EpCombinationTool epCombinationTool_
 
bool produceCalibratedObjs_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitCollectionEBToken_
 
edm::EDGetTokenT< EcalRecHitCollectionrecHitCollectionEEToken_
 
std::unique_ptr< TRandom > semiDeterministicRng_
 

Static Private Attributes

static const std::vector< int > valMapsToStore_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

template<typename T>
class CalibratedElectronProducerT< T >

Definition at line 38 of file CalibratedElectronProducers.cc.

Constructor & Destructor Documentation

template<typename T >
CalibratedElectronProducerT< T >::CalibratedElectronProducerT ( const edm::ParameterSet conf)
explicit

Definition at line 104 of file CalibratedElectronProducers.cc.

References CalibratedElectronProducerT< T >::energyCorrector_, edm::ParameterSet::getParameter(), ElectronEnergyCalibrator::initPrivateRng(), EGEnergySysIndex::name(), CalibratedElectronProducerT< T >::produceCalibratedObjs_, CalibratedElectronProducerT< T >::semiDeterministicRng_, ElectronEnergyCalibrator::setMinEt(), and CalibratedElectronProducerT< T >::valMapsToStore_.

104  :
105  electronToken_(consumes<edm::View<T>>(conf.getParameter<edm::InputTag>("src"))),
106  epCombinationTool_(conf.getParameter<edm::ParameterSet>("epCombConfig")),
108  recHitCollectionEBToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("recHitCollectionEB"))),
109  recHitCollectionEEToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("recHitCollectionEE"))),
110  produceCalibratedObjs_(conf.getParameter<bool>("produceCalibratedObjs"))
111 {
112  energyCorrector_.setMinEt(conf.getParameter<double>("minEtToCalibrate"));
113 
114  if (conf.getParameter<bool>("semiDeterministic")) {
115  semiDeterministicRng_.reset(new TRandom2());
117  }
118 
119  if(produceCalibratedObjs_) produces<std::vector<T>>();
120 
121  for(const auto& toStore : valMapsToStore_){
122  produces<edm::ValueMap<float>>(EGEnergySysIndex::name(toStore));
123  }
124 }
T getParameter(std::string const &) const
static const std::string & name(size_t index)
ElectronEnergyCalibrator energyCorrector_
edm::EDGetTokenT< edm::View< T > > electronToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
std::unique_ptr< TRandom > semiDeterministicRng_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
static const std::vector< int > valMapsToStore_
template<typename T >
CalibratedElectronProducerT< T >::~CalibratedElectronProducerT ( )
inlineoverride

Member Function Documentation

template<typename T >
void CalibratedElectronProducerT< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 127 of file CalibratedElectronProducers.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), EpCombinationTool::makePSetDescription(), EGEnergySysIndex::name(), AlCaHLTBitMon_QueryRunRegistry::string, and CalibratedElectronProducerT< T >::valMapsToStore_.

Referenced by CalibratedElectronProducerT< T >::~CalibratedElectronProducerT().

128 {
130  desc.add<edm::InputTag>("src",edm::InputTag("gedPhotons"));
132  desc.add<edm::InputTag>("recHitCollectionEB",edm::InputTag("reducedEcalRecHitsEB"));
133  desc.add<edm::InputTag>("recHitCollectionEE",edm::InputTag("reducedEcalRecHitsEE"));
134  desc.add<std::string>("correctionFile",std::string());
135  desc.add<double>("minEtToCalibrate",5.0);
136  desc.add<bool>("produceCalibratedObjs",true);
137  desc.add<bool>("semiDeterministic",true);
138  std::vector<std::string> valMapsProduced;
139  for(auto varToStore : valMapsToStore_) valMapsProduced.push_back(EGEnergySysIndex::name(varToStore));
140  desc.add<std::vector<std::string> >("valueMapsStored",valMapsProduced)->setComment("provides to python configs the list of valuemaps stored, can not be overriden in the python config");
141  descriptions.addWithDefaultLabel(desc);
142 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static edm::ParameterSetDescription makePSetDescription()
static const std::string & name(size_t index)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static const std::vector< int > valMapsToStore_
template<typename T >
void CalibratedElectronProducerT< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 146 of file CalibratedElectronProducers.cc.

References ElectronEnergyCalibrator::calibrate(), ElectronEnergyCalibrator::DATA, CalibratedElectronProducerT< T >::electronToken_, CalibratedElectronProducerT< T >::energyCorrector_, CalibratedElectronProducerT< T >::epCombinationTool_, edm::Event::getByToken(), cmsBatch::handle, edm::EventBase::id(), edm::EventBase::isRealData(), EGEnergySysIndex::kNrSysErrs, ElectronEnergyCalibrator::MC, eostools::move(), EGEnergySysIndex::name(), MillePedeFileConverter_cfg::out, CalibratedElectronProducerT< T >::produceCalibratedObjs_, edm::Handle< T >::product(), edm::Event::put(), CalibratedElectronProducerT< T >::recHitCollectionEBToken_, CalibratedElectronProducerT< T >::recHitCollectionEEToken_, mps_update::results, edm::EventID::run(), CalibratedElectronProducerT< T >::semiDeterministicRng_, EpCombinationTool::setEventContent(), CalibratedElectronProducerT< T >::setSemiDetRandomSeed(), edm::Event::size(), edm::Event::streamID(), and CalibratedElectronProducerT< T >::valMapsToStore_.

Referenced by CalibratedElectronProducerT< T >::~CalibratedElectronProducerT().

147 {
148 
150 
151  edm::Handle<edm::View<T>> inHandle;
152  iEvent.getByToken(electronToken_, inHandle);
153 
154  edm::Handle<EcalRecHitCollection> recHitCollectionEBHandle;
155  edm::Handle<EcalRecHitCollection> recHitCollectionEEHandle;
156 
157  iEvent.getByToken(recHitCollectionEBToken_, recHitCollectionEBHandle);
158  iEvent.getByToken(recHitCollectionEEToken_, recHitCollectionEEHandle);
159 
160  std::unique_ptr<std::vector<T>> out = std::make_unique<std::vector<T>>();
161 
162  size_t nrObj = inHandle->size();
163  std::array<std::vector<float>,EGEnergySysIndex::kNrSysErrs> results;
164  for(auto& res : results) res.reserve(nrObj);
165 
166  const ElectronEnergyCalibrator::EventType evtType = iEvent.isRealData() ?
168 
169 
170  for (const auto& ele : *inHandle) {
171  out->push_back(ele);
172 
173  if(semiDeterministicRng_) setSemiDetRandomSeed(iEvent,ele,nrObj,out->size());
174 
175  const EcalRecHitCollection* recHits = (ele.isEB()) ? recHitCollectionEBHandle.product() : recHitCollectionEEHandle.product();
176  std::array<float,EGEnergySysIndex::kNrSysErrs> uncertainties = energyCorrector_.calibrate(out->back(), iEvent.id().run(), recHits, iEvent.streamID(), evtType);
177 
179  results[index].push_back(uncertainties[index]);
180  }
181  }
182 
183  auto fillAndStore = [&](auto handle){
184  for(const auto& mapToStore : valMapsToStore_){
185  fillAndStoreValueMap(iEvent,handle,results[mapToStore],EGEnergySysIndex::name(mapToStore));
186  }
187  };
188 
190  fillAndStore(iEvent.put(std::move(out)));
191  }else{
192  fillAndStore(inHandle);
193  }
194 
195 }
RunNumber_t run() const
Definition: EventID.h:39
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
size_t size() const
Definition: Event.cc:233
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
static const std::string & name(size_t index)
ElectronEnergyCalibrator energyCorrector_
void calibrate(SimpleElectron &electron, edm::StreamID const &)
bool isRealData() const
Definition: EventBase.h:62
Definition: Electron.h:6
edm::EDGetTokenT< edm::View< T > > electronToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
static constexpr size_t kNrSysErrs
void setSemiDetRandomSeed(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
void setEventContent(const edm::EventSetup &iSetup)
T const * product() const
Definition: Handle.h:74
std::unique_ptr< TRandom > semiDeterministicRng_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
edm::EventID id() const
Definition: EventBase.h:59
static const std::vector< int > valMapsToStore_
StreamID streamID() const
Definition: Event.h:95
def move(src, dest)
Definition: eostools.py:511
template<typename T >
void CalibratedElectronProducerT< T >::setSemiDetRandomSeed ( const edm::Event iEvent,
const T obj,
size_t  nrObjs,
size_t  objNr 
)
private

Definition at line 198 of file CalibratedElectronProducers.cc.

References egamma::getRandomSeedFromObj(), egamma::getRandomSeedFromSC(), and CalibratedElectronProducerT< T >::semiDeterministicRng_.

Referenced by CalibratedElectronProducerT< T >::produce(), and CalibratedElectronProducerT< T >::~CalibratedElectronProducerT().

199 {
200  if(obj.superCluster().isNonnull()){
201  semiDeterministicRng_->SetSeed(egamma::getRandomSeedFromSC(iEvent,obj.superCluster()));
202  }else{
203  semiDeterministicRng_->SetSeed(egamma::getRandomSeedFromObj(iEvent,obj,nrObjs,objNr));
204  }
205 }
uint32_t getRandomSeedFromObj(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
std::unique_ptr< TRandom > semiDeterministicRng_
uint32_t getRandomSeedFromSC(const edm::Event &iEvent, const reco::SuperClusterRef scRef)

Member Data Documentation

template<typename T >
edm::EDGetTokenT<edm::View<T> > CalibratedElectronProducerT< T >::electronToken_
private
template<typename T >
ElectronEnergyCalibrator CalibratedElectronProducerT< T >::energyCorrector_
private
template<typename T >
EpCombinationTool CalibratedElectronProducerT< T >::epCombinationTool_
private
template<typename T >
bool CalibratedElectronProducerT< T >::produceCalibratedObjs_
private
template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> CalibratedElectronProducerT< T >::recHitCollectionEBToken_
private
template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> CalibratedElectronProducerT< T >::recHitCollectionEEToken_
private
template<typename T >
std::unique_ptr<TRandom> CalibratedElectronProducerT< T >::semiDeterministicRng_
private
template<typename T >
const std::vector< int > CalibratedElectronProducerT< T >::valMapsToStore_
staticprivate