HighLAND
AnalysisAlgorithm.hxx
1 #ifndef AnalysisAlgorithm_h
2 #define AnalysisAlgorithm_h
3 
4 #include "HighlandInputManager.hxx"
5 #include "SelectionManager.hxx"
6 #include "OutputManager.hxx"
7 #include "ConfigurationManager.hxx"
8 #include "CorrectionManager.hxx"
9 #include "SystematicManager.hxx"
10 #include "EventWeightManager.hxx"
11 #include "EventVariationManager.hxx"
12 #include "CategoryManager.hxx"
13 #include "DocStringManager.hxx"
14 #include "Deprecated.hxx"
15 
16 /// This class provides a base for user analyses. It handles many common
17 /// functions, and provides a structure so that users don't have to write too
18 /// much "boiler-plate" code.
19 ///
20 /// User analyses should inherit from this class.
21 
23 
24 public:
25  enum enumAnalysisPoint{
26  kInitialize=0,
27  kDefineProductions,
28  kDefineInputConverters,
29  kDefineSelections,
30  kDefineCorrections,
31  kDefineSystematics,
32  kDefineConfigurations,
33  kDefineMicroTrees,
34  kDefineTruthTree,
35  kFillConfigTree,
36  kInitializeSpill,
37  kInitializeBunch,
38  kInitializeConfiguration,
39  kInitializeToy,
40  kInitializeSelection,
41  kFinalizeSelection,
42  kFinalizeToy,
43  kFillToyVarsInMicroTrees,
44  kFinalizeConfiguration,
45  kFillCategories,
46  kFillMicroTrees,
47  kFinalizeBunch,
48  kFillTruthTree,
49  kFinalizeSpill,
50  kFinalize
51  };
52 
53 
54  public:
55  /// Constructor, which instantiates the necessary converters for converting
56  /// input files to the AnaSpill format.
58 
59  virtual ~AnalysisAlgorithm(){}
60 
61 
62  //---- Optional Initialize and finalize methods
63  //! [AnalysisAlgorithm_optional]
64  virtual void Finalize(){}
65 
66  virtual bool InitializeSpill(){return true;}
67  virtual void FinalizeSpill(){}
68 
69  virtual void InitializeBunch(){}
70  virtual void FinalizeBunch(){}
71 
72  virtual void InitializeConfiguration(){}
73  virtual bool FinalizeConfiguration(){return true;}
74 
75  virtual void InitializeToy(){}
76  virtual void FinalizeToy(){}
77 
78  virtual void InitializeSelection(const SelectionBase&){}
79  virtual void FinalizeSelection(const SelectionBase&){}
80 
81  virtual void FillCategories(){}
82 
83  virtual void FillConfigTree(){}
84  //! [AnalysisAlgorithm_optional]
85 
86 
87  /// Create the appropriate event time from an Spill and a Bunch in that spill
88  virtual AnaEventC* MakeEvent() = 0;
89 
90  //---- These are mandatory functions
91  //! [AnalysisAlgorithm_mandatory]
92  virtual bool Initialize() = 0;
93 
94  virtual void DefineProductions() = 0;
95  virtual void DefineInputConverters() = 0;
96  virtual void DefineSelections() = 0;
97  virtual void DefineCorrections() = 0;
98  virtual void DefineSystematics() = 0;
99  virtual void DefineConfigurations() = 0;
100  virtual void DefineMicroTrees(bool addBase=true) = 0;
101  virtual void DefineTruthTree() = 0;
102 
103  virtual void FillMicroTrees(bool addBase=true) = 0;
104  virtual void FillToyVarsInMicroTrees(bool addBase=true) = 0;
105  virtual void FillTruthTree() = 0;
106  //! [AnalysisAlgorithm_mandatory]
107  //---------------------------------------------
108 
109  /// Finalize toy
110  void FinalizeToyBase();
111 
112  /// Fill trees and process weight systematics only when any of the branches is successful
113  void SetFillSuccessOnly(bool fill){_fillSuccessOnly= fill;}
114  bool GetFillSuccessOnly(){return _fillSuccessOnly;}
115 
116  /// Initialize trees at the beginning of each configuration
117  void SetInitializeTrees(bool ini){_initializeTrees= ini;}
118  bool GetInitializeTrees(){return _initializeTrees;}
119 
120  /// Set the minimum accumulated cut level to save an event into the micro-tree.
121  void SetMinAccumCutLevelToSave(Int_t level);
122 
123  /// Get the minimum accumulated cut level to save an event into the micro-tree
125 
126  /// Check if the condition is fulfilled for at least one branch
127  bool CheckAccumLevelToSave();
128 
129  /// Set the current event into the algorithm and all used algorithms
130  void SetEvent(AnaEventC* event);
131 
132  /// Set the current box into the algorithm and all used algorithms. This is useful when one Analysis uses another
133  void SetToyBox(const ToyBoxB* box, Int_t isel=0);
134 
135  /// Used a given analysis
136  void UseAnalysis(AnalysisAlgorithm* ana);
137 
138  /// Select one of the selections
139  void SetSelectedSelection(Int_t sel);
140 
141  /// Set version checking
142  void SetVersionCheck(bool check){_versionCheck=check;}
143 
144  /// Set the point of the analysis at which AnalysisLoop is
145  void SetAnalysisPoint(enumAnalysisPoint point);
146 
147 public:
148 
149  HighlandInputManager& input() {return *_inputManager;}
150  SelectionManager& sel() {return *_selManager;}
151  CorrectionManager& corr() {return *_corrManager;}
152  SystematicManager& syst() {return *_systManager;}
153  EventWeightManager& eweight(){return *_weightManager;}
154  EventVariationManager&evar() {return *_variationManager;}
155  OutputManager& output() {return *_outputManager;}
156  ConfigurationManager& conf() {return *_confManager;}
157  CategoryManager& cat() {return *_categManager;}
158  DocStringManager& doc() {return *_docManager;}
159 
160  virtual const ToyBoxB& boxB(Int_t isel=-1) const;
161 
162  protected:
163 
164  /// Input Manager: access to the current Event
166 
167  /// Correction Manager
169 
170  /// Systematics Manager
172 
173  /// EventWeight Manager
175 
176  /// EventVariation Manager
178 
179  /// Output Manager
181 
182  /// Configuration Manager
184 
185  // Selection Manager
186  SelectionManager *_selManager;
187 
188  // TrackCategory Manager
189  CategoryManager *_categManager;
190 
191  // DocString Manager
192  DocStringManager *_docManager;
193 
194  /// The analysis box
195  const ToyBoxB* _box[NMAXSELECTIONS];
196 
197  /// the minimum accumulated cut level to save an event into the micro-tree
199 
200  /// Fill trees and process weight systematics only when any of the branches is succesful
202 
203  /// Initialize trees at the beginning of each configuration
205 
206  /// The current event
208 
209  /// The Vector of used analysis
210  std::vector<AnalysisAlgorithm*> _usedAnalyses;
211 
212  /// The selected selection
214 
215  /// Boolean parameter to know whether nny of the methods that sets things into used analysis has been called
217 
218  // Whether to perform or not version checking to make sure the sofware version and the input file match each other
219  bool _versionCheck;
220 
221  enumAnalysisPoint _analysisPoint;
222 
223 public:
224 
225  enum enumStandardMicroTrees_AnalysisAlgorithm {
226  firstCategory = OutputManager::enumStandardMicroTreesLast_OutputManager+1,
227  firstCategoryCounter = firstCategory+NMAXCATEG,
228  entry = firstCategoryCounter + NMAXCATEGCOUNTERS,
229  toy_ref,
230  toy_index,
231  toy_par_weight,
232  toy_par_var,
233  NWEIGHTSYST,
234  weight_syst,
235  weight_syst_total,
236  weight_corr,
237  weight_corr_total,
238  redo,
239  accum_level,
240  first_cut,
241  last_cut=first_cut+NMAXSTEPS,
242  enumStandardMicroTreesLast_AnalysisAlgorithm
243  };
244 
245  enum enumConfigTree_AnalysisAlgorithm{
246  SoftwareVersion=0,
247  HOSTNAME,
248  CMTPATH,
249  INPUTFILE,
250  OriginalFile,
251  MinAccumLevelToSave,
252  enumConfigTreeLast_AnalysisAlgorithm
253  };
254 
255 };
256 
257 #endif
EventVariationManager * _variationManager
EventVariation Manager.
void SetSelectedSelection(Int_t sel)
Select one of the selections.
void SetMinAccumCutLevelToSave(Int_t level)
Set the minimum accumulated cut level to save an event into the micro-tree.
virtual AnaEventC * MakeEvent()=0
[AnalysisAlgorithm_optional]
void SetInitializeTrees(bool ini)
Initialize trees at the beginning of each configuration.
ConfigurationManager * _confManager
Configuration Manager.
bool _setMethodCalled
Boolean parameter to know whether nny of the methods that sets things into used analysis has been cal...
void SetToyBox(const ToyBoxB *box, Int_t isel=0)
Set the current box into the algorithm and all used algorithms. This is useful when one Analysis uses...
Int_t _selectedSelection
The selected selection.
const ToyBoxB * _box[NMAXSELECTIONS]
The analysis box.
void SetEvent(AnaEventC *event)
Set the current event into the algorithm and all used algorithms.
OutputManager * _outputManager
Output Manager.
AnaEventC * _event
The current event.
HighlandInputManager * _inputManager
Input Manager: access to the current Event.
The maximum number of systematics that is supported.
void SetFillSuccessOnly(bool fill)
Fill trees and process weight systematics only when any of the branches is successful.
AnalysisAlgorithm(AnalysisAlgorithm *ana=NULL)
bool _fillSuccessOnly
Fill trees and process weight systematics only when any of the branches is succesful.
CorrectionManager * _corrManager
Correction Manager.
SystematicManager * _systManager
Systematics Manager.
void SetAnalysisPoint(enumAnalysisPoint point)
Set the point of the analysis at which AnalysisLoop is.
Int_t _min_accum_cut_level
the minimum accumulated cut level to save an event into the micro-tree
virtual void Finalize()
[AnalysisAlgorithm_optional]
EventWeightManager * _weightManager
EventWeight Manager.
std::vector< AnalysisAlgorithm * > _usedAnalyses
The Vector of used analysis.
void SetVersionCheck(bool check)
Set version checking.
bool CheckAccumLevelToSave()
Check if the condition is fulfilled for at least one branch.
void UseAnalysis(AnalysisAlgorithm *ana)
Used a given analysis.
Int_t GetMinAccumCutLevelToSave()
Get the minimum accumulated cut level to save an event into the micro-tree.
void FinalizeToyBase()
[AnalysisAlgorithm_mandatory]
bool _initializeTrees
Initialize trees at the beginning of each configuration.
virtual bool Initialize()=0
[AnalysisAlgorithm_mandatory]