CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=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 EDProduceroperator= (const EDProducer &)=delete
 

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
< EcalRecHitCollection
recHitCollectionEBToken_
 
edm::EDGetTokenT
< EcalRecHitCollection
recHitCollectionEEToken_
 
std::unique_ptr< TRandom > semiDeterministicRng_
 

Static Private Attributes

static const std::vector< int > valMapsToStore_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
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
 

Detailed Description

template<typename T>
class CalibratedElectronProducerT< T >

Definition at line 40 of file CalibratedElectronProducers.cc.

Constructor & Destructor Documentation

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

Definition at line 88 of file CalibratedElectronProducers.cc.

References edm::ParameterSet::getParameterSet().

89  : electronToken_(consumes(conf.getParameter<edm::InputTag>("src"))),
90  epCombinationTool_{conf.getParameterSet("epCombConfig"), consumesCollector()},
92  recHitCollectionEBToken_(consumes(conf.getParameter<edm::InputTag>("recHitCollectionEB"))),
93  recHitCollectionEEToken_(consumes(conf.getParameter<edm::InputTag>("recHitCollectionEE"))),
94  produceCalibratedObjs_(conf.getParameter<bool>("produceCalibratedObjs")) {
95  energyCorrector_.setMinEt(conf.getParameter<double>("minEtToCalibrate"));
96 
97  if (conf.getParameter<bool>("semiDeterministic")) {
98  semiDeterministicRng_ = std::make_unique<TRandom2>();
100  }
101 
103  produces<std::vector<T>>();
104 
105  for (const auto& toStore : valMapsToStore_) {
106  produces<edm::ValueMap<float>>(EGEnergySysIndex::name(toStore));
107  }
108 }
static const std::string & name(size_t index)
ElectronEnergyCalibrator energyCorrector_
edm::EDGetTokenT< edm::View< T > > electronToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
ParameterSet const & getParameterSet(std::string const &) const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< TRandom > semiDeterministicRng_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
static const std::vector< int > valMapsToStore_
template<typename T >
CalibratedElectronProducerT< T >::~CalibratedElectronProducerT ( )
inlineoverride

Definition at line 43 of file CalibratedElectronProducers.cc.

43 {}

Member Function Documentation

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

Definition at line 111 of file CalibratedElectronProducers.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, EpCombinationTool::makePSetDescription(), EGEnergySysIndex::name(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

References ElectronEnergyCalibrator::DATA, edm::Event::getHandle(), patZpeak::handle, edm::EventBase::id(), edm::EventBase::isRealData(), EGEnergySysIndex::kNrSysErrs, ElectronEnergyCalibrator::MC, eostools::move(), EGEnergySysIndex::name(), submitPVResolutionJobs::out, edm::Event::put(), HLT_FULL_cff::recHits, bookConverter::results, edm::EventID::run(), edm::Event::size(), and edm::Event::streamID().

132  {
134 
135  auto inHandle = iEvent.getHandle(electronToken_);
136 
137  auto recHitCollectionEBHandle = iEvent.getHandle(recHitCollectionEBToken_);
138  auto recHitCollectionEEHandle = iEvent.getHandle(recHitCollectionEEToken_);
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:133
size_t size() const
Definition: Event.cc:252
static const std::string & name(size_t index)
ElectronEnergyCalibrator energyCorrector_
dictionary results
void calibrate(SimpleElectron &electron, edm::StreamID const &)
bool isRealData() const
Definition: EventBase.h:62
edm::EDGetTokenT< edm::View< T > > electronToken_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
static constexpr size_t kNrSysErrs
def move
Definition: eostools.py:511
tuple handle
Definition: patZpeak.py:23
void setSemiDetRandomSeed(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
void setEventContent(const edm::EventSetup &iSetup)
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:98
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(), and egamma::getRandomSeedFromSC().

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

Definition at line 50 of file CalibratedElectronProducers.cc.

template<typename T >
ElectronEnergyCalibrator CalibratedElectronProducerT< T >::energyCorrector_
private

Definition at line 53 of file CalibratedElectronProducers.cc.

template<typename T >
EpCombinationTool CalibratedElectronProducerT< T >::epCombinationTool_
private

Definition at line 52 of file CalibratedElectronProducers.cc.

template<typename T >
bool CalibratedElectronProducerT< T >::produceCalibratedObjs_
private

Definition at line 57 of file CalibratedElectronProducers.cc.

template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> CalibratedElectronProducerT< T >::recHitCollectionEBToken_
private

Definition at line 55 of file CalibratedElectronProducers.cc.

template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> CalibratedElectronProducerT< T >::recHitCollectionEEToken_
private

Definition at line 56 of file CalibratedElectronProducers.cc.

template<typename T >
std::unique_ptr<TRandom> CalibratedElectronProducerT< T >::semiDeterministicRng_
private

Definition at line 54 of file CalibratedElectronProducers.cc.

template<typename T >
const std::vector< int > CalibratedElectronProducerT< T >::valMapsToStore_
staticprivate