HighLAND
numuCCFGD2Selection.cxx
1 #include "numuCCFGD2Selection.hxx"
2 #include "baseSelection.hxx"
3 #include "CutUtils.hxx"
4 #include "EventBoxUtils.hxx"
5 #include "SubDetId.hxx"
6 #include "SystId.hxx"
7 #include "VersioningUtils.hxx"
8 #include "SystematicUtils.hxx"
9 
10 //********************************************************************
11 numuCCFGD2Selection::numuCCFGD2Selection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
12 //********************************************************************
13 
14  // Initialize the numuCCSelection, which is used
15  _numuCCSelection.Initialize();
16 }
17 
18 //********************************************************************
20 //********************************************************************
21 
22  // Cuts must be added in the right order
23  // last "true" means the step sequence is broken if cut is not passed (default is "false")
24  AddStep(StepBase::kCut, "event quality", new EventQualityCut(), true);
25  AddStep(StepBase::kCut, "> 0 tracks ", new TotalMultiplicityCut(), true);
26  AddStep(StepBase::kAction, "find leading tracks",new FindLeadingTracksAction());
27  AddStep(StepBase::kAction, "find vertex", new FindVertexAction());
28  AddStep(StepBase::kAction, "fill_summary", new FillSummaryAction_numuCCFGD2());
29  AddStep(StepBase::kCut, "quality+fiducial", new TrackQualityFiducialCut(), true);
30  AddStep(StepBase::kAction, "find veto track", new FindVetoTrackAction());
31  AddStep(StepBase::kCut, "veto", new ExternalFGD2VetoCut());
32  AddStep(StepBase::kAction, "find oofv track", new FindOOFVTrackAction());
33  AddStep(StepBase::kCut, "External FGD2", new ExternalFGD2LastLayersCut());
34  AddStep(StepBase::kCut, "muon PID", new MuonPIDCut());
35 
36  SetBranchAlias(0,"trunk");
37 
38  // By default the preselection correspond to cuts 0-2
39  SetPreSelectionAccumLevel(2);
40 }
41 
42 //********************************************************************
44 //********************************************************************
45 
46  // The detector in which the selection is applied
47  SetDetectorFV(SubDetId::kFGD2);
48 
49  // If we want to use the numuCCSelection we should tell it to use FGD2
50  _numuCCSelection.SetDetectorFV(SubDetId::kFGD2);
51 }
52 
53 //********************************************************************
54 bool numuCCFGD2Selection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
55 //********************************************************************
56 
57  if(allCutsPassed[0]){
58  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD2NuMuCC;
59  }
60  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
61 }
62 
63 //********************************************************************
64 bool ExternalFGD2VetoCut::Apply(AnaEventC& event, ToyBoxB& boxB) const{
65 //********************************************************************
66 
67  // Cast the ToyBox to the appropriate type
68  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
69 
70  if (!box.MainTrack) return false;
71  if( !cutUtils::ExternalVetoCut(*(box.MainTrack),box.VetoTrack)) return false;
72 
73  // Veto also whenever there's a tracker track (or just any track? to be decided) starting in FGD1
74  // this guarantees to veto events with a muon candidate in FGD1
75  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
76  AnaRecObjectC** selTracks = EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithTPC];
77  int nTPC=EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPC];
78 
79  //loop over tpc tracks
80  for (Int_t i=0;i<nTPC; ++i){
81  AnaTrackB* thistrack = static_cast<AnaTrackB*>(selTracks[i]);
82 
83  if (thistrack->Momentum < 0 ) continue; // protection for bad momentum
84 
85  if (anaUtils::InFiducialVolume(SubDetId::kFGD1, thistrack->PositionStart )) return false;
86  }
87 
88  return true;
89 }
90 
91 //********************************************************************
93 //********************************************************************
94 
95  (void)event;
96 
97  // Cast the ToyBox to the appropriate type
98  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
99 
100  /// Reject external background from the last 2 layers of FGD2
101  if (!box.MainTrack) return false;
102  if (!box.OOFVtrack) return true;
103  if (box.MainTrack->PositionStart[2]>1770.) //1795 for 1 layer, +0.15 % eff, -0.18 purity
104  return false;
105 
106  return true;
107 }
108 
109 //********************************************************************
111 //********************************************************************
112 
113  // Cast the ToyBox to the appropriate type
114  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
115 
116  if(!box.HMNtrack) return 1;
117 
118  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD2NuMuCC] = box.HMNtrack;
119  for(int i = 0; i < 4; ++i){
120  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD2NuMuCC][i] = box.HMNtrack->PositionStart[i];
121  }
122  if(box.HMNtrack->GetTrueParticle()) static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD2NuMuCC] = box.HMNtrack->GetTrueParticle()->TrueVertex;
123 
124  return true;
125 }
126 
127 //**************************************************
128 bool numuCCFGD2Selection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
129 //**************************************************
130 
131  return _numuCCSelection.IsRelevantRecObjectForSystematic(event,recObj,systId,branch);
132 }
133 
134 //**************************************************
135 bool numuCCFGD2Selection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
136 //**************************************************
137 
138  return _numuCCSelection.IsRelevantTrueObjectForSystematic(event,trueObj,systId,branch);
139 }
140 
141 //**************************************************
142 bool numuCCFGD2Selection::IsRelevantRecObjectForSystematicInToy(const AnaEventC& event, const ToyBoxB& box, AnaRecObjectC* recObj, SystId_h systId, Int_t branch) const{
143 //**************************************************
144 
145  return _numuCCSelection.IsRelevantRecObjectForSystematicInToy(event, box, recObj, systId, branch);
146 }
147 
148 //**************************************************
149 bool numuCCFGD2Selection::IsRelevantTrueObjectForSystematicInToy(const AnaEventC& event, const ToyBoxB& box, AnaTrueObjectC* trueObj, SystId_h systId, Int_t branch) const{
150 //**************************************************
151 
152  return _numuCCSelection.IsRelevantTrueObjectForSystematicInToy(event, box, trueObj, systId, branch);
153 }
154 
155 //**************************************************
156 bool numuCCFGD2Selection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
157 //**************************************************
158 
159  return _numuCCSelection.IsRelevantSystematic(event, box, systId, branch);
160 }
161 
162 //**************************************************
164 //**************************************************
165 
166  _numuCCSelection.InitializeEvent(event);
167 }
168 
169 //********************************************************************
170 bool numuCCFGD2Selection::CheckRedoSelection(const AnaEventC& event, const ToyBoxB& PreviousToyBox, Int_t& redoFromStep){
171 //********************************************************************
172 
173  return _numuCCSelection.CheckRedoSelection(event, PreviousToyBox, redoFromStep);
174 }
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
void DefineSteps()
Define all steps in the selection.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
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
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...
AnaTrackB * MainTrack
For storing the Main Track (The lepton candidate in geranal: HMN or HMP track)
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
Leading tracks with good quality in FGD1.
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...
AnaTrackB * VetoTrack
For storing the veto track.
AnaTrackB * HMNtrack
For storing the highest momentum negative track.
Representation of a global track.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
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) ...
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) ...
Find the Vertex. For the moment it&#39;s just the Star position of the HM track.
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
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)
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.