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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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 37 of file CalibratedElectronProducers.cc.

Constructor & Destructor Documentation

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

Definition at line 85 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_.

86  : electronToken_(consumes<edm::View<T>>(conf.getParameter<edm::InputTag>("src"))),
87  epCombinationTool_(conf.getParameter<edm::ParameterSet>("epCombConfig")),
89  recHitCollectionEBToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("recHitCollectionEB"))),
90  recHitCollectionEEToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("recHitCollectionEE"))),
91  produceCalibratedObjs_(conf.getParameter<bool>("produceCalibratedObjs")) {
92  energyCorrector_.setMinEt(conf.getParameter<double>("minEtToCalibrate"));
93 
94  if (conf.getParameter<bool>("semiDeterministic")) {
95  semiDeterministicRng_.reset(new TRandom2());
97  }
98 
100  produces<std::vector<T>>();
101 
102  for (const auto& toStore : valMapsToStore_) {
103  produces<edm::ValueMap<float>>(EGEnergySysIndex::name(toStore));
104  }
105 }
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 108 of file CalibratedElectronProducers.cc.

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

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

108  {
110  desc.add<edm::InputTag>("src", edm::InputTag("gedPhotons"));
112  desc.add<edm::InputTag>("recHitCollectionEB", edm::InputTag("reducedEcalRecHitsEB"));
113  desc.add<edm::InputTag>("recHitCollectionEE", edm::InputTag("reducedEcalRecHitsEE"));
114  desc.add<std::string>("correctionFile", std::string());
115  desc.add<double>("minEtToCalibrate", 5.0);
116  desc.add<bool>("produceCalibratedObjs", true);
117  desc.add<bool>("semiDeterministic", true);
118  std::vector<std::string> valMapsProduced;
119  for (auto varToStore : valMapsToStore_)
120  valMapsProduced.push_back(EGEnergySysIndex::name(varToStore));
121  desc.add<std::vector<std::string>>("valueMapsStored", valMapsProduced)
122  ->setComment(
123  "provides to python configs the list of valuemaps stored, can not be overriden in the python config");
124  descriptions.addWithDefaultLabel(desc);
125 }
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 128 of file CalibratedElectronProducers.cc.

References ElectronEnergyCalibrator::calibrate(), ElectronEnergyCalibrator::DATA, CalibratedElectronProducerT< T >::electronToken_, CalibratedElectronProducerT< T >::energyCorrector_, CalibratedElectronProducerT< T >::epCombinationTool_, edm::Event::getByToken(), patZpeak::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_, FastTrackerRecHitMaskProducer_cfi::recHits, bookConverter::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().

128  {
130 
131  edm::Handle<edm::View<T>> inHandle;
132  iEvent.getByToken(electronToken_, inHandle);
133 
134  edm::Handle<EcalRecHitCollection> recHitCollectionEBHandle;
135  edm::Handle<EcalRecHitCollection> recHitCollectionEEHandle;
136 
137  iEvent.getByToken(recHitCollectionEBToken_, recHitCollectionEBHandle);
138  iEvent.getByToken(recHitCollectionEEToken_, recHitCollectionEEHandle);
139 
140  std::unique_ptr<std::vector<T>> out = std::make_unique<std::vector<T>>();
141 
142  size_t nrObj = inHandle->size();
143  std::array<std::vector<float>, EGEnergySysIndex::kNrSysErrs> results;
144  for (auto& res : results)
145  res.reserve(nrObj);
146 
149 
150  for (const auto& ele : *inHandle) {
151  out->push_back(ele);
152 
154  setSemiDetRandomSeed(iEvent, ele, nrObj, out->size());
155 
157  (ele.isEB()) ? recHitCollectionEBHandle.product() : recHitCollectionEEHandle.product();
158  std::array<float, EGEnergySysIndex::kNrSysErrs> uncertainties =
159  energyCorrector_.calibrate(out->back(), iEvent.id().run(), recHits, iEvent.streamID(), evtType);
160 
161  for (size_t index = 0; index < EGEnergySysIndex::kNrSysErrs; index++) {
162  results[index].push_back(uncertainties[index]);
163  }
164  }
165 
166  auto fillAndStore = [&](auto handle) {
167  for (const auto& mapToStore : valMapsToStore_) {
168  fillAndStoreValueMap(iEvent, handle, results[mapToStore], EGEnergySysIndex::name(mapToStore));
169  }
170  };
171 
173  fillAndStore(iEvent.put(std::move(out)));
174  } else {
175  fillAndStore(inHandle);
176  }
177 }
RunNumber_t run() const
Definition: EventID.h:38
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
size_t size() const
Definition: Event.cc:242
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:69
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:96
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 180 of file CalibratedElectronProducers.cc.

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

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

183  {
184  if (obj.superCluster().isNonnull()) {
185  semiDeterministicRng_->SetSeed(egamma::getRandomSeedFromSC(iEvent, obj.superCluster()));
186  } else {
187  semiDeterministicRng_->SetSeed(egamma::getRandomSeedFromObj(iEvent, obj, nrObjs, objNr));
188  }
189 }
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