HighLAND
TPCdEdxMCCorrection.cxx
1 #include <stdio.h>
2 #include "TPCdEdxMCCorrection.hxx"
3 #include "HighlandAnalysisUtils.hxx"
4 #include "VersioningUtils.hxx"
5 
6 //********************************************************************
7 TPCdEdxMCCorrection::TPCdEdxMCCorrection():CorrectionBase(){
8 //********************************************************************
9 
10 }
11 
12 //********************************************************************
13 double TPCdEdxMCCorrection::GetCorrection(int pdg) {
14 //********************************************************************
15  double ccorr = 1.;
16 
17  if (abs(pdg) == 11) {
18  if (versionUtils::prod6_corrections)
19  // in prod6 MC overestimates the energy loss of true electrons by 1%
20  ccorr = ccorr * 1.01;
21  else
22  // in prod5 MC underestimates the energy loss of true electrons by 4%
23  ccorr = ccorr / 1.04;
24  }
25 
26  return ccorr;
27 }
28 
29 //********************************************************************
31 //********************************************************************
32 
33  AnaSpill& spill = *static_cast<AnaSpill*>(&spillBB);
34 
35  // No correction for data
36  if (!spill.GetIsMC())
37  return;
38 
39  for (unsigned int i = 0; i < spill.Bunches.size(); i++) {
40  AnaTrackB* allTpcTracks[100];
41  AnaBunch* bunch = static_cast<AnaBunch*>(spill.Bunches[i]);
42  int nTPC = anaUtils::GetAllTracksUsingDet(*bunch, SubDetId::kTPC, allTpcTracks);
43  for (Int_t j = 0; j < nTPC; j++) {
44  for (int k = 0; k < allTpcTracks[j]->nTPCSegments; k++) {
45 
46  // The raw TPC track
47  AnaTPCParticleB* original = static_cast<const AnaTrackB*>(allTpcTracks[j]->Original)->TPCSegments[k];
48  // The corrected TPC track
49  AnaTPCParticle* tpcTrack = static_cast<AnaTPCParticle*>(allTpcTracks[j]->TPCSegments[k]);
50 
51  // Get the raw CT
52  double CT0 = original->dEdxMeas;
53 
54  // Apply the correction
55  if (CT0 != 999999) {
56  // Apply correction only if the CT is a valid number.
57  int pdg = 0;
58  if (tpcTrack->TrueObject) {
59  pdg = tpcTrack->GetTrueParticle()->PDG;
60  }
61 
62  tpcTrack->dEdxMeas = CT0 / GetCorrection(pdg);
63 
64  //recompute TPC pulls
65  Float_t pulls[4];
66  anaUtils::ComputeTPCPull(*tpcTrack, pulls);
67 
68  tpcTrack->Pullele = pulls[1];
69  tpcTrack->Pullmu = pulls[0];
70  tpcTrack->Pullp = pulls[2];
71  tpcTrack->Pullpi = pulls[3];
72 
73  //for the kaon need to recompute explicitely
74  tpcTrack->Pullk = ((tpcTrack->dEdxMeas - tpcTrack->dEdxexpKaon) / tpcTrack->dEdxSigmaKaon);
75 
76  }
77  }
78  }
79  }
80 }
81 
Float_t Pullmu
Muon pull of the segment: (dEdxMeas-dEdxexpMuon)/dEdxSigmaMuon.
Float_t Pullpi
Pion pull of the segment: (dEdxMeas-dEdxexpPion)/dEdxSigmaPion.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
AnaTPCParticleB * TPCSegments[NMAXTPCS]
The TPC segments that contributed to this global track.
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
All corrections should be registered with the CorrectionManager.
int nTPCSegments
How many TPC tracks are associated with this track.
void Apply(AnaSpillC &spill)
const AnaParticleB * Original
Float_t dEdxSigmaKaon
Expected error on the dE/dx measurement, for the proton hypothesis.
Int_t PDG
The PDG code of this particle.
bool GetIsMC() const
Return whether this spill is from Monte Carlo or not.
Float_t dEdxMeas
dE/dx as measured by the TPC.
Representation of a global track.
Float_t ComputeTPCPull(const AnaTPCParticleB &track, const std::string &particle)
Function to recompute the pull for a TPC track segment.
Representation of a TPC segment of a global track.
Float_t Pullk
Kaon pull of the segment: (dEdxMeas-dEdxexpPion)/dEdxSigmaKaon.
Float_t Pullp
Proton pull of the segment: (dEdxMeas-dEdxexpProton)/dEdxSigmaProton.
Float_t Pullele
Electron pull of the segment: (dEdxMeas-dEdxexpEle)/dEdxSigmaEle.
Representation of a TPC segment of a global track.
int GetAllTracksUsingDet(const AnaBunchB &bunch, SubDetId::SubDetEnum det, AnaTrackB *selTracks[])
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Float_t dEdxexpKaon
Expected dE/dx for a proton, based on the reconstructed momentum.