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 | Private Attributes
CalibratedElectronProducerRun2T< T > Class Template Reference
Inheritance diagram for CalibratedElectronProducerRun2T< T >:
edm::stream::EDProducer<>

Public Member Functions

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

Private Attributes

edm::ESGetToken< GBRForest,
GBRWrapperRcd
gbrforestToken_
 
edm::EDGetTokenT< edm::View< T > > theElectronToken
 
ElectronEnergyCalibratorRun2 theEnCorrectorRun2
 
EpCombinationTool theEpCombinationTool
 
std::string theGBRForestName
 
std::unique_ptr< TRandom > theSemiDeterministicRng
 

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 CalibratedElectronProducerRun2T< T >

Definition at line 26 of file CalibratedElectronProducersRun2.cc.

Constructor & Destructor Documentation

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

Definition at line 44 of file CalibratedElectronProducersRun2.cc.

References DeDxTools::esConsumes(), edm::ParameterSet::existsAs(), CalibratedElectronProducerRun2T< T >::gbrforestToken_, edm::ParameterSet::getParameter(), ElectronEnergyCalibratorRun2::initPrivateRng(), CalibratedElectronProducerRun2T< T >::theEnCorrectorRun2, CalibratedElectronProducerRun2T< T >::theGBRForestName, and CalibratedElectronProducerRun2T< T >::theSemiDeterministicRng.

45  : theElectronToken(consumes<edm::View<T> >(conf.getParameter<edm::InputTag>("electrons"))),
46  theGBRForestName(conf.getParameter<std::string>("gbrForestName")),
49  conf.getParameter<bool>("isMC"),
50  conf.getParameter<bool>("isSynchronization"),
51  conf.getParameter<std::string>("correctionFile")) {
52  if (conf.existsAs<bool>("semiDeterministic") && conf.getParameter<bool>("semiDeterministic")) {
53  theSemiDeterministicRng = std::make_unique<TRandom2>();
55  }
57  produces<std::vector<T> >();
58 }
edm::EDGetTokenT< edm::View< T > > theElectronToken
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::ESGetToken< GBRForest, GBRWrapperRcd > gbrforestToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< TRandom > theSemiDeterministicRng
ElectronEnergyCalibratorRun2 theEnCorrectorRun2
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
template<typename T >
CalibratedElectronProducerRun2T< T >::~CalibratedElectronProducerRun2T ( )
override

Definition at line 61 of file CalibratedElectronProducersRun2.cc.

61 {}

Member Function Documentation

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

Definition at line 64 of file CalibratedElectronProducersRun2.cc.

References edm::EventID::event(), first, edm::Event::getByToken(), edm::EventSetup::getData(), edm::EventBase::id(), recoMuon::in, edm::EventID::luminosityBlock(), M_PI, SiStripPI::max, eostools::move(), submitPVResolutionJobs::out, edm::Event::put(), edm::EventID::run(), fileCollector::seed, and edm::Event::streamID().

64  {
65  const GBRForest *theGBRForest = &iSetup.getData(gbrforestToken_);
66  theEpCombinationTool.init(theGBRForest);
67 
69  iEvent.getByToken(theElectronToken, in);
70 
71  std::unique_ptr<std::vector<T> > out(new std::vector<T>());
72  out->reserve(in->size());
73 
74  if (theSemiDeterministicRng && !in->empty()) { // no need to set a seed if in is empty
75  const auto &first = in->front();
76  std::seed_seq seeder = {int(iEvent.id().event()),
77  int(iEvent.id().luminosityBlock()),
78  int(iEvent.id().run()),
79  int(in->size()),
80  int(std::numeric_limits<int>::max() * first.phi() / M_PI) & 0xFFF,
81  int(first.pdgId())};
82  uint32_t seed = 0, tries = 10;
83  do {
84  seeder.generate(&seed, &seed + 1);
85  tries++;
86  } while (seed == 0 && tries < 10);
87  theSemiDeterministicRng->SetSeed(seed ? seed : iEvent.id().event());
88  }
89 
90  for (const T &ele : *in) {
91  out->push_back(ele);
92  theEnCorrectorRun2.calibrate(out->back(), iEvent.id().run(), iEvent.streamID());
93  }
94 
95  iEvent.put(std::move(out));
96 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
edm::EDGetTokenT< edm::View< T > > theElectronToken
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
bool init(const GBRForest *forest)
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
edm::ESGetToken< GBRForest, GBRWrapperRcd > gbrforestToken_
void calibrate(SimpleElectron &electron, edm::StreamID const &id=edm::StreamID::invalidStreamID()) const
bool getData(T &iHolder) const
Definition: EventSetup.h:128
def move
Definition: eostools.py:511
#define M_PI
std::unique_ptr< TRandom > theSemiDeterministicRng
edm::EventID id() const
Definition: EventBase.h:59
StreamID streamID() const
Definition: Event.h:98
long double T
ElectronEnergyCalibratorRun2 theEnCorrectorRun2

Member Data Documentation

template<typename T >
edm::ESGetToken<GBRForest, GBRWrapperRcd> CalibratedElectronProducerRun2T< T >::gbrforestToken_
private
template<typename T >
edm::EDGetTokenT<edm::View<T> > CalibratedElectronProducerRun2T< T >::theElectronToken
private

Definition at line 33 of file CalibratedElectronProducersRun2.cc.

template<typename T >
ElectronEnergyCalibratorRun2 CalibratedElectronProducerRun2T< T >::theEnCorrectorRun2
private
template<typename T >
EpCombinationTool CalibratedElectronProducerRun2T< T >::theEpCombinationTool
private

Definition at line 36 of file CalibratedElectronProducersRun2.cc.

template<typename T >
std::string CalibratedElectronProducerRun2T< T >::theGBRForestName
private
template<typename T >
std::unique_ptr<TRandom> CalibratedElectronProducerRun2T< T >::theSemiDeterministicRng
private