HighLAND
numuBkgInAntiNuModeCCMultiTrackSelection.cxx
1 #include "numuBkgInAntiNuModeCCMultiTrackSelection.hxx"
2 #include "numuBkgInAntiNuModeCCSelection.hxx"
3 #include "antiNumuCCMultiTrackSelection.hxx"
4 #include "baseSelection.hxx"
5 #include "CutUtils.hxx"
6 #include "Parameters.hxx"
7 #include "SubDetId.hxx"
8 #include "EventBoxId.hxx"
9 #include "SystId.hxx"
10 
11 //********************************************************************
12 numuBkgInAntiNuModeCCMultiTrackSelection::numuBkgInAntiNuModeCCMultiTrackSelection(bool forceBreak): SelectionBase(forceBreak,EventBoxId::kEventBoxTracker) {
13 //********************************************************************
14 
15  // Initialize the numuCCMultiPiSelection, which is used
16  _numuCCMultiPiSelection.Initialize();
17 }
18 
19 //********************************************************************
21 //********************************************************************
22 
23  // Copy all steps from the numuBkgInAntiNuModeCCSelection
24  CopySteps(_numuBkgInAntiNuModeCCSelection);
25 
26  //Additional actions for the multi-pi selection.
27  AddStep(StepBase::kAction, "fill summary numuBkg_CCMultiTrack", new FillSummaryAction_numuBkg_CCMultiTrack());
28 
29  //Add a split to the trunk with 2 branches.
30  AddSplit(2);
31 
32  //First branch is for CC1Track enhanced sample
33  AddStep(0, StepBase::kCut, "CC1Track", new CCQEcut_antinu());
34 
35  //Second branch is for CCNTracks enhanced sample
36  AddStep(1, StepBase::kCut, "CCNTracks", new CCnQEcut_antinu());
37 
38  // Set the branch aliases to the three branches
39  SetBranchAlias(0,"CC1Track",0);
40  SetBranchAlias(1,"CCNTracks",1);
41 
42  // By default the preselection correspond to cuts 0-2
43  SetPreSelectionAccumLevel(2);
44 }
45 
46 //********************************************************************
48 //********************************************************************
49 
50  // The detector in which the selection is applied
51  SetDetectorFV(SubDetId::kFGD1);
52 
53  // Set the detector field into the selection beaing used
54  _numuCCMultiPiSelection.SetDetectorFV(SubDetId::kFGD1);
55  _numuBkgInAntiNuModeCCSelection.SetDetectorFV(SubDetId::kFGD1);
56 }
57 
58 //********************************************************************
59 bool numuBkgInAntiNuModeCCMultiTrackSelection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
60 //********************************************************************
61 
62  //CC1Track
63  if(allCutsPassed[0]){
64  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuBkgInAntiNuModeCC1Track;
65  }
66  //CCNTracks
67  else if (allCutsPassed[1]){
68  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuBkgInAntiNuModeCCNTracks;
69  }
70 
71  // otherwise kUnassigned is used from the EventSummary constructor
72  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
73 }
74 
75 //*********************************************************************
77 //*********************************************************************
78 
79  // Cast the ToyBox to the appropriate type
80  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
81 
82  if(!box.HMNtrack) return 1;
83 
84  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuBkgInAntiNuModeCC1Track] = box.HMNtrack;
85  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuBkgInAntiNuModeCCNTracks] = box.HMNtrack;
86 
87  for(int i = 0; i < 4; ++i){
88  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuBkgInAntiNuModeCC1Track][i] = box.HMNtrack->PositionStart[i];
89  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuBkgInAntiNuModeCCNTracks][i] = box.HMNtrack->PositionStart[i];
90  }
91  if(box.HMNtrack->GetTrueParticle()){
92  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuBkgInAntiNuModeCC1Track] = box.HMNtrack->GetTrueParticle()->TrueVertex;
93  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuBkgInAntiNuModeCCNTracks] = box.HMNtrack->GetTrueParticle()->TrueVertex;
94  }
95  return 1;
96 }
97 
98 
99 //**************************************************
100 bool numuBkgInAntiNuModeCCMultiTrackSelection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* track, SystId_h systId, Int_t branch) const{
101 //**************************************************
102 
103  return _numuCCMultiPiSelection.IsRelevantRecObjectForSystematic(event,track,systId,branch);
104 }
105 
106 //**************************************************
107 bool numuBkgInAntiNuModeCCMultiTrackSelection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueTrack, SystId_h systId, Int_t branch) const{
108 //**************************************************
109 
110  return _numuCCMultiPiSelection.IsRelevantTrueObjectForSystematic(event,trueTrack,systId,branch);
111 }
112 
113 //**************************************************
114 bool numuBkgInAntiNuModeCCMultiTrackSelection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
115 //**************************************************
116 
117  // Same as for antiNumuCCMultiPi but preffers to write it explicitely
118 
119  (void)event;
120  (void)branch;
121  (void)box;
122 
123  if (systId==SystId::kFgdTrackEff) // No FGD track eff
124  return false;
125  else if (systId==SystId::kFgdHybridTrackEff) // No FGD hybrid track eff
126  return false;
127  else if (systId==SystId::kMichelEleEff) // No michel electron Systematic
128  return false;
129  return true;
130 }
131 
132 //**************************************************
134 //**************************************************
135 
136  _numuCCMultiPiSelection.InitializeEvent(event);
137 }
138 
139 //********************************************************************
140 bool numuBkgInAntiNuModeCCMultiTrackSelection::CheckRedoSelection(const AnaEventC& event, const ToyBoxB& PreviousToyBox, Int_t& redoFromStep){
141 //********************************************************************
142 
143  // Must redo selection if _numuBkgInAntiNuModeCCSelection decides so
144  if( _numuBkgInAntiNuModeCCSelection.CheckRedoSelection(event,PreviousToyBox,redoFromStep)) return true;
145 
146  // Otherwise selection should not be redone since the number of tracks with TPC and FGD will not be changed by systematics
147  return false;
148 }
149 
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
Float_t PositionStart[4]
The reconstructed start position of the particle.
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
AnaTrackB * HMNtrack
For storing the highest momentum negative track.
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...
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
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...
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
void Initialize()
Initialize this selection: defines the steps and the detectorFV.