HighLAND
numuCCMultiTargetSelection.cxx
1 #include "numuCCMultiTargetSelection.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 #include "EventBoxUtils.hxx"
4 #include "EventBoxTracker.hxx"
5 
6 bool _doMultiPiSelection = false;
7 
8 //*******************************************************************************
9 numuCCMultiTargetSelection::numuCCMultiTargetSelection(bool doMultiPi, bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker){
10 //*******************************************************************************
11 
12  _doMultiPiSelection = doMultiPi;
13 }
14 
15 //*******************************************************************************
17 //*******************************************************************************
18 
19  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true);
20 
21  // Add a split to the trunk with 2 branches
22  AddSplit(2);
23 
24  // ********* FGD1 ********* //
25  AddStep(0,StepBase::kAction, "FGD1 FV", new SetDetectorFVAction(SubDetId::kFGD1));
26 
27  // Copy from numuCCSelection, branch 0 (trunk), steps from 1(second) to 10, into branch 0
28  numuCCSelection _numuCCSelection;
29  _numuCCSelection.Initialize();
30  CopySteps(_numuCCSelection,0,1,10,0);
31 
32  if (_doMultiPiSelection){
33  //Additional actions for the multi-pi selection in FGD1 (must to this before spliting)
34  AddStep(0, StepBase::kAction, "fill_summary_FGD1", new FillSummaryAction_numuCCMultiPi());
35  AddStep(0, StepBase::kAction, "find_pions_FGD1", new FindPionsAction());
36  }
37 
38  // Set the branch aliases
39  SetBranchAlias(0,"numuCC_FGD1", 0);
40 
41  // ********* FGD2 ********* //
42  // this is needed here to avoid that the box is replaced with the candidate in FGD2
43  AddStep(1,StepBase::kCut, "> 0 tracks & no FGD1 tracks", new TotalMultiplicityFGD2Cut(), true);
44 
45  AddStep(1,StepBase::kAction, "FGD2 FV", new SetDetectorFVAction(SubDetId::kFGD2));
46 
47  // Copy from numuCCFGD2Selection, branch 0 (trunk), steps from 2(third) to 10, into branch 1
48  numuCCFGD2Selection _numuCCFGD2Selection;
49  _numuCCFGD2Selection.Initialize();
50  CopySteps(_numuCCFGD2Selection,0,2,10,1);
51 
52  if (_doMultiPiSelection){
53  // Additional actions for the multi-pi selection in FGD2
54  AddStep(1, StepBase::kAction, "fill_summary_FGD2", new FillSummaryAction_numuCCMultiPiFGD2());
55  AddStep(1, StepBase::kAction, "find_pions_FGD2", new FindPionsAction());
56  }
57 
58  // split in FGD2 into water and scint
59  AddSplit(2,1);
60  AddStep(1,0, StepBase::kCut, "numu CC in water FGD2", new WaterCut());
61  AddStep(1,1, StepBase::kCut, "numu CC in scint FGD2", new ScintillatorCut());
62 
63  // Set the branch aliases
64  SetBranchAlias(1,"numuCC_FGD2", 1);
65  SetBranchAlias(2,"numuCC_FGD2-water",1,0);
66  SetBranchAlias(3,"numuCC_FGD2-scint",1,1);
67 
68  if ( ! _doMultiPiSelection) return;
69 
70 
71  // ******* MultiPi selection ****** //
72 
73  // ********* FGD1 ********* //
74 
75  // multi-pi split for FGD1 (3 branches for branch 0,1 which correspond to branchID 2)
76  AddSplit(3,0);
77  AddStep(0,0, StepBase::kCut, "CC-0pi", new NoPionCut());
78  AddStep(0,1, StepBase::kCut, "CC-1pi", new OnePionCut());
79  AddStep(0,2, StepBase::kCut, "CC-Other", new OthersCut());
80 
81  // Set the branch aliases
82  SetBranchAlias(4,"numuCC_FGD1_CC-0pi", 0,0);
83  SetBranchAlias(5,"numuCC_FGD1_CC-1pi", 0,1);
84  SetBranchAlias(6,"numuCC_FGD1_CC-Other",0,2);
85 
86 
87  // ********* FGD2 ********* //
88 
89  // multi-pi split for FGD2 water (3 branches for branch 1,0 which correspond to branchID 4)
90  AddSplit(3,1,0);
91  AddStep(1,0,0, StepBase::kCut, "CC-0pi", new NoPionCut());
92  AddStep(1,0,1, StepBase::kCut, "CC-1pi", new OnePionCut());
93  AddStep(1,0,2, StepBase::kCut, "CC-Other", new OthersCut());
94 
95  // Set the branch aliases
96  SetBranchAlias(7, "numuCC_FGD2-water_CC-0pi", 1,0,0);
97  SetBranchAlias(8, "numuCC_FGD2-water_CC-1pi", 1,0,1);
98  SetBranchAlias(9, "numuCC_FGD2-water_CC-Other",1,0,2);
99 
100  // multi-pi split for FGD2 scint (3 branches for branch 1,1 which correspond to branchID 5)
101  AddSplit(3,1,1);
102  AddStep(1,1,0, StepBase::kCut, "CC-0pi", new NoPionCut());
103  AddStep(1,1,1, StepBase::kCut, "CC-1pi", new OnePionCut());
104  AddStep(1,1,2, StepBase::kCut, "CC-Other", new OthersCut());
105 
106  // Set the branch aliases
107  SetBranchAlias(10,"numuCC_FGD2-scint_CC-0pi", 1,1,0);
108  SetBranchAlias(11,"numuCC_FGD2-scint_CC-1pi", 1,1,1);
109  SetBranchAlias(12,"numuCC_FGD2-scint_CC-Other",1,1,2);
110 
111 
112  // By default the preselection correspond to cuts 0-2
113  SetPreSelectionAccumLevel(2);
114 }
115 
116 
117 //*******************************************************************************
119 //*******************************************************************************
120 
121  SetDetectorFV(SubDetId::kFGD2);
122  SetDetectorFV(SubDetId::kFGD1, 0);
123 
124  if (_doMultiPiSelection){
125  SetDetectorFV(SubDetId::kFGD1, 4);
126  SetDetectorFV(SubDetId::kFGD1, 5);
127  SetDetectorFV(SubDetId::kFGD1, 6);
128  }
129 }
130 
131 //**************************************************
133 //**************************************************
134 
135  (void)box;
136 
137  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
138 
139  // Check we have at least one reconstructed track in the TPC
140  int nTPC=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPC];
141  if ( nTPC == 0) return false;
142 
143  // Cut if there are track starting in FGD1 FV
144  AnaRecObjectC** selObjects = EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithTPC];
145  for (Int_t i=0; i<nTPC; ++i) {
146  AnaTrackB* track = static_cast<AnaTrackB*>(selObjects[i]);
147  if ( ! track) continue;
148  if (anaUtils::InFiducialVolume(SubDetId::kFGD1, track->PositionStart)) return false;
149  }
150 
151  return true;
152 }
153 
154 
155 //*********************************************************************
156 bool WaterCut::Apply(AnaEventC& event, ToyBoxB& boxB) const{
157 //*********************************************************************
158 
159  // cast the box to the appropriate type
160  ToyBoxCCMultiPi& box = *static_cast<ToyBoxCCMultiPi*>(&boxB);
161 
162  // return false for the fake FGD1 cut
163  if (anaUtils::InFiducialVolume(SubDetId::kFGD1,box.MainTrack->PositionStart)) return false;
164 
165  // GetFgdModuleType: 0 vert bars, 1 horiz bars, 2 water, 3 gaps (air, glue, G10, polypropilene)
166  if (anaUtils::GetFgdModuleType(event.GetIsMC(), box.MainTrack->PositionStart, SubDetId::kFGD2)==0) return true;
167 
168  return false;
169 }
170 
171 
172 //*********************************************************************
173 bool ScintillatorCut::Apply(AnaEventC& event, ToyBoxB& boxB) const{
174 //*********************************************************************
175 
176  // cast the box to the appropriate type
177  ToyBoxCCMultiPi& box = *static_cast<ToyBoxCCMultiPi*>(&boxB);
178 
179  // return true for the fake FGD1 cut
180  if (anaUtils::InFiducialVolume(SubDetId::kFGD1,box.MainTrack->PositionStart)) return true;
181 
182  // GetFgdModuleType: 0 vert bars, 1 horiz bars, 2 water, 3 gaps (air, glue, G10, polypropilene)
183  if (anaUtils::GetFgdModuleType(event.GetIsMC(), box.MainTrack->PositionStart, SubDetId::kFGD2)==1) return true;
184 
185  return false;
186 }
187 
188 
189 //**************************************************
191 //**************************************************
192 
193  AnaEventB& event = *static_cast<AnaEventB*>(&eventC);
194 
195  // Create the appropriate EventBox if it does not exist yet
196  if (!event.EventBoxes[EventBoxId::kEventBoxTracker])
197  event.EventBoxes[EventBoxId::kEventBoxTracker] = new EventBoxTracker();
198 
199  boxUtils::FillTracksWithTPC(event, SubDetId::kFGD1);
200  boxUtils::FillTracksWithFGD(event, SubDetId::kFGD1);
201  boxUtils::FillTrajsChargedInFGDAndNoTPC(event, SubDetId::kFGD1);
202 
203  boxUtils::FillTracksWithTPC(event, SubDetId::kFGD2);
204  boxUtils::FillTracksWithFGD(event, SubDetId::kFGD2);
205  boxUtils::FillTrajsChargedInFGDAndNoTPC(event, SubDetId::kFGD2);
206 
207  boxUtils::FillTrajsChargedInTPC(event);
208 }
209 
210 
211 //*********************************************************************
213 //*********************************************************************
214 
215  (void)event;
216 
217  box.DetectorFV = _detectorFV;
218  return true;
219 }
Float_t PositionStart[4]
The reconstructed start position of the particle.
void DefineSteps()
Define all steps in the selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
bool Apply(AnaEventC &event, ToyBoxB &box) const
SubDetId_h DetectorFV
Indicate the FV we are interested in.
Definition: ToyBoxB.hxx:52
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
Int_t GetFgdModuleType(bool IsMC, const Float_t *pos, SubDetId::SubDetEnum det, bool includeGlueSkin=true)
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
virtual const ToyBoxTracker & box(Int_t isel=-1) const
Returns the ToyBoxTracker.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Representation of a global track.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
virtual bool GetIsMC() const =0
Return whether this event is from Monte Carlo or not.
bool InFiducialVolume(SubDetId::SubDetEnum det, const Float_t *pos, const Float_t *FVdefmin, const Float_t *FVdefmax)
A cut on event quality. Requires good beam and ND280 data quality flags.
void Initialize()
Initialize this selection: defines the steps and the detectorFV.