HighLAND
antiNumuCCMultiTrackFGD2Selection.cxx
1 #include "antiNumuCCMultiTrackFGD2Selection.hxx"
2 #include "antiNumuCCMultiTrackSelection.hxx"
3 #include "antiNumuCCFGD2Selection.hxx"
4 #include "numuCCMultiPiFGD2Selection.hxx"
5 #include "baseSelection.hxx"
6 #include "CutUtils.hxx"
7 #include "Parameters.hxx"
8 #include "SubDetId.hxx"
9 #include "SystId.hxx"
10 #include "EventBoxId.hxx"
11 
12 //********************************************************************
13 antiNumuCCMultiTrackFGD2Selection::antiNumuCCMultiTrackFGD2Selection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
14 //********************************************************************
15 
16  // Initialize selections being used
17  _antiNumuCCFGD2Selection.Initialize();
18  _antiNumuCCMultiTrackSelection.Initialize();
19 }
20 
21 //********************************************************************
23 //********************************************************************
24 
25  // Copy all steps from the antiNumuCCFGD2Selection
26  CopySteps(_antiNumuCCFGD2Selection);
27 
28  //Additional actions for the multi-pi selection.
29  AddStep(StepBase::kAction, "fill summary AntiNuMuCCMultiTrackFGD2", new AntiNuMuCCMultiTrackFGD2_FillSummaryAction());
30 
31  //Add a split to the trunk with 2 branches.
32  AddSplit(2);
33 
34  //First branch is for CC 1track
35  AddStep(0, StepBase::kCut, "CC1Track", new AntiNuMuCCMultiTrackFGD2_CC1TrackCut());
36 
37  //Second branch is for CC nTracks
38  AddStep(1, StepBase::kCut, "CCNTracks", new AntiNuMuCCMultiTrackFGD2_CCNTracksCut());
39 
40  // Set the branch aliases to the three branches
41  SetBranchAlias(0,"CC1Track",0);
42  SetBranchAlias(1,"CCNTracks",1);
43 
44  // By default the preselection correspond to cuts 0-2
45  SetPreSelectionAccumLevel(2);
46 }
47 
48 //********************************************************************
50 //********************************************************************
51 
52  // The detector in which the selection is applied
53  SetDetectorFV(SubDetId::kFGD2);
54 
55  _antiNumuCCFGD2Selection.SetDetectorFV(SubDetId::kFGD2);
56  _antiNumuCCMultiTrackSelection.SetDetectorFV(SubDetId::kFGD2);
57 }
58 
59 //********************************************************************
60 bool antiNumuCCMultiTrackFGD2Selection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
61 //********************************************************************
62 
63  //CC1Track
64  if(allCutsPassed[0]){
65  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2AntiNuMuCC1Track;
66  }
67  //CCNTracks
68  else if (allCutsPassed[1]){
69  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2AntiNuMuCCNTracks;
70  }
71 
72  // otherwise kUnassigned is used from the EventSummary constructor
73  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
74 }
75 
76 //*********************************************************************
78 //*********************************************************************
79 
80  // Cast the ToyBox to the appropriate type
81  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
82 
83  if(!box.HMPtrack) return 1;
84 
85  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2AntiNuMuCC1Track] = box.HMPtrack;
86  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2AntiNuMuCCNTracks] = box.HMPtrack;
87 
88  for(int i = 0; i < 4; ++i){
89  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2AntiNuMuCC1Track][i] = box.HMPtrack->PositionStart[i];
90  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2AntiNuMuCCNTracks][i] = box.HMPtrack->PositionStart[i];
91  }
92  if(box.HMPtrack->GetTrueParticle()){
93  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2AntiNuMuCC1Track] = box.HMPtrack->GetTrueParticle()->TrueVertex;
94  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2AntiNuMuCCNTracks] = box.HMPtrack->GetTrueParticle()->TrueVertex;
95  }
96  return 1;
97 }
98 
99 //**************************************************
101 //**************************************************
102 
103  // Cast the ToyBox to the appropriate type
104  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
105 
106  if (!box.MainTrack)return false;
107  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
108  return (EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPCAndFGD2] == 1);
109 }
110 
111 //**************************************************
113 //**************************************************
114 
115  // Cast the ToyBox to the appropriate type
116  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
117 
118  if (!box.MainTrack)return false;
119  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
120  return (EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPCAndFGD2] > 1);
121 }
122 
123 
124 //**************************************************
125 bool antiNumuCCMultiTrackFGD2Selection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* track, SystId_h systId, Int_t branch) const{
126 //**************************************************
127 
128  return _antiNumuCCFGD2Selection.IsRelevantRecObjectForSystematic(event,track,systId,branch);
129 }
130 
131 //**************************************************
132 bool antiNumuCCMultiTrackFGD2Selection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueTrack, SystId_h systId, Int_t branch) const{
133 //**************************************************
134 
135  return _antiNumuCCFGD2Selection.IsRelevantTrueObjectForSystematic(event,trueTrack,systId,branch);
136 }
137 
138 //**************************************************
139 bool antiNumuCCMultiTrackFGD2Selection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
140 //**************************************************
141 
142  return _antiNumuCCMultiTrackSelection.IsRelevantSystematic(event, box, systId, branch);
143 }
144 
145 //**************************************************
147 //**************************************************
148 
149  return _antiNumuCCFGD2Selection.InitializeEvent(event);
150 }
151 
152 //********************************************************************
153 bool antiNumuCCMultiTrackFGD2Selection::CheckRedoSelection(const AnaEventC& event, const ToyBoxB& PreviousToyBox, Int_t& redoFromStep){
154 //********************************************************************
155 
156  return _antiNumuCCFGD2Selection.CheckRedoSelection(event, PreviousToyBox, redoFromStep);
157 }
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 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...
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
AnaTrackB * HMPtrack
For storing the highest momentum positive track.
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
void DefineSteps()
Define all steps in the selection.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
bool Apply(AnaEventC &event, ToyBoxB &box) const
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 Initialize()
Initialize this selection: defines the steps and the detectorFV.
bool Apply(AnaEventC &event, ToyBoxB &box) const