HighLAND
tutorialSelection.cxx
1 #include "tutorialSelection.hxx"
2 #include "baseSelection.hxx"
3 #include "CutUtils.hxx"
4 #include "SubDetId.hxx"
5 #include "EventBoxUtils.hxx"
6 #include "trackerSelectionUtils.hxx"
7 
8 //********************************************************************
9 tutorialSelection::tutorialSelection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
10 //********************************************************************
11 
12 }
13 
14 //********************************************************************
16 //********************************************************************
17 
18  // Set the detector Fiducial Volume in which the selection is applied. This is now a mandatory method
19  SetDetectorFV(SubDetId::kFGD1);
20 }
21 
22 //********************************************************************
24 //********************************************************************
25 
26  // Cuts must be added in the right order
27  // last "true" means the step sequence is broken if cut is not passed (default is "false")
28  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true);
29  AddStep(StepBase::kCut, "> 0 tracks ", new TotalMultiplicityCut(), true);
30  AddStep(StepBase::kAction, "find leading tracks",new FindLeadingTracksAction());
31  AddStep(StepBase::kAction, "find vertex", new FindVertexAction());
32  AddStep(StepBase::kAction, "fill_summary", new FillSummaryAction_tutorial());
33  AddStep(StepBase::kCut, "quality+fiducial", new TrackQualityFiducialCut(), true);
34  AddStep(StepBase::kAction, "find veto track", new FindVetoTrackAction());
35  AddStep(StepBase::kCut, "veto", new ExternalVetoCut());
36  AddStep(StepBase::kAction, "find oofv track", new FindOOFVTrackAction());
37  AddStep(StepBase::kCut, "External FGD1", new ExternalFGD1lastlayersCut());
38  AddStep(StepBase::kCut, "muon PID", new MuonPIDCut());
39 
40  // This is mandatory. An alias should be given to each of the branches
41  SetBranchAlias(0,"trunk");
42 
43  // By default the preselection correspond to cuts 0-2.
44  // It means that if any of the three first cuts (0,1,2) is not passed
45  // the loop over toys will be broken ===> A single toy will be run
46  SetPreSelectionAccumLevel(2);
47 }
48 
49 //********************************************************************
50 bool tutorialSelection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
51 //********************************************************************
52 
53  if(allCutsPassed[0]){
54  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuCC;
55  }
56  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
57 }
58 
59 //**************************************************
60 bool TotalMultiplicityCut::Apply(AnaEventC& event, ToyBoxB& box) const{
61 //**************************************************
62 
63  (void)box; // This is just to avoid a warning (box not used !!!)
64 
65  // Check we have at least one reconstructed track in the TPC
66  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
67  return (EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPC]>0);
68 }
69 
70 //**************************************************
72 //**************************************************
73 
74  (void)event; // This is just to avoid a warning (event not used !!!)
75 
76  // cast the box to the appropriate type
77  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
78 
79  return (box.Vertex);
80 }
81 
82 //**************************************************
83 bool MuonPIDCut::Apply(AnaEventC& event, ToyBoxB& boxB) const{
84 //**************************************************
85 
86  (void)event; // This is just to avoid a warning (event not used !!!)
87 
88  // cast the box to the appropriate type
89  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
90 
91  if (!box.MainTrack) return false;
92  if (box.MainTrack->Momentum < 0.) return false;
93  return cutUtils::MuonPIDCut(*(box.MainTrack), _prod5Cut);
94 }
95 
96 //********************************************************************
97 bool ExternalVetoCut::Apply(AnaEventC& event, ToyBoxB& boxB) const{
98 //********************************************************************
99 
100  (void)event; // This is just to avoid a warning (event not used !!!)
101 
102  // cast the box to the appropriate type
103  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
104 
105  if (!box.MainTrack) return false;
106  return cutUtils::ExternalVetoCut(*(box.MainTrack),box.VetoTrack);
107 }
108 
109 //********************************************************************
111 //********************************************************************
112 
113  (void)event; // This is just to avoid a warning (event not used !!!)
114 
115  // cast the box to the appropriate type
116  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
117 
118  /// Reject external background from the last 2 layers of FGD1
119  if (!box.MainTrack) return false;
120  if (!box.OOFVtrack) return true;
121  return (box.MainTrack->PositionStart[2]<425.);
122 }
123 
124 //**************************************************
125 bool FindVertexAction::Apply(AnaEventC& event, ToyBoxB& boxB) const{
126 //**************************************************
127 
128  (void)event; // This is just to avoid a warning (event not used !!!)
129 
130  // cast the box to the appropriate type
131  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
132 
133  // reset the vertex
134  box.Vertex = NULL;
135 
136  if (!box.MainTrack) return false;
137 
138  box.Vertex = new AnaVertexB();
139  anaUtils::CreateArray(box.Vertex->Particles, 1);
140 
141  box.Vertex->nParticles = 0;
142  box.Vertex->Particles[box.Vertex->nParticles++] = box.MainTrack;
143 
144  for(int i = 0; i < 4; ++i){
145  box.Vertex->Position[i] = box.MainTrack->PositionStart[i];
146  }
147  if( box.MainTrack->GetTrueParticle() )
149  return true;
150 }
151 
152 //********************************************************************
154 //********************************************************************
155 
156  AnaEventB& event = *static_cast<AnaEventB*>(&eventC);
157 
158  // cast the box to the appropriate type
159  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
160 
161  if(!box.HMNtrack) return 1;
162 
163  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuCC] = box.HMNtrack;
164  for(int i = 0; i < 4; ++i){
165  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuCC][i] = box.HMNtrack->PositionStart[i];
166  }
167  if(box.HMNtrack->GetTrueParticle()) static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuCC] = box.HMNtrack->GetTrueParticle()->TrueVertex;
168 
169  return true;
170 }
171 
172 //**************************************************
174 //**************************************************
175 
176  // Cast the event
177  AnaEventB& event = *static_cast<AnaEventB*>(&eventC);
178 
179  // cast the box to the appropriate type
180  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
181 
182  // Find leading tracks with good quality and only in FGD FV
183  trackerSelUtils::FindLeadingTracks(event,box);
184 
185  // For this selection the main track is the HMN track
186  box.MainTrack = box.HMNtrack;
187  return true;
188 }
189 
190 //**************************************************
191 bool FindVetoTrackAction::Apply(AnaEventC& eventC, ToyBoxB& boxB) const{
192 //**************************************************
193 
194  // Cast the event
195  AnaEventB& event = *static_cast<AnaEventB*>(&eventC);
196 
197  // cast the box to the appropriate type
198  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
199 
200  box.VetoTrack = cutUtils::FindVetoTrack(event, *(box.MainTrack));
201  return true;
202 }
203 
204 //**************************************************
205 bool FindOOFVTrackAction::Apply(AnaEventC& eventC, ToyBoxB& boxB) const{
206 //**************************************************
207 
208  // Cast the event
209  AnaEventB& event = *static_cast<AnaEventB*>(&eventC);
210 
211  // cast the box to the appropriate type
212  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
213 
214  box.OOFVtrack = cutUtils::FindFGDOOFVtrack(event, *(box.MainTrack), static_cast<SubDetId::SubDetEnum>(box.DetectorFV));
215  return true;
216 }
217 
218 //**************************************************
220 //**************************************************
221 
222  // Cast the event
223  AnaEventB& event = *static_cast<AnaEventB*>(&eventC);
224 
225  // Create the appropriate EventBox if it does not exist yet
226  if (!event.EventBoxes[EventBoxId::kEventBoxTracker])
227  event.EventBoxes[EventBoxId::kEventBoxTracker] = new EventBoxTracker();
228 
229  // Fill all objects needed by the selection in the event box
230  boxUtils::FillTracksWithTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
231  boxUtils::FillTracksWithFGD(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
232  boxUtils::FillTrajsChargedInTPC(event);
233  boxUtils::FillTrajsChargedInFGDAndNoTPC(event, static_cast<SubDetId::SubDetEnum>(GetDetectorFV()));
234 }
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
AnaTrueVertexB * TrueVertex
-— Define all steps ----—
bool Apply(AnaEventC &event, ToyBoxB &box) const
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
SubDetId_h DetectorFV
Indicate the FV we are interested in.
Definition: ToyBoxB.hxx:52
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
bool Apply(AnaEventC &event, ToyBoxB &box) const
void DefineDetectorFV()
Set detector FV.
void DefineSteps()
========= These are mandatory functions ==================
bool Apply(AnaEventC &event, ToyBoxB &box) const
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.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Leading tracks with good quality in FGD1.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrackB * VetoTrack
For storing the veto track.
AnaTrackB * HMNtrack
For storing the highest momentum negative track.
AnaParticleB ** Particles
Representation of a global vertex.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
bool Apply(AnaEventC &event, ToyBoxB &box) const
Find the Vertex. For the moment it&#39;s just the Star position of the HM track.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
A cut on event quality. Requires good beam and ND280 data quality flags.
AnaTrackB * OOFVtrack
For storing the oofv fgd tracks.
bool Apply(AnaEventC &event, ToyBoxB &box) const