HighLAND
antiNumuCCMultiPiFGD2Selection.cxx
1 #include "antiNumuCCMultiPiFGD2Selection.hxx"
2 #include "antiNumuCCMultiPiSelection.hxx"
3 #include "numuCCFGD2Selection.hxx"
4 #include "baseSelection.hxx"
5 #include "CutUtils.hxx"
6 #include "EventBoxUtils.hxx"
7 #include "Parameters.hxx"
8 #include "SubDetId.hxx"
9 #include "SystId.hxx"
10 #include "VersioningUtils.hxx"
11 #include "SystematicUtils.hxx"
12 
13 
14 //*******************************************************************************
15 antiNumuCCMultiPiFGD2Selection::antiNumuCCMultiPiFGD2Selection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker){
16  //*******************************************************************************
17  // Initialize selections being used
18  _antiNumuCCFGD2Selection.Initialize();
19  _antiNumuCCMultiPiSelection.Initialize();
20 }
21 
22 //*******************************************************************************
24  //*******************************************************************************
25 
26  // Copy all steps from the numuCCFGD2Selection
27  CopySteps(_antiNumuCCFGD2Selection);
28 
29  //Additional actions for the multi-pi selection.
30  AddStep(StepBase::kAction, "fill_summary_multiPiFGD2", new FillSummaryAction_antiNumuCCMultiPiFGD2());
31  AddStep(StepBase::kAction, "find_pions", new FindPionsAction_antinuCCMultiPi());
32 
33  //Add a split to the trunk with 3 branches.
34  AddSplit(3);
35 
36  //First branch is for CC-0pi
37  AddStep(0, StepBase::kCut, "CC-0pi", new NoPionCut_antinuCCMultiPi());
38  //AddStep(0, StepBase::kCut, "ECal Pi0 veto", new EcalPi0VetoCut());
39 
40  //Second branch is for CC-1pi
41  AddStep(1, StepBase::kCut, "CC-1pi", new OnePionCut_antinuCCMultiPi());
42  //AddStep(1, StepBase::kCut, "ECal Pi0 veto", new EcalPi0VetoCut());
43 
44  //Third branch is for CC-Other
45  AddStep(2, StepBase::kCut, "CC-Other", new OthersCut_antinuCCMultiPi());
46 
47  // Set the branch aliases to the three branches
48  SetBranchAlias(0,"CC-0pi",0);
49  SetBranchAlias(1,"CC-1pi",1);
50  SetBranchAlias(2,"CC-Other",2);
51 
52  // By default the preselection correspond to cuts 0-2
53  SetPreSelectionAccumLevel(2);
54 }
55 
56 
57 //*******************************************************************************
59  //*******************************************************************************
60 
61  // The detector in which the selection is applied
62  SetDetectorFV(SubDetId::kFGD2);
63 
64  _antiNumuCCMultiPiSelection.SetDetectorFV(SubDetId::kFGD2);
65  _antiNumuCCFGD2Selection.SetDetectorFV(SubDetId::kFGD2);
66 
67 }
68 
69 //********************************************************************
70 bool antiNumuCCMultiPiFGD2Selection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
71  //********************************************************************
72 
73  //CC0pi
74  if(allCutsPassed[0]){
75  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2AntiNuMuCC0Pi;
76  }
77  //CC1pi
78  else if (allCutsPassed[1]){
79  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2AntiNuMuCC1Pi;
80  }
81  //CCOther
82  else if (allCutsPassed[2]){
83  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2AntiNuMuCCOther;
84  }
85 
86  // otherwise kUnassigned is used from the EventSummary constructor
87  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
88 }
89 
90 
91 //*********************************************************************
93  //*********************************************************************
94 
95  // Cast the ToyBox to the appropriate type
96  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
97 
98  if(!box.HMPtrack) return 1;
99 
100  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2AntiNuMuCC0Pi] = box.HMPtrack;
101  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2AntiNuMuCC1Pi] = box.HMPtrack;
102  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2AntiNuMuCCOther] = box.HMPtrack;
103 
104  for(int i = 0; i < 4; ++i){
105  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2AntiNuMuCC0Pi][i] = box.HMPtrack->PositionStart[i];
106  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2AntiNuMuCC1Pi][i] = box.HMPtrack->PositionStart[i];
107  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2AntiNuMuCCOther][i] = box.HMPtrack->PositionStart[i];
108  }
109  if(box.HMPtrack->GetTrueParticle()){
110  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2AntiNuMuCC0Pi] = box.HMPtrack->GetTrueParticle()->TrueVertex;
111  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2AntiNuMuCC1Pi] = box.HMPtrack->GetTrueParticle()->TrueVertex;
112  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2AntiNuMuCCOther] = box.HMPtrack->GetTrueParticle()->TrueVertex;
113  }
114  return 1;
115 }
116 
117 //**************************************************
118 bool antiNumuCCMultiPiFGD2Selection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* track, SystId_h systId, Int_t branch) const{
119  //**************************************************
120 
121  return _antiNumuCCFGD2Selection.IsRelevantRecObjectForSystematic(event,track,systId,branch);
122 }
123 
124 //**************************************************
125 bool antiNumuCCMultiPiFGD2Selection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueTrack, SystId_h systId, Int_t branch) const{
126  //**************************************************
127 
128  return _antiNumuCCFGD2Selection.IsRelevantTrueObjectForSystematic(event,trueTrack,systId,branch);
129 }
130 
131 //**************************************************
132 bool antiNumuCCMultiPiFGD2Selection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
133  //**************************************************
134 
135  return _antiNumuCCMultiPiSelection.IsRelevantSystematic(event,box,systId,branch);
136 }
137 
138 //**************************************************
140  //**************************************************
141 
142  AnaEventB& event = *static_cast<AnaEventB*>(&eventBB);
143 
144  _antiNumuCCFGD2Selection.InitializeEvent(event);
145  boxUtils::FillTracksWithECal(event);
146 
147 }
148 
149 //********************************************************************
150 bool antiNumuCCMultiPiFGD2Selection::CheckRedoSelection(const AnaEventC& event, const ToyBoxB& PreviousToyBox, Int_t& redoFromStep){
151  //********************************************************************
152 
153  return _antiNumuCCMultiPiSelection.CheckRedoSelection(event, PreviousToyBox, redoFromStep);
154 }
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
void DefineSteps()
Define all steps in the selection.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
AnaTrackB * HMPtrack
For storing the highest momentum positive track.
bool IsRelevantTrueObjectForSystematic(const AnaEventC &event, AnaTrueObjectC *trueObj, SystId_h systId, Int_t branch) const
Is this true track relevant for a given systematic (prior to selection, call when initializing the ev...
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
bool IsRelevantRecObjectForSystematic(const AnaEventC &event, AnaRecObjectC *recObj, SystId_h systId, Int_t branch) const
Is this track relevant for a given systematic (prior to selection, call when initializing the event...
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
void Initialize()
Initialize this selection: defines the steps and the detectorFV.