HighLAND
ConfigurationManager.hxx
1 #ifndef ConfigurationManager_h
2 #define ConfigurationManager_h
3 
4 #include <stdio.h>
5 #include <iostream>
6 #include <ConfigurationBase.hxx>
7 #include <HLClonesArray.hxx>
8 
9 
10 /// The maximum number of configurations that is supported.
11 const int NMAXCONFIGURATIONS=50;
12 
14 public :
15 
17  ConfigurationManager(const std::string& file, double norm, const std::string& cut);
18  virtual ~ConfigurationManager();
19 
20 
21  //----------- Functions to control configurations ------------------
22 
23  /// return the vector of configurations
24  std::vector<ConfigurationBase*>& GetConfigurations(){return _confs_nonull;}
25 
26  /// return the name of the current configuration
27  const std::string& GetCurrentConfigurationName(){return _confs[_current_conf]->Name();}
28 
29  /// return the current configuration
31 
32  /// return the configuration with a given index
33  ConfigurationBase* GetConfiguration(Int_t index) const{
34  if (index==-1) return GetCurrentConfiguration();
35  else return _confs[index];
36  }
37 
38  /// return the configuration with a given index
39  ConfigurationBase* GetConfiguration(const std::string& conf){
41  }
42 
43  /// return the index of the current configuration
45 
46  /// Set the name of the current configuration
47  void SetCurrentConfigurationName(const std::string& conf);
48 
49  /// Set the index of the current configuration
51 
52  /// Returs the index of a configuration with name
53  Int_t GetConfigurationIndex(const std::string& conf_name);
54 
55  /// Returs the name of a configuration with index
56  const std::string& GetConfigurationName(Int_t index){return _confs[index]->Name();}
57 
58  /// Add a new configuration
59  void AddConfiguration(Int_t index, const std::string& conf, UInt_t ntoys=1, Int_t randomSeed=-1, ToyMaker* toyMaker=NULL);
60 
61  /// Check if a configuration is enabled
62  bool ConfigurationEnabled(const std::string& conf){return _confs[GetConfigurationIndex(conf)]->IsEnabled();}
63 
64  /// Check if a configuration is enabled
65  bool ConfigurationEnabled(Int_t conf){return _confs[conf]->IsEnabled();}
66 
67  /// Enable/Disable configurations
68  void EnableConfiguration(const std::string& conf) {_confs[GetConfigurationIndex(conf)]->SetEnabled(true);}
69  void DisableConfiguration(const std::string& conf){_confs[GetConfigurationIndex(conf)]->SetEnabled(false);}
70  void EnableConfiguration(Int_t conf) {_confs[conf]->SetEnabled(true);}
71  void DisableConfiguration(Int_t conf){_confs[conf]->SetEnabled(false);}
72  void DisableAllConfigurations();
73  void EnableAllConfigurations();
74 
75  /// Read configurations from a file
76  void ReadConfigurations(const std::string& file);
77 
78 
79  /// Enable/disable toys
80  bool GetToyEnabled(const std::string& conf, int toy){return _confs[GetConfigurationIndex(conf)]->GetToyEnabled(toy);}
81  void EnableToy(const std::string& conf, int toy) {_confs[GetConfigurationIndex(conf)]->SetToyEnabled(toy, true);}
82  void DisableToy(const std::string& conf, int toy){_confs[GetConfigurationIndex(conf)]->SetToyEnabled(toy, false);}
83  void DisableAllToys(const std::string& conf){for (int i=0;i<GetNToys(conf);i++) DisableToy(conf,i);}
84  void EnableAllToys(const std::string& conf) {for (int i=0;i<GetNToys(conf);i++) EnableToy(conf,i);}
85 
86  int GetNToys(const std::string& conf){return _confs[GetConfigurationIndex(conf)]->GetNToys();}
87  int GetNToys(){return GetCurrentConfiguration()->GetNToys();}
88 
89  /// Sets the number of toys to a configuration with name
90  void SetNToys(const std::string& conf, int ntoy){_confs[GetConfigurationIndex(conf)]->SetNToys(ntoy);}
91 
92  /// Sets the number of toys to a configuration with index
93  void SetNToys(Int_t index, int ntoy){_confs[index]->SetNToys(ntoy);}
94 
95  /// Sets the Toy random seed to a configuration with index
96  void SetToyRandomSeed(Int_t index, Int_t seed){_confs[index]->SetToyRandomSeed(seed);}
97 
98  /// Get the maximum number of toys in all configurations
99  int GetNMaxToys();
100 
101  /// Set and gets the index of the current toy
102  void SetToyIndex(int index){_toy_index=index;}
103  int GetToyIndex(){return _toy_index;}
104 
105 
106  /// Enable the systematic registered with the given index
107  void EnableSystematic(Int_t syst, Int_t conf=-1){GetConfiguration(conf)->EnableSystematic(syst);}
108 
109  /// Enable the systematics registered with the given indices
110  void EnableSystematics(const std::vector<Int_t>& systs, Int_t conf=-1){GetConfiguration(conf)->EnableSystematics(systs);}
111 
112  /// Disable the systematic registered with the given index
113  void DisableSystematic(Int_t index){(void)index;}
114 
115  /// Disable the systematic registered with the given index
117 
118  /// Get the systematics that are enabled for a given configuration
119  const std::vector<Int_t>& GetEnabledSystematics(Int_t conf=-1){return GetConfiguration(conf)->GetEnabledSystematics();}
120 
121 
122  /// Enable the systematic registered with the given index
123  void EnableEventWeight(Int_t syst, Int_t conf=-1){GetConfiguration(conf)->EnableEventWeight(syst);}
124 
125  /// Enable the systematics registered with the given indices
126  void EnableEventWeights(const std::vector<Int_t>& systs, Int_t conf=-1){GetConfiguration(conf)->EnableEventWeights(systs);}
127 
128  /// Disable the systematic registered with the given index
129  void DisableEventWeight(Int_t index){(void)index;}
130 
131  /// Disable the systematic registered with the given index
133 
134  /// Get the systematics that are enabled for a given configuration
135  const std::vector<Int_t>& GetEnabledEventWeights(Int_t conf=-1){return GetConfiguration(conf)->GetEnabledEventWeights();}
136 
137 
138  /// Enable the systematic registered with the given index
139  void EnableEventVariation(Int_t syst, Int_t conf=-1){GetConfiguration(conf)->EnableEventVariation(syst);}
140 
141  /// Enable the systematics registered with the given indices
142  void EnableEventVariations(const std::vector<Int_t>& systs, Int_t conf=-1){GetConfiguration(conf)->EnableEventVariations(systs);}
143 
144  /// Disable the systematic registered with the given index
145  void DisableEventVariation(Int_t index){(void)index;}
146 
147  /// Disable the systematic registered with the given index
149 
150  /// Get the systematics that are enabled for a given configuration
151  const std::vector<Int_t>& GetEnabledEventVariations(Int_t conf=-1){return GetConfiguration(conf)->GetEnabledEventVariations();}
152 
153 
154  /// Dump summary info about all configurations
155  void DumpConfigurations(SystematicManager* syst=NULL);
156 
157  /// Create the ToyExperiments using the ToyMaker and the SystematicManager
158  void CreateToyExperiments(const SystematicManager& syst);
159 
160  enum enumConf_ConfigurationManager{
161  default_conf=0,
162  enumConfLast_ConfigurationManager
163  };
164 
165 
166  protected:
167 
168  /// current toy index
170 
171  /// Current configuration index
173 
174  /// configurations
175  std::vector<ConfigurationBase* > _confs;
176 
177  /// no NULL configurations
178  std::vector<ConfigurationBase* > _confs_nonull;
179 
180 };
181 
182 #endif
183 
184 
void DumpConfigurations(SystematicManager *syst=NULL)
Dump summary info about all configurations.
void EnableEventWeight(Int_t index)
Enable the systematic registered with the given name.
void AddConfiguration(Int_t index, const std::string &conf, UInt_t ntoys=1, Int_t randomSeed=-1, ToyMaker *toyMaker=NULL)
Add a new configuration.
void SetNToys(const std::string &conf, int ntoy)
Sets the number of toys to a configuration with name.
void EnableEventVariations(const std::vector< Int_t > &indices)
Enable the systematic registered with the given name.
void EnableEventVariations(const std::vector< Int_t > &systs, Int_t conf=-1)
Enable the systematics registered with the given indices.
ConfigurationBase * GetCurrentConfiguration() const
return the current configuration
void SetCurrentConfigurationIndex(Int_t conf)
Set the index of the current configuration.
std::vector< ConfigurationBase *> _confs
configurations
int GetNMaxToys()
Get the maximum number of toys in all configurations.
Int_t GetNToys() const
Get and sets the number of toys.
Int_t GetCurrentConfigurationIndex() const
return the index of the current configuration
Int_t GetConfigurationIndex(const std::string &conf_name)
Returs the index of a configuration with name.
void EnableEventVariation(Int_t index)
Enable the systematic registered with the given name.
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.
Int_t _current_conf
Current configuration index.
void DisableEventVariation(Int_t index)
Disable the systematic registered with the given index.
void EnableSystematics(const std::vector< Int_t > &systs, Int_t conf=-1)
Enable the systematics registered with the given indices.
int _toy_index
current toy index
void SetCurrentConfigurationName(const std::string &conf)
Set the name of the current configuration.
const std::string & GetCurrentConfigurationName()
return the name of the current configuration
void DisableAllEventWeights()
Disable the systematic registered with the given name.
void DisableAllEventVariations()
Disable the systematic registered with the given name.
void DisableEventWeight(Int_t index)
Disable the systematic registered with the given index.
bool GetToyEnabled(const std::string &conf, int toy)
Enable/disable toys.
const std::vector< Int_t > & GetEnabledEventWeights()
Get the weights enabled for this configuration.
void EnableEventWeights(const std::vector< Int_t > &systs, Int_t conf=-1)
Enable the systematics registered with the given indices.
The maximum number of systematics that is supported.
void SetNToys(Int_t index, int ntoy)
Sets the number of toys to a configuration with index.
void SetToyIndex(int index)
Set and gets the index of the current toy.
const std::vector< Int_t > & GetEnabledSystematics(Int_t conf=-1)
Get the systematics that are enabled for a given configuration.
const std::string & GetConfigurationName(Int_t index)
Returs the name of a configuration with index.
const std::vector< Int_t > & GetEnabledEventWeights(Int_t conf=-1)
Get the systematics that are enabled for a given configuration.
std::vector< ConfigurationBase *> _confs_nonull
no NULL configurations
void DisableAllSystematics()
Disable the systematic registered with the given name.
void DisableAllSystematic(Int_t conf=-1)
Disable the systematic registered with the given index.
std::vector< ConfigurationBase * > & GetConfigurations()
return the vector of configurations
void EnableConfiguration(const std::string &conf)
Enable/Disable configurations.
void EnableEventWeight(Int_t syst, Int_t conf=-1)
Enable the systematic registered with the given index.
void EnableEventVariation(Int_t syst, Int_t conf=-1)
Enable the systematic registered with the given index.
void DisableAllEventVariation(Int_t conf=-1)
Disable the systematic registered with the given index.
void EnableEventWeights(const std::vector< Int_t > &indices)
Enable the systematic registered with the given name.
bool ConfigurationEnabled(const std::string &conf)
Check if a configuration is enabled.
void DisableSystematic(Int_t index)
Disable the systematic registered with the given index.
const std::vector< Int_t > & GetEnabledEventVariations(Int_t conf=-1)
Get the systematics that are enabled for a given configuration.
const std::vector< Int_t > & GetEnabledSystematics()
Get the systematics enabled for this configuration.
void ReadConfigurations(const std::string &file)
Read configurations from a file.
bool ConfigurationEnabled(Int_t conf)
Check if a configuration is enabled.
void EnableSystematic(Int_t syst, Int_t conf=-1)
Enable the systematic registered with the given index.
void EnableSystematics(const std::vector< Int_t > &indices)
Enable the systematic registered with the given name.
void SetToyRandomSeed(Int_t index, Int_t seed)
Sets the Toy random seed to a configuration with index.
ConfigurationBase * GetConfiguration(Int_t index) const
return the configuration with a given index
void DisableAllEventWeight(Int_t conf=-1)
Disable the systematic registered with the given index.
ConfigurationBase * GetConfiguration(const std::string &conf)
return the configuration with a given index
void CreateToyExperiments(const SystematicManager &syst)
Create the ToyExperiments using the ToyMaker and the SystematicManager.