HighLAND
TPCClusterEffSystematics.cxx
1 #include "TPCClusterEffSystematics.hxx"
2 #include "ND280AnalysisUtils.hxx"
3 #include "CutUtils.hxx"
4 #include "SystematicUtils.hxx"
5 #include "SystId.hxx"
6 
7 //********************************************************************
8 TPCClusterEffSystematics::TPCClusterEffSystematics():BinnedParams("TPCClusterEff",k1D_EFF_SYMMETRIC, versionUtils::Extension()){
9 //********************************************************************
10 
11  // Get the TPC cluster extra inefficiency
12  //GetParametersForBin(0, _extraIneff, _extraIneffError);
13  //GetParametersForBin(0, _params);
15 }
16 
17 //********************************************************************
19 //********************************************************************
20 
21  // Get the SystBox for this event, and the appropriate selection and branch
23 
24 
25  Weight_h eventWeight = 1.0;
26 
27  // loop over reconstructed tracks in the TPC
28  for (Int_t irec=0;irec<(int) SystBox->nRelevantRecObjects;irec++){
29  AnaTrackB* track = static_cast<AnaTrackB*>(SystBox->RelevantRecObjects[irec]);
30 
31  if (!track) continue;
32 
33  // For example in numuCC inclusive selection, only the Candidate is important at first order
34  if (!sel.IsRelevantRecObjectForSystematicInToy(event, box, track, SystId::kTpcClusterEff, box.SuccessfulBranch)) continue;
35 
36  //SubDetId::SubDetEnum tpc=anaUtils::GetClosestTPC(*track);
37  //AnaTPCParticleB *tpcTrack=static_cast<AnaTPCParticleB*> (anaUtils::GetSegmentInDet(*track,tpc));
38 
39  // AnaTPCParticleB* tpcTrack = static_cast<AnaTPCParticleB*>(track->TPCSegments[0]);
40 
41  // Use the TPC segment with more nodes in closest TPC to the start position of the track
43  if (!tpcTrack)continue;
44  float dir=fabs(tpcTrack->DirectionStart[2]);
45 
46  BinnedParamsParams params;
47  int index;
48  if(!GetBinValues(dir, params, index)) continue;
49 
50  int nn= tpcTrack->NNodes;
51 
52  // pvar_data/pvar_mc *pana
53  //eff_w = ----------------------
54  // pana
55 
56  // 1- pvar_data/pvar_mc *pana
57  //ineff_w =---------------------------
58  // 1 - pana
59 
60  //meanDATA <=> effdata/effmc
61  //meanMC <=> 1
62  //meanMCANA <=> 1
63  //sigmaMC <=> 0
64  //sigmaDATA <=> ratio error
65 
66  /// extra hit inefficiency for MC: 0.0007 = effdata-effMC/effMC
67  /// => effdata/effmc=1-0.0007
68 
69  // weight = effvarWeight ^nn *( (nn+1) * Pineffvar + 1) / ( (nn+1) * Pineff +1)
70 
71 #if useNewWeights
72  Weight_h eff_w= systUtils::ComputeEffLikeWeight(true, toy.GetToyVariations(_index)->Variations[0], params);//new way with data-mc error included
73 #else
74  Weight_h eff_w= systUtils::ComputeEffLikeWeight(true, toy.GetToyVariations(_index)->Variations[0], toy.GetToyVariations(_index)->Variations[1], params);
75 #endif
76  Float_t Pnom=params.meanMCANA;
77  Weight_h Pineff=(eff_w*(-1))+1; //this is true, only if assume that effMC=1
78 
79  Weight_h weight(TMath::Power(eff_w.Correction,(Float_t)nn)*((nn+1)*(Pineff.Correction)+1. )/ ((nn+1)*(1-Pnom)+1. ),
80  TMath::Power(eff_w.Systematic,(Float_t)nn)*((nn+1)*(Pineff.Systematic)+1. )/ ((nn+1)*(1-Pnom)+1. ));
81  eventWeight*=weight;
82  }
83 
84 
85  return eventWeight;
86 
87 }
88 
89 //********************************************************************
90 Int_t TPCClusterEffSystematics::GetRelevantRecObjectGroups(const SelectionBase& sel, Int_t ibranch, Int_t* IDs) const{
91 //********************************************************************
92 
93  SubDetId_h det = sel.GetDetectorFV(ibranch);
94 
95  if (det == SubDetId::kFGD1){
96  IDs[0] = EventBoxTracker::kTracksWithTPCInFGD1FV;
97  return 1;
98  }
99  else if (det == SubDetId::kFGD2){
100  IDs[0] = EventBoxTracker::kTracksWithTPCInFGD2FV;
101  return 1;
102  }
103  else if (det == SubDetId::kFGD){
104  IDs[0] = EventBoxTracker::kTracksWithTPCInFGD1FV;
105  IDs[1] = EventBoxTracker::kTracksWithTPCInFGD2FV;
106  return 2;
107  }else if (det == SubDetId::kP0D){
108  IDs[0] = EventBoxTracker::kTracksWithTPCInP0DFV;
109  return 1;
110  }
111 
112  return 0;
113 }
Int_t _index
The index of this systematic (needed by SystematicsManager);.
Float_t * Variations
the vector of Variations, one for each of the systematic parameters
Int_t SelectionEnabledIndex
The enabled index of this selection this ToyBox belongs to.
Definition: ToyBoxB.hxx:49
Int_t NNodes
The number of nodes in the reconstructed object.
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 GetBinValues(Float_t value, Float_t &mean, Float_t &sigma)
Gets the bin values for a 1D source.
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 GetRelevantRecObjectGroups(const SelectionBase &sel, Int_t ibranch, Int_t *IDs) const
Get the TrackGroup IDs array for this systematic.
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.
Representation of a TPC segment of a global track.
ToyVariations * GetToyVariations(UInt_t index) const
returns the variations for a given systematic (index)
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
Float_t meanMCANA
The mean value for each of the systematic parameters of the analysis sample.
Int_t nRelevantRecObjects
----—— Relevant rec objects and true objects for each systematic ------------—— ...
Definition: SystBoxB.hxx:20
AnaParticleB * GetSegmentWithMostNodesInClosestTpc(const AnaTrackB &track)
Combined function to address NuMu selection needs as efficiently as possible - gets the TPC segment w...
Weight_h ComputeWeight(const ToyExperiment &, const AnaEventC &, const ToyBoxB &)
Int_t GetNBins()
Get the number of bins.
SubDetId_h GetDetectorFV(Int_t ibranch=0) const
Get the detector in which the Fiducial Volume is defined.