CMS 3D CMS Logo

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

Public Member Functions

 CalibratedPhotonProducerT (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
 ~CalibratedPhotonProducerT () 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

PhotonEnergyCalibrator energyCorrector_
 
edm::EDGetTokenT< edm::View< T > > photonToken_
 
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<>
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 CalibratedPhotonProducerT< T >

Definition at line 34 of file CalibratedPhotonProducers.cc.

Constructor & Destructor Documentation

◆ CalibratedPhotonProducerT()

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

Definition at line 79 of file CalibratedPhotonProducers.cc.

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

80  : photonToken_(consumes(conf.getParameter<edm::InputTag>("src"))),
81  energyCorrector_(conf.getParameter<std::string>("correctionFile")),
82  recHitCollectionEBToken_(consumes(conf.getParameter<edm::InputTag>("recHitCollectionEB"))),
83  recHitCollectionEEToken_(consumes(conf.getParameter<edm::InputTag>("recHitCollectionEE"))),
84  produceCalibratedObjs_(conf.getParameter<bool>("produceCalibratedObjs")) {
85  energyCorrector_.setMinEt(conf.getParameter<double>("minEtToCalibrate"));
86 
87  if (conf.getParameter<bool>("semiDeterministic")) {
88  semiDeterministicRng_ = std::make_unique<TRandom2>();
90  }
91 
93  produces<std::vector<T>>();
94 
95  for (const auto& toStore : valMapsToStore_) {
96  produces<edm::ValueMap<float>>(EGEnergySysIndex::name(toStore));
97  }
98 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< TRandom > semiDeterministicRng_
void initPrivateRng(TRandom *rnd)
static const std::string & name(size_t index)
PhotonEnergyCalibrator energyCorrector_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< edm::View< T > > photonToken_
static const std::vector< int > valMapsToStore_

◆ ~CalibratedPhotonProducerT()

template<typename T >
CalibratedPhotonProducerT< T >::~CalibratedPhotonProducerT ( )
inlineoverride

Definition at line 37 of file CalibratedPhotonProducers.cc.

37 {};

Member Function Documentation

◆ fillDescriptions()

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

Definition at line 101 of file CalibratedPhotonProducers.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, EGEnergySysIndex::name(), and AlCaHLTBitMon_QueryRunRegistry::string.

101  {
103  desc.add<edm::InputTag>("src", edm::InputTag("gedGsfElectrons"));
104  desc.add<edm::InputTag>("recHitCollectionEB", edm::InputTag("reducedEcalRecHitsEB"));
105  desc.add<edm::InputTag>("recHitCollectionEE", edm::InputTag("reducedEcalRecHitsEE"));
106  desc.add<std::string>("correctionFile", std::string());
107  desc.add<double>("minEtToCalibrate", 5.0);
108  desc.add<bool>("produceCalibratedObjs", true);
109  desc.add<bool>("semiDeterministic", true);
110  std::vector<std::string> valMapsProduced;
111  valMapsProduced.reserve(valMapsToStore_.size());
112  for (auto varToStore : valMapsToStore_)
113  valMapsProduced.push_back(EGEnergySysIndex::name(varToStore));
114  desc.add<std::vector<std::string>>("valueMapsStored", valMapsProduced)
115  ->setComment(
116  "provides to python configs the list of valuemaps stored, can not be overriden in the python config");
117  descriptions.addWithDefaultLabel(desc);
118 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static const std::string & name(size_t index)
static const std::vector< int > valMapsToStore_

◆ produce()

template<typename T >
void CalibratedPhotonProducerT< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 121 of file CalibratedPhotonProducers.cc.

References PhotonEnergyCalibrator::DATA, patZpeak::handle, iEvent, EGEnergySysIndex::kNrSysErrs, PhotonEnergyCalibrator::MC, eostools::move(), EGEnergySysIndex::name(), MillePedeFileConverter_cfg::out, FastTrackerRecHitMaskProducer_cfi::recHits, and mysort::results.

121  {
122  auto inHandle = iEvent.getHandle(photonToken_);
123 
124  auto recHitCollectionEBHandle = iEvent.getHandle(recHitCollectionEBToken_);
125  auto recHitCollectionEEHandle = iEvent.getHandle(recHitCollectionEEToken_);
126 
127  std::unique_ptr<std::vector<T>> out = std::make_unique<std::vector<T>>();
128 
129  size_t nrObj = inHandle->size();
130  std::array<std::vector<float>, EGEnergySysIndex::kNrSysErrs> results;
131  for (auto& res : results)
132  res.reserve(nrObj);
133 
134  const PhotonEnergyCalibrator::EventType evtType =
136 
137  for (const auto& pho : *inHandle) {
138  out->emplace_back(pho);
139 
141  setSemiDetRandomSeed(iEvent, pho, nrObj, out->size());
142 
144  (pho.isEB()) ? recHitCollectionEBHandle.product() : recHitCollectionEEHandle.product();
145  std::array<float, EGEnergySysIndex::kNrSysErrs> uncertainties =
146  energyCorrector_.calibrate(out->back(), iEvent.id().run(), recHits, iEvent.streamID(), evtType);
147 
148  for (size_t index = 0; index < EGEnergySysIndex::kNrSysErrs; index++) {
149  results[index].push_back(uncertainties[index]);
150  }
151  }
152 
153  auto fillAndStore = [&](auto handle) {
154  for (const auto& mapToStore : valMapsToStore_) {
155  fillAndStoreValueMap(iEvent, handle, results[mapToStore], EGEnergySysIndex::name(mapToStore));
156  }
157  };
158 
160  fillAndStore(iEvent.put(std::move(out)));
161  } else {
162  fillAndStore(inHandle);
163  }
164 }
std::unique_ptr< TRandom > semiDeterministicRng_
static const std::string & name(size_t index)
Definition: Electron.h:6
int iEvent
Definition: GenABIO.cc:224
PhotonEnergyCalibrator energyCorrector_
void setSemiDetRandomSeed(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
static constexpr size_t kNrSysErrs
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< edm::View< T > > photonToken_
std::array< float, EGEnergySysIndex::kNrSysErrs > calibrate(reco::Photon &photon, const unsigned int runNumber, const EcalRecHitCollection *recHits, edm::StreamID const &id, const EventType eventType) const
results
Definition: mysort.py:8
static const std::vector< int > valMapsToStore_
def move(src, dest)
Definition: eostools.py:511

◆ setSemiDetRandomSeed()

template<typename T >
void CalibratedPhotonProducerT< T >::setSemiDetRandomSeed ( const edm::Event iEvent,
const T obj,
size_t  nrObjs,
size_t  objNr 
)
private

Definition at line 168 of file CalibratedPhotonProducers.cc.

References egamma::getRandomSeedFromObj(), egamma::getRandomSeedFromSC(), iEvent, and getGTfromDQMFile::obj.

171  {
172  if (obj.superCluster().isNonnull()) {
173  semiDeterministicRng_->SetSeed(egamma::getRandomSeedFromSC(iEvent, obj.superCluster()));
174  } else {
176  }
177 }
std::unique_ptr< TRandom > semiDeterministicRng_
int iEvent
Definition: GenABIO.cc:224
uint32_t getRandomSeedFromObj(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
uint32_t getRandomSeedFromSC(const edm::Event &iEvent, const reco::SuperClusterRef scRef)

Member Data Documentation

◆ energyCorrector_

template<typename T >
PhotonEnergyCalibrator CalibratedPhotonProducerT< T >::energyCorrector_
private

◆ photonToken_

template<typename T >
edm::EDGetTokenT<edm::View<T> > CalibratedPhotonProducerT< T >::photonToken_
private

Definition at line 44 of file CalibratedPhotonProducers.cc.

◆ produceCalibratedObjs_

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

◆ recHitCollectionEBToken_

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

Definition at line 47 of file CalibratedPhotonProducers.cc.

◆ recHitCollectionEEToken_

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

Definition at line 48 of file CalibratedPhotonProducers.cc.

◆ semiDeterministicRng_

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

◆ valMapsToStore_

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