1 #include "SelectionManager.hxx" 5 SelectionManager::SelectionManager():
HLClonesArray(
"config",
"SEL",
"SelectionBase",NMAXSELECTIONS){
10 _nEnabledSelections=0;
17 for (std::vector<SelectionBase*>::iterator it=_eventSelections.begin();it!=_eventSelections.end();it++){
18 if ((*it)->Name() == name)
return *it;
22 std::cout <<
"SelectionManager::GetSelection(). Selection '" << name <<
"' does not exist !!!!" << std::endl;
31 if (index<0 || index>=(Int_t)_eventSelections.size()){
33 std::cout <<
"SelectionManager::GetSelection(). Selection with index " << index <<
" does not exist !!!!" << std::endl;
37 return _eventSelections[index];
45 if (GetSelection(name,
false))
return;
62 (*_objects)[_NObjects++] = selection;
63 _eventSelections.push_back(selection);
70 _nEnabledSelections++;
81 if (!sel->IsEnabled())
return;
84 _nEnabledSelections--;
90 for (std::vector<SelectionBase*>::iterator it=_eventSelections.begin();it!=_eventSelections.end();it++){
91 if ((*it)->IsEnabled()){
92 (*it)->SetEnabledIndex(isel++);
106 if (sel->IsEnabled())
return;
112 _nEnabledSelections++;
116 for (std::vector<SelectionBase*>::iterator it=_eventSelections.begin();it!=_eventSelections.end();it++){
117 if ((*it)->IsEnabled()){
118 (*it)->SetEnabledIndex(isel++);
129 if (!sel)
return true;
132 if (!sel->IsEnabled())
return true;
135 return sel->
Apply(event, redo);
143 _eventSelections.clear();
147 _nEnabledSelections=0;
150 ReadClonesArray(file);
152 for (
int i=0;i<_NObjects;i++){
154 _eventSelections.push_back(sel);
155 if (sel->IsEnabled()){
162 _nEnabledSelections++;
174 std::cout <<
" -------- List of Selections -----------------------------------------------------------------------------------------------------" << std::endl;
176 sprintf(out,
"%3s: %-25s %-40s %-10s %-10s %-13s %-20s %-22s",
"#",
"name",
"title",
"enabled",
"#branches",
"force break",
"presel accum_level",
"index in accum_level");
177 std::cout << out <<
"\n" << std::endl;
180 for (
int i=0;i<_NObjects;i++){
182 if (sel->IsEnabled()){
183 sprintf(out,
"%3d: %-25s %-40s %-10d %-10d %-13d %-20d %-22d", i, sel->
Name().c_str(), sel->
Title().c_str(),
188 sprintf(out,
"%3d: %-25s %-40s %-10d %-10d %-13d %-20d %-22s", i, sel->
Name().c_str(), sel->
Title().c_str(),
192 std::cout << out << std::endl;
195 std::cout <<
" ----------------------------------------------------------------------------------------------------------------------------------" << std::endl;
204 for (std::vector<SelectionBase*>::iterator it = _eventSelections.begin(); it!=_eventSelections.end(); it++){
205 if ((*it)->IsEnabled())
206 (*it)->PrintStatistics();
250 for (std::vector<SelectionBase*>::iterator it=_eventSelections.begin();it!=_eventSelections.end();it++){
251 (*it)->SetForceFillEventSummary(force);
266 for (std::vector<SelectionBase*>::iterator it=_eventSelections.begin();it!=_eventSelections.end();it++){
267 if ((*it)->IsEnabled()){
268 if ((*it)->PreSelectionPassed(event))
return true;
279 for (std::vector<SelectionBase*>::iterator it = _eventSelections.begin(); it!=_eventSelections.end(); it++){
280 if ((*it)->IsEnabled()){
281 (*it)->CreateToyBoxArray(nevents);
292 for (std::vector<SelectionBase*>::iterator it = _eventSelections.begin(); it!=_eventSelections.end(); it++){
293 if ((*it)->IsEnabled()){
294 (*it)->FinalizeEvent(event);
304 for (std::vector<SelectionBase*>::iterator it = _eventSelections.begin(); it!=_eventSelections.end(); it++){
305 if ((*it)->IsEnabled()){
307 (*it)->InitializeEvent(event);
void PrintStatistics()
Print #events passing cuts.
void SetTitle(const std::string &title)
Set the title of this selection, which is the "nice" version of the selection name,.
void DumpSelections()
Print out the index, name and title of each selection for a given branch (no argument for all branche...
bool GetForceBreak() const
void Enable()
enable and disable selection
const std::string & Name() const
Return the name of this selection.
void CreateToyBoxArray(Int_t nevents)
Create the array of PreviousToyBox for all enabled selections.
void SetPreSelectionAccumLevel(Int_t presel)
Set the pre-selection accum level.
UInt_t GetNMaxCuts() const
Return the number of steps in a given branch.
bool ApplySelection(const std::string &name, AnaEventC &event, bool &redo)
Apply the selection that was registered with the given name.
void SetValidRunPeriods(std::string runPeriods)
bool PreSelectionPassed(const AnaEventC &event)
Chek if preselection cuts have been passed;.
void SetName(const std::string &name)
Set the name of this selection, which is used internally by the SelectionManager. ...
void SetEnabledIndex(Int_t index)
Set the Selection index.
void ReadSelections(const std::string &file)
bool Apply(AnaEventC &event, bool &redo)
Apply all steps in the selection.
void SetForceFillEventSummary(bool force)
const std::string & Title() const
Return the title of this selection. A nice version of the name.
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 GetNBranches() const
Return the number of branches.
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 Initialize()
Initialize this selection: defines the steps and the detectorFV.
void InitializeEvent(AnaEventC &event)
Initialize the EventBox for all enabled selections.
Int_t GetPreSelectionAccumLevel() const
Set the pre-selection accum level.