1 #include "ConfigurationManager.hxx" 2 #include <DocStringManager.hxx> 8 ConfigurationManager::ConfigurationManager():
HLClonesArray(
"config",
"CONF",
"ConfigurationBase",NMAXCONFIGURATIONS) {
13 _confs.resize(NMAXCONFIGURATIONS);
18 ConfigurationManager::ConfigurationManager(
const std::string& file,
double norm,
const std::string& cut):
HLClonesArray(
"config",
"CONF",
"ConfigurationBase",NMAXCONFIGURATIONS) {
25 ReadConfigurations(file);
29 ConfigurationManager::~ConfigurationManager() {
31 for (std::vector<ConfigurationBase*>::iterator it = _confs_nonull.begin(); it != _confs_nonull.end(); it++) {
35 _confs_nonull.clear();
43 if (index >= (Int_t)NMAXCONFIGURATIONS){
44 std::cout <<
"ERROR in ConfigurationManager::AddConfiguration(). The index for configuration '" << conf_name <<
"' with value " 45 << index <<
" exceeds the maximum number of allowed configurations, which is " << NMAXCONFIGURATIONS << std::endl;
53 _confs_nonull.push_back(conf);
59 (*_objects)[_NObjects++] = conf;
75 _confs_nonull.clear();
77 _confs.resize(NMAXCONFIGURATIONS);
79 ReadClonesArray(file);
82 for (
int i=0;i<_NObjects;i++){
84 _confs_nonull.push_back(conf);
85 if (conf->
GetIndex() >= (Int_t)NMAXCONFIGURATIONS){
86 std::cout <<
"WARNING in ConfigurationManager::ReadConfigurations(). The index for configuration '" << conf->
Name() <<
"' with value " 87 << conf->
GetIndex() <<
" exceeds the maximum number of allowed configurations, which is " << NMAXCONFIGURATIONS << std::endl;
88 std::cout <<
" ---> Configuration not added !!!" << std::endl;
140 for (std::vector<ConfigurationBase* >::iterator it= GetConfigurations().begin();it!=GetConfigurations().end();it++){
141 if ((*it)->GetNToys() > nmax) nmax = (*it)->GetNToys();
148 void ConfigurationManager::EnableAllConfigurations(){
151 for (std::vector<ConfigurationBase* >::iterator it= GetConfigurations().begin();it!=GetConfigurations().end();it++){
152 (*it)->SetEnabled(
true);
157 void ConfigurationManager::DisableAllConfigurations(){
160 for ( std::vector<ConfigurationBase* >::iterator it= GetConfigurations().begin();it!=GetConfigurations().end();it++){
161 (*it)->SetEnabled(
false);
193 for (std::vector<ConfigurationBase* >::iterator it= GetConfigurations().begin();it!=GetConfigurations().end();it++){
194 if ((*it)->Name() == conf_name)
return (*it)->GetIndex();
204 for (std::vector<ConfigurationBase* >::iterator it= GetConfigurations().begin();it!=GetConfigurations().end();it++){
205 if ((*it)->Name() == conf_name) SetCurrentConfigurationIndex((*it)->GetIndex());
214 std::cout <<
" -------- List of Configurations ----------------------------------" << std::endl;
216 sprintf(out,
"%3s: %-25s %5s %8s %8s %12s",
"#",
"name",
"NToys",
"enabled",
"NSyst",
"RandomSeed");
217 std::cout << out <<
"\n" << std::endl;
219 for (UInt_t i=0;i<GetConfigurations().size();i++){
222 std::cout << out << std::endl;
224 std::cout <<
" -------------------------------------------------------------------" << std::endl;
229 for (UInt_t i=0;i<GetConfigurations().size();i++){
239 for (std::vector<ConfigurationBase* >::iterator it= GetConfigurations().begin();it!=GetConfigurations().end();it++){
240 (*it)->CreateToyExperiments(syst);
void DumpConfigurations(SystematicManager *syst=NULL)
Dump summary info about all configurations.
void AddConfiguration(Int_t index, const std::string &conf, UInt_t ntoys=1, Int_t randomSeed=-1, ToyMaker *toyMaker=NULL)
Add a new configuration.
int GetNMaxToys()
Get the maximum number of toys in all configurations.
Int_t GetNToys() const
Get and sets the number of toys.
Int_t GetConfigurationIndex(const std::string &conf_name)
Returs the index of a configuration with name.
void SetCurrentConfigurationName(const std::string &conf)
Set the name of the current configuration.
const std::string & Name() const
Returns the name of 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.
const std::vector< Int_t > & GetEnabledSystematics()
Get the systematics enabled for this configuration.
void ReadConfigurations(const std::string &file)
Read configurations from a file.
Int_t GetIndex() const
Returns the configuration index (should match the one in the Configuration Manager) ...
void CreateToyExperiments(const SystematicManager &syst)
Create the ToyExperiments using the ToyMaker and the SystematicManager.