1 #include "PIDUtils.hxx" 2 #include "CutUtils.hxx" 3 #include "VersioningUtils.hxx" 5 const unsigned int NMAXPARTICLESWITHTPC = NMAXPARTICLES;
40 Float_t ExpecteddEP0 = 149.4;
41 Float_t ExpecteddEP1 = 2.765;
42 Float_t ExpecteddEP2 = 0.103;
43 Float_t ExpecteddEP3 = 2.052;
44 Float_t ExpecteddEP4 = 0.5104;
46 if (versionUtils::prod6_corrections){
50 ExpecteddEP2 = 0.001913;
57 if (particle ==
"electron") {
59 }
else if (particle ==
"pion") {
61 }
else if (particle ==
"muon") {
63 }
else if (particle ==
"proton") {
65 }
else if (particle ==
"kaon") {
68 std::cout <<
"Tried to compute dEdx for invalid particle hypothesis" << std::endl;
73 Float_t beta = bg / sqrt(1. + bg * bg);
74 Float_t func = ExpecteddEP1 - pow(beta, ExpecteddEP3) - log(ExpecteddEP2 + 1. / pow(bg, ExpecteddEP4));
75 func = func * ExpecteddEP0 / pow(beta, ExpecteddEP3);
84 UInt_t itrk = track.
Index;
86 if( itrk >= NMAXPARTICLESWITHTPC )
return;
88 Double_t prob[4]={1,1,1,1};
89 Double_t tmp_prob[3][4];
90 Double_t total_prob=0;
94 for(
int i = 0; i < 3; ++i){
95 segmentsInTPC[i] = NULL;
96 for (Int_t j=0;j<4;j++){
107 if (!TPCSegment)
continue;
111 if(!prod5Cut)
if (!cutUtils::TPCTrackQualityCut(*TPCSegment))
continue;
115 if( TPCSegment->
dEdxMeas ==-0xABCDEF )
continue;
117 if( TPCSegment->
dEdxMeas ==-99999 )
continue;
122 Float_t pullmu = pulls[0];
123 Float_t pullp = pulls[2];
124 Float_t pullele = pulls[1];
125 Float_t pullpi = pulls[3];
127 if (!TMath::Finite(pullmu) || !TMath::Finite(pullele) || !TMath::Finite(pullp) || !TMath::Finite(pullpi))
continue;
128 if (pullmu != pullmu || pullele != pullele || pullp != pullp || pullpi != pullpi)
continue;
133 if (segmentsInTPC[det-2]){
135 segmentsInTPC[det-2] = TPCSegment;
136 tmp_prob[det-2][0] = exp(-(pullmu*pullmu)/2);
137 tmp_prob[det-2][1] = exp(-(pullele*pullele)/2);
138 tmp_prob[det-2][2] = exp(-(pullp*pullp)/2);
139 tmp_prob[det-2][3] = exp(-(pullpi*pullpi)/2);
143 segmentsInTPC[det-2] = TPCSegment;
144 tmp_prob[det-2][0] = exp(-(pullmu*pullmu)/2);
145 tmp_prob[det-2][1] = exp(-(pullele*pullele)/2);
146 tmp_prob[det-2][2] = exp(-(pullp*pullp)/2);
147 tmp_prob[det-2][3] = exp(-(pullpi*pullpi)/2);
152 for (
int tpc=0;tpc<3;tpc++){
153 if (segmentsInTPC[tpc]){
155 prob[0] *= tmp_prob[tpc][0];
156 prob[1] *= tmp_prob[tpc][1];
157 prob[2] *= tmp_prob[tpc][2];
158 prob[3] *= tmp_prob[tpc][3];
166 for (
int h=0;h<4;h++){
167 total_prob += prob[h] ;
171 for (
int h=0;h<4;h++){
172 hypo[h] = prob[h]/total_prob ;
183 if( hypo >= 4 )
return -1.e+6;
185 Float_t Likelihood[4];
187 return Likelihood[hypo];
194 Float_t Likelihood[4];
197 Float_t likemu = Likelihood[0];
198 Float_t likepi = Likelihood[3];
199 Float_t likep = Likelihood[2];
201 return (likemu+likepi)/(1-likep);
210 Float_t xbins[18] = {0., 100., 200., 300., 400., 500., 600., 700, 800, 1000., 1200., 1400., 1700, 2000., 2500., 3000., 4000., 5000.};
212 Float_t eprior[17] = {800., 250., 100, 40, 30, 25, 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0};
214 for (Int_t i=0;i<17;i++){
219 for (Int_t i=0;i<17;i++){
225 if (hypo==1)
return eprior[pbin];
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.
Int_t NNodes
The number of nodes in the reconstructed object.
SubDetId::SubDetEnum GetClosestTPC(const AnaTrackB &track)
For tracks that start in the FGD, get the closest TPC in the direction of the track.
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.
static bool GetDetectorUsed(unsigned long BitField, SubDetId::SubDetEnum det)
Method to see if a certain subdetector or subdetector system is used.
void RecomputeTPCPulls(AnaTPCParticleB &track)
Function to recompute all the pull for a TPC track segment and save them into the segment...
Float_t GetPIDPrior(const AnaTrackB &track, Int_t hypo)
A function that is not currently used, and will be documented when it is.
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.
Float_t GetPIDLikelihood(const AnaTrackB &track, Int_t hypo, bool prod5Cut=0)
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Int_t Index
The index of this particle track in the vector of particles. TODO: Not sure it is needed (only use in...
int nTPCSegments
How many TPC tracks are associated with this track.
Float_t dEdxSigmaEle
Expected error on the dE/dx measurement, for the electron hypothesis.
SubDetEnum
Enumeration of all detector systems and subdetectors.
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.
static SubDetId::SubDetEnum GetSubdetectorEnum(unsigned long BitField)
Get the single subdetector that this track is from.
Representation of a TPC segment of a global track.
Float_t ExpectedTPCdEdx(const AnaTPCParticleB &track, const std::string &particle)
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.
Float_t GetPIDLikelihoodMIP(const AnaTrackB &track)
Get the likelihood for MIP: (like_mu+like_pi)/(1-like_p)