1 #ifndef SelectionBase_h 2 #define SelectionBase_h 4 #include "StepBase.hxx" 5 #include "HLClonesArray.hxx" 7 #include "CoreDataClasses.hxx" 8 #include "Deprecated.hxx" 14 const UInt_t NMAXSTEPS=50;
18 const UInt_t NMAXBRANCHES=20;
21 const UInt_t NMAXSELECTIONS=10;
88 SelectionBase(
bool forceBreak=
true, Int_t eventBoxId=UNASSIGNEDID);
94 virtual void DefineSteps(){std::cout <<
"ERROR: DefineSteps must be implemented in your Selection!!!" << std::endl;exit(1);}
97 virtual void DefineDetectorFV(){std::cout <<
"ERROR: DefineDetectorFV must be implemented in your Selection!!!" << std::endl;exit(1);}
100 virtual ToyBoxB*
MakeToyBox(){std::cout <<
"ERROR: MakeToyBox must be implemented in your Selection!!!" << std::endl;exit(1);
return NULL;}
103 virtual void InitializeEvent(
AnaEventC&){std::cout <<
"ERROR: InitializeEvent must be implemented in your Selection!!!" << std::endl;exit(1);}
167 bool IsEnabled()
const {
return _enabled;}
175 void PrintStatistics()
const;
176 void PrintStatistics(
const std::string& name)
const;
177 void PrintStatistics(UInt_t ID)
const;
195 void AddStep(Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5,
StepBase::TypeEnum type,
const std::string& title,
StepBase* step,
bool cut_break=
false);
196 void AddStep(Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5, Int_t b6,
StepBase::TypeEnum type,
const std::string& title,
StepBase* step,
bool cut_break=
false);
197 void AddStep(Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5, Int_t b6, Int_t b7,
StepBase::TypeEnum type,
const std::string& title,
StepBase* step,
bool cut_break=
false);
204 void AddSteps(
const std::vector<UInt_t>& branch_seq,
const std::vector<StepBase*>& steps);
207 void AddSplit(UInt_t nbranches, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1);
208 void AddSplit(UInt_t nbranches,
const std::vector<UInt_t>& branch_seq);
210 void AddBranch(Int_t ibranch,
const std::vector<UInt_t>& branch_seq,
const std::string& alias=
"");
226 void DisableStep(
const std::string& title, Int_t ID=-1);
229 void RemoveStep(
const std::string& title, Int_t ID=-1);
235 void InsertStep(
const std::string& previous_title, Int_t ID,
StepBase::TypeEnum type,
const std::string& title,
StepBase* step,
bool cut_break=
false);
240 Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1);
243 Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1);
245 void CopySteps(
SelectionBase& sel1, UInt_t branchID1, UInt_t first, UInt_t last,
const std::vector<UInt_t>& branch_seq2);
255 void CopyStep(
SelectionBase& sel1,
const std::string& sbranch1, UInt_t istep, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1);
256 void CopyStep(
SelectionBase& sel1, UInt_t istep, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1){
257 CopyStep(sel1,
"trunk",istep, b0,b1,b2,b3,b4,b5,b6,b7);
264 std::vector<StepBase*>
GetStepsInBranch(
const std::vector<UInt_t>& branch_seq, UInt_t first=0, UInt_t last=NMAXSTEPS-1)
const;
267 std::vector<StepBase*>
GetStepsInBranchWithDummy(
const std::vector<UInt_t>& branch_seq, UInt_t first=0, UInt_t last=NMAXSTEPS-1)
const;
270 std::vector<StepBase*>
GetStepsInBranch(
const std::string& branch, UInt_t first=0, UInt_t last=NMAXSTEPS-1)
const;
273 std::vector<StepBase*>
GetStepsInBranch(UInt_t ID, UInt_t first=0, UInt_t last=NMAXSTEPS-1)
const;
276 std::vector<StepBase*>
GetCutsInBranch(
const std::string& branch)
const;
282 StepBase*
GetLastStepInBranch(Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
const;
305 std::vector<UInt_t>
ConvertBranch(Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
const;
308 void SetBranchAlias(Int_t ID,
const std::string& name, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1);
374 bool HasBranch(Int_t ibranch,
const std::string& fromMethod=
"HasBranch")
const;
380 std::vector<std::string>
GetStepNames(Int_t ibranch=0)
const;
383 std::vector<std::string>
GetCutNames(Int_t ibranch=0)
const;
389 Int_t
GetCutNumber(
const std::string& title, Int_t ID=0)
const;
392 Int_t
GetStepNumber(
const std::string& title, Int_t ID=0)
const;
401 UInt_t
GetNCuts(Int_t branch)
const;
414 void DumpSteps(
const std::string& branch=
"",
bool onlycuts=
false)
const;
415 void DumpSteps(Int_t ID,
bool onlycuts=
false)
const;
465 SubDetId_h _detectorFV[NMAXBRANCHES];
499 int _cut_passed_stats[NMAXBRANCHES][NMAXSTEPS];
virtual bool IsRelevantSystematic(const AnaEventC &, const ToyBoxB &, SystId_h syst_index, Int_t branch=0) const
Is this systematic relevant for this selection.
bool _validRunPeriods[10]
bool _cut_passed[NMAXBRANCHES][NMAXSTEPS]
The cuts that were passed.
std::string _name
The name of the selection.
std::vector< StepBase * > _firstSteps
The top level steps in the trunk.
void SetTitle(const std::string &title)
Set the title of this selection, which is the "nice" version of the selection name,.
void DumpBranches() const
Dumps the list of branches.
void DumpCuts(Int_t branch=-1) const
Print out the index, name and title of each cut for a given branch (no argument for all branches) ...
Int_t GetStepNumber(const std::string &title, Int_t ID=0) const
Return the step number (starting at 0) corresponding to an step with a given title.
StepBase * GetLastStepInBranch(Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1) const
Get the last step in a given branch provided the branch sequence (individual integers) ...
void AddBranchUniqueID(std::vector< StepBase *> &steps, UInt_t ibranch)
Add a branch unique ID to all steps in that branch.
Int_t _selEnabledIndex
The index of the selection in the selection manager (for enabled selections)
bool GetForceBreak() const
bool ApplyStep(AnaEventC &event, ToyBoxB &box, const StepBase &step, Int_t branch=-1)
void Enable()
enable and disable selection
std::string GetBranchAlias(Int_t ID) const
Gets the branch alias for a given branch unique ID.
const std::string & Name() const
Return the name of this selection.
void DumpSteps(const std::string &branch="", bool onlycuts=false) const
Print out the index, name and title of each step for a given branch (no argument for all branches) ...
void CopyStep(SelectionBase &sel1, const std::string &sbranch1, UInt_t istep, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Copy a clone of the steps with number istep from branch sbranch1 in selection ssel1 to sbranch2 in se...
void CopySteps(SelectionBase &sel1, UInt_t branchID1, UInt_t first, UInt_t last, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Copy a clone of the steps in range first-last from branch sbranch1 in selection ssel1 to sbranch2 in ...
void SetPreSelectionAccumLevel(Int_t presel)
Set the pre-selection accum level.
UInt_t GetNMaxCuts() const
Return the number of steps in a given branch.
EventBoxId_h GetEventBoxId() const
Returns the Id of the EventBox to be used in this selection.
std::vector< std::string > GetStepNames(Int_t ibranch=0) const
Return all the names of the steps, in the order they were added.
EventBoxId_h _eventBoxId
The ID of the EventBox to be used.
void SetValidRunPeriods(std::string runPeriods)
virtual SampleId_h GetSampleId()
Return the sample type, needed by fitters.
StepBase * GetStepInBranch(const std::vector< UInt_t > &branch_seq, UInt_t index) const
Get step in a given branch provided the branch sequence (vector of integers) and the step index...
std::string _title
the nice name of the selection
void InitializeCutLevels()
Reset all cuts to "not passed", and set the accumulated cut level to 0.
bool PreSelectionPassed(const AnaEventC &event)
Is the preselection passed in any of the branches.
bool ApplySteps(AnaEventC &event, ToyBoxB &box, const std::string &branch, Int_t ifirst=0, Int_t ilast=NMAXSTEPS)
Apply a range of steps in a branch.
void AddSplit(UInt_t nbranches, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Add a split in the step sequence. The user should specify the number of branches in this split and th...
bool _enabled
is this selection enabled ?
Int_t GetBranchUniqueID(const std::string &name) const
Gets the branch unique ID with a given alias.
bool ApplyStepRecursive(AnaEventC &event, ToyBoxB &box, const StepBase &step, Int_t firstStepToApply)
Apply all steps recursively provided the first step in a threadsafe way.
void SetName(const std::string &name)
Set the name of this selection, which is used internally by the SelectionManager. ...
void CreateToyBoxArray(Int_t nevents)
Create the array of PreviousToyBox.
void SetEnabledIndex(Int_t index)
Set the Selection index.
virtual ToyBoxB * MakeToyBox()
Create the appropriate type of box.
std::vector< std::string > _branchAlias
Association between a branch unique ID (entry in vector) and branch alias.
virtual bool IsRelevantRecObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaRecObjectC *, SystId_h syst_index, Int_t branch=0) const
Is this track relevant for a given systematic (after selection, called for each toy) ...
virtual void InitializeEvent(AnaEventC &)
Fill the EventBox with the objects needed by this selection.
void SetForceFillEventSummary(bool force)
virtual const char * GetName() const
Return the name of this selection. This overrides the TObject::GetName() interface.
Int_t GetMaxAccumCutLevelForAllToys() const
Get the maximum cut level for this event and all toys.
std::vector< UInt_t > _nCutsInBranch
Number of cuts in each branch.
std::vector< StepBase * > GetCutsInBranch(const std::string &branch) const
Get all cuts in a given branch provided the branch alias.
const ToyBoxB & GetPreviousToyBox() const
Get the ToyBox of the last processed toy (only for no MULTITHREAD)
bool Apply(AnaEventC &event, bool &redo)
Apply all steps in the selection.
std::vector< StepBase * > GetStepsInBranch(const std::vector< UInt_t > &branch_seq, UInt_t first=0, UInt_t last=NMAXSTEPS-1) const
Get all steps in a given branch provided the branch sequence (vector of integers) ...
std::vector< UInt_t > GetBranchSequence(const std::string &name) const
Get the branch sequence for a specific branch alias.
const std::string & Title() const
Return the title of this selection. A nice version of the name.
virtual bool FillEventSummary(AnaEventC &, Int_t *)
Fill the Event Summary, needed by fitters.
UInt_t GetNCuts(Int_t branch) const
Return the number of cuts in a given branch.
void RemoveStep(const std::string &title, Int_t ID=-1)
Disable step provided title and branch ID.
std::vector< UInt_t > ConvertBranch(Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1) const
Convert the branch sequence of individual integers into a vector of integers.
void Validate() const
Validates this selection.
virtual bool IsRelevantRecObjectForSystematic(const AnaEventC &, AnaRecObjectC *, SystId_h syst_index, Int_t branch=0) const
Is this track relevant for a given systematic (prior to selection, call when initializing the event...
void FinalizeEvent(const AnaEventC &event)
Delete the PreviousToyBox pointer for the last toy of the event.
virtual void DefineSteps()
Define all steps in the selection.
bool CutPassed(bool passed, Int_t branch, ToyBoxB &box)
void SetBranchAlias(Int_t ID, const std::string &name, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Set the branch alias and unique ID provided the branch sequence.
UInt_t GetNBranches() const
Return the number of branches.
virtual bool IsRelevantTrueObjectForSystematic(const AnaEventC &, AnaTrueObjectC *, SystId_h syst_index, Int_t branch=0) const
Is this true track relevant for a given systematic (prior to selection, call when initializing the ev...
std::vector< UInt_t > _nEventsPassed
Used for statistics.
void DisableStep(const std::string &title, Int_t ID=-1)
Replace a step (same structure of AddStep, but for only one step at once)
Int_t * AccumLevel
Accum level for each branch in this toy in the selection this ToyBox belongs to.
bool IsValidRun(int runPeriod) const
Method to see whether this selection should be applied to the given run period.
void SetDetectorFV(SubDetId_h det, Int_t ibranch=-1)
Set the detector in which the Fiducial Volume is defined.
std::vector< std::string > GetCutNames(Int_t ibranch=0) const
Return all the names of the cuts, in the order they were added.
void ReplaceStep(const std::string &old_title, Int_t ID, StepBase::TypeEnum type, const std::string &title, StepBase *step, bool cut_break=false)
Replace step provided title and branch ID of the step to replace.
std::string ConvertBranchToString(const std::vector< UInt_t > &branch, Int_t upToSplit=-1) const
Convert the branch sequence into a string.
StepBase * GetStep(const std::string &title, Int_t ID=0) const
Return an step provided the title and the Branch ID.
Int_t _maxAccumLevelForAllToys
This is the maximum accum level of any of the branches in all toys.
bool HasBranch(Int_t ibranch, const std::string &fromMethod="HasBranch") const
Check the existence of branch.
std::vector< StepBase * > GetStepsInBranchWithDummy(const std::vector< UInt_t > &branch_seq, UInt_t first=0, UInt_t last=NMAXSTEPS-1) const
Get all steps in a given branch provided the branch sequence (vector of integers) ...
bool _initialized
Is this selection initialized ?
virtual bool IsRelevantTrueObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaTrueObjectC *, SystId_h syst_index, Int_t branch=0) const
Is this true track relevant for a given systematic (after selection, called for each toy) ...
Int_t GetAccumCutLevel(Int_t branch=0) const
bool GetCutPassed(Int_t icut, Int_t branch=0) const
Return whether the specified cut was passed or not.
Int_t _presel_accum_cut_level
The preselection accum level.
virtual bool CheckRedoSelection(const AnaEventC &, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
ToyBoxB ** PreviousToyBox
Array of pointers to the PreviousToyBox (for each event)
Int_t GetMaxAccumCutLevel() const
Get the maximum cut level for this event and the last processed toy.
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.
virtual void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
bool _forceFillEventSummary
Int_t _current_cut[NMAXBRANCHES]
The current cut level.
Int_t GetEnabledIndex() const
Get the Selection index.
std::vector< std::vector< UInt_t > > _branchSequence
Association between a branch unique ID (entry in vector) and branch sequence.
void AddStep(StepBase::TypeEnum type, const std::string &title, StepBase *step, bool cut_break=false)
void Initialize()
Initialize this selection: defines the steps and the detectorFV.
Int_t GetCutNumber(const std::string &title, Int_t ID=0) const
Return the cut number (starting at 0) corresponding to an step with a given title.
bool GetForceFillEventSummary() const
Returns the flag to fill the EventSummary even when the selection is not passed.
Int_t GetPreSelectionAccumLevel() const
Set the pre-selection accum level.
TypeEnum
Enumerator describing the values that _type member can take.