]>
Commit | Line | Data |
---|---|---|
0cf0c402 | 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 | **************************************************************************/ | |
06351446 | 15 | |
0cf0c402 | 16 | //------------------------------------------------------------------------- |
17 | // Class AliRsnPID | |
18 | // ------------------- | |
19 | // Simple collection of reconstructed tracks | |
20 | // selected from an ESD event | |
21 | // to be used for analysis. | |
22 | // ......................................... | |
06351446 | 23 | // |
0cf0c402 | 24 | // author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) |
25 | //------------------------------------------------------------------------- | |
26 | ||
27 | #include <TMath.h> | |
e2bafbbc | 28 | #include <TDirectory.h> |
0cf0c402 | 29 | |
30 | #include "AliLog.h" | |
06351446 | 31 | #include "AliRsnMCInfo.h" |
0cf0c402 | 32 | #include "AliRsnDaughter.h" |
33 | #include "AliRsnEvent.h" | |
34 | ||
35 | #include "AliRsnPID.h" | |
36 | ||
aec0ec32 | 37 | ClassImp ( AliRsnPID ) |
0cf0c402 | 38 | |
aec0ec32 | 39 | const Double_t AliRsnPID::fgkParticleMass[AliRsnPID::kSpeciesAll + 1] = |
e2bafbbc | 40 | { |
41 | 0.00051099892, // electron | |
42 | 0.105658369, // muon | |
43 | 0.13957018, // pion | |
44 | 0.493677, // kaon | |
45 | 0.93827203, // proton | |
aec0ec32 | 46 | 0.0, // nothing |
47 | 1.019413, // phi | |
48 | 3.09693 // jpsi | |
e2bafbbc | 49 | }; |
50 | ||
aec0ec32 | 51 | const char* AliRsnPID::fgkParticleNameLong[AliRsnPID::kSpeciesAll + 1] = |
0cf0c402 | 52 | { |
53 | "electron", | |
54 | "muon", | |
55 | "pion", | |
56 | "kaon", | |
57 | "proton", | |
aec0ec32 | 58 | "unknown", |
59 | "phi", | |
60 | "jpsi" | |
0cf0c402 | 61 | }; |
62 | ||
aec0ec32 | 63 | const char* AliRsnPID::fgkParticleNameShort[AliRsnPID::kSpeciesAll + 1] = |
06351446 | 64 | { |
65 | "e", | |
66 | "mu", | |
67 | "pi", | |
68 | "K", | |
69 | "p", | |
aec0ec32 | 70 | "unk", |
71 | "phi", | |
72 | "jpsi" | |
06351446 | 73 | }; |
74 | ||
aec0ec32 | 75 | const char* AliRsnPID::fgkParticleNameLatex[AliRsnPID::kSpeciesAll + 1] = |
06351446 | 76 | { |
77 | "e", | |
78 | "#mu", | |
79 | "#pi", | |
80 | "K", | |
81 | "p", | |
aec0ec32 | 82 | "?", |
83 | "#phi", | |
84 | "J/#psi" | |
06351446 | 85 | }; |
86 | ||
aec0ec32 | 87 | const Int_t AliRsnPID::fgkParticlePDG[AliRsnPID::kSpeciesAll + 1] = |
0cf0c402 | 88 | { |
aec0ec32 | 89 | 11, |
90 | 13, | |
91 | 211, | |
92 | 321, | |
93 | 2212, | |
94 | 0, | |
95 | 333, | |
96 | 443 | |
0cf0c402 | 97 | }; |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | AliRsnPID::AliRsnPID() : | |
aec0ec32 | 101 | TNamed ( "RsnPID", "" ), |
102 | fMaxPt ( 100.0 ), | |
103 | fMinProb ( 0.0 ) | |
0cf0c402 | 104 | { |
06351446 | 105 | // |
e2bafbbc | 106 | // Constructor. |
107 | // Adds also the object in the default directory of the session. | |
06351446 | 108 | // |
109 | ||
aec0ec32 | 110 | Int_t i; |
111 | for ( i = 0; i < kSpecies; i++ ) fPrior[i] = 0.0; | |
112 | ||
113 | // gDirectory->Append(this, kTRUE); | |
0cf0c402 | 114 | } |
115 | ||
116 | //_____________________________________________________________________________ | |
aec0ec32 | 117 | AliRsnPID::EType AliRsnPID::InternalType ( Int_t pdg ) |
06351446 | 118 | // |
0cf0c402 | 119 | // Return the internal enum value corresponding to the PDG |
120 | // code passed as argument, if possible. | |
121 | // Otherwise, returns 'kUnknown' by default. | |
06351446 | 122 | // |
0cf0c402 | 123 | { |
aec0ec32 | 124 | EType value; |
125 | Int_t absPDG = TMath::Abs ( pdg ); | |
126 | ||
127 | switch ( absPDG ) | |
128 | { | |
129 | case 11: | |
130 | value = kElectron; | |
131 | break; | |
132 | case 13: | |
133 | value = kMuon; | |
134 | break; | |
135 | case 211: | |
136 | value = kPion; | |
137 | break; | |
138 | case 321: | |
139 | value = kKaon; | |
140 | break; | |
141 | case 2212: | |
142 | value = kProton; | |
143 | break; | |
144 | case 333: | |
145 | value = kPhi; | |
146 | break; | |
147 | case 443: | |
148 | value = kJPsi; | |
149 | break; | |
150 | default: | |
151 | value = kUnknown; | |
152 | } | |
153 | return value; | |
0cf0c402 | 154 | } |
155 | ||
156 | ||
157 | //_____________________________________________________________________________ | |
aec0ec32 | 158 | Int_t AliRsnPID::PDGCode ( EType type ) |
0cf0c402 | 159 | { |
06351446 | 160 | // |
0cf0c402 | 161 | // Returns the PDG code of the particle type |
162 | // specified as argument (w.r. to the internal enum) | |
06351446 | 163 | // |
164 | ||
aec0ec32 | 165 | if ( type >= kElectron && type <= kUnknown ) |
166 | { | |
167 | return fgkParticlePDG[type]; | |
168 | } | |
169 | else | |
170 | { | |
171 | return 0; | |
172 | } | |
0cf0c402 | 173 | } |
174 | ||
175 | //_____________________________________________________________________________ | |
aec0ec32 | 176 | const char* AliRsnPID::ParticleName ( EType type, Bool_t shortName ) |
0cf0c402 | 177 | { |
06351446 | 178 | // |
0cf0c402 | 179 | // Returns the name of the particle type |
180 | // specified as argument (w.r. to the internal enum) | |
06351446 | 181 | // |
0cf0c402 | 182 | |
aec0ec32 | 183 | if ( type >= kElectron && type <= kSpeciesAll ) |
184 | { | |
185 | return shortName ? fgkParticleNameShort[type] : fgkParticleNameLong[type]; | |
186 | } | |
187 | else | |
188 | { | |
189 | return shortName ? "unk" : "unknown"; | |
190 | } | |
06351446 | 191 | } |
192 | ||
193 | //_____________________________________________________________________________ | |
aec0ec32 | 194 | const char* AliRsnPID::ParticleNameLatex ( EType type ) |
06351446 | 195 | { |
196 | // | |
197 | // Returns the name of the particle type | |
198 | // specified as argument (w.r. to the internal enum) | |
199 | // | |
200 | ||
aec0ec32 | 201 | if ( type >= kElectron && type <= kSpeciesAll ) |
202 | { | |
203 | return fgkParticleNameLatex[type]; | |
204 | } | |
205 | else | |
206 | { | |
207 | return "?"; | |
208 | } | |
0cf0c402 | 209 | } |
210 | ||
211 | //_____________________________________________________________________________ | |
aec0ec32 | 212 | Double_t AliRsnPID::ParticleMass ( EType type ) |
0cf0c402 | 213 | { |
06351446 | 214 | // |
0cf0c402 | 215 | // Returns the mass corresponding to the particle type |
216 | // specified as argument (w.r. to the internal enum) | |
06351446 | 217 | // |
aec0ec32 | 218 | /* |
219 | TDatabasePDG *db = TDatabasePDG::Instance(); | |
220 | Int_t pdg = PDGCode(type); | |
221 | return db->GetParticle(pdg)->Mass(); | |
222 | */ | |
223 | if ( type >= kElectron && type < kSpeciesAll ) return fgkParticleMass[type]; | |
224 | return 0.0; | |
0cf0c402 | 225 | } |
226 | ||
227 | //_____________________________________________________________________________ | |
aec0ec32 | 228 | Bool_t AliRsnPID::ComputeProbs ( AliRsnDaughter *daughter ) |
0cf0c402 | 229 | { |
06351446 | 230 | // |
0cf0c402 | 231 | // Uses the Bayesian combination of prior probabilities |
232 | // with the PID weights of the passed object to compute | |
233 | // the overall PID probabilities for each particle type. | |
234 | // | |
235 | // Once this computation is done, the argument is assigned | |
236 | // the PID corresponding to the largest probability, | |
237 | // and its data members are updated accordingly. | |
238 | // If the track Pt is larger than the cut defined (fMaxPt) | |
239 | // or the probability is smaller than the cut defined (fMinProb), | |
240 | // the track is considered unidentified. | |
241 | // | |
06351446 | 242 | // If the identification procedure encounters errors, |
0cf0c402 | 243 | // the return value will be "FALSE", otherwise it is "TRUE". |
06351446 | 244 | // |
0cf0c402 | 245 | |
aec0ec32 | 246 | // reset all PID probabilities to 0.0 |
247 | Int_t i; | |
248 | for ( i = 0; i < kSpecies; i++ ) daughter->SetPIDProb ( i, 1.0 / ( Double_t ) kSpecies ); | |
249 | ||
250 | // multiply weights and priors | |
251 | Double_t sum = 0.0, prob[kSpecies]; | |
252 | for ( i = 0; i < kSpecies; i++ ) | |
253 | { | |
254 | prob[i] = fPrior[i] * daughter->PID() [i]; | |
255 | sum += prob[i]; | |
256 | } | |
257 | if ( sum <= ( Double_t ) 0. ) | |
258 | { | |
259 | AliError ( Form ( "Sum of weights = %f <= 0", sum ) ); | |
260 | return kFALSE; | |
261 | } | |
262 | ||
263 | // normalize | |
264 | for ( i = 0; i < kSpecies; i++ ) | |
265 | { | |
266 | prob[i] /= sum; | |
267 | daughter->SetPIDProb ( i, prob[i] ); | |
268 | } | |
269 | ||
270 | daughter->AssignRealisticPID(); | |
271 | Double_t assprob; | |
272 | AliRsnDaughter::SetPIDMethod(AliRsnDaughter::kRealistic); | |
273 | AliRsnPID::EType type = daughter->PIDType(assprob); | |
274 | AliDebug(5, Form("Assigned PID: %s [%.2f %]", AliRsnPID::ParticleName(type), assprob*100.)); | |
275 | ||
276 | return kTRUE; | |
0cf0c402 | 277 | } |
278 | ||
279 | //_____________________________________________________________________________ | |
aec0ec32 | 280 | Bool_t AliRsnPID::IdentifiedAs ( AliRsnDaughter *d, EType type, Short_t charge ) |
0cf0c402 | 281 | { |
06351446 | 282 | // |
e2bafbbc | 283 | // Tells if a particle has can be identified to be of a given tipe and charge. |
284 | // If the charge is zero, the check is done only on the PID type, otherwise | |
285 | // both charge and PID type are required to match. | |
286 | // If the track momentum is larger than the pt threshold passed to this object, | |
287 | // or the maximum probability is smaller than the prob thrashold, the return value | |
288 | // is kFALSE even when the type and charge are matched. | |
06351446 | 289 | // |
290 | ||
aec0ec32 | 291 | EType dType = TrackType ( d ); |
292 | if ( dType != type ) return kFALSE; | |
293 | if ( charge == 0 ) | |
294 | { | |
295 | return kTRUE; | |
296 | } | |
297 | else if ( charge > 0 ) | |
298 | { | |
299 | return ( d->Charge() > 0 ); | |
300 | } | |
301 | else | |
302 | { | |
303 | return ( d->Charge() < 0 ); | |
304 | } | |
0cf0c402 | 305 | } |
306 | ||
06351446 | 307 | //_____________________________________________________________________________ |
aec0ec32 | 308 | AliRsnPID::EType AliRsnPID::TrackType ( AliRsnDaughter *d ) |
06351446 | 309 | { |
310 | // | |
e2bafbbc | 311 | // Returns the track type according to the object settings |
312 | // and to the static settings in the AliRsnDaughter object. | |
06351446 | 313 | // |
e2bafbbc | 314 | |
aec0ec32 | 315 | Double_t prob; |
316 | EType type = d->PIDType ( prob ); | |
317 | ||
318 | if ( d->Pt() > fMaxPt ) return kUnknown; | |
319 | if ( prob < fMinProb ) return kUnknown; | |
320 | ||
321 | return type; | |
06351446 | 322 | } |
323 | ||
0cf0c402 | 324 | //_____________________________________________________________________________ |
aec0ec32 | 325 | Bool_t AliRsnPID::Process ( AliRsnEvent *event ) |
0cf0c402 | 326 | { |
06351446 | 327 | // |
0cf0c402 | 328 | // Performs identification for all tracks in a given event. |
329 | // Returns the logical AND of all PID operations. | |
06351446 | 330 | // |
0cf0c402 | 331 | |
aec0ec32 | 332 | Bool_t check = kTRUE; |
333 | if ( !event ) return check; | |
334 | if ( !event->GetTracks() ) return check; | |
335 | if ( event->GetTracks()->IsEmpty() ) return check; | |
06351446 | 336 | |
aec0ec32 | 337 | AliRsnDaughter *daughter = 0; |
338 | TObjArrayIter iter ( event->GetTracks() ); | |
339 | while ( ( daughter = ( AliRsnDaughter* ) iter.Next() ) ) | |
340 | { | |
341 | check = check && ComputeProbs ( daughter ); | |
342 | } | |
343 | event->FillPIDArrays(); | |
0cf0c402 | 344 | |
aec0ec32 | 345 | return check; |
0cf0c402 | 346 | } |
347 | ||
348 | ||
349 | //_____________________________________________________________________________ | |
aec0ec32 | 350 | void AliRsnPID::SetPriorProbability ( EType type, Double_t p ) |
0cf0c402 | 351 | { |
06351446 | 352 | // |
0cf0c402 | 353 | // Sets the prior probability for Realistic PID, for a |
354 | // given particle species. | |
06351446 | 355 | // |
356 | ||
aec0ec32 | 357 | if ( type >= kElectron && type < kSpecies ) |
358 | { | |
359 | fPrior[type] = p; | |
360 | } | |
0cf0c402 | 361 | } |
e2bafbbc | 362 | |
363 | //_____________________________________________________________________________ | |
364 | void AliRsnPID::DumpPriors() | |
365 | { | |
366 | // | |
367 | // Print all prior probabilities | |
368 | // | |
369 | ||
aec0ec32 | 370 | Int_t i; |
371 | Char_t msg[200]; | |
372 | ||
373 | for ( i = 0; i < kSpecies; i++ ) | |
374 | { | |
375 | sprintf ( msg, "Prior probability for '%s' = %3.5f", fgkParticleNameLong[i], fPrior[i] ); | |
376 | AliInfo ( msg ); | |
377 | } | |
e2bafbbc | 378 | } |