HighLAND
numuCC4piSelection.cxx
1 #include "numuCC4piSelection.hxx"
2 #include "baseSelection.hxx"
3 #include "SystematicTuning.hxx"
4 #include "CutUtils.hxx"
5 #include "EventBoxUtils.hxx"
6 #include "Parameters.hxx"
7 #include "SubDetId.hxx"
8 #include "SystId.hxx"
9 #include "SystematicUtils.hxx"
10 
11 
12 //********************************************************************
13 numuCC4piSelection::numuCC4piSelection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
14  //********************************************************************
15 
16  // Initialize systematic tuning parameters
17  systTuning::Initialize();
18 }
19 
20 //********************************************************************
22  //********************************************************************
23 
24  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true); //if passed accum_level=1
25  AddStep(StepBase::kCut, "> 0 tracks ", new numuCC4pi::TotalMultiplicityCut(), true); //if passed accum_level=2
26  AddStep(StepBase::kAction, "Sort TPC tracks", new numuCC4pi::SortTracksAction());
27  AddStep(StepBase::kCut, "quality+fiducial", new numuCC4pi::TrackGQandFVCut(), true); //if passed accum_level=3
28  AddStep(StepBase::kAction, "veto Action", new numuCC4pi::VetoAction());
29  AddStep(StepBase::kAction, "muon PID Action", new numuCC4pi::PIDAction());
30  AddStep(StepBase::kAction, "find vertex", new numuCC4pi::FindVertexAction());
31  AddStep(StepBase::kAction, "fill summary", new FillSummaryAction_numuCC4pi());
32 
33  AddSplit(4);
34 
35  AddStep(0, StepBase::kCut, "Fwd Quality Cut", new numuCC4pi::Fwd_Quality()); //if passed accum_level=4
36  AddStep(0, StepBase::kCut, "Fwd Veto Cut", new numuCC4pi::Fwd_Veto()); //if passed accum_level=5
37  AddStep(0, StepBase::kCut, "Fwd PID Cut", new numuCC4pi::Fwd_PID()); //if passed accum_level=6
38  AddStep(0, StepBase::kCut, "Fwd 4pi Cut", new numuCC4pi::Fwd()); //if passed accum_level=7
39 
40  AddStep(1, StepBase::kCut, "Bwd Quality Cut", new numuCC4pi::Bwd_Quality());
41  AddStep(1, StepBase::kCut, "Bwd Veto Cut", new numuCC4pi::Bwd_Veto());
42  AddStep(1, StepBase::kCut, "Bwd PID Cut", new numuCC4pi::Bwd_PID());
43  AddStep(1, StepBase::kCut, "Bwd 4pi Cut", new numuCC4pi::Bwd());
44 
45  AddStep(2, StepBase::kCut, "HAFwd Quality Cut", new numuCC4pi::HAFwd_Quality());
46  AddStep(2, StepBase::kCut, "HAFwd Veto Cut", new numuCC4pi::HAFwd_Veto());
47  AddStep(2, StepBase::kCut, "HAFwd PID Cut", new numuCC4pi::HAFwd_PID());
48  AddStep(2, StepBase::kCut, "HAFwd 4pi Cut", new numuCC4pi::HAFwd());
49 
50  AddStep(3, StepBase::kCut, "HABwd Quality Cut", new numuCC4pi::HABwd_Quality());
51  AddStep(3, StepBase::kCut, "HABwd Veto Cut", new numuCC4pi::HABwd_Veto());
52  AddStep(3, StepBase::kCut, "HABwd PID Cut", new numuCC4pi::HABwd_PID());
53  AddStep(3, StepBase::kCut, "HABwd 4pi Cut", new numuCC4pi::HABwd());
54 
55  SetBranchAlias(0, "Fwd", 0);
56  SetBranchAlias(1, "Bwd", 1);
57  SetBranchAlias(2, "HAFwd", 2);
58  SetBranchAlias(3, "HABwd", 3);
59 
61 
62 }
63 
64 //********************************************************************
66  //********************************************************************
67 
68  // Change FV definition to take all thickness
69  // Note! this will affect all downstream stuff
70  FVDef::FVdefminFGD1[2] = 0;
71  FVDef::FVdefmaxFGD1[2] = 0;
72 
73  // The detector in which the selection is applied
74  SetDetectorFV(SubDetId::kFGD1);
75 
76 }
77 
78 //**************************************************
80  //**************************************************
81 
82  AnaEventB& event = *static_cast<AnaEventB*>(&eventBB);
83 
84  // Create the appropriate EventBox if it does not exist yet
85  if (!event.EventBoxes[EventBoxId::kEventBoxTracker]) event.EventBoxes[EventBoxId::kEventBoxTracker] = new EventBoxTracker();
86 
87  boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
88  boxUtils::FillTracksWithFGD(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
89  boxUtils::FillTracksWithECal(event);
90 
91  boxUtils::FillTrajsChargedInTPC(event);
92  boxUtils::FillTrajsChargedInFGDAndNoTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
93  boxUtils::FillTrajsChargedHATracker(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
94 }
95 
96 //********************************************************************
97 bool numuCC4piSelection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
98  //********************************************************************
99 
100  if(allCutsPassed[0]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
101  if(allCutsPassed[1]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
102  if(allCutsPassed[2]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
103  if(allCutsPassed[3]) static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
104 
105  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kFGD1NuMuCC);
106 }
107 
108 //**************************************************
110  //**************************************************
111 
112  (void)box;
113 
114  // Check we have at least one reconstructed track in the FGD
115  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
116  return (EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithFGD1]>0);
117 
118 }
119 
120 //**************************************************
122  //**************************************************
123 
124  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
125 
126  // Retrieve the EventBoxTracker
127  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
128 
129  //Find TPCGoodQuality tracks in Fwd and Bwd
130  int nTPC=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV];
131  for (Int_t i=0;i<nTPC; ++i){
132  AnaTrackB* track = static_cast<AnaTrackB*>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithGoodQualityTPCInFGD1FV][i]);
133  if ( track->Charge!=-1 ) continue;
134  cc4pibox->LowAngle.push_back(track);
135  }
136  //Sort TPCGoodQuality using Momentum
137  std::sort(cc4pibox->LowAngle.begin(), cc4pibox->LowAngle.end(), numuCC4pi_utils::HGlobalMomFirst);
138 
139  int nECALTracks=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithECal];
140  for(int i=0;i<nECALTracks;i++){
141  AnaTrackB* track = static_cast<AnaTrackB*>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithECal][i]);
142  if ( anaUtils::InFiducialVolume(SubDetId::kFGD1, track->PositionStart) ) {
143  if ( cutUtils::TrackQualityCut(*track) ) continue;
144  if ( cutUtils::StoppingBrECALorSMRDCut(track->PositionEnd)==-1 ) continue;
145  cc4pibox->HighAngle.push_back(track);
146  }
147  }
148  //Sort HighAngle using RangeMomentum
149  std::sort(cc4pibox->HighAngle.begin(), cc4pibox->HighAngle.end(), numuCC4pi_utils::HRangeMomFirst);
150 
151  return true;
152 
153 }
154 
155 //**************************************************
157  //**************************************************
158 
159  (void)event;
160 
161  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
162 
163  for(UInt_t i=0;i<cc4pibox->LowAngle.size();i++ ){
164  if ( anaUtils::InFiducialVolume(SubDetId::kFGD1, cc4pibox->LowAngle[i]->PositionStart, numuCC4pi_utils::LAFVmin, numuCC4pi_utils::LAFVmax) ){
165  if ( ToFSenseCorrector::IsForward(*cc4pibox->LowAngle[i]) ) cc4pibox->FwdTracks.push_back(cc4pibox->LowAngle[i]);
166  else cc4pibox->BwdTracks.push_back(cc4pibox->LowAngle[i]);
167  break;
168  }
169  }
170 
171  for(UInt_t i=0;i<cc4pibox->HighAngle.size();i++){
172  if ( anaUtils::InFiducialVolume(SubDetId::kFGD1, cc4pibox->HighAngle[i]->PositionStart, numuCC4pi_utils::HAFVmin, numuCC4pi_utils::HAFVmax) ) {
173  if ( ToFSenseCorrector::IsForward(*cc4pibox->HighAngle[i]) ) cc4pibox->HAFwdTracks.push_back(cc4pibox->HighAngle[i]);
174  else cc4pibox->HABwdTracks.push_back(cc4pibox->HighAngle[i]);
175  }
176  }
177 
178  if ( cc4pibox->FwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->FwdTracks[0]; return true; }
179  else if ( cc4pibox->BwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->BwdTracks[0]; return true; }
180  else if ( cc4pibox->HAFwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->HAFwdTracks[0]; return true; }
181  else if ( cc4pibox->HABwdTracks.size()>0 ) { cc4pibox->MainTrack = cc4pibox->HABwdTracks[0]; return true; }
182 
183  return false;
184 
185 }
186 
187 //**************************************************
189  //**************************************************
190 
191  AnaEventB& eventB = *static_cast<AnaEventB*>(&event);
192 
193  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
194 
195  for (UInt_t i=0;i<cc4pibox->FwdTracks.size();i++){
196  if ( numuCC4pi_utils::VetoCut(0,eventB,*(cc4pibox->FwdTracks[i])) ) {
197  if ( numuCC4pi_utils::ExternalCut(0,event,*(cc4pibox->FwdTracks[i])) ) cc4pibox->FwdTracks_Veto.push_back(cc4pibox->FwdTracks[i]);
198  }
199  }
200 
201  for (UInt_t i=0;i<cc4pibox->BwdTracks.size();i++){
202  cc4pibox->BwdTracks_Veto.push_back(cc4pibox->BwdTracks[i]);
203  }
204 
205  for (UInt_t i=0;i<cc4pibox->HAFwdTracks.size();i++){
206  if ( numuCC4pi_utils::VetoCut(2,eventB,*(cc4pibox->HAFwdTracks[i])) ) cc4pibox->HAFwdTracks_Veto.push_back(cc4pibox->HAFwdTracks[i]);
207  }
208 
209  for (UInt_t i=0;i<cc4pibox->HABwdTracks.size();i++){
210  if ( numuCC4pi_utils::VetoCut(3,eventB,*(cc4pibox->HABwdTracks[i])) ) cc4pibox->HABwdTracks_Veto.push_back(cc4pibox->HABwdTracks[i]);
211  }
212 
213  if ( cc4pibox->FwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->FwdTracks_Veto[0];
214  else if ( cc4pibox->BwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->BwdTracks_Veto[0];
215  else if ( cc4pibox->HAFwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->HAFwdTracks_Veto[0];
216  else if ( cc4pibox->HABwdTracks_Veto.size()>0 ) cc4pibox->MainTrack = cc4pibox->HABwdTracks_Veto[0];
217 
218  return true;
219 
220 }
221 
222 //**************************************************
224  //**************************************************
225 
226  (void)event;
227 
228  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
229 
230  for (UInt_t i=0;i<cc4pibox->FwdTracks_Veto.size();i++){
231  if ( numuCC4pi_utils::PIDCut(0,*(cc4pibox->FwdTracks_Veto[i]))==1 ) cc4pibox->FwdTracks_PID.push_back(cc4pibox->FwdTracks_Veto[i]);
232  }
233 
234  for (UInt_t i=0;i<cc4pibox->BwdTracks_Veto.size();i++){
235  if ( numuCC4pi_utils::PIDCut(1,*(cc4pibox->BwdTracks_Veto[i]))==1 ) cc4pibox->BwdTracks_PID.push_back(cc4pibox->BwdTracks_Veto[i]);
236  }
237 
238  for (UInt_t i=0;i<cc4pibox->HAFwdTracks_Veto.size();i++){
239  if ( numuCC4pi_utils::PIDCut(2,*(cc4pibox->HAFwdTracks_Veto[i]))==1 ) cc4pibox->HAFwdTracks_PID.push_back(cc4pibox->HAFwdTracks_Veto[i]);
240  }
241 
242  for (UInt_t i=0;i<cc4pibox->HABwdTracks_Veto.size();i++){
243  if ( numuCC4pi_utils::PIDCut(2,*(cc4pibox->HABwdTracks_Veto[i]))==1 ) cc4pibox->HABwdTracks_PID.push_back(cc4pibox->HABwdTracks_Veto[i]);
244  }
245 
246  if ( cc4pibox->FwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->FwdTracks_PID[0];
247  else if ( cc4pibox->BwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->BwdTracks_PID[0];
248  else if ( cc4pibox->HAFwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->HAFwdTracks_PID[0];
249  else if ( cc4pibox->HABwdTracks_PID.size()>0 ) cc4pibox->MainTrack = cc4pibox->HABwdTracks_PID[0];
250 
251  return true;
252 
253 }
254 
255 //Define vertex
256 //**************************************************
258  //**************************************************
259 
260  (void)event;
261 
262  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
263  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&boxB);
264 
265  // reset the vertex
266  box.Vertex = NULL;
267 
268  if ( !cc4pibox->MainTrack ) return false;
269 
270  box.Vertex = new AnaVertexB();
271  anaUtils::CreateArray(box.Vertex->Particles, 1);
272 
273  box.Vertex->nParticles = 0;
274  box.Vertex->Particles[box.Vertex->nParticles++] = cc4pibox->MainTrack;
275 
276  anaUtils::CopyArray( cc4pibox->MainTrack->PositionStart, box.Vertex->Position, 4);
277 
278  if ( cc4pibox->MainTrack->TrueObject ) box.TrueVertex = box.Vertex->TrueVertex = cc4pibox->MainTrack->GetTrueParticle()->TrueVertex;
279 
280  return true;
281 }
282 
283 //********************************************************************
284 bool FillSummaryAction_numuCC4pi::Apply(AnaEventC& event, ToyBoxB& boxB) const{
285  //********************************************************************
286 
287  // Cast the ToyBox to the appropriate type
288  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&boxB);
289 
290  if(!cc4pibox->MainTrack) return 1;
291 
292  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuCC] = cc4pibox->MainTrack;
293 
294  anaUtils::CopyArray( cc4pibox->MainTrack->PositionStart, static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuCC], 4);
295 
296  if(cc4pibox->MainTrack->GetTrueParticle()) static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuCC] = cc4pibox->MainTrack->GetTrueParticle()->TrueVertex;
297 
298  return true;
299 }
300 
301 //**************************************************
303  //**************************************************
304  (void)event;
305  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
306  if (cc4pibox->FwdTracks.size()>0) return true;
307  return false;
308 }
309 //**************************************************
311  //**************************************************
312  (void)event;
313  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
314  if (cc4pibox->FwdTracks_Veto.size()>0) return true;
315  return false;
316 }
317 //**************************************************
318 bool numuCC4pi::Fwd_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
319  //**************************************************
320  (void)event;
321  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
322  if (cc4pibox->FwdTracks_PID.size()>0) return true;
323  return false;
324 }
325 //**************************************************
326 bool numuCC4pi::Fwd::Apply(AnaEventC& event, ToyBoxB& box) const{
327  //**************************************************
328  (void)event;
329  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
330  if (cc4pibox->FwdTracks_PID.size()>0) return true;
331  return false;
332 }
333 
334 //**************************************************
336  //**************************************************
337  (void)event;
338  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
339  if (cc4pibox->BwdTracks.size()>0) return true;
340  return false;
341 }
342 //**************************************************
344  //**************************************************
345  (void)event;
346  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
347  if (cc4pibox->BwdTracks_Veto.size()>0) return true;
348  return false;
349 }
350 //**************************************************
351 bool numuCC4pi::Bwd_PID::Apply(AnaEventC& event, ToyBoxB& box) const{
352  //**************************************************
353  (void)event;
354  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
355  if (cc4pibox->BwdTracks_PID.size()>0) return true;
356  return false;
357 }
358 //**************************************************
359 bool numuCC4pi::Bwd::Apply(AnaEventC& event, ToyBoxB& box) const{
360  //**************************************************
361  (void)event;
362  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
363  if (cc4pibox->BwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0) return true;
364  return false;
365 }
366 
367 //**************************************************
369  //**************************************************
370  (void)event;
371  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
372  if (cc4pibox->HAFwdTracks.size()>0) return true;
373  return false;
374 }
375 //**************************************************
377  //**************************************************
378  (void)event;
379  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
380  if (cc4pibox->HAFwdTracks_Veto.size()>0) return true;
381  return false;
382 }
383 //**************************************************
385  //**************************************************
386  (void)event;
387  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
388  if (cc4pibox->HAFwdTracks_PID.size()>0) return true;
389  return false;
390 }
391 //**************************************************
392 bool numuCC4pi::HAFwd::Apply(AnaEventC& event, ToyBoxB& box) const{
393  //**************************************************
394  (void)event;
395  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
396  if (cc4pibox->HAFwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0) return true;
397  return false;
398 }
399 
400 //**************************************************
402  //**************************************************
403  (void)event;
404  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
405  if (cc4pibox->HABwdTracks.size()>0) return true;
406  return false;
407 }
408 //**************************************************
410  //**************************************************
411  (void)event;
412  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
413  if (cc4pibox->HABwdTracks_Veto.size()>0) return true;
414  return false;
415 }
416 //**************************************************
418  //**************************************************
419  (void)event;
420  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
421  if (cc4pibox->HABwdTracks_PID.size()>0) return true;
422  return false;
423 }
424 //**************************************************
425 bool numuCC4pi::HABwd::Apply(AnaEventC& event, ToyBoxB& box) const{
426  //**************************************************
427  (void)event;
428  ToyBoxCC4pi* cc4pibox = static_cast<ToyBoxCC4pi*>(&box);
429  if (cc4pibox->HABwdTracks_PID.size()>0 && cc4pibox->FwdTracks_PID.size()==0 && cc4pibox->BwdTracks_PID.size()==0 && cc4pibox->HAFwdTracks_PID.size()==0) return true;
430  return false;
431 }
432 
433 //********************************************************************
434 int numuCC4pi_utils::GetFgdLayer(Float_t* pos){
435  //********************************************************************
436 
437  Float_t initZ=0;
438  Float_t finalZ=0;
439  Float_t barCenter[30];
440 
441  for (Int_t i=0; i<30; i++) {
442  barCenter[i] = DetDef::fgd1BarCenter[i];
443  if (i==0) initZ = barCenter[0]-(DetDef::fgdXYBarWidth/2)-DetDef::fgdXYGlueWidth-DetDef::fgdXYSkinWidth-DetDef::fgdXYAirWidth;
444  else initZ = finalZ;
445  if (i%2==0) finalZ = barCenter[i]+(DetDef::fgdXYBarWidth/2)+(DetDef::fgdXYMiddleGlueWidth/2);
446  else if (i%2==1) finalZ = barCenter[i]+(DetDef::fgdXYBarWidth/2)+DetDef::fgdXYGlueWidth+DetDef::fgdXYSkinWidth+(DetDef::fgdXYAirWidth/2);
447  if (i==29) finalZ += (DetDef::fgdXYAirWidth/2);
448  if (pos[2]>initZ && pos[2]<finalZ) return i;
449  }
450 
451  return -1;
452 
453 }
454 
455 //********************************************************************
456 bool numuCC4pi_utils::HGlobalMomFirst(AnaTrackB* a, AnaTrackB* b){
457  //********************************************************************
458 
459  return a->Momentum > b->Momentum;
460 
461 }
462 
463 //********************************************************************
464 bool numuCC4pi_utils::HRangeMomFirst(AnaTrackB* a, AnaTrackB* b){
465  //********************************************************************
466 
467  return a->RangeMomentumMuon > b->RangeMomentumMuon;
468 
469 }
470 
471 //********************************************************************
472 bool numuCC4pi_utils::VetoCut(int topo, const AnaEventB& event, AnaTrackB& candidate){
473  //********************************************************************
474 
475  if (topo==0) {
476  AnaTrackB* VetoTrack = cutUtils::FindVetoTrack(event, candidate);
477  if (VetoTrack) {
478  if (VetoTrack->PositionStart[2]-candidate.PositionStart[2]<-100. && VetoTrack->Momentum/candidate.Momentum>0.8) return false;
479  }
480  return true;
481  }
482  if (topo==2) {
483  AnaTrackB* VetoTrack = cutUtils::FindVetoTrack(event, candidate);
484  if (VetoTrack) {
485  if (VetoTrack->PositionStart[2]-candidate.PositionStart[2]<-150. && VetoTrack->Momentum/candidate.RangeMomentumMuon>0.9) return false;
486  }
487  return true;
488  }
489  if (topo==3) {
490  AnaTrackB* VetoTrack = cutUtils::FindVetoTrack(event, candidate);
491  if (VetoTrack) {
492  if (VetoTrack->PositionStart[2]-candidate.PositionStart[2]<-400. && VetoTrack->Momentum/candidate.RangeMomentumMuon>0.9) return false;
493  }
494  return true;
495  }
496  return true;
497 
498 }
499 
500 //********************************************************************
501 bool numuCC4pi_utils::ExternalCut(int topo, const AnaEventC& event, AnaTrackB& candidate){
502  //********************************************************************
503  if ( topo==0 ) {
504  if ( GetFgdLayer(candidate.PositionStart) > 27 ) {
505  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
506  int nFgdTracks=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithFGD1AndNoTPC];
507  for (Int_t i=0;i<nFgdTracks;i++){
508  AnaTrackB* track = static_cast<AnaTrackB*>(EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithFGD1AndNoTPC][i]);
509  AnaFGDParticleB *fgdTrack = track->FGDSegments[0];
510  if( !fgdTrack ) continue;
511  if( SubDetId::GetDetectorUsed(fgdTrack->Detector,SubDetId::kFGD1) ) return false;
512  }
513  }
514  return true;
515  }
516  return true;
517 
518 }
519 
520 //**************************************************
521 int numuCC4pi_utils::PIDCut(int topo, const AnaTrackB& candidate) {
522  //**************************************************
523 
524  if ( topo==0 ) {
525  if (cutUtils::MuonPIDCut(candidate, false)){
526  if ( anaUtils::InFiducialVolume(SubDetId::kFGD2, candidate.PositionEnd, _FVdefminFGD2, _FVdefmaxFGD2) ) {
527  if ( candidate.Momentum>280. ) return 2;
528  }
529  if ( candidate.nECALSegments>0 ) {
530  if ( candidate.ECALSegments[0]->PIDMipEm>15 ) {
531  if ( anaUtils::TrackUsesDet(candidate,SubDetId::kTECAL) ) return 3;
532  if ( anaUtils::InFiducialVolume(SubDetId::kDSECAL, candidate.PositionEnd, numuCC4pi_utils::_FVdefminDsECal, numuCC4pi_utils::_FVdefmaxDsECal) ) return 3;
533  }
534  }
535  return 1;
536  }
537  return 0;
538  }
539  else if ( topo==1 ) {
540  if ( anaUtils::GetPIDLikelihood(candidate, 0, false) > 0.05 ) return 1;
541  return 0;
542  }
543  else if ( topo==2 ) {
544  if ( cutUtils::MuonECALPIDCut(candidate) ) return 1;
545  return 0;
546  }
547  return 1;
548 
549 }
550 
551 //**************************************************
552 bool numuCC4piSelection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
553  //**************************************************
554 
555  (void)event;
556  (void)box;
557  (void)systId;
558 
559  // Pile-up deals with an activity in the upstream TPC, the TPC-based BWD selection branch does not veto the upstream activity
560  if (systId == SystId::kPileUp){
561  if (branch == 1) return false; // TPC-based BWD case
562  }
563 
564 
565  return true;
566 
567 }
568 
569 //**************************************************
570 bool numuCC4piSelection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
571  //**************************************************
572 
573  (void)event;
574  (void)branch;
575  (void)systId;
576 
577  AnaTrackB* track = static_cast<AnaTrackB*>(recObj);
578 
579  if (!track) return false;
580  if (!track->TrueObject) return false;
581 
582  return true;
583 
584 }
585 
586 //**************************************************
587 bool numuCC4piSelection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
588  //**************************************************
589 
590  (void)event;
591  (void)branch;
592  (void)systId;
593 
594  AnaTrueParticleB* trueTrack = static_cast<AnaTrueParticleB*>(trueObj);
595 
596  if (!trueTrack) return false;
597 
598  return true;
599 
600 }
601 
602 //**************************************************
603 bool numuCC4piSelection::IsRelevantRecObjectForSystematicInToy(const AnaEventC& event, const ToyBoxB& boxB, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
604  //**************************************************
605 
606  (void)event;
607  (void)branch;
608 
609  const ToyBoxCC4pi& cc4pibox = *static_cast<const ToyBoxCC4pi*>(&boxB);
610 
611  AnaTrackB* track = static_cast<AnaTrackB*>(recObj);
612 
613  if(systId == SystId::kTpcClusterEff){
614  if (track->nTPCSegments == 0) return false;
616  if (!tpcTrack) return false;
617  if (tpcTrack->NNodes != 17 && tpcTrack->NNodes != 18) return false;
618  }
619  if(systId == SystId::kChargeIDEff){
620  if (track != cc4pibox.MainTrack) return false;
621  }
622  if(systId == SystId::kTpcFgdMatchEff){
623  if (track != cc4pibox.MainTrack) return false;
624  }
625  if(systId == SystId::kECalPID){
626  if (branch==1) return false;
627  else { if (track != cc4pibox.MainTrack) return false; }
628  }
629 
630  return true;
631 
632 }
633 
634 //**************************************************
635 bool numuCC4piSelection::IsRelevantTrueObjectForSystematicInToy(const AnaEventC& event, const ToyBoxB& boxB, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
636  //**************************************************
637 
638  (void)event;
639  (void)branch;
640 
641  const ToyBoxCC4pi& cc4pibox = *static_cast<const ToyBoxCC4pi*>(&boxB);
642 
643  AnaTrueParticleB* trueTrack = static_cast<AnaTrueParticleB*>(trueObj);
644 
645  if(systId == SystId::kTpcTrackEff){
646  if (cc4pibox.MainTrack->GetTrueParticle()){
647  if (trueTrack->PDG == 13 && cc4pibox.MainTrack->GetTrueParticle()->PDG!=13) return true;
648  if (branch>1 && branch<4) return false;
649  else { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
650  }
651  }
652  if(systId == SystId::kECalTrackEff){
653  if (cc4pibox.MainTrack->GetTrueParticle()){
654  if (trueTrack->PDG == 13 && cc4pibox.MainTrack->GetTrueParticle()->PDG!=13) return true;
655  if (branch==2 || branch==3) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
656  else return false;
657  }
658  }
659  if(systId == SystId::kTpcP0dMatchEff){
660  if (cc4pibox.MainTrack->GetTrueParticle()){
661  if (branch==1) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
662  else return false;
663  }
664  }
665  if(systId == SystId::kTpcECalMatchEff){
666  if (cc4pibox.MainTrack->GetTrueParticle()){
667  if (branch>-1 && branch<6) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
668  return false;
669  }
670  }
671  if(systId == SystId::kFgdECalMatchEff){
672  if (cc4pibox.MainTrack->GetTrueParticle()){
673  if (branch==2 || branch==3) { if (trueTrack->ID == cc4pibox.MainTrack->GetTrueParticle()->ID) return true; }
674  else return false;
675  }
676  }
677 
678  return true;
679 
680 }
681 
682 //********************************************************************
683 bool numuCC4piSelection::CheckRedoSelection(const AnaEventC& eventC, const ToyBoxB& PreviousToyBoxB, Int_t& redoFromStep){
684  //********************************************************************
685 
686  (void)eventC;
687  (void)PreviousToyBoxB;
688  (void)redoFromStep;
689 
690  return true;
691 
692 }
693 
bool Apply(AnaEventC &event, ToyBoxB &box) const
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.
AnaTrueVertexB * TrueVertex
unsigned long Detector
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
void SetPreSelectionAccumLevel(Int_t presel)
Set the pre-selection accum level.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaECALParticleB * ECALSegments[NMAXECALS]
The ECAL segments that contributed to this global track.
int nECALSegments
How many ECAL tracks are associated with this track.
static bool IsForward(const AnaTrackB &track)
Check whether a track is forward going.
Float_t Position[4]
The identified position of the global vertex.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t NNodes
The number of nodes in the reconstructed object.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
Definition: SubDetId.cxx:40
bool Apply(AnaEventC &event, ToyBoxB &box) const
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
void AddSplit(UInt_t nbranches, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Add a split in the step sequence. The user should specify the number of branches in this split and th...
Float_t RangeMomentumMuon
Momentum by range calculated with muon hypothesis.
bool TrackUsesDet(const AnaTrackB &track, SubDetId::SubDetEnum det)
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t Charge
The reconstructed charge of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
void DefineSteps()
Define all steps in the selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Float_t GetPIDLikelihood(const AnaTrackB &track, Int_t hypo, bool prod5Cut=0)
Definition: PIDUtils.cxx:180
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
AnaVertexB * Vertex
For storing the reconstructed vertex.
int nTPCSegments
How many TPC tracks are associated with this track.
Representation of a true Monte Carlo trajectory/particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
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.
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.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
Representation of a TPC segment of a global track.
AnaParticleB ** Particles
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrackB * MainTrack
For storing tracks information in the bunch.
Representation of a global vertex.
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
Representation of a FGD segment of a global track.
void SetBranchAlias(Int_t ID, const std::string &name, Int_t b0=-1, Int_t b1=-1, Int_t b2=-1, Int_t b3=-1, Int_t b4=-1, Int_t b5=-1, Int_t b6=-1, Int_t b7=-1)
Set the branch alias and unique ID provided the branch sequence.
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 SetDetectorFV(SubDetId_h det, Int_t ibranch=-1)
Set the detector in which the Fiducial Volume is defined.
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...
bool Apply(AnaEventC &event, ToyBoxB &box) const
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
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.
AnaFGDParticleB * FGDSegments[NMAXFGDS]
The FGD segments that contributed to this global track.
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) ...
A cut on event quality. Requires good beam and ND280 data quality flags.
bool Apply(AnaEventC &event, ToyBoxB &box) const
void AddStep(StepBase::TypeEnum type, const std::string &title, StepBase *step, bool cut_break=false)
Float_t PositionEnd[4]
The reconstructed end position of the particle.
bool Apply(AnaEventC &event, ToyBoxB &box) const