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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (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<>
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
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase 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
 
- 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 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

template<typename T>
class CalibratedPhotonProducerT< T >

Definition at line 34 of file CalibratedPhotonProducers.cc.

Constructor & Destructor Documentation

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

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

94  :
96  energyCorrector_(conf.getParameter<std::string >("correctionFile")),
97  recHitCollectionEBToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("recHitCollectionEB"))),
98  recHitCollectionEEToken_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("recHitCollectionEE"))),
99  produceCalibratedObjs_(conf.getParameter<bool>("produceCalibratedObjs"))
100 {
101 
102  energyCorrector_.setMinEt(conf.getParameter<double>("minEtToCalibrate"));
103 
104  if (conf.getParameter<bool>("semiDeterministic")) {
105  semiDeterministicRng_.reset(new TRandom2());
107  }
108 
109  if(produceCalibratedObjs_) produces<std::vector<T>>();
110 
111  for(const auto& toStore : valMapsToStore_){
112  produces<edm::ValueMap<float>>(EGEnergySysIndex::name(toStore));
113  }
114 }
T getParameter(std::string const &) const
std::unique_ptr< TRandom > semiDeterministicRng_
void initPrivateRng(TRandom *rnd)
static const std::string & name(size_t index)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
PhotonEnergyCalibrator energyCorrector_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEEToken_
edm::EDGetTokenT< EcalRecHitCollection > recHitCollectionEBToken_
edm::EDGetTokenT< edm::View< T > > photonToken_
static const std::vector< int > valMapsToStore_
template<typename T >
CalibratedPhotonProducerT< T >::~CalibratedPhotonProducerT ( )
inlineoverride

Member Function Documentation

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

Definition at line 117 of file CalibratedPhotonProducers.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), defaultModuleLabel(), EGEnergySysIndex::name(), AlCaHLTBitMon_QueryRunRegistry::string, and CalibratedPhotonProducerT< T >::valMapsToStore_.

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

118 {
120  desc.add<edm::InputTag>("src",edm::InputTag("gedGsfElectrons"));
121  desc.add<edm::InputTag>("recHitCollectionEB",edm::InputTag("reducedEcalRecHitsEB"));
122  desc.add<edm::InputTag>("recHitCollectionEE",edm::InputTag("reducedEcalRecHitsEE"));
123  desc.add<std::string>("correctionFile",std::string());
124  desc.add<double>("minEtToCalibrate",5.0);
125  desc.add<bool>("produceCalibratedObjs",true);
126  desc.add<bool>("semiDeterministic",true);
127  std::vector<std::string> valMapsProduced;
128  for(auto varToStore : valMapsToStore_) valMapsProduced.push_back(EGEnergySysIndex::name(varToStore));
129  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");
131 }
std::string defaultModuleLabel()
static const std::string & name(size_t index)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static const std::vector< int > valMapsToStore_
template<typename T >
void CalibratedPhotonProducerT< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 135 of file CalibratedPhotonProducers.cc.

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

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

135  {
136 
137  edm::Handle<edm::View<T>> inHandle;
138  iEvent.getByToken(photonToken_, inHandle);
139 
140  edm::Handle<EcalRecHitCollection> recHitCollectionEBHandle;
141  edm::Handle<EcalRecHitCollection> recHitCollectionEEHandle;
142 
143  iEvent.getByToken(recHitCollectionEBToken_, recHitCollectionEBHandle);
144  iEvent.getByToken(recHitCollectionEEToken_, recHitCollectionEEHandle);
145 
146  std::unique_ptr<std::vector<T>> out = std::make_unique<std::vector<T>>();
147 
148  size_t nrObj = inHandle->size();
149  std::array<std::vector<float>,EGEnergySysIndex::kNrSysErrs> results;
150  for(auto& res : results) res.reserve(nrObj);
151 
152  const PhotonEnergyCalibrator::EventType evtType = iEvent.isRealData() ?
154 
155  for (const auto& pho : *inHandle) {
156  out->emplace_back(pho);
157 
158  if(semiDeterministicRng_) setSemiDetRandomSeed(iEvent,pho,nrObj,out->size());
159 
160  const EcalRecHitCollection* recHits = (pho.isEB()) ? recHitCollectionEBHandle.product() : recHitCollectionEEHandle.product();
161  std::array<float,EGEnergySysIndex::kNrSysErrs> uncertainties = energyCorrector_.calibrate(out->back(), iEvent.id().run(), recHits, iEvent.streamID(), evtType);
162 
164  results[index].push_back(uncertainties[index]);
165  }
166  }
167 
168  auto fillAndStore = [&](auto handle){
169  for(const auto& mapToStore : valMapsToStore_){
170  fillAndStoreValueMap(iEvent,handle,results[mapToStore],EGEnergySysIndex::name(mapToStore));
171  }
172  };
173 
175  fillAndStore(iEvent.put(std::move(out)));
176  }else{
177  fillAndStore(inHandle);
178  }
179 
180 }
RunNumber_t run() const
Definition: EventID.h:39
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
size_t size() const
Definition: Event.cc:249
std::unique_ptr< TRandom > semiDeterministicRng_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
static const std::string & name(size_t index)
bool isRealData() const
Definition: EventBase.h:64
Definition: Electron.h:4
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_
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< edm::View< T > > photonToken_
edm::EventID id() const
Definition: EventBase.h:60
StreamID streamID() const
Definition: Event.h:86
static const std::vector< int > valMapsToStore_
def move(src, dest)
Definition: eostools.py:510
std::array< float, EGEnergySysIndex::kNrSysErrs > calibrate(reco::Photon &photon, const unsigned int runNumber, const EcalRecHitCollection *recHits, edm::StreamID const &id, const EventType eventType) const
template<typename T >
void CalibratedPhotonProducerT< T >::setSemiDetRandomSeed ( const edm::Event iEvent,
const T obj,
size_t  nrObjs,
size_t  objNr 
)
private

Definition at line 184 of file CalibratedPhotonProducers.cc.

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

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

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

template<typename T >
PhotonEnergyCalibrator CalibratedPhotonProducerT< T >::energyCorrector_
private
template<typename T >
edm::EDGetTokenT<edm::View<T> > CalibratedPhotonProducerT< T >::photonToken_
private
template<typename T >
bool CalibratedPhotonProducerT< T >::produceCalibratedObjs_
private
template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> CalibratedPhotonProducerT< T >::recHitCollectionEBToken_
private
template<typename T >
edm::EDGetTokenT<EcalRecHitCollection> CalibratedPhotonProducerT< T >::recHitCollectionEEToken_
private
template<typename T >
std::unique_ptr<TRandom> CalibratedPhotonProducerT< T >::semiDeterministicRng_
private
template<typename T >
const std::vector< int > CalibratedPhotonProducerT< T >::valMapsToStore_
staticprivate