HighLAND
FGD2ShowerSystematics.cxx
1 #include "FGD2ShowerSystematics.hxx"
2 #include "CutUtils.hxx"
3 #include "SystematicUtils.hxx"
4 #include "SystId.hxx"
5 #include "EventBoxId.hxx"
6 
7 //#define DEBUG
8 
9 //********************************************************************
10 FGD2ShowerSystematics::FGD2ShowerSystematics(bool comp):BinnedParams("FGD2Shower", k2D_EFF_ASSYMMETRIC){
11 //********************************************************************
12 
13  _computecounters = comp;
15  if(_computecounters)
17 }
18 
19 //********************************************************************
21 //********************************************************************
22 
23 
24  if(_computecounters)
26 
27  (void)event;
28 
29  // Get the SystBox for this event, and the appropriate selection and branch
30  SystBoxB* SystBox = GetSystBox(event, boxB.SelectionEnabledIndex, boxB.SuccessfulBranch);
31 
32  Weight_h eventWeight = 1.;
33 
34 #ifdef DEBUG
35  std::cout << " \n FGD2ShowerSystematics::Apply(): " << SystBox->nRelevantRecObjects<< std::endl;
36 #endif
37 
38  if(boxB.DetectorFV != SubDetId::kFGD1) return eventWeight;
39 
40  // Loop over relevant tracks
41  for (Int_t itrk = 0; itrk < SystBox->nRelevantRecObjects; itrk++){
42 
43  AnaTrackB* track = static_cast<AnaTrackB*>(SystBox->RelevantRecObjects[itrk]);
44  if (!track) continue;
45 
46  if (!sel.IsRelevantRecObjectForSystematicInToy(event, boxB, track, SystId::kFGD2Shower, boxB.SuccessfulBranch)) continue;
47 
48  // Should have a true track
49  AnaTrueParticleB* truePart = track->GetTrueParticle();
50  if (!truePart) continue;
51 
52  int pdg = abs(truePart->PDG);
53 
54  BinnedParamsParams params;
55  int index;
56 
57  //if (!GetBinValues(pdg, truePart->Momentum, params, index)) continue;
58  if (!GetBinValues(pdg, track->Momentum, params, index)) continue;
59 
60  bool found = true;
61 
62  // Found the correspondence, now get the weight
63  eventWeight *= systUtils::ComputeEffLikeWeight(found, toy, GetIndex(), index, params);
64 
65 
66 #ifdef DEBUG
67  std::cout<<"FGD2Shower " << found << " eventWeight local " << eventWeight << std::endl;
68 #endif
69 
70  if(_computecounters)
71  UpdateEfficiencyCounter(index,true);
72 
73  }
74 
75  return eventWeight;
76 }
77 
78 
79 //********************************************************************
80 bool FGD2ShowerSystematics::IsRelevantRecObject(const AnaEventC& event, const AnaRecObjectC& recObj) const{
81  //********************************************************************
82 
83  (void)event;
84 
85  const AnaTrackB& track = *static_cast<const AnaTrackB*>(&recObj);
86 
87  if(!track.TrueObject) return false;
88  if(track.nFGDSegments==0) return false;
89  //if(anaUtils::InFiducialVolume(SubDetId::kFGD2, track.PositionStart)) return false;
90 
91  return true;
92 
93 }
94 
95 
96 //********************************************************************
97 Int_t FGD2ShowerSystematics::GetRelevantRecObjectGroups(const SelectionBase& sel, Int_t ibranch, Int_t* IDs) const{
98  //********************************************************************
99 
100  (void)sel;
101  (void)ibranch;
102  IDs[0] = EventBoxTracker::kTracksWithTPC;
103  //IDs[0] = EventBoxTracker::kTracksWithTPCInFGD1FV;
104  return 1;
105 }
106 
107 
Int_t GetIndex() const
Return the index of this systematic.
bool IsRelevantRecObject(const AnaEventC &event, const AnaRecObjectC &recObj) const
Is this track relevant 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.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
bool GetBinValues(Float_t value, Float_t &mean, Float_t &sigma)
Gets the bin values for a 1D source.
Weight_h ComputeWeight(const ToyExperiment &, const AnaEventC &, const ToyBoxB &)
Apply the systematic.
bool UpdateEfficiencyCounter(Int_t index, bool correct)
Update the efficiency variables _ncorrect and _nwrong.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo trajectory/particle.
virtual bool IsRelevantRecObjectForSystematicInToy(const AnaEventC &, const ToyBoxB &, AnaRecObjectC *, SystId_h syst_index, Int_t branch=0) const
Is this track relevant for a given systematic (after selection, called for each toy) ...
Int_t SuccessfulBranch
The branch that is successful for this toy in the selection this ToyBox belongs to.
Definition: ToyBoxB.hxx:46
Int_t PDG
The PDG code of this particle.
Representation of a global track.
int nFGDSegments
How many FGD tracks are associated with this track.
Int_t nRelevantRecObjects
----—— Relevant rec objects and true objects for each systematic ------------—— ...
Definition: SystBoxB.hxx:20
void InitializeEfficiencyCounter()
Initialize counters.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Int_t GetNBins()
Get the number of bins.
Int_t GetRelevantRecObjectGroups(const SelectionBase &sel, Int_t ibranch, Int_t *IDs) const
Get the TrackGroup IDs array for this systematic.