HighLAND
numuBkgInAntiNuModeCCMultiPiSelection.cxx
1 #include "numuBkgInAntiNuModeCCMultiPiSelection.hxx"
2 #include "numuBkgInAntiNuModeCCSelection.hxx"
3 #include "antiNumuCCMultiPiSelection.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 numuBkgInAntiNuModeCCMultiPiSelection::numuBkgInAntiNuModeCCMultiPiSelection(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_CCMultiPi", new FillSummaryAction_numuBkg_CCMultiPi());
28  AddStep(StepBase::kAction, "find_pions", new FindPionsAction());
29 
30  //Add a split to the trunk with 3 branches.
31  AddSplit(3);
32 
33  //First branch is for CC-0pi
34  AddStep(0, StepBase::kCut, "CC-0pi", new NoPionCut());
35 
36  //Second branch is for CC-1pi
37  AddStep(1, StepBase::kCut, "CC-1pi", new OnePionCut());
38 
39  //Third branch is for CC-Other
40  AddStep(2, StepBase::kCut, "CC-Other", new OthersCut());
41 
42  // Set the branch aliases to the three branches
43  SetBranchAlias(0,"CC-0pi",0);
44  SetBranchAlias(1,"CC-1pi",1);
45  SetBranchAlias(2,"CC-Other",2);
46 
47  // By default the preselection correspond to cuts 0-2
48  SetPreSelectionAccumLevel(2);
49 }
50 
51 //********************************************************************
53 //********************************************************************
54 
55  // The detector in which the selection is applied
56  SetDetectorFV(SubDetId::kFGD1);
57 
58  // Set the detector field into the selection beaing used
59  _numuCCMultiPiSelection.SetDetectorFV(SubDetId::kFGD1);
60  _numuBkgInAntiNuModeCCSelection.SetDetectorFV(SubDetId::kFGD1);
61 }
62 
63 //********************************************************************
64 bool numuBkgInAntiNuModeCCMultiPiSelection::FillEventSummary(AnaEventC& event, Int_t allCutsPassed[]){
65 //********************************************************************
66 
67  //CC0pi
68  if(allCutsPassed[0]){
69  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuBkgInAntiNuModeCC0Pi;
70  }
71  //CC1pi
72  else if (allCutsPassed[1]){
73  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuBkgInAntiNuModeCC1Pi;
74  }
75  //CCOther
76  else if (allCutsPassed[2]){
77  static_cast<AnaEventSummaryB*>(event.Summary)->EventSample = SampleId::kFGD1NuMuBkgInAntiNuModeCCOther;
78  }
79 
80  // otherwise kUnassigned is used from the EventSummary constructor
81  return (static_cast<AnaEventSummaryB*>(event.Summary)->EventSample != SampleId::kUnassigned);
82 }
83 
84 //*********************************************************************
86 //*********************************************************************
87 
88  // Cast the ToyBox to the appropriate type
89  ToyBoxTracker& box = *static_cast<ToyBoxTracker*>(&boxB);
90 
91  if(!box.HMNtrack) return 1;
92 
93  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuBkgInAntiNuModeCC0Pi] = box.HMNtrack;
94  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuBkgInAntiNuModeCC1Pi] = box.HMNtrack;
95  static_cast<AnaEventSummaryB*>(event.Summary)->LeptonCandidate[SampleId::kFGD1NuMuBkgInAntiNuModeCCOther] = box.HMNtrack;
96 
97  for(int i = 0; i < 4; ++i){
98  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuBkgInAntiNuModeCC0Pi][i] = box.HMNtrack->PositionStart[i];
99  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuBkgInAntiNuModeCC1Pi][i] = box.HMNtrack->PositionStart[i];
100  static_cast<AnaEventSummaryB*>(event.Summary)->VertexPosition[SampleId::kFGD1NuMuBkgInAntiNuModeCCOther][i] = box.HMNtrack->PositionStart[i];
101  }
102  if(box.HMNtrack->GetTrueParticle()){
103  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuBkgInAntiNuModeCC0Pi] = box.HMNtrack->GetTrueParticle()->TrueVertex;
104  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuBkgInAntiNuModeCC1Pi] = box.HMNtrack->GetTrueParticle()->TrueVertex;
105  static_cast<AnaEventSummaryB*>(event.Summary)->TrueVertex[SampleId::kFGD1NuMuBkgInAntiNuModeCCOther] = box.HMNtrack->GetTrueParticle()->TrueVertex;
106  }
107  return 1;
108 }
109 
110 
111 //**************************************************
112 bool numuBkgInAntiNuModeCCMultiPiSelection::IsRelevantRecObjectForSystematic(const AnaEventC& event, AnaRecObjectC* track, SystId_h systId, Int_t branch) const{
113 //**************************************************
114 
115  return _numuCCMultiPiSelection.IsRelevantRecObjectForSystematic(event,track,systId,branch);
116 }
117 
118 //**************************************************
119 bool numuBkgInAntiNuModeCCMultiPiSelection::IsRelevantTrueObjectForSystematic(const AnaEventC& event, AnaTrueObjectC* trueTrack, SystId_h systId, Int_t branch) const{
120 //**************************************************
121 
122  return _numuCCMultiPiSelection.IsRelevantTrueObjectForSystematic(event,trueTrack,systId,branch);
123 }
124 
125 //**************************************************
126 bool numuBkgInAntiNuModeCCMultiPiSelection::IsRelevantSystematic(const AnaEventC& event, const ToyBoxB& box, SystId_h systId, Int_t branch) const{
127 //**************************************************
128 
129  // Same as for antiNumuCCMultiPi but preffers to write it explicitely
130 
131  (void)event;
132  (void)branch;
133  (void)box;
134 
135  if (systId==SystId::kFgdTrackEff)// No FGD track eff
136  return false;
137  //else if (systId==SystId::kFgdHybridTrackEff) // No FGD hybrid track eff
138  //return false;
139  //else if (systId==SystId::kMichelEleEff) // No michel electron Systematic
140  //return false;
141  return true;
142 }
143 
144 //**************************************************
146 //**************************************************
147 
148  _numuCCMultiPiSelection.InitializeEvent(event);
149 }
150 
151 //********************************************************************
152 bool numuBkgInAntiNuModeCCMultiPiSelection::CheckRedoSelection(const AnaEventC& event, const ToyBoxB& PreviousToyBox, Int_t& redoFromStep){
153 //********************************************************************
154 
155  // Must redo selection if _numuBkgInAntiNuModeCCSelection decides so
156  if( _numuBkgInAntiNuModeCCSelection.CheckRedoSelection(event,PreviousToyBox,redoFromStep)) return true;
157 
158  // Otherwise selection should not be redone since the number of tracks with TPC and FGD will not be changed by systematics
159  return false;
160 }
161 
void InitializeEvent(AnaEventC &event)
Fill the EventBox with the objects needed by this selection.
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 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 DefineSteps()
Define all steps in the selection.
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 * HMNtrack
For storing the highest momentum negative track.
void DefineDetectorFV()
Define the detector Fiducial Volume in which this selection is applied.
bool Apply(AnaEventC &event, ToyBoxB &box) const
AnaEventSummaryC * Summary
A summary of the event with high level quantities.
bool CheckRedoSelection(const AnaEventC &event, const ToyBoxB &PreviousToyBox, Int_t &redoFromStep)
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
bool IsRelevantSystematic(const AnaEventC &event, const ToyBoxB &box, SystId_h systId, Int_t branch) const
Is this systematic relevant for this selection.
void Initialize()
Initialize this selection: defines the steps and the detectorFV.