ATLAS Offline Software
BootstrapGeneratorAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 #ifndef ASG_ANALYSIS_ALGORITHMS__BOOTSTRAP_GENERATOR_ALG_H
8 #define ASG_ANALYSIS_ALGORITHMS__BOOTSTRAP_GENERATOR_ALG_H
9 
16 #include <TRandomGen.h>
17 
18 namespace CP
19 {
22  {
24  public:
26 
28  public:
29  std::uint64_t fnv1a_64(const void *buffer, size_t size, std::uint64_t offset_basis);
30 
32  public:
34 
36  public:
38 
40  public:
41  std::uint8_t getBootstrap() { return m_rng.Poisson(1); };
42 
44  private:
45  static constexpr std::uint64_t m_offset = 14695981039346656037u;
46  static constexpr std::uint64_t m_prime = 1099511628211u;
47 
49  private:
50  TRandomRanluxpp m_rng;
51  };
52 
53 
56  {
58  public:
59  BootstrapGeneratorAlg(const std::string &name,
60  ISvcLocator *pSvcLocator);
61 
62  public:
63  StatusCode initialize() override;
64 
65  public:
66  StatusCode execute() override;
67 
69  private:
71 
73  private:
75  this, "eventInfo", "EventInfo", "the EventInfo container"};
76 
78  private:
79  Gaudi::Property<int> m_nReplicas {this, "nReplicas", 1000, "number of bootstrapped weights (toys) to generate"};
80 
82  private:
83  Gaudi::Property<bool> m_data {this, "isData", false, "whether we are running on data"};
84 
86  private:
88 
90  private:
91  std::vector<std::uint8_t> m_weights;
92 
94  private:
96  this, "decorationName", "bootstrapWeights_%SYS%", "decoration name for the vector of bootstrapped weights"};
97  };
98 } // namespace CP
99 
100 #endif
CP::BootstrapGeneratorAlg::m_eventInfoHandle
SysReadHandle< xAOD::EventInfo > m_eventInfoHandle
the EventInfo container
Definition: BootstrapGeneratorAlg.h:74
CP::BootstrapGenerator::getBootstrap
std::uint8_t getBootstrap()
get the next bootstrap weight
Definition: BootstrapGeneratorAlg.h:41
PropertyWrapper.h
CP::BootstrapGeneratorAlg::m_systematicsList
SysListHandle m_systematicsList
the systematics list we run
Definition: BootstrapGeneratorAlg.h:70
CP::SysListHandle
a class managing the property to configure the list of systematics to process
Definition: SysListHandle.h:33
SysWriteDecorHandle.h
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SysListHandle.h
CP::BootstrapGenerator
a class to generate random numbers with a unique seed
Definition: BootstrapGeneratorAlg.h:22
CP::BootstrapGenerator::setSeed
void setSeed(std::uint64_t eventNumber, std::uint32_t runNumber, std::uint32_t mcChannelNumber)
set the seed of the random number generator based on event properties
Definition: BootstrapGeneratorAlg.cxx:33
CP::SysReadHandle
a data handle for reading systematics varied input data
Definition: SysReadHandle.h:32
xAOD::mcChannelNumber
mcChannelNumber
Definition: EventInfo_v1.cxx:197
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
CP::BootstrapGeneratorAlg::m_bootstrap
BootstrapGenerator m_bootstrap
the bootstrap generator instance
Definition: BootstrapGeneratorAlg.h:87
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
SysReadHandle.h
AnaAlgorithm.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CP::BootstrapGeneratorAlg::m_data
Gaudi::Property< bool > m_data
flag whether we are running on data
Definition: BootstrapGeneratorAlg.h:83
createCoolChannelIdFile.buffer
buffer
Definition: createCoolChannelIdFile.py:12
EL::AnaAlgorithm
the (new) base class for EventLoop algorithms
Definition: AnaAlgorithm.h:73
CP::BootstrapGenerator::m_offset
static constexpr std::uint64_t m_offset
constants for seed generation
Definition: BootstrapGeneratorAlg.h:45
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
xAOD::eventNumber
eventNumber
Definition: EventInfo_v1.cxx:124
CP::BootstrapGeneratorAlg::m_nReplicas
Gaudi::Property< int > m_nReplicas
the number of bootstrap replicas
Definition: BootstrapGeneratorAlg.h:79
CP::BootstrapGeneratorAlg
an algorithm to compute per-event bootstrap replica weights
Definition: BootstrapGeneratorAlg.h:56
CP::BootstrapGeneratorAlg::m_decoration
SysWriteDecorHandle< std::vector< std::uint8_t > > m_decoration
the output decoration
Definition: BootstrapGeneratorAlg.h:95
CP::BootstrapGeneratorAlg::execute
StatusCode execute() override
Definition: BootstrapGeneratorAlg.cxx:54
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
CP::BootstrapGeneratorAlg::initialize
StatusCode initialize() override
Definition: BootstrapGeneratorAlg.cxx:39
CP::BootstrapGenerator::m_prime
static constexpr std::uint64_t m_prime
Definition: BootstrapGeneratorAlg.h:46
EventInfo.h
CP::BootstrapGenerator::m_rng
TRandomRanluxpp m_rng
the random number generator (Ranlux++)
Definition: BootstrapGeneratorAlg.h:50
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
CP::BootstrapGeneratorAlg::m_weights
std::vector< std::uint8_t > m_weights
the vector of bootstrap replica weights
Definition: BootstrapGeneratorAlg.h:91
CP::BootstrapGenerator::BootstrapGenerator
BootstrapGenerator()
the standard constructor
Definition: BootstrapGeneratorAlg.h:25
CP::SysWriteDecorHandle
a data handle for reading systematics varied input data
Definition: SysWriteDecorHandle.h:42
CP::BootstrapGeneratorAlg::BootstrapGeneratorAlg
BootstrapGeneratorAlg(const std::string &name, ISvcLocator *pSvcLocator)
the standard constructor
Definition: BootstrapGeneratorAlg.cxx:9
CP::BootstrapGenerator::generateSeed
std::uint64_t generateSeed(std::uint64_t eventNumber, std::uint32_t runNumber, std::uint32_t mcChannelNumber)
generate a unique seed based on event identifiers
Definition: BootstrapGeneratorAlg.cxx:25
CP::BootstrapGenerator::fnv1a_64
std::uint64_t fnv1a_64(const void *buffer, size_t size, std::uint64_t offset_basis)
implementation of the hash function from https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo...
Definition: BootstrapGeneratorAlg.cxx:15