CMS 3D CMS Logo

EgammaRandomSeeds.h
Go to the documentation of this file.
1 #ifndef RecoEgamma_EgammaTools_EgammaRandomSeeds_h
2 #define RecoEgamma_EgammaTools_EgammaRandomSeeds_h
3 
4 //author: Sam Harper (RAL)
5 //description:
6 // provides a seed for a random number generator based on object / event properties
7 // the supercluster method is prefered as it will be the same for electrons & photons
8 // the SC is based on seed ID and #crystals in SC, the #crystals in SC is for added
9 // entropy although this means any re-recos will change the returned number as #crystals
10 // will likely change with any re-reco while seed ID is fairly stable
11 
14 
15 #include <random>
16 
17 namespace egamma {
18 
19  uint32_t getRandomSeedFromSC(const edm::Event& iEvent, const reco::SuperClusterRef scRef);
20  template <typename T>
21  uint32_t getRandomSeedFromObj(const edm::Event& iEvent, const T& obj, size_t nrObjs, size_t objNr) {
22  std::seed_seq seeder = {int(iEvent.id().event()),
23  int(iEvent.id().luminosityBlock()),
24  int(iEvent.id().run()),
25  int(nrObjs),
26  int(std::numeric_limits<int>::max() * obj.phi() / M_PI) & 0xFFF,
27  int(objNr)};
28  uint32_t seed = 0, tries = 10;
29  do {
30  seeder.generate(&seed, &seed + 1);
31  tries++;
32  } while (seed == 0 && tries < 10);
33  return seed ? seed : iEvent.id().event() + 10000 * objNr;
34  }
35 } // namespace egamma
36 
37 #endif
edm::Ref< SuperClusterCollection >
egamma::getRandomSeedFromObj
uint32_t getRandomSeedFromObj(const edm::Event &iEvent, const T &obj, size_t nrObjs, size_t objNr)
Definition: EgammaRandomSeeds.h:21
egamma::getRandomSeedFromSC
uint32_t getRandomSeedFromSC(const edm::Event &iEvent, const reco::SuperClusterRef scRef)
Definition: EgammaRandomSeeds.cc:5
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:50
egamma
Definition: EgAmbiguityTools.h:10
SuperClusterFwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
edm::Event
Definition: Event.h:73
SurveyInfoScenario_cff.seed
seed
Definition: SurveyInfoScenario_cff.py:295