1 #include "SelectionBase.hxx" 2 #include "CoreUtils.hxx" 3 #include "MultiThread.hxx" 15 _branchSequence.clear();
17 _nEventsPassed.clear();
20 for(
unsigned int branch = 0; branch < NMAXBRANCHES; ++branch){
21 for(
unsigned int cut = 0; cut < NMAXSTEPS; ++cut){
22 _cut_passed_stats[branch][cut] = 0;
27 _nCutsInBranch.clear();
32 _forceBreak = forceBreak;
36 _forceFillEventSummary =
false;
40 for(
int i = 0; i < 10; ++i){
41 _validRunPeriods[i] =
true;
45 _presel_accum_cut_level = 0;
51 for (UInt_t b=0;b<NMAXBRANCHES;b++)
52 _detectorFV[b] = UNASSIGNEDID;
55 _eventBoxId = eventBoxId;
63 std::cout <<
"ERROR. SelectionBase::" << fromMethod <<
"() Unknown branch " << ibranch
64 <<
". There are " <<
GetNBranches() <<
" branches in selection of type " <<
typeid(*this).name() << std::endl;
78 else if (!
HasBranch(ibranch,
"SetDetectorFV"))
81 _detectorFV[ibranch]=det;
88 if (!
HasBranch(ibranch,
"GetDetectorFV")) exit(1);
89 return _detectorFV[ibranch];
116 std::cout <<
"SelectionBase::Validate(). Validating selection '" <<
_name <<
"' of type " <<
typeid(*this).name() <<
" .....";
120 (*it)->ValidateStepRecursive();
124 std::cout <<
"ERROR. SelectionBase::Validate(). _eventBoxId is not set in this selection. Please use the constructor to specify the EventBox to be used. " 125 <<
"The standard way is to write something like 'numuCCSelection::numuCCSelection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker)'. " 126 <<
"_eventBoxId is a integer (not an enum) and therefor values in the EventBoxId.hxx file (in psycheEventModel) can be extended using a different enum" << std::endl;
130 std::cout <<
" OK " << std::endl;
143 for (Int_t k= 0;k<nevents;k++){
168 uniqueID =
event.UniqueID;
187 uniqueID =
event.UniqueID;
200 std::cout <<
"ERROR. SelectionBase::GetPreviousToyBox() with no Event provided cannot be called in MULTITHREAD mode " << std::endl;
216 uniqueID =
event.UniqueID;
223 Int_t firstStepToApply=0;
240 if (firstStepToApply==0){
247 bool ok =
ApplySteps(event, *ToyBox, firstStepToApply);
250 Int_t all_cuts_passed[NMAXBRANCHES];
255 if(all_cuts_passed[i]) ok =
true;
270 void SelectionBase::PrintStatistics()
const{
273 std::cout <<
"----------- Statistics for selection '" <<
_name <<
"'" << std::endl;
282 void SelectionBase::PrintStatistics(UInt_t ID)
const{
287 for(
unsigned int cut = 0; cut <
GetNCuts(ID); ++cut){
288 std::cout <<
"cut " << cut <<
" = " << _cut_passed_stats[ID][cut] << std::endl;
291 std::cout <<
"SelectionBase::PrintStatistics(). No statistics can be printed in MULTITHREAD mode !!!" << std::endl;
296 void SelectionBase::PrintStatistics(
const std::string& name)
const{
317 bool passed = step.
Apply(event, ToyBox);
319 if (step.
Type() != StepBase::kCut){
338 if (step.
Index() >= firstStepToApply){
341 passed = step.
Apply(event, ToyBox);
345 if (step.
Type() == StepBase::kCut){
355 for (UInt_t i = 0; i < step.
GetNextSteps().size(); ++i){
360 if (passed) passed=passed2;
375 bool all_passed=
true;
384 Int_t ilast2 = std::min(ilast,(Int_t)steps.size());
385 for (Int_t i=ifirst;i<ilast2;i++ ){
386 bool passed =
ApplyStep(event, ToyBox, *steps[i], ID);
387 if (!passed) all_passed=
false;
390 if ((steps[i]->Break() ||
_forceBreak) && !passed)
break;
432 if (step.
Type() != StepBase::kCut)
return true;
438 for (UInt_t i = 0;i<branches.size();i++){
470 _cut_passed_stats[branch][ _current_cut[branch] ]++;
509 if (!
HasBranch(ibranch,
"GetNCuts"))
return 0;
518 std::cout <<
"ERROR. SelectionBase::DumpSteps(). Cannot dump steps before setting the branch aliases" << std::endl;
523 std::vector<std::string>::const_iterator it;
538 std::vector<std::string>::const_iterator it;
544 std::cout <<
"SelectionBase::DumpSteps(). Branch with index " << ID <<
" does not exist in selection '"<<
_name <<
"' !!!" << std::endl;
550 std::string steps_cuts =
"Steps";
551 std::stringstream sID;
554 std::string sbranch =
"branch " + sID.str() +
" --> " +
ConvertBranchToString(branch) +
" '" + alias +
"'";
556 if (onlycuts) steps_cuts =
"Cuts";
557 if (
_branchAlias.size()==1) sbranch =
" with no branches";
559 std::cout <<
"-------------------------------------------------------------------" << std::endl;
560 std::cout <<
" " << steps_cuts <<
" for selection '" <<
_name <<
"' " << sbranch << std::endl;
561 std::cout <<
"-------------------------------------------------------------------" << std::endl;
564 sprintf(out,
"%3s: %-10s %-25s %-6s %-10s",
"#",
"type",
"title",
"break",
"branches");
565 std::cout << out <<
"\n" << std::endl;
569 for (UInt_t i=0;i<steps.size();i++ ){
570 if ((!onlycuts || steps[i]->Type() == StepBase::kCut) && steps[i]->Title()!=
"dummy"){
571 if (steps[i]->IsDisabledInBranch(ID))
572 sprintf(out,
"%3d: %-10s %-25s %-6d ", step, (steps[i]->ConvertType()+
" (D)").c_str(), steps[i]->Title().c_str(), (int)steps[i]->Break());
574 sprintf(out,
"%3d: %-10s %-25s %-6d ", step, steps[i]->ConvertType().c_str(), steps[i]->
Title().c_str(), (
int)steps[i]->Break());
576 const std::vector<UInt_t>& IDs = steps[i]->GetBranchUniqueIDs();
577 for (UInt_t j=0;j<IDs.size();j++){
578 if (steps[i]->IsDisabledInBranch(IDs[j]))
579 std::cout <<
"("<<IDs[j] <<
") ";
581 std::cout << IDs[j] <<
" ";
583 std::cout << std::endl;
587 if (steps[i]->GetNextSteps().size()>1)
588 std::cout <<
"--- split with " << steps[i]->GetNextSteps().size() <<
" branches" << std::endl;
590 std::cout <<
"-------------------------------------------------------------------" << std::endl;
599 std::cout <<
"-------------------------------------------------------------------" << std::endl;
600 std::cout <<
" Branches for selection '" <<
_name <<
"' " << std::endl;
601 std::cout <<
"-------------------------------------------------------------------" << std::endl;
604 sprintf(out,
"%3s: %-25s %-10s %-10s %-10s",
"ID",
"name",
"Sequence",
"#steps",
"#cuts");
605 std::cout << out <<
"\n" << std::endl;
614 std::cout << out << std::endl;
616 std::cout <<
"-------------------------------------------------------------------" << std::endl;
629 std::cout <<
"ERROR. SelectionBase::DisableStep(). Step with title '" << title <<
"' does not exist in branch "<< ID2 << std::endl;
633 if (step->
Type() == StepBase::kAction && ID!=-1){
634 std::cout <<
"ERROR. SelectionBase::DisableStep(). Action '" << title <<
"' cannot be disabled in a single branch. " 635 <<
"Actions should be disabled in all branches. Don't specify branch ID" << std::endl;
641 for (UInt_t i=0;i<branches.size();i++)
658 std::cout <<
"ERROR. SelectionBase::DisableStep(). Step with title '" << title <<
"' does not exist in branch "<< ID2 << std::endl;
663 const std::vector<StepBase*> nextSteps = step->
GetNextSteps();
665 if (nextSteps.size() > 1){
666 std::cout <<
"ERROR. SelectionBase::DisableStep(). Step with title '" << title <<
"' in branch "<< ID2
667 <<
" cannot be removed because it contains an split (with " << nextSteps.size() <<
" branches)" << std::endl;
672 if (step->
Index() == 0){
675 std::cout <<
"ERROR. SelectionBase::RemoveStep(). branch " << ID2 <<
" not defined in first steps in selection '" <<
_name <<
"'" << std::endl;
681 std::cout <<
"ERROR. SelectionBase::RemoveStep(). Selection '" <<
_name <<
"' does not have a first step '" << title <<
"' in branch " << ID2 << std::endl;
692 if (nextSteps.size()>0)
701 if (nextSteps.size()>0)
706 std::vector<StepBase*> nextSteps2;
708 for (std::vector<StepBase*>::iterator it=nextSteps2.begin();it!=nextSteps2.end();it++){
709 (*it)->SetIndex((*it)->Index()-1);
715 void SelectionBase::InsertStep(
const std::string& previous_title, Int_t ID,
StepBase::TypeEnum type,
const std::string& title,
StepBase* step,
bool cut_break){
718 (void) previous_title;
755 void SelectionBase::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){
757 std::vector<UInt_t> branch =
ConvertBranch(b0,b1,b2,b3,b4,b5,b6,b7);
758 AddStep(branch, type, title, step, cut_break);
762 void SelectionBase::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){
764 std::vector<UInt_t> branch =
ConvertBranch(b0,b1,b2,b3,b4,b5,b6);
765 AddStep(branch, type, title, step, cut_break);
771 std::vector<UInt_t> branch =
ConvertBranch(b0,b1,b2,b3,b4,b5);
772 AddStep(branch, type, title, step, cut_break);
779 AddStep(branch, type, title, step, cut_break);
786 AddStep(branch, type, title, step, cut_break);
793 AddStep(branch, type, title, step, cut_break);
800 AddStep(branch, type, title, step, cut_break);
807 AddStep(branch, type, title, step, cut_break);
814 AddStep(branch, type, title, step, cut_break);
823 for (UInt_t i=0;i<steps.size();i++){
824 if (steps[i]->
Title() == title){
825 std::cout <<
"ERROR. SelectionBase::AddStep(). An step with title '" << title <<
"' already exists in this branch " <<
ConvertBranchToString(branch)
826 <<
" at position " << i <<
" in selection of type " <<
typeid(*this).name() << std::endl;
838 if (step->
Type() == StepBase::kCut)
854 if (step->
Title()==
"dummy") index=-1;
863 if (!laststep)
return;
864 if (branch.size()==0)
869 laststep->
AddNextStep(step, branch[branch.size()-1]);
871 index = laststep->
Index()+1;
879 void SelectionBase::AddSteps(
const std::vector<UInt_t>& branch,
const std::vector<StepBase*>& steps){
882 for (std::vector<StepBase*>::const_iterator it= steps.begin(); it!=steps.end();it++){
888 void SelectionBase::AddSplit(UInt_t nbranches, Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5, Int_t b6, Int_t b7){
891 std::vector<UInt_t> branch =
ConvertBranch(b0,b1,b2,b3,b4,b5,b6,b7);
904 std::cout <<
"SelectionBase::AddSplit(). Add split with " << nbranches <<
" branches to branch "<<
ConvertBranchToString(branch_seq) << std::endl;
908 if (!laststep)
return;
911 std::cout <<
"SelectionBase::AddSplit(). Last step in branch " <<
ConvertBranchToString(branch_seq) <<
" with title '" << laststep->
Title() <<
"'" 912 <<
" already has an split with " << laststep->
GetNextSteps().size() <<
" branches !!!!" << std::endl;
917 for (UInt_t i=0;i<nbranches;i++){
929 if ((*steps.begin())->
Title()==
"dummy")
930 steps.erase(steps.begin());
938 std::vector<StepBase*> steps;
949 (*steps.rbegin())->GetNextSteps(steps);
952 StepBase::BranchStatus status= StepBase::BranchOK;
953 for (UInt_t i=0;i<branch.size();i++){
957 if (*steps.rbegin()) status = (*steps.rbegin())->GetNextStepsInBranch(steps,branch[i]);
958 status=StepBase::BranchOK;
962 if (status==StepBase::BranchOK && *steps.rbegin()){
963 status = (*steps.rbegin())->GetNextStepsInBranch(steps,branch[i]);
964 if ((status == StepBase::NoBranches && i>0)||
965 (status == StepBase::BranchEmpty && i<branch.size()-1) ||
966 (status == StepBase::BranchOutOfRange)){
967 std::cout <<
"ERROR. SelectionBase::GetStepsInBranchWithDummy(). Branch " <<
ConvertBranchToString(branch)
968 <<
" does not exist in selection of type " <<
typeid(*this).name() <<
". ";
969 if (status==StepBase::NoBranches && i>0){
972 else if (status == StepBase::BranchEmpty && i<branch.size()-1){
975 else if (status == StepBase::BranchOutOfRange){
976 std::cout <<
"Last number in " <<
ConvertBranchToString(branch,i) <<
" is out of range" << std::endl;
985 if (first==0 && last==NMAXSTEPS-1){
990 UInt_t first2 = first;
992 UInt_t size2 = steps.size();
1000 std::vector<StepBase*> steps2;
1002 std::cout <<
"SelectionBase::GetStepsInBranchWithDummy(). Invalid first step " << first <<
", there are " << size2 <<
" steps !!!" << std::endl;
1006 std::cout <<
"SelectionBase::GetStepsInBranchWithDummy(). Invalid last step " << last <<
", there are " << size2 <<
" steps !!!" << std::endl;
1010 std::cout <<
"SelectionBase::GetStepsInBranchWithDummy(). Last step " << last <<
" smaller than first step " << size2 <<
" !!!" << std::endl;
1014 for (UInt_t i=first2;i<=last2;i++)
1015 steps2.push_back(steps[i]);
1040 std::vector<StepBase*> cuts;
1042 for (std::vector<StepBase*>::iterator it=steps.begin();it!=steps.end();it++){
1043 if ((*it)->Type() == StepBase::kCut) cuts.push_back(*it);
1065 if (steps.size()!=0)
1066 return *(steps.rbegin());
1076 std::vector<UInt_t> branch =
ConvertBranch(b0,b1,b2,b3,b4,b5,b6,b7);
1094 if (steps.size()!=0)
1095 return *(steps.begin());
1106 if (steps.size()!=0)
1107 return *(steps.begin());
1118 if (steps.size()!=0)
1119 return *(steps.begin());
1129 std::vector<UInt_t> branch;
1130 if (b0>=0) branch.push_back(b0);
1131 if (b1>=0) branch.push_back(b1);
1132 if (b2>=0) branch.push_back(b2);
1133 if (b3>=0) branch.push_back(b3);
1134 if (b4>=0) branch.push_back(b4);
1135 if (b5>=0) branch.push_back(b5);
1136 if (b6>=0) branch.push_back(b6);
1137 if (b7>=0) branch.push_back(b7);
1146 if (branch.size()==0)
return "'trunk'";
1148 std::stringstream os;
1150 UInt_t nsplits = branch.size();
1151 if (upToSplit>=0 && (UInt_t)upToSplit<branch.size())
1152 nsplits=(UInt_t)upToSplit+1;
1153 else if (upToSplit!=-1){
1154 std::cout <<
"ERROR. SelectionBase::ConvertBranchToString(). Branch sequence " <<
ConvertBranchToString(branch) <<
" has less than " << upToSplit+1 <<
" splits !!!" << std::endl;
1160 for (UInt_t i=0;i<nsplits;i++){
1171 void SelectionBase::AddBranch(Int_t ibranch,
const std::vector<UInt_t>& branch_seq,
const std::string& alias){
1178 sprintf(branch,
"branch%d", ibranch);
1192 if (steps.size()==0)
return;
1213 std::cout <<
"ERROR. SelectionBase::SetBranchAlias(). Invalid branch unique ID " << ID <<
" for branch with alias '"<< name <<
"' . It should be " <<
_branchSequence.size() << std::endl;
1220 std::cout <<
"ERROR. SelectionBase::SetBranchAlias(). Alias '" << name <<
"' cannot be used for branch " << ID <<
" since is already used for branch " << i << std::endl;
1227 std::vector<UInt_t> branch_seq =
ConvertBranch(b0, b1, b2, b3, b4, b5, b6, b7);
1236 AddBranch(ID,branch_seq,name);
1251 std::vector<StepBase*>::iterator it;
1252 for (it=steps.begin();it!=steps.end();it++){
1253 if (*it) (*it)->AddBranchUniqueID(ID);
1262 std::cout <<
"ERROR. SelectionBase::GetBranchSequence(). Branch with index " << ID <<
" does not exist in selection '"<<
_name <<
"' !!!" << std::endl;
1282 if (*it == name)
return ID;
1285 std::cout <<
"ERROR. SelectionBase::GetBranchUniqueID(). Branch with alias '" << name <<
"' does not exist in selection '"<<
_name <<
"' of type " <<
typeid(*this).name() << std::endl;
1295 if (ID<0 || ID >= (Int_t)
_branchAlias.size())
return "";
1303 std::vector<std::string> cut_names;
1305 for (std::vector<StepBase*>::iterator it=steps.begin();it!=steps.end();it++){
1306 if ((*it)->Type() == StepBase::kCut) cut_names.push_back((*it)->Title());
1315 std::vector<std::string> step_names;
1317 for (std::vector<StepBase*>::iterator it=steps.begin();it!=steps.end();it++){
1318 step_names.push_back((*it)->Title());
1330 for (std::vector<StepBase*>::iterator it=steps.begin();it!=steps.end();it++){
1331 if ((*it)->Type() == StepBase::kCut) icut ++;
1332 if ((*it)->Title() == title)
break;
1342 if (step)
return step->
Index();
1344 std::cout <<
"ERROR. SelectionBase::GetStepNumber(). Step with title '" << title <<
"' does not exist in branch "<< ID << std::endl;
1354 for (std::vector<StepBase*>::iterator it=steps.begin();it!=steps.end();it++){
1355 if ((*it)->Title() == title)
return *it;
1368 std::vector<StepBase*> steps1 = sel1.
GetStepsInBranch(branchID1, first, last);
1371 for (UInt_t i=0;i<steps1.size();i++){
1374 if (
typeid(*stepC) !=
typeid(*step)){
1375 std::cout <<
"ERROR. SelectionBase::CopySteps(). Error when cloning step '" << step->
Title() <<
"' in selection of type '" <<
typeid(*this).name() <<
"'" << std::endl;
1376 std::cout <<
" ---> Incompatiple types " <<
typeid(*stepC).name() <<
" and " <<
typeid(*step).name() << std::endl;
1377 std::cout <<
" ---> Please correct the MakeClone() method of this step" << std::endl;
1386 void SelectionBase::CopySteps(
SelectionBase& sel1, UInt_t branchID1, UInt_t first, UInt_t last, Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5, Int_t b6, Int_t b7){
1389 CopySteps(sel1, branchID1, first, last,
ConvertBranch(b0,b1,b2,b3,b4,b5,b6,b7));
1394 void SelectionBase::CopySteps(
SelectionBase& sel1,
const std::string& sbranch1, UInt_t first, UInt_t last, Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5, Int_t b6, Int_t b7){
1400 CopySteps(sel1, sel1.
GetBranchUniqueID(sbranch1), first, last,
ConvertBranch(b0,b1,b2,b3,b4,b5,b6,b7));
1411 std::cout <<
"ERROR. SelectionBase::CopySteps(). Selection of type " <<
typeid(sel1).name() <<
" has " << sel1.
GetNBranches()
1412 <<
" branches. Branch ID or name must be specified: CopySteps(SelectionBase& sel1, const std::string& sbranch1 ...) " << std::endl;
1418 CopySteps(sel1,sbranch1,0,steps1.size()-1,0);
1422 void SelectionBase::CopyStep(
SelectionBase& sel1,
const std::string& sbranch1, UInt_t istep, Int_t b0, Int_t b1, Int_t b2, Int_t b3, Int_t b4, Int_t b5, Int_t b6, Int_t b7){
1426 CopySteps(sel1,sbranch1,istep,istep,b0,b1,b2,b3,b4,b5,b6,b7);
1434 for(
int i = 0; i < 10; ++i){
1439 std::stringstream ss(runPeriods);
1446 if (ss.peek() ==
',') ss.ignore();
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.
Int_t Index() const
Return the index of this step.
void DumpBranches() const
Dumps the list of 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 ApplyStep(AnaEventC &event, ToyBoxB &box, const StepBase &step, Int_t branch=-1)
std::string GetBranchAlias(Int_t ID) const
Gets the branch alias for a given branch unique ID.
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 ...
UInt_t GetNMaxCuts() const
Return the number of steps in a given branch.
const std::vector< StepBase * > & GetNextSteps() const
Returns the vector of next steps.
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.
Int_t SelectionEnabledIndex
The enabled index of this selection this ToyBox belongs to.
const std::vector< UInt_t > & GetBranchUniqueIDs() const
Returns the vector of branche unique IDs associated to this step.
SubDetId_h DetectorFV
Indicate the FV we are interested in.
void SetValidRunPeriods(std::string runPeriods)
const std::string & Title() const
Return the title of this step.
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...
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 SetType(TypeEnum type)
Set the type of this step.
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...
Int_t GetBranchUniqueID(const std::string &name) const
Gets the branch unique ID with a given alias.
UInt_t nBranches
The number of branches in the selection this ToyBox belongs to.
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 CreateToyBoxArray(Int_t nevents)
Create the array of PreviousToyBox.
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.
Int_t SuccessfulBranch
The branch that is successful for this toy in the selection this ToyBox belongs to.
virtual bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Break() const
Return true if the cut sequence should be stopped when a cut fails.
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.
void AddNextStep(StepBase *step, Int_t branch=-1)
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) ...
void SoftReset()
Reset the ToyBoxB.
void SetBreak(bool b)
Set whether the cut sequence should be stopped when this cut fails.
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.
void FinalizeEvent(const AnaEventC &event)
Delete the PreviousToyBox pointer for the last toy of the event.
void SetIndex(Int_t index)
Set the index of this step.
virtual void DefineSteps()
Define all steps in the selection.
void SetTitle(const std::string &title)
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.
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.
void RemoveNextStep(const std::string &title, Int_t ID=0)
Remove step with a given title (and branch ID) from next steps.
void SetDetectorFV(SubDetId_h det, Int_t ibranch=-1)
Set the detector in which the Fiducial Volume is defined.
virtual void Reset()=0
Mandatory method to be implemented by the derived class. Reset the top level derived box...
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.
virtual StepBase * MakeClone()
MANDATORY FUNCTIONS !!!
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 void ResetBase()=0
Mandatory method to be implemented by the derived class. Reset the base class for the top level box...
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)
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.
TypeEnum Type() const
Return the type of this step.
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.
bool IsDisabledInBranch(Int_t branch) const
Returns true if the step is disabled in the specified branch.
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.
void DisableInBranch(Int_t branch)
Disable step in a given branch.
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.
TypeEnum
Enumerator describing the values that _type member can take.