HighLAND
SelectionManager.hxx
1 #ifndef SelectionManager_h
2 #define SelectionManager_h
3 
4 #include "SelectionBase.hxx"
5 
6 
7 /// This class holds a collection of SelectionBase. It allows us to have multiple selections
8 ///
9 
11  public :
12 
14  virtual ~SelectionManager(){}
15 
16  /// Return the selection that was registered with the given name. NULL if it does not exist
17  SelectionBase* GetSelection(const std::string& name, bool print_error=true);
18 
19  /// Return the selection that was registered with the given index. NULL if it does not exist
20  SelectionBase* GetSelection(Int_t, bool print_error=true);
21 
22  /// Add a user selection to the selection manager.
23  void AddSelection(const std::string& name, const std::string& title, SelectionBase* sel, Int_t presel=-1);
24 
25  /// Apply the selection that was registered with the given name
26  bool ApplySelection(const std::string& name, AnaEventC& event, bool& redo);
27 
28  /// Return the map of selections
29  std::vector<SelectionBase*>& GetSelections(){return _eventSelections;}
30 
31  /// Disable a selection
32  void DisableSelection(const std::string& sel);
33 
34  /// Enable a selection
35  void EnableSelection(const std::string& sel);
36 
37  /// Read the "config" tree from the given file, to read the selections that were
38  /// used when running the analysis. This is used so we can access the selections in
39  /// the DrawingTools.
40  void ReadSelections(const std::string& file);
41 
42  /// Print out the index, name and title of each selection for a given branch (no argument for all branches)
43  void DumpSelections();
44 
45  /// Print #events passing cuts
46  void PrintStatistics();
47  /* NOT NEEDED ANYMORE, WE SHOULD USE THE METHODS IN SelectionBase
48 
49  /// Copy a clone of the steps in range first-last from branch sbranch1 in selection ssel1 to sbranch2 in selection ssel2
50  void CopySteps(const std::string& ssel1, const std::string& sbranch1, UInt_t first, UInt_t last,const std::string& ssel2, const std::string& sbranch2="trunk");
51 
52  void CopySteps(const std::string& ssel1, UInt_t first, UInt_t last,const std::string& ssel2, const std::string& sbranch2="trunk"){
53  CopySteps(ssel1,"trunk",first,last,ssel2,sbranch2);
54  }
55 
56  /// Copy a clone of all the steps from branch sbranch1 in selection ssel1 to sbranch2 in selection ssel2
57  void CopySteps(const std::string& ssel1, const std::string& sbranch1, const std::string& ssel2, const std::string& sbranch2="trunk");
58 
59  void CopySteps(const std::string& ssel1, const std::string& ssel2, const std::string& sbranch2="trunk"){
60  CopySteps(ssel1,"trunk",ssel2,sbranch2);
61  }
62 
63 
64  /// Copy a clone of the steps with number istep from branch sbranch1 in selection ssel1 to sbranch2 in selection ssel2
65  void CopyStep(const std::string& ssel1, const std::string& sbranch1, UInt_t istep, const std::string& ssel2, const std::string& sbranch2="trunk");
66 
67  void CopyStep(const std::string& ssel1, UInt_t istep, const std::string& ssel2, const std::string& sbranch2="trunk"){
68  CopyStep(ssel1,"trunk",istep,ssel2,sbranch2);
69  }
70  */
71  /// Returns the number of enabled selections
73 
74  /// Returns the maximum number of branches in all selections
75  UInt_t GetNMaxBranches(){return _nMaxBranches;}
76 
77  /// Returns the maximum number of cuts in all selections
78  UInt_t GetNMaxCuts(){return _nMaxCuts;}
79 
80  /// By default EventSummary class is created and filled when the selection is passed. But this might be necessary also for events not passing the selection
81  /// The user can force the EventSummary to be filled always. This function enables/disables this option for all selections in the manager
82  void SetForceFillEventSummary(bool force);
83 
84  /// Method to set the valid run periods for this selection (e.g. Anti-neutrino selections should only be valid when looking at anti-neutrino data or MC)
85  void SetValidRunPeriods(const std::string& ssel1, const std::string validRunPeriods);
86 
87  /// Chek if preselection cuts have been passed;
88  bool PreSelectionPassed(const AnaEventC& event);
89 
90  /// Initialize the EventBox for all enabled selections
91  void InitializeEvent(AnaEventC& event);
92 
93  /// Create the array of PreviousToyBox for all enabled selections
94  void CreateToyBoxArray(Int_t nevents);
95 
96  /// Delete the PreviousToyBox pointer for the last toy of the event for all enabled selections
97  void FinalizeEvent(const AnaEventC& event);
98 
99 protected:
100 
101  /// Internal storage fo the selections that were added.
102  std::vector<SelectionBase*> _eventSelections;
103 
104  /// maximum number of branches
105  UInt_t _nMaxBranches; //!
106 
107  /// maximum number of cuts
108  UInt_t _nMaxCuts; //!
109 
110  /// number of enabled selections
112 
113 };
114 
115 #endif
void PrintStatistics()
Print #events passing cuts.
UInt_t _nEnabledSelections
number of enabled selections
void DumpSelections()
Print out the index, name and title of each selection for a given branch (no argument for all branche...
void CreateToyBoxArray(Int_t nevents)
Create the array of PreviousToyBox for all enabled selections.
bool ApplySelection(const std::string &name, AnaEventC &event, bool &redo)
Apply the selection that was registered with the given name.
UInt_t GetNMaxCuts()
Returns the maximum number of cuts in all selections.
UInt_t GetNEnabledSelections()
Returns the number of enabled selections.
bool PreSelectionPassed(const AnaEventC &event)
Chek if preselection cuts have been passed;.
std::vector< SelectionBase * > & GetSelections()
Return the map of selections.
UInt_t _nMaxBranches
maximum number of branches
UInt_t _nMaxCuts
maximum number of cuts
std::vector< SelectionBase * > _eventSelections
Internal storage fo the selections that were added.
void ReadSelections(const std::string &file)
void SetForceFillEventSummary(bool force)
void AddSelection(const std::string &name, const std::string &title, SelectionBase *sel, Int_t presel=-1)
Add a user selection to the selection manager.
UInt_t GetNMaxBranches()
Returns the maximum number of branches in all selections.
void DisableSelection(const std::string &sel)
Disable a selection.
void EnableSelection(const std::string &sel)
Enable a selection.
void FinalizeEvent(const AnaEventC &event)
Delete the PreviousToyBox pointer for the last toy of the event for all enabled selections.
SelectionBase * GetSelection(const std::string &name, bool print_error=true)
Return the selection that was registered with the given name. NULL if it does not exist...
void SetValidRunPeriods(const std::string &ssel1, const std::string validRunPeriods)
Method to set the valid run periods for this selection (e.g. Anti-neutrino selections should only be ...
void InitializeEvent(AnaEventC &event)
Initialize the EventBox for all enabled selections.