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