HighLAND
numuCC4piSelection.cxx
1 #include "numuCC4piSelection.hxx"
2 #include "baseSelection.hxx"
3 #include "CutUtils.hxx"
4 #include "EventBoxUtils.hxx"
5 #include "VersioningUtils.hxx"
6 #include "SystematicUtils.hxx"
7 #include "trackerSelectionUtils.hxx"
8 #include "numuCC4piUtils.hxx"
9 
10 
11 //********************************************************************
12 numuCC4piSelection::numuCC4piSelection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
13 //********************************************************************
14 
15 
16 }
17 
18 //********************************************************************
20 //********************************************************************
21 
22  //last true means that if that cut is not fulfill the sequence is stop
23  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true); //if passed accum_level=1
24  AddStep(StepBase::kCut, "> 0 tracks ", new TotalMultiplicityCut(), true); //if passed accum_level=2
25  AddStep(StepBase::kAction, "Sort TPC tracks", new SortTracksAction());
26  AddStep(StepBase::kCut, "quality+fiducial", new TrackGQandFVCut(), true); //if passed accum_level=3
27  AddStep(StepBase::kAction, "veto Action", new VetoAction());
28  AddStep(StepBase::kAction, "muon PID Action", new PIDAction());
29  AddStep(StepBase::kAction, "find vertex", new FindVertexAction());
30  AddStep(StepBase::kAction, "fill summary", new FillSummaryAction_numuCC4pi());
31 
32  AddSplit(4);
33 
34  AddStep(0, StepBase::kCut, "Fwd Quality Cut", new Fwd_Quality()); //if passed accum_level=4
35  AddStep(0, StepBase::kCut, "Fwd Veto Cut", new Fwd_Veto()); //if passed accum_level=5
36 
37  AddSplit(3,0);
38 
39  AddStep(0, 0, StepBase::kCut, "Fwd PID Cut", new Fwd_PID()); //if passed accum_level=6
40  AddStep(0, 0, StepBase::kCut, "Fwd 4pi Cut", new Fwd_4pi()); //if passed accum_level=7
41  AddStep(0, 1, StepBase::kCut, "CSFGD2 PID Cut", new CSFGD2_PID());
42  AddStep(0, 1, StepBase::kCut, "CSFGD2 4pi Cut", new CSFGD2_4pi());
43  AddStep(0, 2, StepBase::kCut, "CSECAL PID Cut", new CSECAL_PID());
44  AddStep(0, 2, StepBase::kCut, "CSECAL 4pi Cut", new CSECAL_4pi());
45 
46  AddStep(1, StepBase::kCut, "Bwd Quality Cut", new Bwd_Quality());
47  AddStep(1, StepBase::kCut, "Bwd Veto Cut", new Bwd_Veto());
48  AddStep(1, StepBase::kCut, "Bwd PID Cut", new Bwd_PID());
49  AddStep(1, StepBase::kCut, "Bwd 4pi Cut", new Bwd_4pi());
50 
51  AddStep(2, StepBase::kCut, "HAFwd Quality Cut", new HAFwd_Quality());
52  AddStep(2, StepBase::kCut, "HAFwd Veto Cut", new HAFwd_Veto());
53  AddStep(2, StepBase::kCut, "HAFwd PID Cut", new HAFwd_PID());
54  AddStep(2, StepBase::kCut, "HAFwd 4pi Cut", new HAFwd_4pi());
55 
56  AddStep(3, StepBase::kCut, "HABwd Quality Cut", new HABwd_Quality());
57  AddStep(3, StepBase::kCut, "HABwd Veto Cut", new HABwd_Veto());
58  AddStep(3, StepBase::kCut, "HABwd PID Cut", new HABwd_PID());
59  AddStep(3, StepBase::kCut, "HABwd 4pi Cut", new HABwd_4pi());
60 
61  SetBranchAlias(0, "Fwd", 0, 0);
62  SetBranchAlias(1, "Bwd", 1);
63  SetBranchAlias(2, "HAFwd", 2);
64  SetBranchAlias(3, "HABwd", 3);
65  SetBranchAlias(4, "CSFGD2", 0, 1);
66  SetBranchAlias(5, "CSECAL", 0, 2);
67 
68  //if first two cuts are not fulfill dont throw toys
69  SetPreSelectionAccumLevel(2);
70 
71 }
72 
73 //********************************************************************
75 //********************************************************************
76 
77  // Change FV definition to take all thickness
78  // Note! this will affect all downstream stuff
79  FVDef::FVdefminFGD1[2] = 0;
80  FVDef::FVdefmaxFGD1[2] = 0;
81 
82  // The detector in which the selection is applied
83  SetDetectorFV(SubDetId::kFGD1);
84 
85 }
86 
87 //**************************************************
89 //**************************************************
90 
91  AnaEventB& event = *static_cast<AnaEventB*>(&eventBB);
92 
93  // Create the appropriate EventBox if it does not exist yet
94  if (!event.EventBoxes[EventBoxId::kEventBoxTracker]) event.EventBoxes[EventBoxId::kEventBoxTracker] = new EventBoxTracker();
95 
96  boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
97  boxUtils::FillTracksWithFGD(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
98  boxUtils::FillTracksWithECal(event);
99 
100  boxUtils::FillTrajsChargedInTPC(event);
101  boxUtils::FillTrajsChargedInFGDAndNoTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
102  boxUtils::FillTrajsChargedHATracker(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
103  boxUtils::FillTrajsInECal(event);
104 
105 }
106 
107 //********************************************************************
108 bool numuCC4piSelection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
109 //********************************************************************
110 
111  if(allCutsPassed[0]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
112  if(allCutsPassed[1]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
113  if(allCutsPassed[2]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
114  if(allCutsPassed[3]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
115  if(allCutsPassed[4]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
116  if(allCutsPassed[5]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
117 
118  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kFGD1NuMuCC);
119 }
120 
121 //**************************************************
123 //**************************************************
124 
125  (void)box;
126 
127  // Check we have at least one reconstructed track in the FGD
128  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
129  return (EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithFGD1]>0);
130 
131 }
132 
133 //**************************************************
135 //**************************************************
136 
137  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
138 
139  // Retrieve the EventBoxTracker
140  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
141 
142  //Find TPCGoodQuality tracks in Fwd and Bwd
143  int nTPC=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV];
144  for (Int_t i=0;i<nTPC; ++i){
145  AnaTrackB* track = static_cast<AnaTrackB*>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV][i]);
146  if ( track->Charge!=-1 ) continue;
147  cc4pibox->LowAngle.push_back(track);
148  }
149  //Sort TPCGoodQuality using Momentum
150  std::sort(cc4pibox->LowAngle.begin(), cc4pibox->LowAngle.end(), numuCC4pi_utils::HGlobalMomFirst);
151 
152  int nECALTracks=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithECal];
153  for(int i=0;i<nECALTracks;i++){
154  AnaTrackB* track = static_cast<AnaTrackB*>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithECal][i]);
155  if ( anaUtils::InFiducialVolume(SubDetId::kFGD1, track->PositionStart) ) {
156  if ( cutUtils::TrackQualityCut(*track) ) continue;
157  if ( cutUtils::StoppingBrECALorSMRDCut(track->PositionEnd)==-1 ) continue;
158  cc4pibox->HighAngle.push_back(track);
159  }
160  }
161  //Sort HighAngle using RangeMomentum
162  std::sort(cc4pibox->HighAngle.begin(), cc4pibox->HighAngle.end(), numuCC4pi_utils::HRangeMomFirst);
163 
164  return true;
165 
166 }
167 
168 //**************************************************
170 //**************************************************
171 
172  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
173 
174  for(UInt_t i=0;i<cc4pibox->LowAngle.size();i++ ){
175  if ( anaUtils::InFiducialVolume(SubDetId::kFGD1, cc4pibox->LowAngle[i]->PositionStart, LAFVmin, LAFVmax) ){
176  if ( ToFSenseCorrector::IsForward(*cc4pibox->LowAngle[i]) ) cc4pibox->FwdTracks.push_back(cc4pibox->LowAngle[i]);
177  else cc4pibox->BwdTracks.push_back(cc4pibox->LowAngle[i]);
178  break;
179  }
180  }
181 
182  for(UInt_t i=0;i<cc4pibox->HighAngle.size();i++){
183  if ( anaUtils::InFiducialVolume(SubDetId::kFGD1, cc4pibox->HighAngle[i]->PositionStart, HAFVmin, HAFVmax) ) {
184  if ( ToFSenseCorrector::IsForward(*cc4pibox->HighAngle[i]) ) cc4pibox->HAFwdTracks.push_back(cc4pibox->HighAngle[i]);
185  else cc4pibox->HABwdTracks.push_back(cc4pibox->HighAngle[i]);
186  }
187  }
188 
189  if ( cc4pibox->FwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->FwdTracks[0]; return true; }
190  else if ( cc4pibox->BwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->BwdTracks[0]; return true; }
191  else if ( cc4pibox->HAFwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->HAFwdTracks[0]; return true; }
192  else if ( cc4pibox->HABwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->HABwdTracks[0]; return true; }
193 
194  return false;
195 
196 }
197 
198 //**************************************************
199 bool VetoAction::Apply(AnaEventC& event, ToyBoxB& box) const{
200 //**************************************************
201 
202  AnaEventB& eventB = *static_cast<AnaEventB*>(&event);
203 
204  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
205 
206  for (UInt_t i=0;i<cc4pibox->FwdTracks.size();i++){
207  if ( numuCC4pi_utils::VetoCut(0,eventB,*(cc4pibox->FwdTracks[i])) ) {
208  if ( numuCC4pi_utils::ExternalCut(0,event,*(cc4pibox->FwdTracks[i])) ) cc4pibox->FwdTracks_Veto.push_back(cc4pibox->FwdTracks[i]);
209  }
210  }
211 
212  for (UInt_t i=0;i<cc4pibox->BwdTracks.size();i++){
213  cc4pibox->BwdTracks_Veto.push_back(cc4pibox->BwdTracks[i]);
214  }
215 
216  for (UInt_t i=0;i<cc4pibox->HAFwdTracks.size();i++){
217  if ( numuCC4pi_utils::VetoCut(2,eventB,*(cc4pibox->HAFwdTracks[i])) ) cc4pibox->HAFwdTracks_Veto.push_back(cc4pibox->HAFwdTracks[i]);
218  }
219 
220  for (UInt_t i=0;i<cc4pibox->HABwdTracks.size();i++){
221  if ( numuCC4pi_utils::VetoCut(3,eventB,*(cc4pibox->HABwdTracks[i])) ) cc4pibox->HABwdTracks_Veto.push_back(cc4pibox->HABwdTracks[i]);
222  }
223 
224  if ( cc4pibox->FwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->FwdTracks_Veto[0];
225  else if ( cc4pibox->BwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->BwdTracks_Veto[0];
226  else if ( cc4pibox->HAFwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->HAFwdTracks_Veto[0];
227  else if ( cc4pibox->HABwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->HABwdTracks_Veto[0];
228 
229  return true;
230 
231 }
232 
233 //**************************************************
234 bool PIDAction::Apply(AnaEventC& event, ToyBoxB& box) const{
235 //**************************************************
236 
237  (void)event;
238 
239  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
240 
241  for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
242  if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==1 ) cc4pibox->FwdTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
243  }
244 
245  for (UInt_t i=0;i<cc4pibox->BwdTracks_Veto.size();i++){
246  if ( numuCC4pi_utils::PIDCut(1,*(cc4pibox->BwdTracks_Veto[i]))==1 ) cc4pibox->BwdTracks_PID.push_back(cc4pibox->BwdTracks_Veto[i]);
247  }
248 
249  for (UInt_t i=0;i<cc4pibox->HAFwdTracks_Veto.size();i++){
250  if ( numuCC4pi_utils::PIDCut(2,*(cc4pibox->HAFwdTracks_Veto[i]))==1 ) cc4pibox->HAFwdTracks_PID.push_back(cc4pibox->HAFwdTracks_Veto[i]);
251  }
252 
253  for (UInt_t i=0;i<cc4pibox->HABwdTracks_Veto.size();i++){
254  if ( numuCC4pi_utils::PIDCut(3,*(cc4pibox->HABwdTracks_Veto[i]))==1 ) cc4pibox->HABwdTracks_PID.push_back(cc4pibox->HABwdTracks_Veto[i]);
255  }
256 
257  for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
258  if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==2 ) cc4pibox->CSFD2Tracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
259  }
260 
261  for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
262  if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==3 ) cc4pibox->CSECALTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
263  }
264 
265  if ( cc4pibox->FwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->FwdTracks_PID[0];
266  else if ( cc4pibox->BwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->BwdTracks_PID[0];
267  else if ( cc4pibox->HAFwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->HAFwdTracks_PID[0];
268  else if ( cc4pibox->HABwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->HABwdTracks_PID[0];
269  else if ( cc4pibox->CSFD2Tracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->CSFD2Tracks_PID[0];
270  else if ( cc4pibox->CSECALTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->CSECALTracks_PID[0];
271 
272  return true;
273 
274 }
275 
276 //Define vertex
277 //**************************************************
278 bool FindVertexAction::Apply(AnaEventC& event, ToyBoxB& boxB) const{
279 //**************************************************
280 
281  (void)event;
282 
283  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
284  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&boxB);
285 
286  // reset the vertex
287  box.Vertex = NULL;
288  box.TrueVertex = NULL;
289 
290  if ( !cc4pibox->MainTrack ) return false;
291  box.MainTrack = cc4pibox->MainTrack;
292 
293  box.Vertex = new AnaVertexB();
294  anaUtils::CreateArray(box.Vertex->Particles, 1);
295 
296  box.Vertex->nParticles = 0;
297  box.Vertex->Particles[box.Vertex->nParticles++] = box.MainTrack;
298 
299  for(int i = 0; i < 4; ++i) box.Vertex->Position[i] = box.MainTrack->PositionStart[i];
300 
301  if ( box.MainTrack->GetTrueParticle() ) box.TrueVertex = box.Vertex->TrueVertex = cc4pibox->MainTrack->GetTrueParticle()->TrueVertex;
302 
303  return true;
304 
305 }
306 
307 //********************************************************************
309  //********************************************************************
310 
311  // Cast the ToyBox to the appropriate type
312  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
313 
314  if(!box.MainTrack) return 1;
315 
316  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuCC] = box.MainTrack;
317 
318  for(int i = 0; i < 4; ++i) static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuCC][i] = box.MainTrack->PositionStart[i];
319 
320  if(box.MainTrack->GetTrueParticle()) static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuCC] = box.MainTrack->GetTrueParticle()->TrueVertex;
321 
322  return true;
323 
324 }
325 
326 //**************************************************
328 //**************************************************
329  (void)event;
330  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
331  if (cc4pibox->FwdTracks.size()>0) return true;
332  return false;
333 }
334 //**************************************************
335 bool Fwd_Veto::Apply(AnaEventC& event, ToyBoxB& box) const{
336 //**************************************************
337  (void)event;
338  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
339  if (cc4pibox->FwdTracks_Veto.size()>0) return true;
340  return false;
341 }
342 //**************************************************
343 bool Fwd_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
344 //**************************************************
345  (void)event;
346  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
347  if (cc4pibox->FwdTracks_PID.size()>0) return true;
348  return false;
349 }
350 //**************************************************
351 bool Fwd_4pi::Apply(AnaEventC& event, ToyBoxB& box) const{
352 //**************************************************
353  (void)event;
354  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
355  if (cc4pibox->FwdTracks_PID.size()>0) return true;
356  return false;
357 }
358 
359 //**************************************************
361 //**************************************************
362  (void)event;
363  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
364  if (cc4pibox->BwdTracks.size()>0) return true;
365  return false;
366 }
367 //**************************************************
368 bool Bwd_Veto::Apply(AnaEventC& event, ToyBoxB& box) const{
369 //**************************************************
370  (void)event;
371  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
372  if (cc4pibox->BwdTracks_Veto.size()>0) return true;
373  return false;
374 }
375 //**************************************************
376 bool Bwd_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
377 //**************************************************
378  (void)event;
379  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
380  if (cc4pibox->BwdTracks_PID.size()>0) return true;
381  return false;
382 }
383 //**************************************************
384 bool Bwd_4pi::Apply(AnaEventC& event, ToyBoxB& box) const{
385 //**************************************************
386  (void)event;
387  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
388  if (cc4pibox->BwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0) return true;
389  return false;
390 }
391 
392 //**************************************************
394 //**************************************************
395  (void)event;
396  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
397  if (cc4pibox->HAFwdTracks.size()>0) return true;
398  return false;
399 }
400 //**************************************************
401 bool HAFwd_Veto::Apply(AnaEventC& event, ToyBoxB& box) const{
402 //**************************************************
403  (void)event;
404  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
405  if (cc4pibox->HAFwdTracks_Veto.size()>0) return true;
406  return false;
407 }
408 //**************************************************
409 bool HAFwd_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
410 //**************************************************
411  (void)event;
412  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
413  if (cc4pibox->HAFwdTracks_PID.size()>0) return true;
414  return false;
415 }
416 //**************************************************
417 bool HAFwd_4pi::Apply(AnaEventC& event, ToyBoxB& box) const{
418 //**************************************************
419  (void)event;
420  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
421  if (cc4pibox->HAFwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0) return true;
422  return false;
423 }
424 
425 //**************************************************
427 //**************************************************
428  (void)event;
429  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
430  if (cc4pibox->HABwdTracks.size()>0) return true;
431  return false;
432 }
433 //**************************************************
434 bool HABwd_Veto::Apply(AnaEventC& event, ToyBoxB& box) const{
435 //**************************************************
436  (void)event;
437  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
438  if (cc4pibox->HABwdTracks_Veto.size()>0) return true;
439  return false;
440 }
441 //**************************************************
442 bool HABwd_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
443 //**************************************************
444  (void)event;
445  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
446  if (cc4pibox->HABwdTracks_PID.size()>0) return true;
447  return false;
448 }
449 //**************************************************
450 bool HABwd_4pi::Apply(AnaEventC& event, ToyBoxB& box) const{
451 //**************************************************
452  (void)event;
453  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
454  if (cc4pibox->HABwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0) return true;
455  return false;
456 }
457 
458 //**************************************************
459 bool CSFGD2_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
460 //**************************************************
461  (void)event;
462  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
463  if (cc4pibox->CSFD2Tracks_PID.size()>0) return true;
464  return false;
465 }
466 //**************************************************
467 bool CSFGD2_4pi::Apply(AnaEventC& event, ToyBoxB& box) const{
468 //**************************************************
469  (void)event;
470  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
471  if (cc4pibox->CSFD2Tracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0 && cc4pibox->HABwdTracks_PID.size()==0) return true;
472  return false;
473 }
474 
475 //**************************************************
476 bool CSECAL_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
477 //**************************************************
478  (void)event;
479  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
480  if (cc4pibox->CSECALTracks_PID.size()>0) return true;
481  return false;
482 }
483 //**************************************************
484 bool CSECAL_4pi::Apply(AnaEventC& event, ToyBoxB& box) const{
485 //**************************************************
486  (void)event;
487  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
488  if (cc4pibox->CSECALTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0 && cc4pibox->HABwdTracks_PID.size()==0 && cc4pibox->CSFD2Tracks_PID.size()==0) return true;
489  return false;
490 }
491 
492 //**************************************************
493 bool numuCC4piSelection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
494 //**************************************************
495 
496  (void)event;
497  (void)box;
498 
499  if(systId == SystId::kPileUp){
500  if (branch==1) return false;
501  }
502 
503  return true;
504 
505 }
506 
507 //**************************************************
508 bool numuCC4piSelection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
509 //**************************************************
510 
511  (void)event;
512  (void)branch;
513 
514  AnaTrackB* track = static_cast<AnaTrackB*>(recObj);
515 
516  if (!track) return false;
517  if (!track->TrueObject) return false;
518 
519  return true;
520 
521 }
522 
523 //**************************************************
524 bool numuCC4piSelection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
525 //**************************************************
526 
527  (void)event;
528  (void)branch;
529 
530  AnaTrueParticleB* trueTrack = static_cast<AnaTrueParticleB*>(trueObj);
531 
532  if (!trueTrack) return false;
533 
534  return true;
535 
536 }
537 
538 //**************************************************
539 bool numuCC4piSelection::IsRelevantRecObjectForSystematicInToy(const AnaEventC& event, const ToyBoxB& boxB, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
540 //**************************************************
541 
542  (void)event;
543  (void)branch;
544 
545  const ToyBoxCC4pi& cc4pibox = *static_cast<const ToyBoxCC4pi*>(&boxB);
546 
547  AnaTrackB* track = static_cast<AnaTrackB*>(recObj);
548 
549  if(systId == SystId::kOOFV){
550  if (branch==1 || branch==3) return false;
551  }
552  if(systId == SystId::kTpcClusterEff){
553  if (track->nTPCSegments > 0) {
555  if (tpcTrack) {
556  if (tpcTrack->NNodes > 16 && tpcTrack->NNodes < 19) return true;
557  }
558  }
559  return false;
560  }
561  if(systId == SystId::kChargeIDEff){
562  if (track == cc4pibox.MainTrack) return true;
563  return false;
564  }
565  if(systId == SystId::kTpcFgdMatchEff){
566  if (track == cc4pibox.MainTrack) return true;
567  return false;
568  }
569  if(systId == SystId::kECalPID){
570  if (track == cc4pibox.MainTrack) {
571  if (branch==2 || branch==3) return true;
572  else if (branch==0 || branch==4 || branch==5) {
573  if ( anaUtils::TrackUsesDet(*track,SubDetId::kTECAL) ) return true;
574  if ( anaUtils::InFiducialVolume(SubDetId::kDSECAL, track->PositionEnd, _FVdefminDsECal, _FVdefmaxDsECal) ) return true;
575  }
576  }
577  return false;
578  }
579 
580  return true;
581 
582 }
583 
584 //**************************************************
585 bool numuCC4piSelection::IsRelevantTrueObjectForSystematicInToy(const AnaEventC& event, const ToyBoxB& boxB, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
586 //**************************************************
587 
588  (void)event;
589  (void)branch;
590 
591  const ToyBoxCC4pi& cc4pibox = *static_cast<const ToyBoxCC4pi*>(&boxB);
592 
593  AnaTrueParticleB* trueTrack = static_cast<AnaTrueParticleB*>(trueObj);
594 
595  if ( !cc4pibox.MainTrack->GetTrueParticle() ) return false;
596 
597  if(systId == SystId::kTpcTrackEff){
598  if (trueTrack->PDG == 13 && cc4pibox.MainTrack->GetTrueParticle()->PDG!=13) return true;
599  if (branch!=2 && branch!=3) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
600  return false;
601  }
602  if(systId == SystId::kECalTrackEff){
603  if (trueTrack->PDG == 13 && cc4pibox.MainTrack->GetTrueParticle()->PDG!=13) return true;
604  if (branch==2 || branch==3) {
605  if (cc4pibox.MainTrack->nTPCSegments == 0) {
606  if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true;
607  }
608  }
609  return false;
610  }
611  if(systId == SystId::kTpcECalMatchEff){
612  if (branch>-1 && branch<6) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
613  return false;
614  }
615  if(systId == SystId::kTpcP0dMatchEff){
616  if (branch==1) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
617  return false;
618  }
619  if(systId == SystId::kFgdECalMatchEff){
620  if (branch==2 || branch==3) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
621  return false;
622  }
623  if(systId == SystId::kFgdECalSmrdMatchEff){
624  if (branch==2 || branch==3) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
625  return false;
626  }
627  if(systId == SystId::kSIPion){
628  // If this trueTrack is associated to the MainTrack
629  if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID){
630  if (abs(cc4pibox.MainTrack->GetTrueParticle()->PDG) == 211) return true;
631  if (abs(cc4pibox.MainTrack->GetTrueParticle()->ParentPDG) == 211) return true;
632  if (abs(cc4pibox.MainTrack->GetTrueParticle()->GParentPDG) == 211) return true;
633  }
634  // If this trueTrack is NOT associated to the MainTrack, consider the posibility of this trueTrack to become the MainTrack and be identified as muon
635  // For the moment assume a negative pion may become the MainTrack if its momentum its above 90% of the current MainTrack momentum.
636  // Ideally we should check that this true pion is not associated to any reconstructed track, but this is not possible now without looping.
637  // Multiply by the charge of the MainTrack such that it can be use for antiNumu selection
638  if (trueTrack->PDG == 211*((Int_t)cc4pibox.MainTrack->Charge) && trueTrack->Momentum > 0.9*cc4pibox.MainTrack->Momentum) return true;
639  return false;
640  }
641  if(systId == SystId::kSIProton){
642  // If this trueTrack is associated to the MainTrack
643  if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID){
644  if (cc4pibox.MainTrack->GetTrueParticle()->PDG == 2212) return true;
645  if (cc4pibox.MainTrack->GetTrueParticle()->ParentPDG == 2212) return true;
646  if (cc4pibox.MainTrack->GetTrueParticle()->GParentPDG == 2212) return true;
647  }
648  return false;
649  }
650 
651  return true;
652 
653 }
654 
655 //********************************************************************
656 bool numuCC4piSelection::CheckRedoSelection(const AnaEventC& eventBB, const ToyBoxB& PreviousToyBoxB, Int_t& redoFromStep){
657 //********************************************************************
658 
659  (void)eventBB;
660  (void)PreviousToyBox;
661  (void)redoFromStep;
662 
663  return true;
664 
665 }
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
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
Float_t PositionStart[4]
The reconstructed start position of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueVertexB * TrueVertex
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
static bool IsForward(const AnaTrackB &track)
Check whether a track is forward going.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Position[4]
The identified position of the global vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t NNodes
The number of nodes in the reconstructed object.
Int_t GParentPDG
The PDG code of this particle&#39;s grandparent, or 0 if there is no grandparent.
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Momentum
The initial momentum of the true particle.
AnaTrueVertexB * TrueVertex
For storing the true vertex, for analyses with no reconstructed primary vertex.
Definition: ToyBoxND280.hxx:22
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool TrackUsesDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
Float_t Charge
The reconstructed charge of the particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
bool Apply(AnaEventC &event, ToyBoxB &box) const
void DefineSteps()
Define all steps in the selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
AnaVertexB * Vertex
For storing the reconstructed vertex.
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
bool IsRelevantTrueObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaTrueObjectC *, SystId_h systId, Int_t branch=0) const
Is this true track relevant for a given systematic (after selection, called for each toy) ...
Int_t PDG
The PDG code of this particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t ParentPDG
The PDG code of this particle&#39;s immediate parent, or 0 if there is no parent.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Representation of a global track.
Representation of a TPC segment of a global track.
AnaParticleB ** Particles
AnaTrackB * MainTrack
For storing tracks information in the bunch.
Representation of a global vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
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 Apply(AnaEventC &event, ToyBoxB &box) const
Find the Vertex. For the moment it&#39;s just the Star position of the HM track.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaParticleB * GetSegmentWithMostNodesInClosestTpc(const AnaTrackB &track)
Combined function to address NuMu selection needs as efficiently as possible - gets the TPC segment w...
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
bool InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool IsRelevantRecObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaRecObjectC *, SystId_h systId, Int_t branch=0) const
Is this track relevant for a given systematic (after selection, called for each toy) ...
bool Apply(AnaEventC &event, ToyBoxB &box) const
A cut on event quality. Requires good beam and ND280 data quality flags.
Float_t PositionEnd[4]
The reconstructed end position of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const