]>
Commit | Line | Data |
---|---|---|
b0f03c34 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
dab811d0 | 16 | /* $Id$ */ |
17 | ||
b52cb1b6 | 18 | //////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Implementation of the TRD PID class // | |
21 | // // | |
22 | // Assigns the electron and pion likelihoods to each ESD track. // | |
c8ab4518 | 23 | // The function MakePID(AliESDEvent *event) calculates the probability // |
b52cb1b6 | 24 | // of having dedx and a maximum timbin at a given // |
25 | // momentum (mom) and particle type k // | |
26 | // from the precalculated distributions. // | |
27 | // // | |
dab811d0 | 28 | // Authors : // |
c8ab4518 | 29 | // Prashant Shukla <shukla@pi0.physi.uni-heidelberg.de> (orig. version) // |
30 | // Alex Bercuci (a.bercuci@gsi.de) // | |
b52cb1b6 | 31 | // // |
32 | //////////////////////////////////////////////////////////////////////////// | |
b0f03c34 | 33 | |
b52cb1b6 | 34 | #include "AliLog.h" |
af885e0f | 35 | #include "AliESDEvent.h" |
b0f03c34 | 36 | #include "AliESDtrack.h" |
c6011b06 | 37 | #include "AliTracker.h" |
c8ab4518 | 38 | #include "AliRun.h" |
b52cb1b6 | 39 | |
40 | #include "AliTRDpidESD.h" | |
41 | #include "AliTRDgeometry.h" | |
cc7cef99 | 42 | #include "AliTRDcalibDB.h" |
dab811d0 | 43 | #include "AliTRDtrack.h" |
720a0a16 | 44 | #include "Cal/AliTRDCalPID.h" |
b0f03c34 | 45 | |
46 | ClassImp(AliTRDpidESD) | |
47 | ||
c8ab4518 | 48 | Bool_t AliTRDpidESD::fgCheckTrackStatus = kTRUE; |
49 | Bool_t AliTRDpidESD::fgCheckKinkStatus = kFALSE; | |
50 | Int_t AliTRDpidESD::fgMinPlane = 0; | |
df34b21e | 51 | |
b52cb1b6 | 52 | //_____________________________________________________________________________ |
dab811d0 | 53 | AliTRDpidESD::AliTRDpidESD() |
c8ab4518 | 54 | :TObject() |
55 | ,fTrack(0x0) | |
b0f03c34 | 56 | { |
57 | // | |
b52cb1b6 | 58 | // Default constructor |
b0f03c34 | 59 | // |
b52cb1b6 | 60 | |
b0f03c34 | 61 | } |
62 | ||
b52cb1b6 | 63 | //_____________________________________________________________________________ |
dab811d0 | 64 | AliTRDpidESD::AliTRDpidESD(const AliTRDpidESD &p) |
c8ab4518 | 65 | :TObject(p) |
66 | ,fTrack(0x0) | |
eab5961e | 67 | { |
b0f03c34 | 68 | // |
b52cb1b6 | 69 | // AliTRDpidESD copy constructor |
b0f03c34 | 70 | // |
eab5961e | 71 | |
b52cb1b6 | 72 | ((AliTRDpidESD &) p).Copy(*this); |
73 | ||
74 | } | |
75 | ||
c6011b06 | 76 | //_____________________________________________________________________________ |
77 | AliTRDpidESD::~AliTRDpidESD() | |
78 | { | |
79 | // | |
80 | // Destructor | |
81 | // | |
c8ab4518 | 82 | |
83 | if(fTrack) delete fTrack; | |
84 | ||
c6011b06 | 85 | } |
86 | ||
b52cb1b6 | 87 | //_____________________________________________________________________________ |
88 | AliTRDpidESD &AliTRDpidESD::operator=(const AliTRDpidESD &p) | |
89 | { | |
90 | // | |
91 | // Assignment operator | |
92 | // | |
93 | ||
94 | if (this != &p) ((AliTRDpidESD &) p).Copy(*this); | |
95 | return *this; | |
96 | ||
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | void AliTRDpidESD::Copy(TObject &p) const | |
101 | { | |
102 | // | |
103 | // Copy function | |
104 | // | |
105 | ||
c8ab4518 | 106 | ((AliTRDpidESD &) p).fgCheckTrackStatus = fgCheckTrackStatus; |
107 | ((AliTRDpidESD &) p).fgCheckKinkStatus = fgCheckKinkStatus; | |
108 | ((AliTRDpidESD &) p).fgMinPlane = fgMinPlane; | |
c6011b06 | 109 | ((AliTRDpidESD &) p).fTrack = 0x0; |
110 | ||
b0f03c34 | 111 | } |
112 | ||
b52cb1b6 | 113 | //_____________________________________________________________________________ |
af885e0f | 114 | Int_t AliTRDpidESD::MakePID(AliESDEvent *event) |
bd50219c | 115 | { |
116 | // | |
b52cb1b6 | 117 | // This function calculates the PID probabilities based on TRD signals |
bd50219c | 118 | // |
dab811d0 | 119 | // The method produces probabilities based on the charge |
120 | // and the position of the maximum time bin in each layer. | |
121 | // The dE/dx information can be used as global charge or 2 to 3 | |
720a0a16 | 122 | // slices. Check AliTRDCalPID and AliTRDCalPIDRefMaker for the actual |
dab811d0 | 123 | // implementation. |
124 | // | |
125 | // Author | |
126 | // Alex Bercuci (A.Bercuci@gsi.de) 2nd May 2007 | |
c8ab4518 | 127 | // |
dab811d0 | 128 | |
129 | AliTRDcalibDB *calibration = AliTRDcalibDB::Instance(); | |
130 | if (!calibration) { | |
131 | AliErrorGeneral("AliTRDpidESD::MakePID()" | |
132 | ,"No access to calibration data"); | |
133 | return -1; | |
134 | } | |
135 | ||
136 | // Retrieve the CDB container class with the probability distributions | |
44dbae42 | 137 | const AliTRDCalPID *pd = calibration->GetPIDObject(1); |
dab811d0 | 138 | if (!pd) { |
139 | AliErrorGeneral("AliTRDpidESD::MakePID()" | |
720a0a16 | 140 | ,"No access to AliTRDCalPID"); |
dab811d0 | 141 | return -1; |
b52cb1b6 | 142 | } |
143 | ||
dab811d0 | 144 | // Loop through all ESD tracks |
145 | Double_t p[10]; | |
146 | AliESDtrack *t = 0x0; | |
c6011b06 | 147 | Float_t dedx[AliTRDtrack::kNslice], dEdx; |
148 | Int_t timebin; | |
149 | Float_t mom, length; | |
150 | Int_t nPlanePID; | |
dab811d0 | 151 | for (Int_t i=0; i<event->GetNumberOfTracks(); i++) { |
152 | t = event->GetTrack(i); | |
c6011b06 | 153 | |
dab811d0 | 154 | // Check track |
155 | if(!CheckTrack(t)) continue; | |
c6011b06 | 156 | |
dab811d0 | 157 | |
158 | // Skip tracks which have no TRD signal at all | |
159 | if (t->GetTRDsignal() == 0.) continue; | |
160 | ||
161 | // Loop over detector layers | |
c6011b06 | 162 | mom = 0.; |
163 | length = 0.; | |
dab811d0 | 164 | nPlanePID = 0; |
c8ab4518 | 165 | for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) |
166 | p[iSpecies] = 1./AliPID::kSPECIES; | |
167 | ||
dab811d0 | 168 | for (Int_t iPlan = 0; iPlan < AliTRDgeometry::kNplan; iPlan++) { |
169 | // read data for track segment | |
170 | for(int iSlice=0; iSlice<AliTRDtrack::kNslice; iSlice++) | |
171 | dedx[iSlice] = t->GetTRDsignals(iPlan, iSlice); | |
172 | dEdx = t->GetTRDsignals(iPlan, -1); | |
173 | timebin = t->GetTRDTimBin(iPlan); | |
174 | ||
175 | // check data | |
176 | if ((dEdx <= 0.) || (timebin <= -1.)) continue; | |
177 | ||
178 | // retrive kinematic info for this track segment | |
c8b2a461 | 179 | if(!RecalculateTrackSegmentKine(t, iPlan, mom, length)){ |
180 | // information is not fully reliable especialy for length | |
181 | // estimation. To be used in the future. | |
182 | } | |
dab811d0 | 183 | |
184 | // this track segment has fulfilled all requierments | |
185 | nPlanePID++; | |
c8b2a461 | 186 | |
dab811d0 | 187 | // Get the probabilities for the different particle species |
188 | for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) { | |
44dbae42 | 189 | p[iSpecies] *= pd->GetProbability(iSpecies, mom, dedx, length, iPlan); |
c6011b06 | 190 | //p[iSpecies] *= pd->GetProbabilityT(iSpecies, mom, timebin); |
dab811d0 | 191 | } |
192 | } | |
c6011b06 | 193 | if(nPlanePID == 0) continue; |
194 | ||
dab811d0 | 195 | // normalize probabilities |
c6011b06 | 196 | Double_t probTotal = 0.; |
197 | for (Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) probTotal += p[iSpecies]; | |
198 | if(probTotal <= 0.){ | |
c8ab4518 | 199 | AliWarning(Form("The total probability (%e) over all species <= 0 in ESD track %d." |
200 | , probTotal, i)); | |
201 | AliWarning("This may be caused by some error in reference data."); | |
202 | AliWarning("Calculation continues but results might be corrupted."); | |
c6011b06 | 203 | continue; |
204 | } | |
205 | for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++) p[iSpecies] /= probTotal; | |
dab811d0 | 206 | |
207 | // book PID to the track | |
208 | t->SetTRDpid(p); | |
c6011b06 | 209 | t->SetTRDpidQuality(nPlanePID); |
dab811d0 | 210 | } |
211 | ||
212 | return 0; | |
c8ab4518 | 213 | |
dab811d0 | 214 | } |
b52cb1b6 | 215 | |
dab811d0 | 216 | //_____________________________________________________________________________ |
217 | Bool_t AliTRDpidESD::CheckTrack(AliESDtrack *t) | |
218 | { | |
219 | // | |
220 | // Check if track is eligible for PID calculations | |
221 | // | |
222 | ||
223 | // Check the ESD track status | |
c8ab4518 | 224 | if (fgCheckTrackStatus) { |
dab811d0 | 225 | if (((t->GetStatus() & AliESDtrack::kTRDout ) == 0) && |
226 | ((t->GetStatus() & AliESDtrack::kTRDrefit) == 0)) return kFALSE; | |
227 | } | |
b52cb1b6 | 228 | |
dab811d0 | 229 | // Check for ESD kink tracks |
c8ab4518 | 230 | if (fgCheckKinkStatus && (t->GetKinkIndex(0) != 0)) return kFALSE; |
b52cb1b6 | 231 | |
dab811d0 | 232 | return kTRUE; |
c8ab4518 | 233 | |
dab811d0 | 234 | } |
b52cb1b6 | 235 | |
dab811d0 | 236 | //_____________________________________________________________________________ |
c8ab4518 | 237 | Bool_t AliTRDpidESD::RecalculateTrackSegmentKine(AliESDtrack *esd |
238 | , Int_t plan | |
239 | , Float_t &mom | |
240 | , Float_t &length) | |
dab811d0 | 241 | { |
242 | // | |
243 | // Retrive momentum "mom" and track "length" in TRD chamber from plane | |
244 | // "plan" according to information stored in AliESDtrack "t". | |
c6011b06 | 245 | // |
246 | // Origin | |
247 | // Alex Bercuci (A.Bercuci@gsi.de) | |
c8ab4518 | 248 | // |
dab811d0 | 249 | |
dab811d0 | 250 | const Float_t kAmHalfWidth = AliTRDgeometry::AmThick() / 2.; |
f162af62 | 251 | const Float_t kDrWidth = AliTRDgeometry::DrThick(); |
c6011b06 | 252 | const Float_t kTime0 = AliTRDgeometry::GetTime0(plan); |
dab811d0 | 253 | |
c6011b06 | 254 | // set initial length value to chamber height |
255 | length = 2 * kAmHalfWidth + kDrWidth; | |
dab811d0 | 256 | |
c6011b06 | 257 | // retrive track's outer param |
258 | const AliExternalTrackParam *op = esd->GetOuterParam(); | |
259 | if(!op){ | |
260 | mom = esd->GetP(); | |
dab811d0 | 261 | return kFALSE; |
262 | } | |
dab811d0 | 263 | |
c6011b06 | 264 | AliExternalTrackParam *param = 0x0; |
265 | if(!fTrack){ | |
266 | fTrack = new AliExternalTrackParam(*op); | |
267 | param = fTrack; | |
c8b2a461 | 268 | } else param = new(fTrack) AliExternalTrackParam(*op); |
269 | ||
c6011b06 | 270 | // retrive the magnetic field |
271 | Double_t xyz0[3]; | |
272 | op->GetXYZ(xyz0); | |
273 | Float_t field = AliTracker::GetBz(xyz0); // Bz in kG at point xyz0 | |
c8b2a461 | 274 | Double_t s, t; |
275 | ||
c6011b06 | 276 | // propagate to chamber entrance |
277 | if(!param->PropagateTo(kTime0-kAmHalfWidth-kDrWidth, field)){ | |
c8b2a461 | 278 | mom = op->GetP(); |
279 | s = op->GetSnp(); | |
280 | t = op->GetTgl(); | |
01d8ed58 | 281 | if (s < 1.) length /= TMath::Sqrt((1. - s*s) / (1. + t*t)); |
c6011b06 | 282 | return kFALSE; |
283 | } | |
284 | mom = param->GetP(); | |
c8b2a461 | 285 | s = param->GetSnp(); |
286 | t = param->GetTgl(); | |
01d8ed58 | 287 | if (s < 1.) length /= TMath::Sqrt((1. - s*s) / (1. + t*t)); |
c6011b06 | 288 | |
289 | // check if track is crossing tracking sector by propagating to chamber exit- maybe is too much :) | |
290 | Double_t alpha = param->GetAlpha(); | |
291 | if(!param->PropagateTo(kTime0+kAmHalfWidth, field)) return kFALSE; | |
292 | ||
293 | // mark track segments which are crossing SM boundaries along chamber | |
294 | if(TMath::Abs(alpha-param->GetAlpha())>.01) return kFALSE; | |
295 | ||
dab811d0 | 296 | return kTRUE; |
dab811d0 | 297 | |
c8ab4518 | 298 | } |