HighLAND
ToyMaker.cxx
1 #include "ToyMaker.hxx"
2 
3 //******************************************************************
5 //******************************************************************
6 
7  _toys.clear();
8 
9  _nSystematics=0;
10 
11  for (UInt_t isyst = 0; isyst<NMAXSYSTEMATICS;isyst++)
12  _systematics[isyst] = NULL;
13 }
14 
15 //******************************************************************
17 //******************************************************************
18 
19  for (std::vector<ToyExperiment*>::iterator it=_toys.begin();it!=_toys.end();it++){
20  if (*it) delete *it;
21  }
22  _toys.clear();
23 }
24 
25 //***********************************************************
27 //***********************************************************
28 
29  _systematics[sys->GetIndex()] = sys;
30  _nSystematics++;
31 }
32 
33 //********************************************************************
34 void ToyMaker::CreateToyExperiments(Int_t ntoys, const std::vector<SystematicBase*>& systematicsEnabled){
35 //********************************************************************
36 
37  if (systematicsEnabled.size()==0) return;
38 
39  // Add the enabled systematics
40  for (UInt_t i=0;i<systematicsEnabled.size();i++){
41  // Make sure the systematic with a given index exist, since the position in the vector is the Index of the systematics in SystId and not the order in which they are added
42  // (It depends on how systematicsEnabled was filled)
43  if (systematicsEnabled[i])
44  AddSystematic(systematicsEnabled[i]);
45  }
46 
47  // Create the variations for ntoys
48  for (Int_t itoy= 0; itoy<ntoys; itoy++){
49 
50  // Copy the structure of the template toy
51  ToyExperiment* toy = new ToyExperiment();
52 
53  // Fill the ToyExperiment using the user defined ToyMaker
54  FillToyExperiment(*toy);
55 
56  // put it into the vector of toys
57  _toys.push_back(toy);
58  }
59 
60 }
61 
62 
63 
Int_t GetIndex() const
Return the index of this systematic.
void AddSystematic(SystematicBase *sys)
Add a SystematicBase.
Definition: ToyMaker.cxx:26
std::vector< ToyExperiment * > _toys
The vector of toys.
Definition: ToyMaker.hxx:43
SystematicBase * _systematics[NMAXSYSTEMATICS]
The systematics that need to be considered.
Definition: ToyMaker.hxx:46
ToyMaker()
Create the Toy experiment.
Definition: ToyMaker.cxx:4
void CreateToyExperiments(Int_t ntoys, const std::vector< SystematicBase *> &systematicsEnabled)
Create the Toy Experiment, provided the number of toys,.
Definition: ToyMaker.cxx:34
virtual ~ToyMaker()
Everyone should have a destructor.
Definition: ToyMaker.cxx:16
virtual void FillToyExperiment(ToyExperiment &toy)=0
Fills the Toy Experiment with a given index.