HighLAND
FGDTrackEffSystematics.cxx
1 #include "FGDTrackEffSystematics.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 #include "EventBoxTracker.hxx"
4 #include "SystematicUtils.hxx"
5 #include "SystId.hxx"
6 #include "EventBoxId.hxx"
7 
8 //********************************************************************
9 FGDTrackEffSystematics::FGDTrackEffSystematics(bool comp):EventWeightBase(1){
10 //********************************************************************
11 
12  _fgd1 = NULL;
13  _fgd2 = NULL;
14 
15  _computecounters = comp;
16  _fgd1 = new BinnedParams("FGD1TrackEff_p5F",BinnedParams::k1D_EFF_SYMMETRIC);
17  //_fgd2 = new BinnedParams("FGD2TrackEff_p5F",BinnedParams::k1D_EFF_SYMMETRIC);
18  if( _computecounters) {
19  _fgd1->InitializeEfficiencyCounter();
20  //_fgd2->InitializeEfficiencyCounter();
21  }
22  //SetNParameters(2*(_fgd1->GetNBins()+_fgd2->GetNBins()));
23  SetNParameters(2*(_fgd1->GetNBins()));
24 }
25 
26 //********************************************************************
28 //********************************************************************
29 
30  // Get the SystBox for this event, and the appropriate selection and branch
32 
33  if(_computecounters){
34  _fgd1->InitializeEfficiencyCounter();
35  // _fgd2->InitializeEfficiencyCounter();
36  }
37  Weight_h eventWeight=1;
38 
39  BinnedParamsParams params;
40 
41 
42  for (Int_t itrue=0;itrue< SystBox->nRelevantTrueObjects; itrue++){
43  AnaTrueParticleB* trueTrack = static_cast<AnaTrueParticleB*>(SystBox->RelevantTrueObjects[itrue]);
44  // retrieve the reconstructed track associated
45  AnaTrackB* recoTrack = static_cast<AnaTrackB*>(SystBox->RelevantTrueObjectsReco[itrue]);
46 
47  // Retrieve the cos (theta) value
48  Float_t costheta = trueTrack->Direction[2];
49  if (recoTrack) costheta=recoTrack->DirectionStart[2];
50 
51  bool found = (recoTrack);
52 
53  // Get the FGD tracking efficiency
54  Int_t index;
55  if(box.DetectorFV == SubDetId::kFGD1 || box.DetectorFV == SubDetId::kFGD ){
56  if( !_fgd1->GetBinValues(fabs(costheta), params, index)) continue;
57  if(_computecounters)
58  _fgd1->UpdateEfficiencyCounter(index,found);
59  }
60  else return eventWeight;
61  // if(box.DetectorFV == SubDetId::kFGD2 || box.DetectorFV == SubDetId::kFGD ){
62  // if(!_fgd2->GetBinValues(fabs(costheta), params, index)) continue;
63  // if(_computecounters)
64  // _fgd2->UpdateEfficiencyCounter(index,found);
65  //}
66  eventWeight *= systUtils::ComputeEffLikeWeight(found, toy, GetIndex(), index, params);
67  }
68 
69  return eventWeight;
70 }
71 
72 
73 //********************************************************************
74 bool FGDTrackEffSystematics::IsRelevantTrueObject(const AnaEventC& event, const AnaTrueObjectC& trueTrack) const{
75 //********************************************************************
76 
77  EventBoxB* EventBox = event.EventBoxes[EventBoxId::kEventBoxTracker];
78 
79  //we should not take into account the tracks that are matched to the tpc,
80  //this is done in tpc-fgd matching efficiency
81  for (Int_t i=0;i<EventBox->nRecObjectsInGroup[EventBoxTracker::kTracksWithTPC];i++){
82  AnaRecObjectC* track = EventBox->RecObjectsInGroup[EventBoxTracker::kTracksWithTPC][i];
83  if (CheckTrueRecoAssociation(trueTrack, *track))
84  return false;
85  }
86 
87  // costheta larger than 0.3
88  if(fabs(static_cast<const AnaTrueParticleB*>(&trueTrack)->Direction[2]) < 0.3 ) return false;
89 
90  return true;
91 }
92 
93  //********************************************************************
94 Int_t FGDTrackEffSystematics::GetRelevantRecObjectGroups(const SelectionBase& sel, Int_t ibranch, Int_t* IDs) const{
95 //********************************************************************
96 
97  SubDetId_h det = sel.GetDetectorFV(ibranch);
98 
99  if (det == SubDetId::kFGD1){
100  IDs[0] = EventBoxTracker::kTracksWithFGD1AndNoTPC;
101  return 1;
102  }
103  else if (det == SubDetId::kFGD2){
104  IDs[0] = EventBoxTracker::kTracksWithFGD2AndNoTPC;
105  return 1;
106  }
107  else if (det == SubDetId::kFGD){
108  IDs[0] = EventBoxTracker::kTracksWithFGD1AndNoTPC;
109  IDs[1] = EventBoxTracker::kTracksWithFGD2AndNoTPC;
110  return 2;
111  }
112 
113  return 0;
114 }
115 
116 //********************************************************************
117 Int_t FGDTrackEffSystematics::GetRelevantTrueObjectGroups(const SelectionBase& sel, Int_t ibranch, Int_t* IDs) const{
118 //********************************************************************
119 
120  SubDetId_h det = sel.GetDetectorFV(ibranch);
121 
122  if (det == SubDetId::kFGD1){
123  IDs[0] = EventBoxTracker::kTrueParticlesChargedInFGD1AndNoTPCInBunch;
124  return 1;
125  }
126  else if (det == SubDetId::kFGD2){
127  IDs[0] = EventBoxTracker::kTrueParticlesChargedInFGD2AndNoTPCInBunch;
128  return 1;
129  }
130  else if (det == SubDetId::kFGD){
131  IDs[0] = EventBoxTracker::kTrueParticlesChargedInFGD1AndNoTPCInBunch;
132  IDs[1] = EventBoxTracker::kTrueParticlesChargedInFGD2AndNoTPCInBunch;
133  return 2;
134  }
135 
136  return 0;
137 }
Int_t GetIndex() const
Return the index of this systematic.
Int_t GetRelevantRecObjectGroups(const SelectionBase &sel, Int_t ibranch, Int_t *IDs) const
Get the TrackGroup IDs array for this systematic.
Int_t SelectionEnabledIndex
The enabled index of this selection this ToyBox belongs to.
Definition: ToyBoxB.hxx:49
SubDetId_h DetectorFV
Indicate the FV we are interested in.
Definition: ToyBoxB.hxx:52
SystBoxB * GetSystBox(const AnaEventC &event, Int_t isel=0, Int_t ibranch=0) const
Get the SystBox corresponding to a selection, branch and event.
void SetNParameters(int N)
Set the number of systematic parameters associated to this systematic.
bool IsRelevantTrueObject(const AnaEventC &event, const AnaTrueObjectC &trueTrack) const
Is this true track relevant for this systematic ?
Weight_h ComputeWeight(const ToyExperiment &toy, const AnaEventC &event, const ToyBoxB &box)
Int_t nRecObjectsInGroup[NMAXRECOBJECTGROUPS]
----—— RecObjects and TrueRecObjects used in the selection and systematics ------------—— ...
Representation of a true Monte Carlo trajectory/particle.
Int_t SuccessfulBranch
The branch that is successful for this toy in the selection this ToyBox belongs to.
Definition: ToyBoxB.hxx:46
Representation of a global track.
Int_t nRelevantTrueObjects
Array of Relevant True RecObjects for each systematic.
Definition: SystBoxB.hxx:24
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
AnaRecObjectC ** RelevantTrueObjectsReco
Definition: SystBoxB.hxx:29
Float_t Direction[3]
The initial direction of the true particle.
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.
Int_t GetRelevantTrueObjectGroups(const SelectionBase &sel, Int_t ibranch, Int_t *IDs) const
Get the TrueTrackGroup IDs array for this systematic.