HighLAND
ConfigurationBase.hxx
1 #ifndef ConfigurationBase_h
2 #define ConfigurationBase_h
3 
4 #include <stdio.h>
5 #include <iostream>
6 #include <map>
7 #include <vector>
8 #include <stdexcept>
9 
10 #include <TObject.h>
11 #include <BasicTypes.hxx>
12 #include "SystematicManager.hxx"
13 #include "ToyMaker.hxx"
14 
15 /// Maximum number of systematic parameters to be saved in the config tree
16 const UInt_t NMAXPARAMETERS = 500;
17 
18 /// A Class that allows saving the variations in the config tree
20 public:
21  ToyVariationWrite(){npar=0;}
22  virtual ~ToyVariationWrite(){}
23 
24 public:
25  Float_t variations[NMAXPARAMETERS];
26  Float_t weights[NMAXPARAMETERS];
27  Int_t par_index[NMAXPARAMETERS];
28  UInt_t npar;
29 
30  ClassDef(ToyVariationWrite, 1);
31 };
32 
33 class ConfigurationBase: public TObject{
34 public :
35 
37  ConfigurationBase(Int_t index, const std::string& conf_name, UInt_t ntoys=1, Int_t randomSeed=-1, ToyMaker* toyMaker=NULL);
38  virtual ~ConfigurationBase(){}
39 
40  /// Enable the systematic registered with the given name
41  void EnableSystematic(Int_t index){_systematicsEnabled.push_back(index);}
42 
43  /// Enable the systematic registered with the given name
44  void EnableSystematics(const std::vector<Int_t>& indices);
45 
46  /// Disable the systematic registered with the given name
47  void DisableSystematic(Int_t index){(void)index;}
48 
49  /// Disable the systematic registered with the given name
50  void DisableAllSystematics(){_systematicsEnabled.clear();}
51 
52  /// Get the systematics enabled for this configuration
53  const std::vector<Int_t>& GetEnabledSystematics(){return _systematicsEnabled;}
54 
55 
56  /// Enable the systematic registered with the given name
57  void EnableEventWeight(Int_t index){_weightsEnabled.push_back(index);}
58 
59  /// Enable the systematic registered with the given name
60  void EnableEventWeights(const std::vector<Int_t>& indices){_weightsEnabled = indices;}
61 
62  /// Disable the systematic registered with the given name
63  void DisableEventWeight(Int_t index){(void)index;}
64 
65  /// Disable the systematic registered with the given name
66  void DisableAllEventWeights(){_weightsEnabled.clear();}
67 
68  /// Get the weights enabled for this configuration
69  const std::vector<Int_t>& GetEnabledEventWeights(){return _weightsEnabled;}
70 
71 
72  /// Enable the systematic registered with the given name
73  void EnableEventVariation(Int_t index){_variationsEnabled.push_back(index);}
74 
75  /// Enable the systematic registered with the given name
76  void EnableEventVariations(const std::vector<Int_t>& indices){_variationsEnabled = indices;}
77 
78  /// Disable the systematic registered with the given name
79  void DisableEventVariation(Int_t index){(void)index;}
80 
81  /// Disable the systematic registered with the given name
82  void DisableAllEventVariations(){_variationsEnabled.clear();}
83 
84  /// Get the variations enabled for this configuration
85  const std::vector<Int_t>& GetEnabledEventVariations(){return _variationsEnabled;}
86 
87 
88  /// Is this configuration enabled ?
89  void SetEnabled(bool ena){_enabled=ena;}
90  bool IsEnabled() const {return _enabled;}
91 
92  /// Set and gets enable flags for a given toy
93  void SetToyEnabled(Int_t n, bool ena){_toyEnabled[n]=ena;}
94  bool GetToyEnabled(Int_t n) const {return _toyEnabled[n];}
95 
96  /// Get and sets the number of toys
97  Int_t GetNToys() const {return _ntoys;}
98  void SetNToys(Int_t ntoys){_ntoys= ntoys;}
99 
100  /// Returns the refernce toy experiment index
101  Int_t GetRefToyIndex() const {return _toy_ref;}
102 
103  /// Get and sets the random seed used to generate the toys
104  Int_t GetToyRandomSeed() const {return _toy_randomSeed;}
105  void SetToyRandomSeed(UInt_t seed){_toy_randomSeed = (Int_t)seed;}
106 
107  /// Sets the ToyMaker
108  void SetToyMaker(ToyMaker* toyMaker){_toyMaker = toyMaker;}
109 
110  /// Returns the ToyMaker
111  ToyMaker& GetToyMaker(){return *_toyMaker;}
112 
113  /// Returns the configuration index (should match the one in the Configuration Manager)
114  Int_t GetIndex() const {return _conf_index;}
115 
116  /// Sets the configuration index
117  void SetIndex(Int_t index){_conf_index= index;}
118 
119  /// Returns the index of the tree associated to this configuration in the TreeManager
120  Int_t GetTreeIndex() const {return _tree_index;}
121 
122  /// Sets the tree index
123  void SetTreeIndex(Int_t index){_tree_index= index;}
124 
125  /// Returns the name of this configuration
126  const std::string& Name() const {return _name;}
127 
128  /// Dump on the screen info about this configuration
129  using TObject::Dump;
130  void Dump(SystematicManager& syst);
131 
132  /// Create the ToyExperiments using the ToyMaker and the SystematicManager
133  void CreateToyExperiments(const SystematicManager& syst);
134 
135  ClassDef(ConfigurationBase, 1);
136 
137 protected:
138 
139  /// Name of the configuration
140  std::string _name;
141 
142  /// Configuration index
143  Int_t _conf_index;
144 
145  /// the index of the tree associated to this configuration in the TreeManager
146  Int_t _tree_index;
147 
148  /// Number of Toy experiments or virtual analyses
149  Int_t _ntoys;
150 
151  /// The reference toy with the nominal selection
152  Int_t _toy_ref;
153 
154  /// The random seed used to generate the toys
156 
157  /// Is this configuration enabled ?
158  bool _enabled;
159 
160  /// Tell wether a toy is enabled or not
161  std::vector<bool> _toyEnabled; //!
162 
163  /// Vector of indices of the systematics enabled in this configuration
164  std::vector<Int_t> _systematicsEnabled;
165 
166  /// Vector of indices of the weights enabled in this configuration
167  std::vector<Int_t> _weightsEnabled; //!
168 
169  /// Vector of indices of the variations enabled in this configuration
170  std::vector<Int_t> _variationsEnabled; //!
171 
172 
173  /// The ToyMaker, which fills the toy
175 
176 public:
177 
178  /// The variations for each of the toys
179  std::vector< ToyVariationWrite > _toys;
180 
181 };
182 
183 #endif
184 
185 
std::string _name
Name of the configuration.
void EnableEventWeight(Int_t index)
Enable the systematic registered with the given name.
ToyMaker * _toyMaker
The ToyMaker, which fills the toy.
void SetIndex(Int_t index)
Sets the configuration index.
void EnableEventVariations(const std::vector< Int_t > &indices)
Enable the systematic registered with the given name.
Int_t GetNToys() const
Get and sets the number of toys.
std::vector< Int_t > _systematicsEnabled
Vector of indices of the systematics enabled in this configuration.
std::vector< Int_t > _variationsEnabled
Vector of indices of the variations enabled in this configuration.
void EnableEventVariation(Int_t index)
Enable the systematic registered with the given name.
void SetToyMaker(ToyMaker *toyMaker)
Sets the ToyMaker.
void EnableSystematic(Int_t index)
Enable the systematic registered with the given name.
const std::vector< Int_t > & GetEnabledEventVariations()
Get the variations enabled for this configuration.
ToyMaker & GetToyMaker()
Returns the ToyMaker.
std::vector< Int_t > _weightsEnabled
Vector of indices of the weights enabled in this configuration.
void SetToyEnabled(Int_t n, bool ena)
Set and gets enable flags for a given toy.
void DisableEventVariation(Int_t index)
Disable the systematic registered with the given name.
std::vector< bool > _toyEnabled
Tell wether a toy is enabled or not.
Int_t GetRefToyIndex() const
Returns the refernce toy experiment index.
void DisableAllEventWeights()
Disable the systematic registered with the given name.
A Class that allows saving the variations in the config tree.
const std::string & Name() const
Returns the name of this configuration.
void DisableAllEventVariations()
Disable the systematic registered with the given name.
const std::vector< Int_t > & GetEnabledEventWeights()
Get the weights enabled for this configuration.
Int_t GetToyRandomSeed() const
Get and sets the random seed used to generate the toys.
The maximum number of systematics that is supported.
Int_t GetTreeIndex() const
Returns the index of the tree associated to this configuration in the TreeManager.
std::vector< ToyVariationWrite > _toys
The variations for each of the toys.
Int_t _toy_ref
The reference toy with the nominal selection.
void DisableSystematic(Int_t index)
Disable the systematic registered with the given name.
void DisableAllSystematics()
Disable the systematic registered with the given name.
void SetTreeIndex(Int_t index)
Sets the tree index.
void SetEnabled(bool ena)
Is this configuration enabled ?
void EnableEventWeights(const std::vector< Int_t > &indices)
Enable the systematic registered with the given name.
bool _enabled
Is this configuration enabled ?
const std::vector< Int_t > & GetEnabledSystematics()
Get the systematics enabled for this configuration.
Int_t GetIndex() const
Returns the configuration index (should match the one in the Configuration Manager) ...
Int_t _tree_index
the index of the tree associated to this configuration in the TreeManager
Int_t _conf_index
Configuration index.
void DisableEventWeight(Int_t index)
Disable the systematic registered with the given name.
Int_t _ntoys
Number of Toy experiments or virtual analyses.
Int_t _toy_randomSeed
The random seed used to generate the toys.