HighLAND
TPCPIDVariation.cxx
1 #include "TPCPIDVariation.hxx"
2 
3 //#define DEBUG
4 
5 //**************************************************
7  //**************************************************
8 
9 
10 #ifdef DEBUG
11  std::cout << " TPCPIDVariation::ApplyVariation(): start " << std::endl;
12 #endif
13 
14 
15  // Check track validity
16  if (!track) return;
17 
18  // Do not do anything if a track does use a TPC
19  if (track->nTPCSegments == 0) return;
20 
21  // Loop over TPC segments
22  for (int k = 0; k < track->nTPCSegments; k++) {
23 
24  if (!track->TPCSegments[k]) continue;
25 
26  // The segment to be modified
27  AnaTPCParticleB* tpcTrack = track->TPCSegments[k];
28 
29 #ifdef DEBUG
30  std::cout << " TPCPIDVariation::ApplyVariation(): tpcSegment " << std::endl;
31  tpcTrack->Print();
32 #endif
33 
34  // The un-corrected TPC track t
35  const AnaTPCParticleB* original = static_cast<const AnaTPCParticleB*>(tpcTrack->Original);
36 
37  if (!track->TrueObject) continue; //?
38  if (!original) continue; //?
39  if (original->dEdxMeas == -99999) continue; //?
40 
41  Float_t mean_var, sigma_var;
42 
43  if (!GetVariation(*tpcTrack, mean_var, sigma_var, *track, exp)) continue;
44 
45 #ifdef DEBUG
46  std::cout << " TPCPIDVariation::ApplyVariation(): variation params -- mean var " << mean_var
47  << " sigma_var " << sigma_var << std::endl;
48 #endif
49 
50 
51  // The expected dEdX
52  Float_t dEdxExp;
53  Float_t dEdxSigma;
54 
55  if (!GetPIDParams(*tpcTrack, dEdxExp, dEdxSigma, *track)) continue;
56 
57 #ifdef DEBUG
58  std::cout << " TPCPIDVariation::ApplyVariation(): dEdX params -- dEdxExp " << dEdxExp
59  << " dEdxSigma " << dEdxSigma << " dEdxMeas_0 " << tpcTrack->dEdxMeas <<std::endl;
60 #endif
61  // Apply the systematic variation for the sigma
62  // smear/queeze to match the new resolution
63  Float_t dEdXMeasNew = dEdxExp + (tpcTrack->dEdxMeas - dEdxExp) * sigma_var;
64  if (dEdXMeasNew < 0) continue;
65  tpcTrack->dEdxMeas = dEdXMeasNew;
66 
67 #ifdef DEBUG
68  std::cout << " TPCPIDVariation::ApplyVariation(): dEdxMeas_1 (sigma) " << tpcTrack->dEdxMeas <<std::endl;
69 #endif
70 
71  // Apply variation related to sigma
72  dEdXMeasNew = tpcTrack->dEdxMeas + (mean_var) * dEdxSigma;
73  if (dEdXMeasNew < 0) continue;
74 
75  tpcTrack->dEdxMeas = dEdXMeasNew;
76 
77 #ifdef DEBUG
78  std::cout << " TPCPIDVariation::ApplyVariation(): dEdxMeas_2 (mean) " << tpcTrack->dEdxMeas <<std::endl;
79 #endif
80  }
81 
82 #ifdef DEBUG
83  std::cout << " TPCPIDVariation::ApplyVariation(): end \n " << std::endl;
84 #endif
85 
86 }
87 
88 //**************************************************
90  Float_t& dEdxExp, Float_t& dEdxSigma,
91  const AnaTrackB& track){
92  //**************************************************
93 
94  // Need true particle
95  if (!track.GetTrueParticle()) return false;
96 
97  // Get the expected dEdx and error on the dEdx depending on the true particle of the
98  // (global) track
99 
100  Int_t PDG = abs(track.GetTrueParticle()->PDG);
101 
102  switch (PDG){
103  case 13: // Muon
104  dEdxExp = (Float_t)tpcTrack.dEdxexpMuon;
105  dEdxSigma = (Float_t)tpcTrack.dEdxSigmaMuon;
106  break;
107  case 211: // Pion
108  dEdxExp = (Float_t)tpcTrack.dEdxexpPion;
109  dEdxSigma = (Float_t)tpcTrack.dEdxSigmaPion;
110  break;
111  case 11: // Electron
112  dEdxExp = (Float_t)tpcTrack.dEdxexpEle;
113  dEdxSigma = (Float_t)tpcTrack.dEdxSigmaEle;
114  break;
115  case 2212: // Proton
116  dEdxExp = (Float_t)tpcTrack.dEdxexpProton;
117  dEdxSigma = (Float_t)tpcTrack.dEdxSigmaProton;
118  break;
119  default:
120  return false;
121  break;
122  }
123 
124  // Is it needed?
125  if (dEdxSigma == -99999 || dEdxExp ==-99999) return false;
126  if (dEdxSigma == -0xABCDEF || dEdxExp ==-0xABCDEF) return false;
127 
128  return true;
129 
130 }
131 
132 
133 
Float_t dEdxexpMuon
Expected dE/dx for a muon, based on the reconstructed momentum.
Float_t dEdxexpProton
Expected dE/dx for a proton, based on the reconstructed momentum.
virtual void ApplyVariation(AnaTrackB *track, const ToyExperiment &exp)
Apply variation for a track, the most general case given a certain ToyExperiment. ...
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
Float_t dEdxSigmaProton
Expected error on the dE/dx measurement, for the proton hypothesis.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
Float_t dEdxexpPion
Expected dE/dx for a pion, based on the reconstructed momentum.
Float_t dEdxexpEle
Expected dE/dx for an electron, based on the reconstructed momentum.
int nTPCSegments
How many TPC tracks are associated with this track.
const AnaParticleB * Original
Float_t dEdxSigmaEle
Expected error on the dE/dx measurement, for the electron hypothesis.
Int_t PDG
The PDG code of this particle.
virtual void Print() const
Dump the object to screen.
Float_t dEdxMeas
dE/dx as measured by the TPC.
Representation of a global track.
virtual bool GetVariation(const AnaTPCParticleB &tpcTrack, Float_t &mean_var, Float_t &sigma_var, const AnaTrackB &track, const ToyExperiment &exp)=0
Representation of a TPC segment of a global track.
Float_t dEdxSigmaMuon
Expected error on the dE/dx measurement, for the muon hypothesis.
Float_t dEdxSigmaPion
Expected error on the dE/dx measurement, for the pion hypothesis.
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
virtual bool GetPIDParams(const AnaTPCParticleB &tpcTrack, Float_t &dEdxExp, Float_t &dEdxSigma, const AnaTrackB &track)