HighLAND
nueCCFGD2Selection.cxx
1 #include "nueCCFGD2Selection.hxx"
2 
3 #include "baseSelection.hxx"
4 #include "CutUtils.hxx"
5 #include "EventBoxUtils.hxx"
6 #include "VersioningUtils.hxx"
7 #include "SystematicUtils.hxx"
8 #include "trackerSelectionUtils.hxx"
9 
10 #include "nueCCUtils.hxx"
11 #include "nueCutUtils.hxx"
12 
13 //********************************************************************
14 nueCCFGD2Selection::nueCCFGD2Selection(bool forceBreak): SelectionBase(forceBreak, EventBoxId::kEventBoxTracker) {
15 //********************************************************************
16 
17  // Initialize the nueCCSelection, which is used
18  _nueCCSelection.Initialize();
19 }
20 
21 //********************************************************************
23 //********************************************************************
24 
25  // The detector in which the selection is applied
26  SetDetectorFV(SubDetId::kFGD2);
27  _nueCCSelection.SetDetectorFV(SubDetId::kFGD2);
28 }
29 
30 //********************************************************************
32 //********************************************************************
33 
34  // last "true" means the step sequence is broken if cut is not passed (default is "false")
35 
36  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true); // 0
37  AddStep(StepBase::kCut, "> 0 tracks ", new MultiplicityCut(), true); // 1
38  AddStep(StepBase::kAction, "find leading tracks", new FillLeadingTracksAction());
39 
40  AddStep(StepBase::kAction, "Fill vertex info", new FillVertex());
41  AddStep(StepBase::kAction, "fill summary", new FillSummaryAction_nueCCFGD2Selection());
42 
43  AddStep(StepBase::kCut, "TPC Quality", new TrackQualityCut(), true); // 2
44  AddStep(StepBase::kCut, "Momentum", new HighestMomentumCut()); // 3
45 
46  // e- PID cuts.
47  AddStep(StepBase::kCut, "TPC Electron Pull", new TPCElectronPullCut()); // 4
48  AddStep(StepBase::kCut, "TPC Muon Pull", new TPCMuonPullCut()); // 5
49  AddStep(StepBase::kCut, "TPC Pion Pull", new TPCPionPullCut()); // 6
50  AddStep(StepBase::kCut, "Ecal EMEnergy", new EcalEMEnergyCut()); // 7
51  AddStep(StepBase::kCut, "Ecal MIPEM PID", new EcalMIPEMPIDCut()); // 8
52  AddStep(StepBase::kCut, "EoP", new EOverPCut()); // 9
53 
54  // Upstream vetos. Reduce OOFV background.
55  AddStep(StepBase::kAction, "find TPC Veto tracks", new FillTPCVetoTrackAction());
56  AddStep(StepBase::kCut, "TPC Veto", new TPCVetoCut_FGD2()); // 10
57  AddStep(StepBase::kCut, "Gamma Iso Veto", new GammaIsoVetoCut()); // 11
58  AddStep(StepBase::kCut, "External FGD2", new ExternalFGD2layersCut()); // 12
59 
60  AddStep(StepBase::kAction, "find best e+e- pair", new FindPairsAction());
61  AddStep(StepBase::kCut, "Pair Veto", new PairCut()); // 13
62 
63  AddStep(StepBase::kAction, "find P0D-FGD1 veto track", new FindP0DVetoTrackAction());
64  AddStep(StepBase::kCut, "P0D-FGD1 Veto", new P0DFGD1VetoCut()); // 14
65 
66  AddStep(StepBase::kAction, "find ecal veto track", new FindECalVetoTrackAction());
67  AddStep(StepBase::kCut, "ECal Veto", new ECalVetoCut()); // 15
68 
69  // ToF
70  AddStep(StepBase::kCut, "ToF", new ToFCut()); // 16
71 
72  // Momentum quality cut
73  AddStep(StepBase::kCut, "Momentum quality", new MomentumQualityCut()); // 17
74 
75  SetBranchAlias(0,"trunk");
76 
77  // By default the preselection correspond to cuts 0-3
78  // It means that if any of the four first cuts (0,1,2,3) is not passed
79  // the loop over toys will be broken ===> A single toy will be run
80  SetPreSelectionAccumLevel(3);
81 }
82 
83 //********************************************************************
84 bool nueCCFGD2Selection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
85 //********************************************************************
86 
87  if(allCutsPassed[0])
88  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2NuECC;
89 
90  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
91 }
92 
93 //********************************************************************
95 //********************************************************************
96 
97  //ToyBoxTracker& nuebox = *static_cast<ToyBoxTracker*>(&box);
98  ToyBoxNueCC& nuebox = *static_cast<ToyBoxNueCC*>(&box);
99 
100  if(!nuebox.MainTrack) return false;
101 
102  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2NuECC] = nuebox.MainTrack;
103  for(Int_t i = 0; i < 4; ++i)
104  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2NuECC][i] = nuebox.MainTrack->PositionStart[i];
105  if(nuebox.MainTrack->GetTrueParticle())
106  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2NuECC] = nuebox.MainTrack->GetTrueParticle()->TrueVertex;
107 
108  return true;
109 }
110 
111 //*********************************************************************
112 bool nueCCFGD2Selection::IsRelevantRecObjectForSystematic(const AnaEventC& eventC, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
113 //*********************************************************************
114 
115  return _nueCCSelection.IsRelevantRecObjectForSystematic(eventC, recObj, systId, branch);
116 
117 }
118 
119 //*********************************************************************
120 bool nueCCFGD2Selection::IsRelevantTrueObjectForSystematic(const AnaEventC& eventC, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
121 //*********************************************************************
122 
123  return _nueCCSelection.IsRelevantTrueObjectForSystematic(eventC, trueObj, systId, branch);
124 }
125 
126 //**************************************************
127 bool nueCCFGD2Selection::IsRelevantRecObjectForSystematicInToy(const AnaEventC& eventC, const ToyBoxB& boxB, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
128 //**************************************************
129 
130  return _nueCCSelection.IsRelevantRecObjectForSystematicInToy(eventC, boxB, recObj, systId, branch);
131 }
132 
133 //**************************************************
134 bool nueCCFGD2Selection::IsRelevantTrueObjectForSystematicInToy(const AnaEventC& eventC, const ToyBoxB& boxB, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
135 //**************************************************
136 
137  return _nueCCSelection.IsRelevantTrueObjectForSystematicInToy(eventC, boxB, trueObj, systId, branch);
138 }
139 
140 //*********************************************************************
141 bool nueCCFGD2Selection::IsRelevantSystematic(const AnaEventC& eventC, const ToyBoxB& boxB, SystId_h systId, Int_t branch) const{
142 //*********************************************************************
143 
144  return _nueCCSelection.IsRelevantSystematic(eventC, boxB, systId, branch);
145 }
146 
147 //*********************************************************************
148 bool nueCCFGD2Selection::CheckRedoSelection(const AnaEventC& eventC, const ToyBoxB& PreviousToyBoxB, Int_t& redoFromStep){
149 //*********************************************************************
150 
151  return _nueCCSelection.CheckRedoSelection(eventC, PreviousToyBoxB, redoFromStep);
152 }
153 
154 //*********************************************************************
156 //*********************************************************************
157 
158  _nueCCSelection.InitializeEvent(eventC);
159 }
160 
161 //**************************************************
162 bool EOverPCut::Apply(AnaEventC& event, ToyBoxB& boxB) const {
163 //**************************************************
164 
165  (void) event;
166 
167  // cast the box to the appropriate type
168  ToyBoxNueCC& nuebox = *static_cast<ToyBoxNueCC*>(&boxB);
169 
170  AnaTrackB* track = nuebox.MainTrack;
171  if(!track) return false;
172 
173  return nueCutUtils::EOverPNuE(track, _eoverp_threshold, _eoverp_minmom);
174 }
175 
176 //**************************************************
177 bool P0DFGD1VetoCut::Apply(AnaEventC& eventC, ToyBoxB& boxB) const {
178 //**************************************************
179 
180  (void) eventC;
181 
182  // Cast the ToyBox to the appropriate type
183  ToyBoxNueCC& nuebox = *static_cast<ToyBoxNueCC*>(&boxB);
184 
185  if(nuebox.P0DVetoP0DTracks > 0 || nuebox.P0DVetoP0DEcalTracks > 0 || nuebox.P0DVetoFGD1Tracks > 0) return false;
186 
187  return true;
188 }
189 
190 //**************************************************
191 bool TPCVetoCut_FGD2::Apply(AnaEventC& event, ToyBoxB& boxB) const {
192 //**************************************************
193 
194  (void) event;
195 
196  // cast the box to the appropriate type
197  ToyBoxNueCC& nuebox = *static_cast<ToyBoxNueCC*>(&boxB);
198 
199  AnaTrackB* track = nuebox.MainTrack;
200  if(!track) return false;
201 
202  AnaTrackB* vetoTrack = nuebox.VetoTrack;
203  if(!vetoTrack) return true;
204 
205  return (nueCutUtils::TPCVeto(*track, vetoTrack, _delta_z_min));
206 }
207 
208 //********************************************************************
210 //********************************************************************
211 
212  (void)event;
213  // Cast the ToyBox to the appropriate type
214  ToyBoxNueCC& nuebox = *static_cast<ToyBoxNueCC*>(&boxB);
215 
216  if(!nuebox.MainTrack) return false;
217 
218  // Reject external background from the first layer of FGD2
219  if(nuebox.NOOFVTracks > 0) return false;
220 
221  // Reject external background from the last 2 layers of FGD2
222  if(!nuebox.OOFVtrack) return true;
223 
224  if(nuebox.MainTrack->PositionStart[2] > 1770.) return false;
225 
226  return true;
227 }
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
bool IsRelevantTrueObjectForSystematic(const AnaEventC &event, AnaTrueObjectC *trueTrack, SystId_h systId, Int_t branch) const
Is this true track relevant for a given systematic (prior to selection, call when initializing the ev...
Int_t P0DVetoP0DEcalTracks
Number of P0DEcal tracks. Used in the P0D veto cut.
void DefineSteps()
Define all steps in the selection.
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 IsRelevantRecObjectForSystematic(const AnaEventC &event, AnaRecObjectC *track, 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 &boxB) const
Int_t P0DVetoFGD1Tracks
The number of tracks that start in FGD1. Used in the P0D veto cut.
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
AnaTrackB * VetoTrack
The TPC veto track.
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) ...
Representation of a global track.
Int_t NOOFVTracks
OOFV tracks.
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.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Int_t P0DVetoP0DTracks
The number of tracks that start in the P0D. Used in the P0D veto cut.
bool CheckRedoSelection(const AnaEventC &eventC, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
bool Apply(AnaEventC &event, ToyBoxB &boxB) const
A cut on event quality. Requires good beam and ND280 data quality flags.
AnaTrackB * OOFVtrack
For storing the oofv fgd tracks.
void Initialize()
Initialize this selection: defines the steps and the detectorFV.
bool Apply(AnaEventC &event, ToyBoxB &boxB) const