1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // Implementation of the TRD PID class //
22 // Assigns the electron and pion likelihoods to each ESD track. //
23 // The function MakePID(AliESDEvent *event) calculates the probability //
24 // of having dedx and a maximum timbin at a given //
25 // momentum (mom) and particle type k //
26 // from the precalculated distributions. //
29 // Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de> (Original version)//
30 // Alex Bercuci (a.bercuci@gsi.de) //
32 ////////////////////////////////////////////////////////////////////////////
35 #include "AliESDEvent.h"
36 #include "AliESDtrack.h"
37 #include "AliTracker.h"
39 #include "AliTRDpidESD.h"
40 #include "AliTRDgeometry.h"
41 #include "AliTRDcalibDB.h"
43 #include "AliTRDtrack.h"
44 #include "Cal/AliTRDCalPIDLQ.h"
47 ClassImp(AliTRDpidESD)
49 Bool_t AliTRDpidESD::fCheckTrackStatus = kTRUE;
50 Bool_t AliTRDpidESD::fCheckKinkStatus = kFALSE;
51 Int_t AliTRDpidESD::fMinPlane = 0;
53 //_____________________________________________________________________________
54 AliTRDpidESD::AliTRDpidESD()
55 :TObject(), fTrack(0x0)
58 // Default constructor
63 //_____________________________________________________________________________
64 AliTRDpidESD::AliTRDpidESD(const AliTRDpidESD &p)
65 :TObject(p), fTrack(0x0)
68 // AliTRDpidESD copy constructor
71 ((AliTRDpidESD &) p).Copy(*this);
75 //_____________________________________________________________________________
76 AliTRDpidESD::~AliTRDpidESD()
81 if(fTrack) delete fTrack;
84 //_____________________________________________________________________________
85 AliTRDpidESD &AliTRDpidESD::operator=(const AliTRDpidESD &p)
88 // Assignment operator
91 if (this != &p) ((AliTRDpidESD &) p).Copy(*this);
96 //_____________________________________________________________________________
97 void AliTRDpidESD::Copy(TObject &p) const
103 ((AliTRDpidESD &) p).fCheckTrackStatus = fCheckTrackStatus;
104 ((AliTRDpidESD &) p).fCheckKinkStatus = fCheckKinkStatus;
105 ((AliTRDpidESD &) p).fMinPlane = fMinPlane;
106 ((AliTRDpidESD &) p).fTrack = 0x0;
110 //_____________________________________________________________________________
111 Int_t AliTRDpidESD::MakePID(AliESDEvent *event)
114 // This function calculates the PID probabilities based on TRD signals
116 // The method produces probabilities based on the charge
117 // and the position of the maximum time bin in each layer.
118 // The dE/dx information can be used as global charge or 2 to 3
119 // slices. Check AliTRDCalPIDLQ and AliTRDCalPIDLQRef for the actual
123 // Alex Bercuci (A.Bercuci@gsi.de) 2nd May 2007
125 AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
127 AliErrorGeneral("AliTRDpidESD::MakePID()"
128 ,"No access to calibration data");
132 // Retrieve the CDB container class with the probability distributions
133 const AliTRDCalPIDLQ *pd = calibration->GetPIDLQObject();
135 AliErrorGeneral("AliTRDpidESD::MakePID()"
136 ,"No access to AliTRDCalPIDLQ");
140 // Loop through all ESD tracks
142 AliESDtrack *t = 0x0;
143 Float_t dedx[AliTRDtrack::kNslice], dEdx;
147 for (Int_t i=0; i<event->GetNumberOfTracks(); i++) {
148 t = event->GetTrack(i);
151 if(!CheckTrack(t)) continue;
154 // Skip tracks which have no TRD signal at all
155 if (t->GetTRDsignal() == 0.) continue;
157 // Loop over detector layers
161 for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] = 1./AliPID::kSPECIES;
162 for (Int_t iPlan = 0; iPlan < AliTRDgeometry::kNplan; iPlan++) {
163 // read data for track segment
164 for(int iSlice=0; iSlice<AliTRDtrack::kNslice; iSlice++)
165 dedx[iSlice] = t->GetTRDsignals(iPlan, iSlice);
166 dEdx = t->GetTRDsignals(iPlan, -1);
167 timebin = t->GetTRDTimBin(iPlan);
170 if ((dEdx <= 0.) || (timebin <= -1.)) continue;
172 // retrive kinematic info for this track segment
173 if(!RecalculateTrackSegmentKine(t, iPlan, mom, length)){
174 // information is not fully reliable especialy for length
175 // estimation. To be used in the future.
178 // this track segment has fulfilled all requierments
181 // Get the probabilities for the different particle species
182 for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) {
183 p[iSpecies] *= pd->GetProbability(iSpecies, mom, dedx, length);
184 //p[iSpecies] *= pd->GetProbabilityT(iSpecies, mom, timebin);
187 if(nPlanePID == 0) continue;
189 // normalize probabilities
190 Double_t probTotal = 0.;
191 for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) probTotal += p[iSpecies];
193 AliWarningGeneral("AliTRDpidESD::MakePID()", Form("The total probability (%e) over all species <= 0 in ESD track %d. This may be caused by some error in reference data. Calculation continue but results might be corrupted.", probTotal, i));
196 for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] /= probTotal;
198 // book PID to the track
200 t->SetTRDpidQuality(nPlanePID);
206 //_____________________________________________________________________________
207 Bool_t AliTRDpidESD::CheckTrack(AliESDtrack *t)
210 // Check if track is eligible for PID calculations
213 // Check the ESD track status
214 if (fCheckTrackStatus) {
215 if (((t->GetStatus() & AliESDtrack::kTRDout ) == 0) &&
216 ((t->GetStatus() & AliESDtrack::kTRDrefit) == 0)) return kFALSE;
219 // Check for ESD kink tracks
220 if (fCheckKinkStatus && (t->GetKinkIndex(0) != 0)) return kFALSE;
225 //_____________________________________________________________________________
226 Bool_t AliTRDpidESD::RecalculateTrackSegmentKine(AliESDtrack *esd, Int_t plan, Float_t &mom, Float_t &length)
229 // Retrive momentum "mom" and track "length" in TRD chamber from plane
230 // "plan" according to information stored in AliESDtrack "t".
233 // Alex Bercuci (A.Bercuci@gsi.de)
235 const Float_t kAmHalfWidth = AliTRDgeometry::AmThick() / 2.;
236 const Float_t kDrWidth = AliTRDgeometry::DrThick();
237 const Float_t kTime0 = AliTRDgeometry::GetTime0(plan);
239 // set initial length value to chamber height
240 length = 2 * kAmHalfWidth + kDrWidth;
242 // retrive track's outer param
243 const AliExternalTrackParam *op = esd->GetOuterParam();
249 AliExternalTrackParam *param = 0x0;
251 fTrack = new AliExternalTrackParam(*op);
253 } else param = new(fTrack) AliExternalTrackParam(*op);
255 // retrive the magnetic field
258 Float_t field = AliTracker::GetBz(xyz0); // Bz in kG at point xyz0
261 // propagate to chamber entrance
262 if(!param->PropagateTo(kTime0-kAmHalfWidth-kDrWidth, field)){
266 length /= TMath::Sqrt((1. - s*s) / (1. - t*t));
272 length /= TMath::Sqrt((1. - s*s) / (1. - t*t));
274 // check if track is crossing tracking sector by propagating to chamber exit- maybe is too much :)
275 Double_t alpha = param->GetAlpha();
276 if(!param->PropagateTo(kTime0+kAmHalfWidth, field)) return kFALSE;
278 // mark track segments which are crossing SM boundaries along chamber
279 if(TMath::Abs(alpha-param->GetAlpha())>.01) return kFALSE;