]>
Commit | Line | Data |
---|---|---|
b8bfee30 | 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 | ||
16 | ||
17 | //----------------------------------------------------------------- | |
18 | // Base class for combining PID of different detectors // | |
19 | // (user selected) and compute Bayesian probabilities // | |
20 | // // | |
21 | // // | |
22 | // Origin: Pietro Antonioli, INFN-BO Pietro.Antonioli@cern.ch // | |
23 | // // | |
24 | //----------------------------------------------------------------- | |
25 | ||
26 | #include <TH1.h> | |
27 | ||
28 | #include <AliVTrack.h> | |
29 | #include <AliLog.h> | |
30 | #include <AliPID.h> | |
31 | #include <AliPIDResponse.h> | |
32 | ||
33 | #include "AliPIDCombined.h" | |
34 | ||
80f28562 | 35 | #include "TMath.h" |
36 | #include "TFile.h" | |
37 | ||
38 | #include "AliOADBContainer.h" | |
39 | ||
40 | // initialize static members | |
00a38d07 | 41 | TH2F* AliPIDCombined::fDefaultPriorsTPC[]={0x0}; |
506c1482 | 42 | TH2F* AliPIDCombined::fDefaultPriorsTPCpPb[]={0x0}; |
42fcc729 | 43 | Float_t AliPIDCombined::fTOFmismProb = 0; |
80f28562 | 44 | |
45 | ClassImp(AliPIDCombined); | |
46 | ||
b8bfee30 | 47 | AliPIDCombined::AliPIDCombined(): |
48 | TNamed("CombinedPID","CombinedPID"), | |
49 | fDetectorMask(0), | |
50 | fRejectMismatchMask(0x7F), | |
51 | fEnablePriors(kTRUE), | |
80f28562 | 52 | fSelectedSpecies(AliPID::kSPECIES), |
53 | fUseDefaultTPCPriors(kFALSE) | |
b8bfee30 | 54 | { |
55 | // | |
56 | // default constructor | |
57 | // | |
00a38d07 | 58 | for (Int_t i=0;i<AliPID::kSPECIESC;i++) fPriorsDistributions[i]=NULL; |
b8bfee30 | 59 | AliLog::SetClassDebugLevel("AliPIDCombined",10); |
60 | } | |
61 | ||
62 | //------------------------------------------------------------------------------------------------- | |
63 | AliPIDCombined::AliPIDCombined(const TString& name,const TString& title): | |
64 | TNamed(name,title), | |
65 | fDetectorMask(0), | |
66 | fRejectMismatchMask(0x7F), | |
67 | fEnablePriors(kTRUE), | |
80f28562 | 68 | fSelectedSpecies(AliPID::kSPECIES), |
69 | fUseDefaultTPCPriors(kFALSE) | |
b8bfee30 | 70 | { |
71 | // | |
72 | // default constructor with name and title | |
73 | // | |
00a38d07 | 74 | for (Int_t i=0;i<AliPID::kSPECIESC;i++) fPriorsDistributions[i]=NULL; |
b8bfee30 | 75 | AliLog::SetClassDebugLevel("AliPIDCombined",10); |
76 | ||
77 | } | |
78 | ||
79 | //------------------------------------------------------------------------------------------------- | |
80 | AliPIDCombined::~AliPIDCombined() { | |
81 | ||
00a38d07 | 82 | for(Int_t i=0;i < AliPID::kSPECIESC;i++){ |
b8bfee30 | 83 | if(fPriorsDistributions[i]) |
84 | delete fPriorsDistributions[i]; | |
85 | } | |
86 | } | |
87 | ||
88 | //------------------------------------------------------------------------------------------------- | |
89 | void AliPIDCombined::SetPriorDistribution(AliPID::EParticleType type,TH1F *prior) { | |
00a38d07 | 90 | if ( (type < 0) || ( type >= ((AliPID::EParticleType)AliPID::kSPECIESC) ) ){ |
b8bfee30 | 91 | AliError(Form("Invalid EParticleType setting prior (offending type: %d)",type)); |
92 | return; | |
93 | } | |
94 | if(prior) { | |
8de3b790 | 95 | Int_t i = (Int_t)type; |
b8bfee30 | 96 | if (fPriorsDistributions[i]) { |
97 | delete fPriorsDistributions[i]; | |
98 | } | |
99 | fPriorsDistributions[i]=new TH1F(*prior); | |
100 | } | |
101 | } | |
102 | ||
103 | //------------------------------------------------------------------------------------------------- | |
506c1482 | 104 | UInt_t AliPIDCombined::ComputeProbabilities(const AliVTrack *track, const AliPIDResponse *response, Double_t* bayesProbabilities,Double_t *priorsOwn) const { |
3ed61c90 | 105 | // |
106 | // (1) Get raw probabilities of requested detectors and combine | |
506c1482 | 107 | // (2) priors passed as argument |
3ed61c90 | 108 | // (3) Compute Bayes probabilities |
109 | // | |
b8bfee30 | 110 | |
111 | ||
3ed61c90 | 112 | // (1) Get raw probabilities of selected detectors and combine |
113 | UInt_t usedMask=0; // detectors actually used for track | |
42fcc729 | 114 | fTOFmismProb = 0; // reset TOF mismatch weights |
115 | ||
3ed61c90 | 116 | AliPIDResponse::EDetPidStatus status=AliPIDResponse::kDetNoSignal; |
506c1482 | 117 | Double_t p[AliPID::kSPECIESC]; // combined probabilities of selected detectors |
118 | Double_t pMismTOF[AliPID::kSPECIESC]; // combined TOF mismatch probabilities using selected detectors | |
42fcc729 | 119 | for (Int_t i=0;i<fSelectedSpecies;i++){ p[i]=1.;pMismTOF[i]=1.;} // no decision |
3ed61c90 | 120 | for (Int_t ibit = 0; ibit < 7 ; ibit++) { |
121 | AliPIDResponse::EDetCode detBit = (AliPIDResponse::EDetCode)(1<<ibit); | |
122 | if (fDetectorMask & detBit) { // getting probabilities for requested detectors only | |
506c1482 | 123 | Double_t detProb[AliPID::kSPECIESC]; |
3ed61c90 | 124 | status = response->ComputePIDProbability(detBit,track,fSelectedSpecies,detProb); |
125 | if (status == AliPIDResponse::kDetPidOk) { | |
126 | if (fRejectMismatchMask & detBit) { // mismatch check (currently just for TOF) | |
127 | if (detBit == AliPIDResponse::kDetTOF) { | |
42fcc729 | 128 | fTOFmismProb = response->GetTOFMismatchProbability(); // mismatch weights computed with TOF probs (no arguments) |
506c1482 | 129 | //Float_t probMis = response->GetTOFMismatchProbability(track); // mismatch compatibility TPC-TOF cut |
130 | SetCombinedStatus(status,&usedMask,detBit,detProb,fTOFmismProb); | |
3ed61c90 | 131 | } else { |
132 | SetCombinedStatus(status,&usedMask,detBit); | |
133 | } | |
134 | } else { | |
135 | SetCombinedStatus(status,&usedMask,detBit); | |
b8bfee30 | 136 | } |
42fcc729 | 137 | for (Int_t i=0;i<fSelectedSpecies;i++){ |
138 | p[i] *= detProb[i]; | |
506c1482 | 139 | if(detBit == AliPIDResponse::kDetTOF){ |
fd7be7b2 | 140 | Double_t pt = track->Pt(); |
141 | Double_t mismPropagationFactor[] = {1.,1.,1.,1. + TMath::Exp(1. - 1.12*pt), | |
142 | 1. + 1./(4.71114 - 5.72372*pt + 2.94715*pt*pt),1.,1.,1.,1.,1.}; // correction for kaons and protons which has to be alligned with the one in AliPIDResponse | |
506c1482 | 143 | pMismTOF[i] *= fTOFmismProb*mismPropagationFactor[i]; |
144 | } | |
42fcc729 | 145 | else pMismTOF[i] *= detProb[i]; |
146 | } | |
3ed61c90 | 147 | } |
148 | } | |
149 | } | |
150 | // if no detectors available there is no point to go further | |
151 | if (usedMask == 0) return usedMask; | |
152 | ||
153 | // (2) Get priors and propagate depending on detectors used | |
506c1482 | 154 | Double_t priors[AliPID::kSPECIESC]; |
3ed61c90 | 155 | memset(priors,0,fSelectedSpecies*sizeof(Double_t)); |
506c1482 | 156 | |
157 | if(priorsOwn){ | |
158 | for(Int_t ipr=0;ipr < fSelectedSpecies;ipr++) | |
159 | priors[ipr] = priorsOwn[ipr]; | |
160 | } | |
161 | ||
162 | else if (fEnablePriors){ | |
163 | Bool_t isPPB = (response->GetBeamType() == AliPIDResponse::kPPB); | |
164 | GetPriors(track,priors,response->GetCurrentCentrality(),isPPB); | |
6d4e360d AM |
165 | |
166 | // We apply the propagation factors of the more external detector | |
167 | // | |
168 | // TPC+HMPID --> apply HMPID propagation factors (TRD and TOF may be present) | |
3ed61c90 | 169 | // TPC+EMCAL --> apply EMCAL propagation factors (TRD and TOF may be present) |
6d4e360d AM |
170 | // TPC+TOF --> apply TOF propagation factors (TRD may be present, HMPID and EMCAL not (if requested)) |
171 | // TPC+TRD --> apply TRD propagation factors (TOF, HMPID and EMCAL not present (if requested) ) | |
172 | // | |
3ed61c90 | 173 | if(fUseDefaultTPCPriors) { |
6d4e360d | 174 | |
3ed61c90 | 175 | Double_t pt=TMath::Abs(track->Pt()); |
6d4e360d AM |
176 | if ( ( (usedMask & AliPIDResponse::kDetEMCAL)==AliPIDResponse::kDetEMCAL) || ( (usedMask & AliPIDResponse::kDetHMPID)==AliPIDResponse::kDetHMPID) ) { |
177 | // we assume EMCAL and HMPID cannot be simultaneously present | |
178 | if ( (usedMask & AliPIDResponse::kDetEMCAL)==AliPIDResponse::kDetEMCAL ) { | |
3ed61c90 | 179 | // EMCal case (for the moment only in combination with TPC) |
180 | // propagation factors determined from LHC11d MC (LHC12a15f) | |
181 | // v2 clusterizer, dEta < 0.015, dPhi < 0.03, NonLinearityFunction = 6 | |
44bea91d | 182 | |
3ed61c90 | 183 | Float_t electronEMCALfactor=0.1; |
184 | Float_t kaonEMCALfactor = 0.1; | |
185 | Float_t protonEMCALfactor = 0.1; | |
44bea91d | 186 | |
3ed61c90 | 187 | if(track->Charge() > 0){ |
188 | // positiv charge (start parametrization at 0.75 GeV/c and stop at 20 GeV/c for the moment) | |
189 | if(pt > 0.75 && pt < 20.0){ | |
190 | electronEMCALfactor = ( 0.214159 * ( 1 - TMath::Exp(-TMath::Power(pt,0.484512)/0.700499)*TMath::Power(pt,-0.669644)) ) / ( 0.210436 * ( 1 - TMath::Exp(-TMath::Power(pt,-0.219228)/0.947432)*TMath::Power(pt,-0.700792)) ); | |
191 | kaonEMCALfactor = ( 0.208686 * ( 1 - TMath::Exp(-TMath::Power(pt,-3.98149e-05)/1.28447)*TMath::Power(pt,-0.629191)) ) / ( 0.210436 * ( 1 - TMath::Exp(-TMath::Power(pt,-0.219228)/0.947432)*TMath::Power(pt,-0.700792)) ); | |
192 | protonEMCALfactor = ( 0.27555 * ( 1 - TMath::Exp(-TMath::Power(pt,-1.97226e-05)/1.52719)*TMath::Power(pt,-0.209068)) ) / ( 0.210436 * ( 1 - TMath::Exp(-TMath::Power(pt,-0.219228)/0.947432)*TMath::Power(pt,-0.700792)) ); | |
44bea91d | 193 | |
3ed61c90 | 194 | } |
195 | } | |
44bea91d | 196 | |
3ed61c90 | 197 | if(track->Charge() < 0){ |
198 | // negative charge (start parametrization at 0.75 GeV/c and stop at 20 GeV/c for the moment) | |
199 | if(pt > 0.75 && pt < 20.0){ | |
200 | electronEMCALfactor = ( 0.216895 * ( 1 - TMath::Exp(-TMath::Power(pt,0.000105924)/0.865938)*TMath::Power(pt,-1.32787)) ) / ( 0.210385 * ( 1 - TMath::Exp(-TMath::Power(pt,4.41206e-07)/1.08984)*TMath::Power(pt,-0.544375)) ); | |
201 | kaonEMCALfactor = ( 0.204117 * ( 1 - TMath::Exp(-TMath::Power(pt,-1.6853e-05)/1.61765)*TMath::Power(pt,-0.738355)) ) / ( 0.210385 * ( 1 - TMath::Exp(-TMath::Power(pt,4.41206e-07)/1.08984)*TMath::Power(pt,-0.544375)) ); | |
202 | protonEMCALfactor = ( 0.215679 * ( 1 - TMath::Exp(-TMath::Power(pt,-4.10015e-05)/1.40921)*TMath::Power(pt,-0.533752)) ) / ( 0.210385 * ( 1 - TMath::Exp(-TMath::Power(pt,4.41206e-07)/1.08984)*TMath::Power(pt,-0.544375)) ); | |
203 | } | |
204 | } | |
205 | priors[0] *= electronEMCALfactor; | |
206 | priors[3] *= kaonEMCALfactor; | |
207 | priors[4] *= protonEMCALfactor; | |
208 | } // end of EMCAL case | |
6d4e360d AM |
209 | |
210 | else if ( (usedMask & AliPIDResponse::kDetHMPID)==AliPIDResponse::kDetHMPID ) { // HMPID case | |
211 | ||
212 | Float_t kaonHMPIDfactor = 0.; | |
213 | Float_t protonHMPIDfactor = 0.; | |
214 | if(pt>1. && pt<6.) kaonHMPIDfactor = (-0.0729337 + pt*0.0999531 - pt*pt*0.0371803 + pt*pt*pt*0.00706436 - pt*pt*pt*pt*0.000643619 + pt*pt*pt*pt*pt*2.21853e-05)/(-0.00896231+ pt*0.0330702 - pt*pt*0.0109562+ pt*pt*pt*0.00232895 - pt*pt*pt*pt*0.000246143 + pt*pt*pt*pt*pt*9.59812e-06); | |
215 | if(pt>1.4 && pt<6.) protonHMPIDfactor = (-0.0444188 + pt*0.0681506 - pt*pt*0.0231819 + pt*pt*pt*0.00400771 - pt*pt*pt*pt*0.000339315 + pt*pt*pt*pt*pt*1.12616e-05)/(-0.00896231+ pt*0.0330702 - pt*pt*0.0109562+ pt*pt*pt*0.00232895 - pt*pt*pt*pt*0.000246143 + pt*pt*pt*pt*pt*9.59812e-06); | |
216 | if(pt>6. && pt<8.) kaonHMPIDfactor = (-0.0729337 + pt*0.0999531 - pt*pt*0.0371803 + pt*pt*pt*0.00706436 - pt*pt*pt*pt*0.000643619 + pt*pt*pt*pt*pt*2.21853e-05)/0.0530456; | |
217 | if(pt>8.) kaonHMPIDfactor = 0.0550432/0.0530456; | |
218 | if(pt>6. && pt<8.5) protonHMPIDfactor = (-0.0444188 + pt*0.0681506 - pt*pt*0.0231819 + pt*pt*pt*0.00400771 - pt*pt*pt*pt*0.000339315 + pt*pt*pt*pt*pt*1.12616e-05)/0.0530456; | |
219 | if(pt>8.5) protonHMPIDfactor = 0.0530071/0.0530456; | |
220 | ||
221 | if(track->Charge() < 0){ | |
222 | if(pt>0.4 && pt<6.) protonHMPIDfactor = (-0.0351485 + pt*0.0473821 - pt*pt*0.0147947 + pt*pt*pt*0.00254811- pt*pt*pt*pt*0.000224724 + pt*pt*pt*pt*pt*7.9303e-06)/(-0.00896231+ pt*0.0330702 - pt*pt*0.0109562+ pt*pt*pt*0.00232895 - pt*pt*pt*pt*0.000246143 + pt*pt*pt*pt*pt*9.59812e-06); | |
223 | if(pt>6. && pt<8.5) protonHMPIDfactor = (-0.0351485 + pt*0.0473821 - pt*pt*0.0147947 + pt*pt*pt*0.00254811- pt*pt*pt*pt*0.000224724 + pt*pt*pt*pt*pt*7.9303e-06)/0.0530456; | |
224 | if(pt>8.5) protonHMPIDfactor = 0.0457756/0.0530456; | |
225 | } | |
226 | ||
227 | priors[3] *= kaonHMPIDfactor; | |
228 | priors[4] *= protonHMPIDfactor; | |
229 | ||
230 | } | |
231 | ||
232 | } // end of outer cases: EMCAL/HMPID | |
3ed61c90 | 233 | else if ( (usedMask & AliPIDResponse::kDetTOF) == AliPIDResponse::kDetTOF ){ |
234 | Float_t kaonTOFfactor = 0.1; | |
506c1482 | 235 | if(pt > 0.29){ |
236 | kaonTOFfactor = 1 - TMath::Exp(-TMath::Power(pt,4.19618E-07)/4.96502e-01)*TMath::Power(pt,-1.50705); | |
506c1482 | 237 | } |
238 | ||
3ed61c90 | 239 | Float_t protonTOFfactor = 0.1; |
240 | if(pt > 0.4) protonTOFfactor = 1 - TMath::Exp(-TMath::Power(pt,3.30978)/8.57396E-02)*TMath::Power(pt,-4.42661E-01); | |
506c1482 | 241 | |
3ed61c90 | 242 | if(track->Charge() < 0){ // for negative tracks |
243 | kaonTOFfactor *= 1 - TMath::Exp(-TMath::Power(pt,4.87912E-07)/3.26431E-01)*TMath::Power(pt,-1.22893); | |
244 | protonTOFfactor *= 1 - TMath::Exp(-TMath::Power(pt,2.00575E-07)/4.95605E-01)*TMath::Power(pt,-6.71305E-01); | |
245 | } | |
246 | // TODO: we may need an electron factor for TOF as well, especially if TRD is present! | |
247 | priors[3] *= kaonTOFfactor; | |
248 | priors[4] *= protonTOFfactor; | |
249 | } // end of TOF case | |
250 | else if ( (usedMask & AliPIDResponse::kDetTRD)==AliPIDResponse::kDetTRD ) { | |
251 | Float_t electronTRDfactor=0.1; | |
252 | Float_t kaonTRDfactor = 0.1; | |
253 | Float_t protonTRDfactor = 0.1; | |
df0293b3 | 254 | |
3ed61c90 | 255 | if(track->Charge() > 0){ |
256 | // positiv charge | |
257 | if(pt > 0.25) electronTRDfactor = 1 - TMath::Exp(-TMath::Power(pt,5.13315e-03)/2.11145e-01)*TMath::Power(pt,-2.97659e+00); | |
258 | if(pt > 0.35) kaonTRDfactor = 1 - TMath::Exp(-TMath::Power(pt,-4.29549e-02)/4.87989e-01)*TMath::Power(pt,-1.54270e+00); | |
259 | if(pt > 0.35) protonTRDfactor = 1 - TMath::Exp(-TMath::Power(pt,2.81238e+00)/7.57082e-02)*TMath::Power(pt,-8.12595e-01); | |
260 | } | |
df0293b3 | 261 | |
3ed61c90 | 262 | if(track->Charge() < 0){ |
263 | // negative charge | |
264 | if(pt > 0.25) electronTRDfactor = 1 - TMath::Exp(-TMath::Power(pt,2.45537e-02)/1.90397e-01)*TMath::Power(pt,-3.33121e+00); | |
265 | if(pt > 0.35) kaonTRDfactor = 1 - TMath::Exp(-TMath::Power(pt, -3.42831e-03)/5.57013e-01)*TMath::Power(pt,-1.39202e+00); | |
266 | if(pt > 0.35) protonTRDfactor = 1 - TMath::Exp(-TMath::Power(pt,3.36631e+00)/7.18819e-02)*TMath::Power(pt,-2.00577e-01); | |
267 | } | |
268 | // what about electrons | |
269 | priors[0] *= electronTRDfactor; | |
270 | priors[3] *= kaonTRDfactor; | |
271 | priors[4] *= protonTRDfactor; | |
272 | } // end of TRD case | |
273 | } // end of fUseDefaultTPCPriors | |
274 | } // end of use priors | |
275 | else { for (Int_t i=0;i<fSelectedSpecies;i++) priors[i]=1.;} | |
276 | ||
506c1482 | 277 | // Compute Bayes probabilities |
278 | ComputeBayesProbabilities(bayesProbabilities,p,priors,pMismTOF); | |
42fcc729 | 279 | |
280 | // compute TOF probability contribution from mismatch | |
281 | fTOFmismProb = 0; | |
282 | for (Int_t i=0;i<fSelectedSpecies;i++) fTOFmismProb += pMismTOF[i]; | |
283 | ||
3ed61c90 | 284 | return usedMask; |
b8bfee30 | 285 | } |
286 | ||
287 | ||
288 | //------------------------------------------------------------------------------------------------- | |
506c1482 | 289 | void AliPIDCombined::GetPriors(const AliVTrack *track, Double_t* p,Float_t centrality,Bool_t isPPB) const { |
b8bfee30 | 290 | |
291 | // | |
292 | // get priors from distributions | |
293 | // | |
294 | ||
506c1482 | 295 | |
b8bfee30 | 296 | Double_t pt=TMath::Abs(track->Pt()); |
80f28562 | 297 | |
298 | if(fUseDefaultTPCPriors){ // use default priors if requested | |
299 | Float_t usedCentr = centrality+5*(centrality>0); | |
300 | if(usedCentr < -0.99) usedCentr = -0.99; | |
301 | else if(usedCentr > 99) usedCentr = 99; | |
302 | if(pt > 9.99) pt = 9.99; | |
303 | else if(pt < 0.01) pt = 0.01; | |
506c1482 | 304 | |
305 | if(! isPPB) | |
306 | for(Int_t i=0;i<AliPID::kSPECIESC;i++) p[i] = fDefaultPriorsTPC[i]->Interpolate(usedCentr,pt); | |
307 | else | |
308 | for(Int_t i=0;i<AliPID::kSPECIESC;i++) p[i] = fDefaultPriorsTPCpPb[i]->Interpolate(usedCentr,pt); | |
80f28562 | 309 | |
310 | return; | |
311 | } | |
312 | ||
b8bfee30 | 313 | Double_t sumPriors = 0; |
314 | for (Int_t i=0;i<fSelectedSpecies;++i){ | |
315 | if (fPriorsDistributions[i]){ | |
316 | p[i]=fPriorsDistributions[i]->Interpolate(pt); | |
317 | } | |
318 | else { | |
319 | p[i]=0.; | |
320 | } | |
321 | sumPriors+=p[i]; | |
322 | } | |
323 | ||
324 | // normalizing priors | |
325 | if (sumPriors == 0) return; | |
326 | for (Int_t i=0;i<fSelectedSpecies;++i){ | |
327 | p[i]=p[i]/sumPriors; | |
328 | } | |
329 | return; | |
330 | } | |
80f28562 | 331 | //------------------------------------------------------------------------------------------------- |
332 | void AliPIDCombined::GetPriors(const AliVTrack *track,Double_t* p,const AliPIDResponse *response,UInt_t detUsed) const{ | |
333 | ||
334 | // | |
335 | // get priors from distributions | |
336 | // | |
337 | Double_t pt=TMath::Abs(track->Pt()); | |
338 | ||
339 | if(fUseDefaultTPCPriors){ // use default priors if requested | |
340 | Float_t usedCentr = response->GetCurrentCentrality()+5*(response->GetCurrentCentrality()>0); | |
341 | if(usedCentr < -0.99) usedCentr = -0.99; | |
342 | else if(usedCentr > 99) usedCentr = 99; | |
343 | if(pt > 9.99) pt = 9.99; | |
344 | else if(pt < 0.01) pt = 0.01; | |
345 | ||
506c1482 | 346 | for(Int_t i=0;i<AliPID::kSPECIESC;i++) p[i] = fDefaultPriorsTPC[i]->Interpolate(usedCentr,pt); |
80f28562 | 347 | |
348 | // Extra factor if TOF matching was required | |
349 | if(detUsed & AliPIDResponse::kDetTOF){ | |
350 | Float_t kaonTOFfactor = 0.1; | |
506c1482 | 351 | if(pt > 0.29){ |
352 | kaonTOFfactor = 1 - TMath::Exp(-TMath::Power(pt,4.19618E-07)/4.96502e-01)*TMath::Power(pt,-1.50705); | |
506c1482 | 353 | } |
80f28562 | 354 | Float_t protonTOFfactor = 0.1; |
355 | if(pt > 0.4) protonTOFfactor = 1 - TMath::Exp(-TMath::Power(pt,3.30978)/8.57396E-02)*TMath::Power(pt,-4.42661E-01); | |
356 | ||
357 | if(track->Charge() < 0){ // for negative tracks | |
358 | kaonTOFfactor *= 1 - TMath::Exp(-TMath::Power(pt,4.87912E-07)/3.26431E-01)*TMath::Power(pt,-1.22893); | |
359 | protonTOFfactor *= 1 - TMath::Exp(-TMath::Power(pt,2.00575E-07)/4.95605E-01)*TMath::Power(pt,-6.71305E-01); | |
360 | } | |
361 | ||
362 | p[3] *= kaonTOFfactor; | |
363 | p[4] *= protonTOFfactor; | |
364 | } | |
365 | ||
366 | return; | |
367 | } | |
368 | ||
369 | ||
370 | Double_t sumPriors = 0; | |
371 | for (Int_t i=0;i<fSelectedSpecies;++i){ | |
372 | if (fPriorsDistributions[i]){ | |
373 | p[i]=fPriorsDistributions[i]->Interpolate(pt); | |
374 | } | |
375 | else { | |
376 | p[i]=0.; | |
377 | } | |
378 | sumPriors+=p[i]; | |
379 | } | |
b8bfee30 | 380 | |
80f28562 | 381 | // normalizing priors |
382 | if (sumPriors == 0) return; | |
383 | for (Int_t i=0;i<fSelectedSpecies;++i){ | |
384 | p[i]=p[i]/sumPriors; | |
385 | } | |
386 | return; | |
387 | } | |
b8bfee30 | 388 | //------------------------------------------------------------------------------------------------- |
42fcc729 | 389 | void AliPIDCombined::ComputeBayesProbabilities(Double_t* probabilities, const Double_t* probDensity, const Double_t* prior, Double_t* probDensityMism) const { |
b8bfee30 | 390 | |
391 | ||
392 | // | |
393 | // calculate Bayesian probabilities | |
394 | // | |
395 | Double_t sum = 0.; | |
396 | for (Int_t i = 0; i < fSelectedSpecies; i++) { | |
397 | sum += probDensity[i] * prior[i]; | |
398 | } | |
399 | if (sum <= 0) { | |
80f28562 | 400 | |
b8bfee30 | 401 | AliError("Invalid probability densities or priors"); |
90dfb7f1 | 402 | for (Int_t i = 0; i < fSelectedSpecies; i++) probabilities[i] = 1./fSelectedSpecies; |
b8bfee30 | 403 | return; |
404 | } | |
405 | for (Int_t i = 0; i < fSelectedSpecies; i++) { | |
406 | probabilities[i] = probDensity[i] * prior[i] / sum; | |
42fcc729 | 407 | if(probDensityMism) probDensityMism[i] *= prior[i] / sum; |
b8bfee30 | 408 | } |
409 | ||
410 | ||
411 | } | |
412 | ||
3ed61c90 | 413 | |
b8bfee30 | 414 | //---------------------------------------------------------------------------------------- |
3ed61c90 | 415 | void AliPIDCombined::SetCombinedStatus(AliPIDResponse::EDetPidStatus status, UInt_t *maskDetIn, AliPIDResponse::EDetCode bit) const { |
b8bfee30 | 416 | switch (status) { |
3ed61c90 | 417 | case AliPIDResponse::kDetNoParams: |
418 | case AliPIDResponse::kDetNoSignal: | |
419 | case AliPIDResponse::kDetMismatch: // for backward compatibilty, we need then to remove kDetMismatch from AliPIDResponse | |
b8bfee30 | 420 | break; |
421 | case AliPIDResponse::kDetPidOk: | |
422 | *maskDetIn = *maskDetIn | bit; | |
423 | break; | |
3ed61c90 | 424 | } |
425 | ||
426 | } | |
427 | ||
428 | //---------------------------------------------------------------------------------------- | |
506c1482 | 429 | void AliPIDCombined::SetCombinedStatus(AliPIDResponse::EDetPidStatus status, UInt_t *maskDetIn, AliPIDResponse::EDetCode bit, Double_t* /*p*/, const Float_t /*probMis*/) const { |
3ed61c90 | 430 | switch (status) { |
431 | case AliPIDResponse::kDetNoParams: | |
432 | case AliPIDResponse::kDetNoSignal: | |
433 | case AliPIDResponse::kDetMismatch: // for backward compatibility, we need then to remove kDeteMismatch from AliPIDResponse | |
434 | break; | |
435 | case AliPIDResponse::kDetPidOk: | |
506c1482 | 436 | // if (probMis > 0.5) for (Int_t j=0;j<fSelectedSpecies;j++) p[j]=1./fSelectedSpecies; // no longer used because mismatch is in the framework now |
437 | //else | |
438 | *maskDetIn = *maskDetIn | bit; | |
b8bfee30 | 439 | break; |
440 | } | |
441 | ||
442 | } | |
443 | ||
3ed61c90 | 444 | |
445 | ||
80f28562 | 446 | //---------------------------------------------------------------------------------------- |
447 | void AliPIDCombined::SetDefaultTPCPriors(){ | |
448 | fEnablePriors=kTRUE; | |
449 | fUseDefaultTPCPriors = kTRUE; | |
450 | ||
7f6d8b5c | 451 | //Check if priors are already initialized |
00a38d07 | 452 | if (fDefaultPriorsTPC[0]) return; |
453 | ||
7f6d8b5c | 454 | TString oadbfilename("$ALICE_PHYSICS/OADB/COMMON/PID/data/"); |
455 | // TString oadbfilename("$ALICE_ROOT/OADB/COMMON/PID/data/"); | |
456 | // TString oadbfilename(Form("%s/COMMON/PID/data/",AliAnalysisManager::GetOADBPath())); | |
80f28562 | 457 | oadbfilename += "/PIDdefaultPriors.root"; |
458 | TFile * foadb = TFile::Open(oadbfilename.Data()); | |
00a38d07 | 459 | if(!foadb || !foadb->IsOpen()) { |
460 | delete foadb; | |
461 | AliFatal(Form("Cannot open OADB file %s", oadbfilename.Data())); | |
462 | return; | |
463 | } | |
80f28562 | 464 | |
465 | AliOADBContainer * priorsContainer = (AliOADBContainer*) foadb->Get("priorsTPC"); | |
466 | if (!priorsContainer) AliFatal("Cannot fetch OADB container for Priors"); | |
467 | ||
506c1482 | 468 | const char *namespecies[AliPID::kSPECIESC] = {"El","Mu","Pi","Ka","Pr","De","Tr","He3","He3"}; |
80f28562 | 469 | char name[100]; |
470 | ||
506c1482 | 471 | for(Int_t i=0;i < AliPID::kSPECIESC;i++){ |
4c234df8 | 472 | snprintf(name,99,"hDefault%sPriors",namespecies[i]); |
80f28562 | 473 | fDefaultPriorsTPC[i] = (TH2F*) priorsContainer->GetDefaultObject(name); |
474 | if (!fDefaultPriorsTPC[i]) AliFatal(Form("Cannot find priors for %s", namespecies[i])); | |
506c1482 | 475 | snprintf(name,99,"hDefault%sPriorsPPb",namespecies[i]); |
476 | fDefaultPriorsTPCpPb[i] = (TH2F*) priorsContainer->GetDefaultObject(name); | |
477 | if (!fDefaultPriorsTPCpPb[i]) { | |
478 | fDefaultPriorsTPCpPb[i] = fDefaultPriorsTPC[i]; // use PbPb ones | |
479 | } | |
80f28562 | 480 | } |
00a38d07 | 481 | |
482 | delete foadb; | |
80f28562 | 483 | } |