- // The class AliTRDCalPIDLQ contains precalculated prob dis.
- AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
- if (!pd) return -1;
-
- // Example to get mean for particle 2 (pi) and momentum number 4 (2 GeV)
- // printf("%.2f \n", pd->GetMean(2, 4));
- // Example of use of Copy Constructor
- // AliTRDCalPIDLQ *pd1 = new AliTRDCalPIDLQ(*pd);
-
- Int_t ntrk=event->GetNumberOfTracks();
- for (Int_t i=0; i<ntrk; i++) {
- AliESDtrack *t=event->GetTrack(i);
- if ((t->GetStatus()&AliESDtrack::kTRDin)==0)
- if ((t->GetStatus()&AliESDtrack::kTRDout)==0)
- if ((t->GetStatus()&AliESDtrack::kTRDrefit)==0) continue;
- if(t->GetTRDsignal()==0) continue;
- // Int_t ns=AliESDtrack::kSPECIES;
- Int_t ns=AliPID::kSPECIES;
- Double_t p[10];
- Double_t mom=t->GetP();
- Double_t probTotal=0.0;
- for (Int_t j=0; j<ns; j++) {
- p[j]=1.;
- for (Int_t ilayer=0; ilayer <6; ilayer++) {
- Double_t dedx=t->GetTRDsignals(ilayer);
- Int_t timbin=t->GetTRDTimBin(ilayer);
- p[j]*= pd->GetProbability(j,mom,dedx);
- p[j]*= pd->GetProbabilityT(j,mom,timbin);
- p[j]*= 100;
- } // loop over layers
- probTotal+=p[j];
- } //loop over particle species
- // printf(" %f %d %f %f %f \n", mom, timbin, p[0], p[1], p[2]);
- for (Int_t j=0; j<ns; j++) {
- if(probTotal) p[j]/= probTotal;
- else p[j]=1.0;
- // p[j]=1.;
- } //loop over particle species
+// AliTRDrecoParam *rec = AliTRDReconstructor::RecoParam();
+// if (!rec) {
+// AliErrorGeneral("AliTRDpidESD::MakePID()", "No TRD reco param.");
+// return 0x0;
+// }
+
+ // Retrieve the CDB container class with the probability distributions
+ const AliTRDCalPID *pd = calibration->GetPIDObject(AliTRDpidUtil::kLQ);
+ if (!pd) {
+ AliErrorGeneral("AliTRDpidESD::MakePID()"
+ ,"No access to AliTRDCalPID");
+ return -1;
+ }
+
+ // Loop through all ESD tracks
+ Double_t p[10];
+ AliESDtrack *t = NULL;
+ Float_t dedx[AliTRDCalPID::kNSlicesLQ], dEdx;
+ Int_t timebin;
+ Float_t mom, length;
+ Int_t nPlanePID;
+ for (Int_t i=0; i<event->GetNumberOfTracks(); i++) {
+ t = event->GetTrack(i);
+
+ // Check track
+ if(!CheckTrack(t)) continue;
+
+
+ // Skip tracks which have no TRD signal at all
+ if (t->GetTRDsignal()<1.e-5) continue;
+
+ // Loop over detector layers
+ mom = 0.;
+ length = 0.;
+ nPlanePID = 0;
+ for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)
+ p[iSpecies] = 1./AliPID::kSPECIES;
+
+ for (Int_t iLayer = 0; iLayer < AliTRDgeometry::kNlayer; iLayer++) {
+ // read data for track segment
+ for(int iSlice=0; iSlice<AliTRDCalPID::kNSlicesLQ; iSlice++)
+ dedx[iSlice] = t->GetTRDslice(iLayer, iSlice);
+ dEdx = t->GetTRDslice(iLayer, -1);
+ timebin = t->GetTRDTimBin(iLayer);
+
+ // check data
+ if ((dEdx <= 0.) || (timebin <= -1.)) continue;
+
+ // retrive kinematic info for this track segment
+ if(!RecalculateTrackSegmentKine(t, iLayer, mom, length)){
+ // information is not fully reliable especialy for length
+ // estimation. To be used in the future.
+ }
+
+ // this track segment has fulfilled all requierments
+ nPlanePID++;
+
+ // Get the probabilities for the different particle species
+ for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) {
+ p[iSpecies] *= pd->GetProbability(iSpecies, mom, dedx, length, iLayer);
+ //p[iSpecies] *= pd->GetProbabilityT(iSpecies, mom, timebin);
+ }
+ }
+ if(nPlanePID == 0) continue;
+
+ // normalize probabilities
+ Double_t probTotal = 0.;
+ for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) probTotal += p[iSpecies];
+ if(probTotal <= 0.){
+ AliWarning(Form("The total probability (%e) over all species <= 0 in ESD track %d."
+ , probTotal, i));
+ AliWarning("This may be caused by some error in reference data.");
+ AliWarning("Calculation continues but results might be corrupted.");
+ continue;
+ }
+ for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] /= probTotal;
+
+ // book PID to the track