HighLAND
antiNumuCCFGD2Selection.cxx
1 #include "antiNumuCCFGD2Selection.hxx"
2 #include "antiNumuCCSelection.hxx"
3 #include "numuCCFGD2Selection.hxx"
4 #include "baseSelection.hxx"
5 #include "CutUtils.hxx"
6 #include "SubDetId.hxx"
7 #include "SystId.hxx"
8 #include "EventBoxUtils.hxx"
9 
10 //********************************************************************
11 antiNumuCCFGD2Selection::antiNumuCCFGD2Selection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
12 //********************************************************************
13 
14  // Initialize selections being used
15  _numuCCFGD2Selection.Initialize();
16 }
17 
18 //********************************************************************
20 //********************************************************************
21 
22  // Cuts must be added in the right order
23  // last "true" means the step sequence is broken if cut is not passed (default is "false")
24  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true); // cut 0
25  AddStep(StepBase::kCut, "> 0 tracks ", new TotalMultiplicityCut(), true); // cut 1
26  AddStep(StepBase::kAction, "find leading tracks", new FindLeadingTracksAction_antinu() );
27  AddStep(StepBase::kAction, "find vertex", new FindVertexAction() );
28  AddStep(StepBase::kAction, "summary", new FillSummaryAction_antiNumuCCFGD2() );
29  AddStep(StepBase::kCut, "quality+fiducial", new TrackQualityFiducialCut(), true); // cut 2
30  AddStep(StepBase::kCut, "pos_mult", new PositiveMultiplicityCut(), true); // cut 3
31  //AddStep(StepBase::kCut, "> 0 positive tracks", new PositiveMultiplicityCut_antiNumuCCFGD2(), true); // cut 3
32  AddStep(StepBase::kAction, "find veto track", new FindVetoTrackAction() );
33  AddStep(StepBase::kCut, "veto", new ExternalFGD2VetoCut(), true); // cut 4
34  AddStep(StepBase::kAction, "find oofv track", new FindOOFVTrackAction() );
35  AddStep(StepBase::kCut, "external FGD2", new ExternalFGD2LastLayersCut(), true); // cut 5
36  AddStep(StepBase::kCut, "pid", new AntiMuonPIDCut() ); // cut 6
37  //AddStep(StepBase::kCut, "HMPtrack == HMtrack", new AntiNuMuFGD2HighestMomentumTrack() ); // cut 7
38  //AddStep(StepBase::kCut, "HMNtrack is not mu-", new AntiNuMuFGD2NegativeMuonVeto() ); // cut 8
39  //AddStep(StepBase::kCut, "Vertex in layer after water", new AntiNuMuFGD2FGDLayer() ); // cut 9
40  //AddStep(StepBase::kCut, "Mu+ momentum > 200 MeV", new AntiNuMuFGD2MuPlusMomentum() ); // cut 10
41 
42  SetBranchAlias(0,"trunk");
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  // Set the detector field into the selection beaing used
56  _numuCCFGD2Selection.SetDetectorFV(SubDetId::kFGD2);
57 
58 }
59 
60 //**************************************************
61 bool antiNumuCCFGD2Selection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
62 
63  // The event sample corresponding to this selection
64  if(allCutsPassed[0]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2AntiNuMuCC;
65 
66  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
67 }
68 
69 //**************************************************
71 
72  // Cast the ToyBox to the appropriate type
73  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
74 
75  if(!box.HMPtrack) return 1;
76 
77  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2AntiNuMuCC] = box.HMPtrack;
78 
79  for(int i = 0; i < 4; i++){
80  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2AntiNuMuCC][i] = box.HMPtrack->PositionStart[i];
81  }
82 
83  if(box.HMPtrack->GetTrueParticle()){
84  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2AntiNuMuCC] = box.HMPtrack->GetTrueParticle()->TrueVertex;
85  }
86  return 1;
87 }
88 
89 // //********************************************************************
90 // bool ExternalFGD2VetoCut_antiNumuCCFGD2::Apply(AnaEventC& event, ToyBoxB& box) const{
91 // //********************************************************************
92 
93 // (void)event;
94 
95 // if (!box.MainTrack) return false;
96 // if( !cutUtils::ExternalVetoCut(*(box.MainTrack),box.VetoTrack)) return false;
97 
98 // EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
99 
100 // // Veto also whenever there's a tracker track (or just any track? to be decided) starting in FGD1
101 // // this guarantees to veto events with a muon candidate in FGD1
102 // AnaTrackB** selTracks = EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithTPC];
103 // int nTPC=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPC];
104 
105 // //loop over tpc tracks
106 // for (Int_t i=0;i<nTPC; ++i){
107 // AnaTrackB* thistrack = selTracks[i];
108 
109 // if (thistrack->Momentum < 0 ) continue; // protection for bad momentum
110 
111 // if (anaUtils::InFiducialVolume(SubDetId::kFGD1, thistrack->PositionStart )) return false;
112 // }
113 
114 // return true;
115 // }
116 
117 
118 //**************************************************
119 //bool PositiveMultiplicityCut_antiNumuCCFGD2::Apply(AnaEventC& event, ToyBoxB& box) const{
120 //**************************************************
121 
122 //(void)event;
123 
124 //if (box.HMPtrack)
125 // return true;
126 //else
127 // return false;
128 //}
129 
130 //**************************************************
131 //bool AntiNuMuFGD2HighestMomentumTrack::Apply(AnaEventC& event, ToyBoxB& box) const{
132 
133 //(void)event;
134 
135 //if(box.HMPtrack != box.HMtrack){return false;}
136 //return true;
137 //}
138 
139 //**************************************************
140 //bool AntiNuMuFGD2NegativeMuonVeto::Apply(AnaEventC& event, ToyBoxB& box) const{
141 
142 //(void)event;
143 
144 //if(!box.HMNtrack){return true;} // No muon candidate, so pass cut
145 //if(cutUtils::MuonPIDCut(*(box.HMNtrack))){return false;} // Have a muon, so fail cut
146 //else{return true;}
147 //}
148 
149 //**************************************************
150 //bool AntiNuMuFGD2FGDLayer::Apply(AnaEventC& event, ToyBoxB& box) const{
151 
152 //float pos[3] = {box.Vertex->Position[0], box.Vertex->Position[1], box.Vertex->Position[2]};
153 
154  // 0=vertical layer, 1=horizontal layer, 2=water, 3=gap: glue, air, G10, polypropilene
155  //int module = anaUtils::GetFgdModuleType(event, pos, SubDetId::kFGD2);
156 
157  //if(module == 0){return true;}
158  //return false;
159 //}
160 
161 //**************************************************
162 //bool AntiNuMuFGD2MuPlusMomentum::Apply(AnaEventC& event, ToyBoxB& box) const{
163 
164 //(void)event;
165 
166 //double mom = box.HMPtrack->Momentum;
167 //if(mom < 200){return false;}
168 //return true;
169 //}
170 
171 
172 //**************************************************
173 bool antiNumuCCFGD2Selection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* track, SystId_h systId, Int_t branch) const{
174 //**************************************************
175 
176  return _numuCCFGD2Selection.IsRelevantRecObjectForSystematic(event,track,systId,branch);
177 }
178 
179 //**************************************************
180 bool antiNumuCCFGD2Selection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueTrack, SystId_h systId, Int_t branch) const{
181 //**************************************************
182 
183  return _numuCCFGD2Selection.IsRelevantTrueObjectForSystematic(event,trueTrack,systId,branch);
184 }
185 
186 //**************************************************
187 bool antiNumuCCFGD2Selection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
188 //**************************************************
189 
190  // Nu flux is not relevant
191  if (SystId::kFluxWeightNu)
192  return false;
193 
194  // AntiNu flux is relevant
195  if (SystId::kFluxWeightAntiNu)
196  return true;
197 
198  // For the rest trust numu
199  _numuCCFGD2Selection.IsRelevantSystematic(event, box, systId, branch);
200 
201 }
202 
203 //**************************************************
205 //**************************************************
206 
207  _numuCCFGD2Selection.InitializeEvent(event);
208 }
209 
210 //********************************************************************
211 bool antiNumuCCFGD2Selection::CheckRedoSelection(const AnaEventC& event, const ToyBoxB& PreviousToyBox, Int_t& redoFromStep){
212 //********************************************************************
213 
214  return _numuCCFGD2Selection.CheckRedoSelection(event,PreviousToyBox,redoFromStep);
215 }
216 
217 
218 
void DefineSteps()
Define all steps in the selection.
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.
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...
Leading tracks with good quality in FGD1.
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 InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
Find the Vertex. For the moment it&#39;s just the Star position of the HM track.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
A cut on event quality. Requires good beam and ND280 data quality flags.
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