6ad0bfa0 |
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 | |
b2a60966 |
16 | /* $Id$ */ |
17 | |
6ad0bfa0 |
18 | //_________________________________________________________________________ |
b2a60966 |
19 | // Implementation version v1 of the PHOS particle identifier |
7acf6008 |
20 | // Particle identification based on the |
148b2bba |
21 | // - RCPV: distance from CPV recpoint to EMCA recpoint. |
22 | // - TOF |
23 | // - PCA: Principal Components Analysis.. |
24 | // The identified particle has an identification number corresponding |
25 | // to a 9 bits number: |
bc0c084c |
26 | // -Bit 0 to 2: bit set if RCPV > CpvEmcDistance (each bit corresponds |
148b2bba |
27 | // to a different efficiency-purity point of the photon identification) |
bc0c084c |
28 | // -Bit 3 to 5: bit set if TOF < TimeGate (each bit corresponds |
148b2bba |
29 | // to a different efficiency-purity point of the photon identification) |
30 | // -Bit 6 to 9: bit set if Principal Components are |
50739f15 |
31 | // inside an ellipse defined by the parameters a, b, c, x0 and y0. |
148b2bba |
32 | // (each bit corresponds to a different efficiency-purity point of the |
50739f15 |
33 | // photon identification) |
34 | // The PCA (Principal components analysis) needs a file that contains |
35 | // a previous analysis of the correlations between the particles. This |
bc0c084c |
36 | // file is $ALICE_ROOT/PHOS/PCA8pa15_0.5-100.root. Analysis done for |
50739f15 |
37 | // energies between 0.5 and 100 GeV. |
9fa5f1d0 |
38 | // A calibrated energy is calculated. The energy of the reconstructed |
50739f15 |
39 | // cluster is corrected with the formula A + B * E + C * E^2, whose |
bc0c084c |
40 | // parameters where obtained through the study of the reconstructed |
50739f15 |
41 | // energy distribution of monoenergetic photons. |
a4e98857 |
42 | // |
bc0c084c |
43 | // All the parameters (RCPV(2 rows-3 columns),TOF(1r-3c),PCA(5r-4c) |
50739f15 |
44 | // and calibration(1r-3c))are stored in a file called |
45 | // $ALICE_ROOT/PHOS/Parameters.dat. Each time that AliPHOSPIDv1 is |
bc0c084c |
46 | // initialized, this parameters are copied to a Matrix (9,4), a |
50739f15 |
47 | // TMatrixD object. |
7acf6008 |
48 | // |
a4e98857 |
49 | // use case: |
50739f15 |
50 | // root [0] AliPHOSPIDv1 * p = new AliPHOSPIDv1("galice1.root") |
a4e98857 |
51 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
50739f15 |
52 | // // reading headers from file galice1.root and create RecParticles |
53 | // TrackSegments and RecPoints are used |
54 | // // set file name for the branch RecParticles |
f0a4c9e9 |
55 | // root [1] p->ExecuteTask("deb all time") |
50739f15 |
56 | // // available options |
57 | // // "deb" - prints # of reconstructed particles |
58 | // // "deb all" - prints # and list of RecParticles |
59 | // // "time" - prints benchmarking results |
7acf6008 |
60 | // |
50739f15 |
61 | // root [2] AliPHOSPIDv1 * p2 = new AliPHOSPIDv1("galice1.root","v1",kTRUE) |
148b2bba |
62 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
50739f15 |
63 | // //Split mode. |
f0a4c9e9 |
64 | // root [3] p2->ExecuteTask() |
65 | // |
50739f15 |
66 | |
f0a4c9e9 |
67 | |
7acf6008 |
68 | //*-- Author: Yves Schutz (SUBATECH) & Gines Martinez (SUBATECH) & |
148b2bba |
69 | // Gustavo Conesa April 2002 |
50739f15 |
70 | // PCA redesigned by Gustavo Conesa October 2002: |
71 | // The way of using the PCA has changed. Instead of 2 |
72 | // files with the PCA, each one with different energy ranges |
73 | // of application, we use the wide one (0.5-100 GeV), and instead |
bc0c084c |
74 | // of fixing 3 ellipses for different ranges of energy, it has been |
50739f15 |
75 | // studied the dependency of the ellipses parameters with the |
76 | // energy, and they are implemented in the code as a funtion |
77 | // of the energy. |
78 | // |
79 | // |
80 | // |
6ad0bfa0 |
81 | // --- ROOT system --- |
c947e71a |
82 | |
83 | |
84 | // --- Standard library --- |
acb5beb7 |
85 | #include "TFormula.h" |
7acf6008 |
86 | #include "TBenchmark.h" |
148b2bba |
87 | #include "TPrincipal.h" |
c947e71a |
88 | #include "TFile.h" |
e3817e5f |
89 | #include "TSystem.h" |
148b2bba |
90 | |
6ad0bfa0 |
91 | // --- AliRoot header files --- |
c947e71a |
92 | //#include "AliLog.h" |
7acf6008 |
93 | #include "AliGenerator.h" |
e3817e5f |
94 | #include "AliPHOS.h" |
26d4b141 |
95 | #include "AliPHOSPIDv1.h" |
7b7c1533 |
96 | #include "AliPHOSGetter.h" |
6ad0bfa0 |
97 | |
26d4b141 |
98 | ClassImp( AliPHOSPIDv1) |
6ad0bfa0 |
99 | |
1cb7c1ee |
100 | //____________________________________________________________________________ |
101 | AliPHOSPIDv1::AliPHOSPIDv1():AliPHOSPID() |
102 | { |
a4e98857 |
103 | // default ctor |
148b2bba |
104 | |
8d0f3f77 |
105 | InitParameters() ; |
92f521a9 |
106 | fDefaultInit = kTRUE ; |
7acf6008 |
107 | } |
108 | |
581354c5 |
109 | //____________________________________________________________________________ |
88cb7938 |
110 | AliPHOSPIDv1::AliPHOSPIDv1(const AliPHOSPIDv1 & pid ):AliPHOSPID(pid) |
581354c5 |
111 | { |
386aef34 |
112 | // ctor |
581354c5 |
113 | InitParameters() ; |
581354c5 |
114 | Init() ; |
581354c5 |
115 | |
116 | } |
117 | |
7acf6008 |
118 | //____________________________________________________________________________ |
88cb7938 |
119 | AliPHOSPIDv1::AliPHOSPIDv1(const TString alirunFileName, const TString eventFolderName):AliPHOSPID(alirunFileName, eventFolderName) |
7acf6008 |
120 | { |
a4e98857 |
121 | //ctor with the indication on where to look for the track segments |
7b7c1533 |
122 | |
8d0f3f77 |
123 | InitParameters() ; |
2bd5457f |
124 | Init() ; |
92f521a9 |
125 | fDefaultInit = kFALSE ; |
7acf6008 |
126 | } |
7b7c1533 |
127 | |
7acf6008 |
128 | //____________________________________________________________________________ |
129 | AliPHOSPIDv1::~AliPHOSPIDv1() |
130 | { |
79bb1b62 |
131 | // dtor |
acb5beb7 |
132 | fPrincipalPhoton = 0; |
133 | fPrincipalPi0 = 0; |
9fa5f1d0 |
134 | |
e3817e5f |
135 | delete [] fX ; // Principal input |
136 | delete [] fPPhoton ; // Photon Principal components |
137 | delete [] fPPi0 ; // Pi0 Principal components |
acb5beb7 |
138 | |
139 | delete fParameters; |
140 | delete fTFphoton; |
141 | delete fTFpiong; |
142 | delete fTFkaong; |
143 | delete fTFkaonl; |
144 | delete fTFhhadrong; |
145 | delete fTFhhadronl; |
146 | delete fDFmuon; |
7acf6008 |
147 | } |
a496c46c |
148 | //____________________________________________________________________________ |
149 | const TString AliPHOSPIDv1::BranchName() const |
150 | { |
88cb7938 |
151 | |
152 | return GetName() ; |
a496c46c |
153 | } |
154 | |
148b2bba |
155 | //____________________________________________________________________________ |
156 | void AliPHOSPIDv1::Init() |
157 | { |
158 | // Make all memory allocations that are not possible in default constructor |
159 | // Add the PID task to the list of PHOS tasks |
a496c46c |
160 | |
adcca1e6 |
161 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
162 | if(!gime) |
163 | gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()) ; |
88cb7938 |
164 | |
165 | if ( !gime->PID() ) |
166 | gime->PostPID(this) ; |
148b2bba |
167 | } |
8d0f3f77 |
168 | |
169 | //____________________________________________________________________________ |
170 | void AliPHOSPIDv1::InitParameters() |
171 | { |
e3817e5f |
172 | // Initialize PID parameters |
adcca1e6 |
173 | fWrite = kTRUE ; |
8d0f3f77 |
174 | fRecParticlesInRun = 0 ; |
8d0f3f77 |
175 | fNEvent = 0 ; |
8d0f3f77 |
176 | fRecParticlesInRun = 0 ; |
35adb638 |
177 | fBayesian = kTRUE ; |
9fa5f1d0 |
178 | SetParameters() ; // fill the parameters matrix from parameters file |
eabde521 |
179 | SetEventRange(0,-1) ; |
35adb638 |
180 | |
cc1fe362 |
181 | // initialisation of response function parameters |
182 | // Tof |
183 | // Photons |
35adb638 |
184 | fTphoton[0] = 0.218 ; |
185 | //fTphoton[0] = 1. ; |
186 | fTphoton[1] = 1.55E-8 ; |
187 | fTphoton[2] = 5.05E-10 ; |
188 | fTFphoton = new TFormula("ToF response to photons" , "gaus") ; |
cc1fe362 |
189 | fTFphoton->SetParameters( fTphoton[0], fTphoton[1], fTphoton[2]) ; |
35adb638 |
190 | // // Electrons |
191 | // fTelectron[0] = 0.2 ; |
192 | // fTelectron[1] = 1.55E-8 ; |
193 | // fTelectron[2] = 5.35E-10 ; |
194 | // fTFelectron = new TFormula("ToF response to electrons" , "gaus") ; |
195 | // fTFelectron->SetParameters( fTelectron[0], fTelectron[1], fTelectron[2]) ; |
196 | // // Muons |
197 | // fTmuon[0] = 0.2 ; |
198 | // fTmuon[1] = 1.55E-8 ; |
199 | // fTmuon[2] = 5.1E-10 ; |
200 | // fTFmuon = new TFormula("ToF response to muons" , "gaus") ; |
201 | // fTFmuon->SetParameters( fTmuon[0], fTmuon[1], fTmuon[2]) ; |
202 | |
203 | // Pions |
204 | //Gaus (0 to max probability) |
205 | fTpiong[0] = 0.0971 ; |
206 | //fTpiong[0] = 1. ; |
207 | fTpiong[1] = 1.58E-8 ; |
208 | fTpiong[2] = 5.69E-10 ; |
209 | fTFpiong = new TFormula("ToF response to pions" , "gaus") ; |
210 | fTFpiong->SetParameters( fTpiong[0], fTpiong[1], fTpiong[2]) ; |
211 | // Landau (max probability to inf) |
212 | // fTpionl[0] = 0.05 ; |
213 | // //fTpionl[0] = 5.53 ; |
214 | // fTpionl[1] = 1.68E-8 ; |
215 | // fTpionl[2] = 5.38E-10 ; |
216 | // fTFpionl = new TFormula("ToF response to pions" , "landau") ; |
217 | // fTFpionl->SetParameters( fTpionl[0], fTpionl[1], fTpionl[2]) ; |
218 | |
219 | |
220 | // Kaons |
221 | //Gaus (0 to max probability) |
222 | fTkaong[0] = 0.0542 ; |
223 | //fTkaong[0] = 1. ; |
224 | fTkaong[1] = 1.64E-8 ; |
225 | fTkaong[2] = 6.07-10 ; |
226 | fTFkaong = new TFormula("ToF response to kaon" , "gaus") ; |
227 | fTFkaong->SetParameters( fTkaong[0], fTkaong[1], fTkaong[2]) ; |
228 | //Landau (max probability to inf) |
229 | fTkaonl[0] = 0.264 ; |
230 | //fTkaonl[0] = 5.53 ; |
231 | fTkaonl[1] = 1.68E-8 ; |
232 | fTkaonl[2] = 4.10E-10 ; |
233 | fTFkaonl = new TFormula("ToF response to kaon" , "landau") ; |
234 | fTFkaonl->SetParameters( fTkaonl[0], fTkaonl[1], fTkaonl[2]) ; |
235 | |
236 | //Heavy Hadrons |
237 | //Gaus (0 to max probability) |
238 | fThhadrong[0] = 0.0302 ; |
239 | //fThhadrong[0] = 1. ; |
240 | fThhadrong[1] = 1.73E-8 ; |
241 | fThhadrong[2] = 9.52E-10 ; |
242 | fTFhhadrong = new TFormula("ToF response to heavy hadrons" , "gaus") ; |
243 | fTFhhadrong->SetParameters( fThhadrong[0], fThhadrong[1], fThhadrong[2]) ; |
244 | //Landau (max probability to inf) |
245 | fThhadronl[0] = 0.139 ; |
246 | //fThhadronl[0] = 5.53 ; |
247 | fThhadronl[1] = 1.745E-8 ; |
248 | fThhadronl[2] = 1.00E-9 ; |
249 | fTFhhadronl = new TFormula("ToF response to heavy hadrons" , "landau") ; |
250 | fTFhhadronl->SetParameters( fThhadronl[0], fThhadronl[1], fThhadronl[2]) ; |
251 | |
252 | /// /gaussian parametrization for pions |
253 | // fTpion[0] = 3.93E-2 ; fTpion[1] = 0.130 ; fTpion[2] =-6.37E-2 ;//constant |
254 | // fTpion[3] = 1.65E-8 ; fTpion[4] =-1.40E-9 ; fTpion[5] = 5.96E-10;//mean |
255 | // fTpion[6] = 8.09E-10; fTpion[7] =-4.65E-10; fTpion[8] = 1.50E-10;//sigma |
256 | |
257 | // //landau parametrization for kaons |
258 | // fTkaon[0] = 0.107 ; fTkaon[1] = 0.166 ; fTkaon[2] = 0.243 ;//constant |
259 | // fTkaon[3] = 1.80E-8 ; fTkaon[4] =-2.96E-9 ; fTkaon[5] = 9.60E-10;//mean |
260 | // fTkaon[6] = 1.37E-9 ; fTkaon[7] =-1.80E-9 ; fTkaon[8] = 6.74E-10;//sigma |
261 | |
262 | // //landau parametrization for nucleons |
263 | // fThhadron[0] = 6.33E-2 ; fThhadron[1] = 2.52E-2 ; fThhadron[2] = 2.16E-2 ;//constant |
264 | // fThhadron[3] = 1.94E-8 ; fThhadron[4] =-7.06E-10; fThhadron[5] =-4.69E-10;//mean |
265 | // fThhadron[6] = 2.55E-9 ; fThhadron[7] =-1.90E-9 ; fThhadron[8] = 5.41E-10;//sigma |
266 | |
267 | |
268 | // Shower shape: dispersion gaussian parameters |
269 | // Photons |
270 | |
c947e71a |
271 | // fDphoton[0] = 3.84e-2; fDphoton[1] = 4.46e-3 ; fDphoton[2] = -2.36e-2;//constant |
272 | // //fDphoton[0] = 1.0 ; fDphoton[1] = 0. ; fDphoton[2] = 0. ;//constant |
273 | // fDphoton[3] = 1.55 ; fDphoton[4] =-0.0863 ; fDphoton[5] = 0.287 ;//mean |
274 | // fDphoton[6] = 0.0451 ; fDphoton[7] =-0.0803 ; fDphoton[8] = 0.314 ;//sigma |
275 | |
276 | fDphoton[0] = 4.62e-2; fDphoton[1] = 1.39e-2 ; fDphoton[2] = -3.80e-2;//constant |
277 | //fDphoton[0] = 1.0 ; fDphoton[1] = 0. ; fDphoton[2] = 0. ;//constant |
278 | fDphoton[3] = 1.53 ; fDphoton[4] =-6.62e-2 ; fDphoton[5] = 0.339 ;//mean |
279 | fDphoton[6] = 6.89e-2; fDphoton[7] =-6.59e-2 ; fDphoton[8] = 0.194 ;//sigma |
35adb638 |
280 | |
281 | fDpi0[0] = 0.0586 ; fDpi0[1] = 1.06E-3 ; fDpi0[2] = 0. ;//constant |
282 | //fDpi0[0] = 1.0 ; fDpi0[1] = 0.0 ; fDpi0[2] = 0. ;//constant |
283 | fDpi0[3] = 2.67 ; fDpi0[4] =-2.00E-2 ; fDpi0[5] = 9.37E-5 ;//mean |
284 | fDpi0[6] = 0.153 ; fDpi0[7] = 9.34E-4 ; fDpi0[8] =-1.49E-5 ;//sigma |
285 | //landau |
286 | // fDhadron[0] = 0.007 ; fDhadron[1] = 0. ; fDhadron[2] = 0. ;//constant |
287 | // //fDhadron[0] = 5.53 ; fDhadron[1] = 0. ; fDhadron[2] = 0. ;//constant |
288 | // fDhadron[3] = 3.38 ; fDhadron[4] = 0.0833 ; fDhadron[5] =-0.845 ;//mean |
289 | // fDhadron[6] = 0.627 ; fDhadron[7] = 0.012 ; fDhadron[8] =-0.170 ;//sigma |
290 | |
c947e71a |
291 | fDhadron[0] = 1.61E-2 ; fDhadron[1] = 3.03E-3 ; fDhadron[2] = 1.01E-2 ;//constant |
292 | fDhadron[3] = 3.81 ; fDhadron[4] = 0.232 ; fDhadron[5] =-1.25 ;//mean |
293 | fDhadron[6] = 0.897 ; fDhadron[7] = 0.0987 ; fDhadron[8] =-0.534 ;//sigma |
35adb638 |
294 | // Muons |
295 | fDmuon[0] = 0.0631 ; |
296 | fDmuon[1] = 1.4 ; |
297 | fDmuon[2] = 0.0557 ; |
298 | fDFmuon = new TFormula("Shower shape response to muons" , "landau") ; |
299 | fDFmuon->SetParameters( fDmuon[0], fDmuon[1], fDmuon[2]) ; |
300 | |
35adb638 |
301 | |
c947e71a |
302 | // x(CPV-EMC) distance gaussian parameters |
303 | |
304 | fXelectron[0] = 8.06e-2 ; fXelectron[1] = 1.00e-2; fXelectron[2] =-5.14e-2;//constant |
305 | //fXelectron[0] = 1.0 ; fXelectron[1] = 0. ; fXelectron[2] = 0. ;//constant |
306 | fXelectron[3] = 0.202 ; fXelectron[4] = 8.15e-3; fXelectron[5] = 4.55 ;//mean |
307 | fXelectron[6] = 0.334 ; fXelectron[7] = 0.186 ; fXelectron[8] = 4.32e-2;//sigma |
308 | |
309 | //charged hadrons gaus |
310 | fXcharged[0] = 6.43e-3 ; fXcharged[1] =-4.19e-5; fXcharged[2] = 1.42e-3;//constant |
311 | fXcharged[3] = 2.75 ; fXcharged[4] =-0.40 ; fXcharged[5] = 1.68 ;//mean |
312 | fXcharged[6] = 3.135 ; fXcharged[7] =-9.41e-2; fXcharged[8] = 1.31e-2;//sigma |
313 | |
314 | // z(CPV-EMC) distance gaussian parameters |
315 | |
316 | fZelectron[0] = 8.22e-2 ; fZelectron[1] = 5.11e-3; fZelectron[2] =-3.05e-2;//constant |
317 | //fZelectron[0] = 1.0 ; fZelectron[1] = 0. ; fZelectron[2] = 0. ;//constant |
318 | fZelectron[3] = 3.09e-2 ; fZelectron[4] = 5.87e-2; fZelectron[5] =-9.49e-2;//mean |
319 | fZelectron[6] = 0.263 ; fZelectron[7] =-9.02e-3; fZelectron[8] = 0.151 ;//sigma |
320 | |
321 | //charged hadrons gaus |
322 | |
323 | fZcharged[0] = 1.00e-2 ; fZcharged[1] = 2.82E-4 ; fZcharged[2] = 2.87E-3 ;//constant |
324 | fZcharged[3] =-4.68e-2 ; fZcharged[4] =-9.21e-3 ; fZcharged[5] = 4.91e-2 ;//mean |
325 | fZcharged[6] = 1.425 ; fZcharged[7] =-5.90e-2 ; fZcharged[8] = 5.07e-2 ;//sigma |
326 | |
35adb638 |
327 | for (Int_t i =0; i< AliESDtrack::kSPECIESN ; i++) |
328 | fInitPID[i] = 1.; |
329 | |
8d0f3f77 |
330 | } |
331 | |
88cb7938 |
332 | //________________________________________________________________________ |
eabde521 |
333 | void AliPHOSPIDv1::Exec(Option_t *option) |
88cb7938 |
334 | { |
eabde521 |
335 | // Steering method to perform particle reconstruction and identification |
336 | // for the event range from fFirstEvent to fLastEvent. |
337 | // This range is optionally set by SetEventRange(). |
338 | // if fLastEvent=-1 (by default), then process events until the end. |
61d3d6aa |
339 | |
88cb7938 |
340 | if(strstr(option,"tim")) |
341 | gBenchmark->Start("PHOSPID"); |
342 | |
343 | if(strstr(option,"print")) { |
344 | Print() ; |
345 | return ; |
346 | } |
347 | |
348 | |
adcca1e6 |
349 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
88cb7938 |
350 | |
71cee46d |
351 | if (fLastEvent == -1) |
352 | fLastEvent = gime->MaxEvent() - 1 ; |
353 | else |
354 | fLastEvent = TMath::Min(fLastEvent,gime->MaxEvent()); |
eabde521 |
355 | Int_t nEvents = fLastEvent - fFirstEvent + 1; |
88cb7938 |
356 | |
71cee46d |
357 | Int_t ievent ; |
358 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { |
88cb7938 |
359 | gime->Event(ievent,"TR") ; |
360 | if(gime->TrackSegments() && //Skip events, where no track segments made |
361 | gime->TrackSegments()->GetEntriesFast()) { |
362 | MakeRecParticles() ; |
35adb638 |
363 | |
364 | if(fBayesian) |
365 | MakePID() ; |
366 | |
90cceaf6 |
367 | WriteRecParticles(); |
88cb7938 |
368 | if(strstr(option,"deb")) |
369 | PrintRecParticles(option) ; |
370 | //increment the total number of rec particles per run |
371 | fRecParticlesInRun += gime->RecParticles()->GetEntriesFast() ; |
372 | } |
373 | } |
ff417097 |
374 | if(strstr(option,"deb")) |
375 | PrintRecParticles(option); |
88cb7938 |
376 | if(strstr(option,"tim")){ |
377 | gBenchmark->Stop("PHOSPID"); |
351dd634 |
378 | AliInfo(Form("took %f seconds for PID %f seconds per event", |
88cb7938 |
379 | gBenchmark->GetCpuTime("PHOSPID"), |
351dd634 |
380 | gBenchmark->GetCpuTime("PHOSPID")/nEvents)) ; |
88cb7938 |
381 | } |
adcca1e6 |
382 | if(fWrite) |
383 | Unload(); |
88cb7938 |
384 | } |
385 | |
35adb638 |
386 | //________________________________________________________________________ |
17323043 |
387 | Double_t AliPHOSPIDv1::GausF(Double_t x, Double_t y, Double_t * par) |
35adb638 |
388 | { |
c947e71a |
389 | //Given the energy x and the parameter y (tof, shower dispersion or cpv-emc distance), |
390 | //this method returns a density probability of this parameter, given by a gaussian |
391 | //function whose parameters depend with the energy with a function: a/(x*x)+b/x+b |
392 | Double_t cnt = par[1] / (x*x) + par[2] / x + par[0] ; |
35adb638 |
393 | Double_t mean = par[4] / (x*x) + par[5] / x + par[3] ; |
394 | Double_t sigma = par[7] / (x*x) + par[8] / x + par[6] ; |
c947e71a |
395 | |
35adb638 |
396 | // Double_t arg = - (y-mean) * (y-mean) / (2*sigma*sigma) ; |
397 | // return cnt * TMath::Exp(arg) ; |
c947e71a |
398 | if(TMath::Abs(sigma) > 1.e-10){ |
acb5beb7 |
399 | return cnt*TMath::Gaus(y,mean,sigma); |
35adb638 |
400 | } |
401 | else |
402 | return 0.; |
c947e71a |
403 | |
35adb638 |
404 | } |
405 | //________________________________________________________________________ |
17323043 |
406 | Double_t AliPHOSPIDv1::GausPol2(Double_t x, Double_t y, Double_t * par) |
35adb638 |
407 | { |
c947e71a |
408 | //Given the energy x and the parameter y (tof, shower dispersion or cpv-emc distance), |
409 | //this method returns a density probability of this parameter, given by a gaussian |
410 | //function whose parameters depend with the energy like second order polinomial |
411 | |
35adb638 |
412 | Double_t cnt = par[0] + par[1] * x + par[2] * x * x ; |
413 | Double_t mean = par[3] + par[4] * x + par[5] * x * x ; |
414 | Double_t sigma = par[6] + par[7] * x + par[8] * x * x ; |
415 | |
c947e71a |
416 | if(TMath::Abs(sigma) > 1.e-10){ |
acb5beb7 |
417 | return cnt*TMath::Gaus(y,mean,sigma); |
35adb638 |
418 | } |
419 | else |
420 | return 0.; |
c947e71a |
421 | |
422 | |
423 | |
35adb638 |
424 | } |
425 | |
69183710 |
426 | //____________________________________________________________________________ |
e3817e5f |
427 | const TString AliPHOSPIDv1::GetFileNamePrincipal(TString particle) const |
148b2bba |
428 | { |
e3817e5f |
429 | //Get file name that contains the PCA for a particle ("photon or pi0") |
430 | particle.ToLower(); |
431 | TString name; |
351dd634 |
432 | if (particle=="photon") |
433 | name = fFileNamePrincipalPhoton ; |
434 | else if (particle=="pi0" ) |
435 | name = fFileNamePrincipalPi0 ; |
436 | else |
437 | AliError(Form("Wrong particle name: %s (choose from pi0/photon)\n", |
438 | particle.Data())); |
e3817e5f |
439 | return name; |
440 | } |
bc0c084c |
441 | |
e3817e5f |
442 | //____________________________________________________________________________ |
fc7e2f43 |
443 | Float_t AliPHOSPIDv1::GetParameterCalibration(Int_t i) const |
e3817e5f |
444 | { |
445 | // Get the i-th parameter "Calibration" |
446 | Float_t param = 0.; |
351dd634 |
447 | if (i>2 || i<0) { |
448 | AliError(Form("Invalid parameter number: %d",i)); |
449 | } else |
e3817e5f |
450 | param = (*fParameters)(0,i); |
451 | return param; |
452 | } |
bc0c084c |
453 | |
88cb7938 |
454 | //____________________________________________________________________________ |
fc7e2f43 |
455 | Float_t AliPHOSPIDv1::GetCalibratedEnergy(Float_t e) const |
88cb7938 |
456 | { |
457 | // It calibrates Energy depending on the recpoint energy. |
458 | // The energy of the reconstructed cluster is corrected with |
459 | // the formula A + B* E + C* E^2, whose parameters where obtained |
460 | // through the study of the reconstructed energy distribution of |
461 | // monoenergetic photons. |
462 | |
463 | Float_t p[]={0.,0.,0.}; |
464 | for (Int_t i=0; i<3; i++) p[i] = GetParameterCalibration(i); |
465 | Float_t enerec = p[0] + p[1]*e + p[2]*e*e; |
466 | return enerec ; |
467 | |
468 | } |
469 | |
e3817e5f |
470 | //____________________________________________________________________________ |
fc7e2f43 |
471 | Float_t AliPHOSPIDv1::GetParameterCpv2Emc(Int_t i, TString axis) const |
e3817e5f |
472 | { |
473 | // Get the i-th parameter "CPV-EMC distance" for the specified axis |
474 | Float_t param = 0.; |
351dd634 |
475 | if(i>2 || i<0) { |
476 | AliError(Form("Invalid parameter number: %d",i)); |
477 | } else { |
e3817e5f |
478 | axis.ToLower(); |
351dd634 |
479 | if (axis == "x") |
480 | param = (*fParameters)(1,i); |
481 | else if (axis == "z") |
482 | param = (*fParameters)(2,i); |
483 | else { |
484 | AliError(Form("Invalid axis name: %s",axis.Data())); |
485 | } |
e3817e5f |
486 | } |
487 | return param; |
488 | } |
489 | |
490 | //____________________________________________________________________________ |
fc7e2f43 |
491 | Float_t AliPHOSPIDv1::GetCpv2EmcDistanceCut(TString axis, Float_t e) const |
e3817e5f |
492 | { |
88cb7938 |
493 | // Get CpvtoEmcDistance Cut depending on the cluster energy, axis and |
494 | // Purity-Efficiency point |
495 | |
496 | axis.ToLower(); |
497 | Float_t p[]={0.,0.,0.}; |
498 | for (Int_t i=0; i<3; i++) p[i] = GetParameterCpv2Emc(i,axis); |
499 | Float_t sig = p[0] + TMath::Exp(p[1] - p[2]*e); |
500 | return sig; |
e3817e5f |
501 | } |
502 | |
88cb7938 |
503 | //____________________________________________________________________________ |
fc7e2f43 |
504 | Float_t AliPHOSPIDv1::GetEllipseParameter(TString particle, TString param, Float_t e) const |
88cb7938 |
505 | { |
506 | // Calculates the parameter param of the ellipse |
e3817e5f |
507 | |
508 | particle.ToLower(); |
509 | param. ToLower(); |
88cb7938 |
510 | Float_t p[4]={0.,0.,0.,0.}; |
511 | Float_t value = 0.0; |
512 | for (Int_t i=0; i<4; i++) p[i] = GetParameterToCalculateEllipse(particle,param,i); |
513 | if (particle == "photon") { |
514 | if (param.Contains("a")) e = TMath::Min((Double_t)e,70.); |
515 | else if (param.Contains("b")) e = TMath::Min((Double_t)e,70.); |
516 | else if (param.Contains("x0")) e = TMath::Max((Double_t)e,1.1); |
517 | } |
e3817e5f |
518 | |
443caba9 |
519 | if (particle == "photon") |
520 | value = p[0]/TMath::Sqrt(e) + p[1]*e + p[2]*e*e + p[3]; |
521 | else if (particle == "pi0") |
522 | value = p[0] + p[1]*e + p[2]*e*e; |
523 | |
88cb7938 |
524 | return value; |
e3817e5f |
525 | } |
526 | |
527 | //_____________________________________________________________________________ |
fc7e2f43 |
528 | Float_t AliPHOSPIDv1::GetParameterPhotonBoundary (Int_t i) const |
e3817e5f |
529 | { |
530 | // Get the parameter "i" to calculate the boundary on the moment M2x |
531 | // for photons at high p_T |
532 | Float_t param = 0; |
351dd634 |
533 | if (i>3 || i<0) { |
534 | AliError(Form("Wrong parameter number: %d\n",i)); |
535 | } else |
e3817e5f |
536 | param = (*fParameters)(14,i) ; |
537 | return param; |
148b2bba |
538 | } |
e3817e5f |
539 | |
148b2bba |
540 | //____________________________________________________________________________ |
fc7e2f43 |
541 | Float_t AliPHOSPIDv1::GetParameterPi0Boundary (Int_t i) const |
e3817e5f |
542 | { |
543 | // Get the parameter "i" to calculate the boundary on the moment M2x |
544 | // for pi0 at high p_T |
545 | Float_t param = 0; |
351dd634 |
546 | if (i>2 || i<0) { |
547 | AliError(Form("Wrong parameter number: %d\n",i)); |
548 | } else |
e3817e5f |
549 | param = (*fParameters)(15,i) ; |
550 | return param; |
551 | } |
148b2bba |
552 | |
e3817e5f |
553 | //____________________________________________________________________________ |
fc7e2f43 |
554 | Float_t AliPHOSPIDv1::GetParameterTimeGate(Int_t i) const |
e3817e5f |
555 | { |
88cb7938 |
556 | // Get TimeGate parameter depending on Purity-Efficiency i: |
557 | // i=0 - Low purity, i=1 - Medium purity, i=2 - High purity |
558 | Float_t param = 0.; |
351dd634 |
559 | if(i>2 || i<0) { |
560 | AliError(Form("Invalid Efficiency-Purity choice %d",i)); |
561 | } else |
88cb7938 |
562 | param = (*fParameters)(3,i) ; |
563 | return param; |
e3817e5f |
564 | } |
565 | |
148b2bba |
566 | //_____________________________________________________________________________ |
fc7e2f43 |
567 | Float_t AliPHOSPIDv1::GetParameterToCalculateEllipse(TString particle, TString param, Int_t i) const |
88cb7938 |
568 | { |
569 | // Get the parameter "i" that is needed to calculate the ellipse |
570 | // parameter "param" for the particle "particle" ("photon" or "pi0") |
571 | |
e3817e5f |
572 | particle.ToLower(); |
573 | param. ToLower(); |
88cb7938 |
574 | Int_t offset = -1; |
351dd634 |
575 | if (particle == "photon") |
576 | offset=0; |
577 | else if (particle == "pi0") |
578 | offset=5; |
e3817e5f |
579 | else |
351dd634 |
580 | AliError(Form("Wrong particle name: %s (choose from pi0/photon)\n", |
581 | particle.Data())); |
88cb7938 |
582 | |
583 | Int_t p= -1; |
584 | Float_t par = 0; |
e3817e5f |
585 | |
586 | if (param.Contains("a")) p=4+offset; |
587 | else if(param.Contains("b")) p=5+offset; |
588 | else if(param.Contains("c")) p=6+offset; |
589 | else if(param.Contains("x0"))p=7+offset; |
590 | else if(param.Contains("y0"))p=8+offset; |
12022e83 |
591 | |
351dd634 |
592 | if (i>4 || i<0) { |
593 | AliError(Form("No parameter with index %d", i)) ; |
594 | } else if (p==-1) { |
595 | AliError(Form("No parameter with name %s", param.Data() )) ; |
596 | } else |
88cb7938 |
597 | par = (*fParameters)(p,i) ; |
598 | |
599 | return par; |
12022e83 |
600 | } |
601 | |
12022e83 |
602 | |
603 | //____________________________________________________________________________ |
8d4608b5 |
604 | Float_t AliPHOSPIDv1::GetDistance(AliPHOSEmcRecPoint * emc,AliPHOSCpvRecPoint * cpv, Option_t * axis)const |
69183710 |
605 | { |
606 | // Calculates the distance between the EMC RecPoint and the PPSD RecPoint |
148b2bba |
607 | |
88cb7938 |
608 | const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ; |
69183710 |
609 | TVector3 vecEmc ; |
7acf6008 |
610 | TVector3 vecCpv ; |
148b2bba |
611 | if(cpv){ |
612 | emc->GetLocalPosition(vecEmc) ; |
613 | cpv->GetLocalPosition(vecCpv) ; |
2bb500e5 |
614 | |
148b2bba |
615 | if(emc->GetPHOSMod() == cpv->GetPHOSMod()){ |
616 | // Correct to difference in CPV and EMC position due to different distance to center. |
617 | // we assume, that particle moves from center |
618 | Float_t dCPV = geom->GetIPtoOuterCoverDistance(); |
619 | Float_t dEMC = geom->GetIPtoCrystalSurface() ; |
620 | dEMC = dEMC / dCPV ; |
621 | vecCpv = dEMC * vecCpv - vecEmc ; |
e3817e5f |
622 | if (axis == "X") return vecCpv.X(); |
623 | if (axis == "Y") return vecCpv.Y(); |
624 | if (axis == "Z") return vecCpv.Z(); |
625 | if (axis == "R") return vecCpv.Mag(); |
626 | } |
148b2bba |
627 | return 100000000 ; |
628 | } |
7acf6008 |
629 | return 100000000 ; |
69183710 |
630 | } |
bc0c084c |
631 | //____________________________________________________________________________ |
8d4608b5 |
632 | Int_t AliPHOSPIDv1::GetCPVBit(AliPHOSEmcRecPoint * emc,AliPHOSCpvRecPoint * cpv, Int_t effPur, Float_t e) const |
bc0c084c |
633 | { |
c947e71a |
634 | //Calculates the pid bit for the CPV selection per each purity. |
e3817e5f |
635 | if(effPur>2 || effPur<0) |
351dd634 |
636 | AliError(Form("Invalid Efficiency-Purity choice %d",effPur)); |
bc0c084c |
637 | |
e3817e5f |
638 | Float_t sigX = GetCpv2EmcDistanceCut("X",e); |
639 | Float_t sigZ = GetCpv2EmcDistanceCut("Z",e); |
bc0c084c |
640 | |
641 | Float_t deltaX = TMath::Abs(GetDistance(emc, cpv, "X")); |
642 | Float_t deltaZ = TMath::Abs(GetDistance(emc, cpv, "Z")); |
35adb638 |
643 | //Info("GetCPVBit"," xdist %f, sigx %f, zdist %f, sigz %f",deltaX, sigX, deltaZ,sigZ ) ; |
644 | if((deltaX>sigX*(effPur+1))&&(deltaZ>sigZ*(effPur+1))) |
bc0c084c |
645 | return 1;//Neutral |
646 | else |
647 | return 0;//Charged |
bc0c084c |
648 | } |
69183710 |
649 | |
6ad0bfa0 |
650 | //____________________________________________________________________________ |
fc7e2f43 |
651 | Int_t AliPHOSPIDv1::GetPrincipalBit(TString particle, const Double_t* p, Int_t effPur, Float_t e)const |
148b2bba |
652 | { |
50739f15 |
653 | //Is the particle inside de PCA ellipse? |
581354c5 |
654 | |
e3817e5f |
655 | particle.ToLower(); |
656 | Int_t prinbit = 0 ; |
657 | Float_t a = GetEllipseParameter(particle,"a" , e); |
658 | Float_t b = GetEllipseParameter(particle,"b" , e); |
659 | Float_t c = GetEllipseParameter(particle,"c" , e); |
660 | Float_t x0 = GetEllipseParameter(particle,"x0", e); |
661 | Float_t y0 = GetEllipseParameter(particle,"y0", e); |
662 | |
663 | Float_t r = TMath::Power((p[0] - x0)/a,2) + |
664 | TMath::Power((p[1] - y0)/b,2) + |
665 | c*(p[0] - x0)*(p[1] - y0)/(a*b) ; |
50739f15 |
666 | //3 different ellipses defined |
e3817e5f |
667 | if((effPur==2) && (r<1./2.)) prinbit= 1; |
668 | if((effPur==1) && (r<2. )) prinbit= 1; |
669 | if((effPur==0) && (r<9./2.)) prinbit= 1; |
50739f15 |
670 | |
581354c5 |
671 | if(r<0) |
351dd634 |
672 | AliError("Negative square?") ; |
1f0e7ccd |
673 | |
674 | return prinbit; |
148b2bba |
675 | |
148b2bba |
676 | } |
1f0e7ccd |
677 | //____________________________________________________________________________ |
fc7e2f43 |
678 | Int_t AliPHOSPIDv1::GetHardPhotonBit(AliPHOSEmcRecPoint * emc) const |
1f0e7ccd |
679 | { |
e3817e5f |
680 | // Set bit for identified hard photons (E > 30 GeV) |
681 | // if the second moment M2x is below the boundary |
682 | |
683 | Float_t e = emc->GetEnergy(); |
684 | if (e < 30.0) return 0; |
685 | Float_t m2x = emc->GetM2x(); |
686 | Float_t m2xBoundary = GetParameterPhotonBoundary(0) * |
687 | TMath::Exp(-TMath::Power(e-GetParameterPhotonBoundary(1),2)/2.0/ |
688 | TMath::Power(GetParameterPhotonBoundary(2),2)) + |
689 | GetParameterPhotonBoundary(3); |
351dd634 |
690 | AliDebug(1, Form("GetHardPhotonBit","E=%f, m2x=%f, boundary=%f", |
691 | e,m2x,m2xBoundary)); |
e3817e5f |
692 | if (m2x < m2xBoundary) |
693 | return 1;// A hard photon |
694 | else |
695 | return 0;// Not a hard photon |
1f0e7ccd |
696 | } |
92f521a9 |
697 | |
e3817e5f |
698 | //____________________________________________________________________________ |
fc7e2f43 |
699 | Int_t AliPHOSPIDv1::GetHardPi0Bit(AliPHOSEmcRecPoint * emc) const |
e3817e5f |
700 | { |
701 | // Set bit for identified hard pi0 (E > 30 GeV) |
702 | // if the second moment M2x is above the boundary |
703 | |
704 | Float_t e = emc->GetEnergy(); |
705 | if (e < 30.0) return 0; |
706 | Float_t m2x = emc->GetM2x(); |
707 | Float_t m2xBoundary = GetParameterPi0Boundary(0) + |
708 | e * GetParameterPi0Boundary(1); |
351dd634 |
709 | AliDebug(1,Form("E=%f, m2x=%f, boundary=%f",e,m2x,m2xBoundary)); |
e3817e5f |
710 | if (m2x > m2xBoundary) |
711 | return 1;// A hard pi0 |
bc0c084c |
712 | else |
e3817e5f |
713 | return 0;// Not a hard pi0 |
f0a4c9e9 |
714 | } |
e3817e5f |
715 | |
716 | //____________________________________________________________________________ |
8d4608b5 |
717 | TVector3 AliPHOSPIDv1::GetMomentumDirection(AliPHOSEmcRecPoint * emc, AliPHOSCpvRecPoint * )const |
88cb7938 |
718 | { |
719 | // Calculates the momentum direction: |
720 | // 1. if only a EMC RecPoint, direction is given by IP and this RecPoint |
721 | // 2. if a EMC RecPoint and CPV RecPoint, direction is given by the line through the 2 recpoints |
722 | // However because of the poor position resolution of PPSD the direction is always taken as if we were |
723 | // in case 1. |
f0a4c9e9 |
724 | |
88cb7938 |
725 | TVector3 dir(0,0,0) ; |
9688c1dd |
726 | |
88cb7938 |
727 | TVector3 emcglobalpos ; |
728 | TMatrix dummy ; |
bf8f1fbd |
729 | |
88cb7938 |
730 | emc->GetGlobalPosition(emcglobalpos, dummy) ; |
bf8f1fbd |
731 | |
fbf811ec |
732 | |
88cb7938 |
733 | dir = emcglobalpos ; |
88cb7938 |
734 | dir.SetMag(1.) ; |
e3817e5f |
735 | |
88cb7938 |
736 | //account correction to the position of IP |
737 | Float_t xo,yo,zo ; //Coordinates of the origin |
adcca1e6 |
738 | if(gAlice && gAlice->GetMCApp() && gAlice->Generator()) |
739 | gAlice->Generator()->GetOrigin(xo,yo,zo) ; |
740 | else{ |
741 | xo=yo=zo=0.; |
742 | } |
88cb7938 |
743 | TVector3 origin(xo,yo,zo); |
744 | dir = dir - origin ; |
e3817e5f |
745 | |
88cb7938 |
746 | return dir ; |
7b7c1533 |
747 | } |
748 | |
35adb638 |
749 | //________________________________________________________________________ |
17323043 |
750 | Double_t AliPHOSPIDv1::LandauF(Double_t x, Double_t y, Double_t * par) |
35adb638 |
751 | { |
c947e71a |
752 | //Given the energy x and the parameter y (tof, shower dispersion or cpv-emc distance), |
753 | //this method returns a density probability of this parameter, given by a landau |
754 | //function whose parameters depend with the energy with a function: a/(x*x)+b/x+b |
755 | |
756 | Double_t cnt = par[1] / (x*x) + par[2] / x + par[0] ; |
35adb638 |
757 | Double_t mean = par[4] / (x*x) + par[5] / x + par[3] ; |
758 | Double_t sigma = par[7] / (x*x) + par[8] / x + par[6] ; |
c947e71a |
759 | |
760 | if(TMath::Abs(sigma) > 1.e-10){ |
acb5beb7 |
761 | return cnt*TMath::Landau(y,mean,sigma); |
35adb638 |
762 | } |
763 | else |
764 | return 0.; |
765 | |
766 | } |
767 | //________________________________________________________________________ |
17323043 |
768 | Double_t AliPHOSPIDv1::LandauPol2(Double_t x, Double_t y, Double_t * par) |
35adb638 |
769 | { |
c947e71a |
770 | |
771 | //Given the energy x and the parameter y (tof, shower dispersion or cpv-emc distance), |
772 | //this method returns a density probability of this parameter, given by a landau |
773 | //function whose parameters depend with the energy like second order polinomial |
774 | |
35adb638 |
775 | Double_t cnt = par[2] * (x*x) + par[1] * x + par[0] ; |
c947e71a |
776 | Double_t mean = par[5] * (x*x) + par[4] * x + par[3] ; |
777 | Double_t sigma = par[8] * (x*x) + par[7] * x + par[6] ; |
35adb638 |
778 | |
c947e71a |
779 | if(TMath::Abs(sigma) > 1.e-10){ |
acb5beb7 |
780 | return cnt*TMath::Landau(y,mean,sigma); |
35adb638 |
781 | } |
782 | else |
783 | return 0.; |
c947e71a |
784 | |
785 | |
35adb638 |
786 | } |
787 | // //________________________________________________________________________ |
788 | // Double_t AliPHOSPIDv1::ChargedHadronDistProb(Double_t x, Double_t y, Double_t * parg, Double_t * parl) |
789 | // { |
790 | // Double_t cnt = 0.0 ; |
791 | // Double_t mean = 0.0 ; |
792 | // Double_t sigma = 0.0 ; |
793 | // Double_t arg = 0.0 ; |
794 | // if (y < parl[4] / (x*x) + parl[5] / x + parl[3]){ |
795 | // cnt = parg[1] / (x*x) + parg[2] / x + parg[0] ; |
796 | // mean = parg[4] / (x*x) + parg[5] / x + parg[3] ; |
797 | // sigma = parg[7] / (x*x) + parg[8] / x + parg[6] ; |
798 | // TF1 * f = new TF1("gaus","gaus",0.,100.); |
799 | // f->SetParameters(cnt,mean,sigma); |
800 | // arg = f->Eval(y) ; |
801 | // } |
802 | // else{ |
803 | // cnt = parl[1] / (x*x) + parl[2] / x + parl[0] ; |
804 | // mean = parl[4] / (x*x) + parl[5] / x + parl[3] ; |
805 | // sigma = parl[7] / (x*x) + parl[8] / x + parl[6] ; |
806 | // TF1 * f = new TF1("landau","landau",0.,100.); |
807 | // f->SetParameters(cnt,mean,sigma); |
808 | // arg = f->Eval(y) ; |
809 | // } |
810 | // // Double_t mean = par[3] + par[4] * x + par[5] * x * x ; |
811 | // // Double_t sigma = par[6] + par[7] * x + par[8] * x * x ; |
812 | |
813 | // //Double_t arg = -(y-mean)*(y-mean)/(2*sigma*sigma) ; |
814 | // //return cnt * TMath::Exp(arg) ; |
815 | |
816 | // return arg; |
817 | |
818 | // } |
2cc71c1e |
819 | //____________________________________________________________________________ |
820 | void AliPHOSPIDv1::MakePID() |
821 | { |
822 | // construct the PID weight from a Bayesian Method |
c947e71a |
823 | |
2cc71c1e |
824 | Int_t index ; |
cc1fe362 |
825 | const Int_t kSPECIES = AliESDtrack::kSPECIESN ; |
2cc71c1e |
826 | Int_t nparticles = AliPHOSGetter::Instance()->RecParticles()->GetEntriesFast() ; |
c947e71a |
827 | |
828 | // const Int_t kMAXPARTICLES = 2000 ; |
829 | // if (nparticles >= kMAXPARTICLES) |
830 | // Error("MakePID", "Change size of MAXPARTICLES") ; |
831 | // Double_t stof[kSPECIES][kMAXPARTICLES] ; |
832 | |
53ab54c8 |
833 | // const Int_t kMAXPARTICLES = 2000 ; |
834 | // if (nparticles >= kMAXPARTICLES) |
351dd634 |
835 | // AliError("Change size of MAXPARTICLES") ; |
53ab54c8 |
836 | // Double_t stof[kSPECIES][kMAXPARTICLES] ; |
53ab54c8 |
837 | |
35adb638 |
838 | Double_t * stof[kSPECIES] ; |
839 | Double_t * sdp [kSPECIES] ; |
840 | Double_t * scpv[kSPECIES] ; |
841 | |
842 | //Info("MakePID","Begin MakePID"); |
843 | |
844 | for (Int_t i =0; i< kSPECIES; i++){ |
845 | stof[i] = new Double_t[nparticles] ; |
846 | sdp [i] = new Double_t[nparticles] ; |
847 | scpv[i] = new Double_t[nparticles] ; |
848 | } |
849 | |
cc1fe362 |
850 | // make the normalized distribution of pid for this event |
851 | // w(pid) in the Bayesian formulation |
2cc71c1e |
852 | for(index = 0 ; index < nparticles ; index ++) { |
cc1fe362 |
853 | |
35adb638 |
854 | AliPHOSRecParticle * recpar = AliPHOSGetter::Instance()->RecParticle(index) ; |
855 | AliPHOSEmcRecPoint * emc = AliPHOSGetter::Instance()->EmcRecPoint(index) ; |
856 | AliPHOSCpvRecPoint * cpv = AliPHOSGetter::Instance()->CpvRecPoint(index) ; |
cc1fe362 |
857 | |
35adb638 |
858 | Float_t en = emc->GetEnergy(); |
c947e71a |
859 | |
35adb638 |
860 | // Tof |
c947e71a |
861 | |
862 | // Info("MakePID", "TOF"); |
35adb638 |
863 | Double_t time = recpar->ToF() ; |
864 | //cout<<">>>>>>>Energy "<<en<<"Time "<<time<<endl; |
865 | //Electrons initial population to be removed |
866 | fInitPID[AliESDtrack::kEleCon] = 0. ; |
cc1fe362 |
867 | |
35adb638 |
868 | // now get the signals probability |
869 | // s(pid) in the Bayesian formulation |
cc1fe362 |
870 | |
c947e71a |
871 | stof[AliESDtrack::kPhoton][index] = 1.; |
872 | stof[AliESDtrack::kElectron][index] = 1.; |
873 | stof[AliESDtrack::kPion][index] = 1.; |
874 | stof[AliESDtrack::kKaon][index] = 1.; |
875 | stof[AliESDtrack::kProton][index] = 1.; |
876 | stof[AliESDtrack::kNeutron][index] = 1.; |
877 | stof[AliESDtrack::kEleCon][index] = 1.; |
878 | stof[AliESDtrack::kKaon0][index] = 1.; |
879 | stof[AliESDtrack::kMuon][index] = 1.; |
880 | |
35adb638 |
881 | if(en < 2.) { |
c947e71a |
882 | stof[AliESDtrack::kPhoton][index] = fTFphoton ->Eval(time) ; //gaus distribution |
883 | stof[AliESDtrack::kPion][index] = fTFpiong ->Eval(time) ; //gaus distribution |
884 | stof[AliESDtrack::kElectron][index] = stof[AliESDtrack::kPion][index] ; |
885 | |
35adb638 |
886 | if(time < fTkaonl[1]) |
887 | stof[AliESDtrack::kKaon][index] = fTFkaong ->Eval(time) ; //gaus distribution |
888 | else |
889 | stof[AliESDtrack::kKaon][index] = fTFkaonl ->Eval(time) ; //landau distribution |
890 | if(time < fThhadronl[1]) |
891 | stof[AliESDtrack::kProton][index] = fTFhhadrong ->Eval(time) ; //gaus distribution |
892 | else |
893 | stof[AliESDtrack::kProton][index] = fTFhhadronl ->Eval(time) ; //landau distribution |
c947e71a |
894 | |
35adb638 |
895 | stof[AliESDtrack::kNeutron][index] = stof[AliESDtrack::kProton][index] ; |
896 | stof[AliESDtrack::kEleCon][index] = stof[AliESDtrack::kPhoton][index] ; |
897 | // a conversion electron has the photon ToF |
898 | stof[AliESDtrack::kKaon0][index] = stof[AliESDtrack::kKaon][index] ; |
899 | stof[AliESDtrack::kMuon][index] = stof[AliESDtrack::kPhoton][index] ; |
cc1fe362 |
900 | } |
c947e71a |
901 | |
902 | // Info("MakePID", "Dispersion"); |
cc1fe362 |
903 | |
35adb638 |
904 | // Shower shape: Dispersion |
905 | Float_t dispersion = emc->GetDispersion(); |
906 | //dispersion is not well defined if the cluster is only in few crystals |
cc1fe362 |
907 | |
c947e71a |
908 | sdp[AliESDtrack::kPhoton][index] = 1. ; |
909 | sdp[AliESDtrack::kElectron][index] = 1. ; |
910 | sdp[AliESDtrack::kPion][index] = 1. ; |
911 | sdp[AliESDtrack::kKaon][index] = 1. ; |
912 | sdp[AliESDtrack::kProton][index] = 1. ; |
913 | sdp[AliESDtrack::kNeutron][index] = 1. ; |
914 | sdp[AliESDtrack::kEleCon][index] = 1. ; |
915 | sdp[AliESDtrack::kKaon0][index] = 1. ; |
916 | sdp[AliESDtrack::kMuon][index] = 1. ; |
917 | |
918 | if(en > 0.5 && emc->GetMultiplicity() > 3){ |
35adb638 |
919 | sdp[AliESDtrack::kPhoton][index] = GausF (en , dispersion, fDphoton) ; |
920 | sdp[AliESDtrack::kElectron][index] = sdp[AliESDtrack::kPhoton][index] ; |
921 | sdp[AliESDtrack::kPion][index] = LandauF(en , dispersion, fDhadron ) ; |
922 | sdp[AliESDtrack::kKaon][index] = sdp[AliESDtrack::kPion][index] ; |
923 | sdp[AliESDtrack::kProton][index] = sdp[AliESDtrack::kPion][index] ; |
924 | sdp[AliESDtrack::kNeutron][index] = sdp[AliESDtrack::kPion][index] ; |
925 | sdp[AliESDtrack::kEleCon][index] = sdp[AliESDtrack::kPhoton][index]; |
926 | sdp[AliESDtrack::kKaon0][index] = sdp[AliESDtrack::kPion][index] ; |
927 | sdp[AliESDtrack::kMuon][index] = fDFmuon ->Eval(dispersion) ; //landau distribution |
928 | } |
cc1fe362 |
929 | |
c947e71a |
930 | // Info("MakePID","multiplicity %d, dispersion %f", emc->GetMultiplicity(), dispersion); |
931 | // Info("MakePID","ss: photon %f, hadron %f ", sdp[AliESDtrack::kPhoton][index], sdp[AliESDtrack::kPion][index]); |
adcca1e6 |
932 | |
c947e71a |
933 | // cout<<">>>>>multiplicity "<<emc->GetMultiplicity()<<", dispersion "<< dispersion<<endl ; |
934 | // cout<<"<<<<<ss: photon "<<sdp[AliESDtrack::kPhoton][index]<<", hadron "<<sdp[AliESDtrack::kPion][index]<<endl; |
935 | |
35adb638 |
936 | // CPV-EMC Distance |
c947e71a |
937 | // Info("MakePID", "Distance"); |
938 | // Float_t distance = GetDistance(emc, cpv, "R") ; |
939 | Float_t x = TMath::Abs(GetDistance(emc, cpv, "X")) ; |
940 | Float_t z = GetDistance(emc, cpv, "Z") ; |
35adb638 |
941 | // Info("MakePID", "Distance %f", distance); |
c947e71a |
942 | Double_t pcpv = 0 ; |
943 | Double_t pcpvneutral = 0. ; |
944 | Double_t elprobx = GausF(en , x, fXelectron) ; |
945 | Double_t elprobz = GausF(en , z, fZelectron) ; |
946 | Double_t chprobx = GausF(en , x, fXcharged) ; |
947 | Double_t chprobz = GausF(en , z, fZcharged) ; |
948 | Double_t pcpvelectron = elprobx * elprobz; |
949 | Double_t pcpvcharged = chprobx * chprobz; |
950 | |
951 | // cout<<">>>>electron : x "<<x<<" xprob "<<elprobx<<" z "<<z<<" zprob "<<elprobz<<endl; |
952 | // cout<<">>>>hadron : x "<<x<<" xprob "<<chprobx<<" z "<<z<<" zprob "<<chprobz<<endl; |
953 | // cout<<">>>>electron : px*pz "<<pcpvelectron <<" hadron: px*pz "<<pcpvcharged<<endl; |
954 | |
35adb638 |
955 | if(pcpvelectron >= pcpvcharged) |
956 | pcpv = pcpvelectron ; |
957 | else |
958 | pcpv = pcpvcharged ; |
959 | |
c947e71a |
960 | if(pcpv < 1e-7) |
35adb638 |
961 | { |
962 | pcpvneutral = 1. ; |
963 | pcpvcharged = 0. ; |
964 | pcpvelectron = 0. ; |
965 | } |
c947e71a |
966 | // else |
967 | // cout<<">>>>>>>>>>>CHARGED>>>>>>>>>>>"<<endl; |
35adb638 |
968 | |
969 | scpv[AliESDtrack::kPion][index] = pcpvcharged ; |
970 | scpv[AliESDtrack::kKaon][index] = pcpvcharged ; |
971 | scpv[AliESDtrack::kProton][index] = pcpvcharged ; |
972 | scpv[AliESDtrack::kPhoton][index] = pcpvneutral ; |
973 | scpv[AliESDtrack::kElectron][index] = pcpvelectron ; |
974 | scpv[AliESDtrack::kNeutron][index] = pcpvneutral ; |
975 | scpv[AliESDtrack::kEleCon][index] = pcpvelectron ; |
976 | scpv[AliESDtrack::kKaon0][index] = pcpvneutral ; |
977 | scpv[AliESDtrack::kMuon][index] = pcpvelectron ; |
978 | |
979 | // Info("MakePID", "CPV passed"); |
c947e71a |
980 | |
981 | //Pi0 |
982 | stof[AliESDtrack::kPi0][index] = 0. ; |
983 | scpv[AliESDtrack::kPi0][index] = 0. ; |
984 | sdp [AliESDtrack::kPi0][index] = 0. ; |
985 | fInitPID[AliESDtrack::kPi0] = 0. ; |
986 | |
35adb638 |
987 | if(en > 30.){ |
988 | // pi0 are detected via decay photon |
989 | stof[AliESDtrack::kPi0][index] = fTFphoton ->Eval(time) ; |
990 | scpv[AliESDtrack::kPi0][index] = pcpvneutral ; |
c947e71a |
991 | sdp [AliESDtrack::kPi0][index] = 1. ; |
992 | if(emc->GetMultiplicity() > 3) |
35adb638 |
993 | sdp [AliESDtrack::kPi0][index] = GausPol2(en , dispersion, fDpi0) ; |
35adb638 |
994 | } |
995 | |
996 | if(en > 0.5){ |
997 | //Muons deposit few energy |
c947e71a |
998 | scpv[AliESDtrack::kMuon][index] = 0 ; |
999 | stof[AliESDtrack::kMuon][index] = 0 ; |
1000 | sdp [AliESDtrack::kMuon][index] = 0 ; |
1001 | } |
1002 | |
1003 | if(en > 0.5){ |
1004 | cout<<"######################################################"<<endl; |
1005 | //cout<<"MakePID: energy "<<en<<", tof "<<time<<", distance "<<distance<<", dispersion "<<dispersion<<endl ; |
1006 | cout<<"MakePID: energy "<<en<<", tof "<<time<<", dispersion "<<dispersion<<", x "<<x<<", z "<<z<<endl ; |
1007 | cout<<">>>>>multiplicity "<<emc->GetMultiplicity()<<endl; |
1008 | cout<<">>>>electron : xprob "<<elprobx<<" zprob "<<elprobz<<endl; |
1009 | cout<<">>>>hadron : xprob "<<chprobx<<" zprob "<<chprobz<<endl; |
1010 | cout<<">>>>electron : px*pz "<<pcpvelectron <<" hadron: px*pz "<<pcpvcharged<<endl; |
1011 | |
1012 | |
1013 | cout<<"Photon , pid "<< fInitPID[AliESDtrack::kPhoton]<<" tof "<<stof[AliESDtrack::kPhoton][index] |
1014 | <<", cpv "<<scpv[AliESDtrack::kPhoton][index]<<", ss "<<sdp[AliESDtrack::kPhoton][index]<<endl; |
1015 | cout<<"EleCon , pid "<< fInitPID[AliESDtrack::kEleCon]<<", tof "<<stof[AliESDtrack::kEleCon][index] |
1016 | <<", cpv "<<scpv[AliESDtrack::kEleCon][index]<<" ss "<<sdp[AliESDtrack::kEleCon][index]<<endl; |
1017 | cout<<"Electron , pid "<< fInitPID[AliESDtrack::kElectron]<<", tof "<<stof[AliESDtrack::kElectron][index] |
1018 | <<", cpv "<<scpv[AliESDtrack::kElectron][index]<<" ss "<<sdp[AliESDtrack::kElectron][index]<<endl; |
1019 | cout<<"Muon , pid "<< fInitPID[AliESDtrack::kMuon]<<", tof "<<stof[AliESDtrack::kMuon][index] |
1020 | <<", cpv "<<scpv[AliESDtrack::kMuon][index]<<" ss "<<sdp[AliESDtrack::kMuon][index]<<endl; |
1021 | cout<<"Pi0 , pid "<< fInitPID[AliESDtrack::kPi0]<<", tof "<<stof[AliESDtrack::kPi0][index] |
1022 | <<", cpv "<<scpv[AliESDtrack::kPi0][index]<<" ss "<<sdp[AliESDtrack::kPi0][index]<<endl; |
1023 | cout<<"Pion , pid "<< fInitPID[AliESDtrack::kPion]<<", tof "<<stof[AliESDtrack::kPion][index] |
1024 | <<", cpv "<<scpv[AliESDtrack::kPion][index]<<" ss "<<sdp[AliESDtrack::kPion][index]<<endl; |
1025 | cout<<"Kaon0 , pid "<< fInitPID[AliESDtrack::kKaon0]<<", tof "<<stof[AliESDtrack::kKaon0][index] |
1026 | <<", cpv "<<scpv[AliESDtrack::kKaon0][index]<<" ss "<<sdp[AliESDtrack::kKaon0][index]<<endl; |
1027 | cout<<"Kaon , pid "<< fInitPID[AliESDtrack::kKaon]<<", tof "<<stof[AliESDtrack::kKaon][index] |
1028 | <<", cpv "<<scpv[AliESDtrack::kKaon][index]<<" ss "<<sdp[AliESDtrack::kKaon][index]<<endl; |
1029 | cout<<"Neutron , pid "<< fInitPID[AliESDtrack::kNeutron]<<", tof "<<stof[AliESDtrack::kNeutron][index] |
1030 | <<", cpv "<<scpv[AliESDtrack::kNeutron][index]<<" ss "<<sdp[AliESDtrack::kNeutron][index]<<endl; |
1031 | cout<<"Proton , pid "<< fInitPID[AliESDtrack::kProton]<<", tof "<<stof[AliESDtrack::kProton][index] |
1032 | <<", cpv "<<scpv[AliESDtrack::kProton][index]<<" ss "<<sdp[AliESDtrack::kProton][index]<<endl; |
1033 | cout<<"######################################################"<<endl; |
35adb638 |
1034 | } |
cc1fe362 |
1035 | } |
35adb638 |
1036 | |
1037 | //for (index = 0 ; index < kSPECIES ; index++) |
1038 | // pid[index] /= nparticles ; |
1039 | |
1040 | // Info("MakePID", "Total Probability calculation"); |
1041 | |
cc1fe362 |
1042 | for(index = 0 ; index < nparticles ; index ++) { |
1043 | // calculates the Bayesian weight |
1044 | Int_t jndex ; |
1045 | Double_t wn = 0.0 ; |
1046 | for (jndex = 0 ; jndex < kSPECIES ; jndex++) |
35adb638 |
1047 | //wn += stof[jndex][index] * pid[jndex] ; |
1048 | wn += stof[jndex][index] * sdp[jndex][index] * scpv[jndex][index] * fInitPID[jndex] ; |
1049 | //cout<<"*************wn "<<wn<<endl; |
cc1fe362 |
1050 | AliPHOSRecParticle * recpar = AliPHOSGetter::Instance()->RecParticle(index) ; |
e74ea0e9 |
1051 | if (TMath::Abs(wn)>0) |
1052 | for (jndex = 0 ; jndex < kSPECIES ; jndex++) { |
35adb638 |
1053 | //cout<<"jndex "<<jndex<<" wn "<<wn<<" SetPID * wn" |
1054 | //<<stof[jndex][index] * sdp[jndex][index] * pid[jndex] << endl; |
1055 | //cout<<" tof "<<stof[jndex][index] << " disp " <<sdp[jndex][index] << " pid "<< fInitPID[jndex] << endl; |
1056 | // cout<<"Particle "<<jndex<<" final prob * wn " |
1057 | // <<stof[jndex][index] * sdp[jndex][index] * scpv[jndex][index] * fInitPID[jndex] <<" wn "<< wn<<endl; |
1058 | recpar->SetPID(jndex, stof[jndex][index] * sdp[jndex][index] * |
1059 | scpv[jndex][index] * fInitPID[jndex] / wn) ; |
1060 | // cout<<"final prob "<<stof[jndex][index] * sdp[jndex][index] * scpv[jndex][index] * fInitPID[jndex] / wn<<endl; |
1061 | //recpar->SetPID(jndex, stof[jndex][index] * fInitPID[jndex] / wn) ; |
1062 | //cout<<"After SetPID"<<endl; |
1063 | //recpar->Print(); |
e74ea0e9 |
1064 | } |
2cc71c1e |
1065 | } |
35adb638 |
1066 | // Info("MakePID", "Delete"); |
1067 | |
acb5beb7 |
1068 | for (Int_t i =0; i< kSPECIES; i++){ |
1069 | delete [] stof[i]; |
1070 | delete [] sdp[i]; |
1071 | delete [] scpv[i]; |
1072 | } |
35adb638 |
1073 | // Info("MakePID","End MakePID"); |
2cc71c1e |
1074 | } |
1075 | |
7acf6008 |
1076 | //____________________________________________________________________________ |
e3817e5f |
1077 | void AliPHOSPIDv1::MakeRecParticles() |
1078 | { |
b2a60966 |
1079 | // Makes a RecParticle out of a TrackSegment |
148b2bba |
1080 | |
88cb7938 |
1081 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
fbf811ec |
1082 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
1083 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; |
1084 | TClonesArray * trackSegments = gime->TrackSegments() ; |
148b2bba |
1085 | if ( !emcRecPoints || !cpvRecPoints || !trackSegments ) { |
351dd634 |
1086 | AliFatal("RecPoints or TrackSegments not found !") ; |
148b2bba |
1087 | } |
fbf811ec |
1088 | TClonesArray * recParticles = gime->RecParticles() ; |
01a599c9 |
1089 | recParticles->Clear(); |
148b2bba |
1090 | |
7b7c1533 |
1091 | TIter next(trackSegments) ; |
7acf6008 |
1092 | AliPHOSTrackSegment * ts ; |
6ad0bfa0 |
1093 | Int_t index = 0 ; |
09fc14a0 |
1094 | AliPHOSRecParticle * rp ; |
7acf6008 |
1095 | while ( (ts = (AliPHOSTrackSegment *)next()) ) { |
fad3e5b9 |
1096 | |
7b7c1533 |
1097 | new( (*recParticles)[index] ) AliPHOSRecParticle() ; |
1098 | rp = (AliPHOSRecParticle *)recParticles->At(index) ; |
f0a4c9e9 |
1099 | rp->SetTrackSegment(index) ; |
9688c1dd |
1100 | rp->SetIndexInList(index) ; |
148b2bba |
1101 | |
7acf6008 |
1102 | AliPHOSEmcRecPoint * emc = 0 ; |
1103 | if(ts->GetEmcIndex()>=0) |
7b7c1533 |
1104 | emc = (AliPHOSEmcRecPoint *) emcRecPoints->At(ts->GetEmcIndex()) ; |
fad3e5b9 |
1105 | |
8d4608b5 |
1106 | AliPHOSCpvRecPoint * cpv = 0 ; |
7acf6008 |
1107 | if(ts->GetCpvIndex()>=0) |
8d4608b5 |
1108 | cpv = (AliPHOSCpvRecPoint *) cpvRecPoints->At(ts->GetCpvIndex()) ; |
fad3e5b9 |
1109 | |
bd76890a |
1110 | Int_t track = 0 ; |
1111 | track = ts->GetTrackIndex() ; |
1112 | |
148b2bba |
1113 | // Now set type (reconstructed) of the particle |
1114 | |
1115 | // Choose the cluster energy range |
9fa5f1d0 |
1116 | |
fbf811ec |
1117 | if (!emc) { |
351dd634 |
1118 | AliFatal(Form("-> emc(%d) = %d", ts->GetEmcIndex(), emc )) ; |
fbf811ec |
1119 | } |
50739f15 |
1120 | |
e3817e5f |
1121 | Float_t e = emc->GetEnergy() ; |
bc0c084c |
1122 | |
6f969528 |
1123 | Float_t lambda[2] ; |
1124 | emc->GetElipsAxis(lambda) ; |
50739f15 |
1125 | |
1126 | if((lambda[0]>0.01) && (lambda[1]>0.01)){ |
1127 | // Looking PCA. Define and calculate the data (X), |
bc0c084c |
1128 | // introduce in the function X2P that gives the components (P). |
1129 | |
c947e71a |
1130 | Float_t spher = 0. ; |
1131 | Float_t emaxdtotal = 0. ; |
50739f15 |
1132 | |
bc0c084c |
1133 | if((lambda[0]+lambda[1])!=0) |
c947e71a |
1134 | spher=fabs(lambda[0]-lambda[1])/(lambda[0]+lambda[1]); |
50739f15 |
1135 | |
c947e71a |
1136 | emaxdtotal=emc->GetMaximalEnergy()/emc->GetEnergy(); |
50739f15 |
1137 | |
1138 | fX[0] = lambda[0] ; |
1139 | fX[1] = lambda[1] ; |
1140 | fX[2] = emc->GetDispersion() ; |
c947e71a |
1141 | fX[3] = spher ; |
50739f15 |
1142 | fX[4] = emc->GetMultiplicity() ; |
c947e71a |
1143 | fX[5] = emaxdtotal ; |
50739f15 |
1144 | fX[6] = emc->GetCoreEnergy() ; |
1145 | |
e3817e5f |
1146 | fPrincipalPhoton->X2P(fX,fPPhoton); |
1147 | fPrincipalPi0 ->X2P(fX,fPPi0); |
1f0e7ccd |
1148 | |
50739f15 |
1149 | } |
1150 | else{ |
e3817e5f |
1151 | fPPhoton[0]=-100.0; //We do not accept clusters with |
1152 | fPPhoton[1]=-100.0; //one cell as a photon-like |
1153 | fPPi0[0] =-100.0; |
1154 | fPPi0[1] =-100.0; |
50739f15 |
1155 | } |
1156 | |
2cc71c1e |
1157 | Float_t time = emc->GetTime() ; |
1158 | rp->SetTof(time) ; |
9fa5f1d0 |
1159 | |
bc0c084c |
1160 | // Loop of Efficiency-Purity (the 3 points of purity or efficiency |
1161 | // are taken into account to set the particle identification) |
e3817e5f |
1162 | for(Int_t effPur = 0; effPur < 3 ; effPur++){ |
50739f15 |
1163 | |
bc0c084c |
1164 | // Looking at the CPV detector. If RCPV greater than CpvEmcDistance, |
1165 | // 1st,2nd or 3rd bit (depending on the efficiency-purity point ) |
1166 | // is set to 1 |
35adb638 |
1167 | if(GetCPVBit(emc, cpv, effPur,e) == 1 ){ |
e3817e5f |
1168 | rp->SetPIDBit(effPur) ; |
35adb638 |
1169 | //cout<<"CPV bit "<<effPur<<endl; |
1170 | } |
50739f15 |
1171 | // Looking the TOF. If TOF smaller than gate, 4th, 5th or 6th |
1172 | // bit (depending on the efficiency-purity point )is set to 1 |
2cc71c1e |
1173 | if(time< (*fParameters)(3,effPur)) |
e3817e5f |
1174 | rp->SetPIDBit(effPur+3) ; |
2cc71c1e |
1175 | |
e3817e5f |
1176 | //Photon PCA |
50739f15 |
1177 | //If we are inside the ellipse, 7th, 8th or 9th |
1178 | // bit (depending on the efficiency-purity point )is set to 1 |
e3817e5f |
1179 | if(GetPrincipalBit("photon",fPPhoton,effPur,e) == 1) |
1180 | rp->SetPIDBit(effPur+6) ; |
1f0e7ccd |
1181 | |
e3817e5f |
1182 | //Pi0 PCA |
1f0e7ccd |
1183 | //If we are inside the ellipse, 10th, 11th or 12th |
1184 | // bit (depending on the efficiency-purity point )is set to 1 |
e3817e5f |
1185 | if(GetPrincipalBit("pi0" ,fPPi0 ,effPur,e) == 1) |
1186 | rp->SetPIDBit(effPur+9) ; |
f0a4c9e9 |
1187 | } |
e3817e5f |
1188 | if(GetHardPhotonBit(emc)) |
1189 | rp->SetPIDBit(12) ; |
1190 | if(GetHardPi0Bit (emc)) |
1191 | rp->SetPIDBit(13) ; |
1f0e7ccd |
1192 | |
bd76890a |
1193 | if(track >= 0) |
1194 | rp->SetPIDBit(14) ; |
1195 | |
9fa5f1d0 |
1196 | //Set momentum, energy and other parameters |
50739f15 |
1197 | Float_t encal = GetCalibratedEnergy(e); |
9fa5f1d0 |
1198 | TVector3 dir = GetMomentumDirection(emc,cpv) ; |
1199 | dir.SetMag(encal) ; |
1200 | rp->SetMomentum(dir.X(),dir.Y(),dir.Z(),encal) ; |
1201 | rp->SetCalcMass(0); |
e0ed2e49 |
1202 | rp->Name(); //If photon sets the particle pdg name to gamma |
e747b8da |
1203 | rp->SetProductionVertex(0,0,0,0); |
1204 | rp->SetFirstMother(-1); |
1205 | rp->SetLastMother(-1); |
1206 | rp->SetFirstDaughter(-1); |
1207 | rp->SetLastDaughter(-1); |
1208 | rp->SetPolarisation(0,0,0); |
d956e9b7 |
1209 | //Set the position in global coordinate system from the RecPoint |
1210 | AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
1211 | AliPHOSTrackSegment * ts = gime->TrackSegment(rp->GetPHOSTSIndex()) ; |
1212 | AliPHOSEmcRecPoint * erp = gime->EmcRecPoint(ts->GetEmcIndex()) ; |
1213 | TVector3 pos ; |
1214 | geom->GetGlobal(erp, pos) ; |
1215 | rp->SetPos(pos); |
6ad0bfa0 |
1216 | index++ ; |
1217 | } |
6ad0bfa0 |
1218 | } |
e3817e5f |
1219 | |
09fc14a0 |
1220 | //____________________________________________________________________________ |
88cb7938 |
1221 | void AliPHOSPIDv1::Print() const |
09fc14a0 |
1222 | { |
b2a60966 |
1223 | // Print the parameters used for the particle type identification |
bc0c084c |
1224 | |
351dd634 |
1225 | AliInfo("=============== AliPHOSPIDv1 ================") ; |
88cb7938 |
1226 | printf("Making PID\n") ; |
1227 | printf(" Pricipal analysis file from 0.5 to 100 %s\n", fFileNamePrincipalPhoton.Data() ) ; |
1228 | printf(" Name of parameters file %s\n", fFileNameParameters.Data() ) ; |
1229 | printf(" Matrix of Parameters: 14x4\n") ; |
1230 | printf(" Energy Calibration 1x3 [3 parametres to calibrate energy: A + B* E + C * E^2]\n") ; |
1231 | printf(" RCPV 2x3 rows x and z, columns function cut parameters\n") ; |
1232 | printf(" TOF 1x3 [High Eff-Low Pur,Medium Eff-Pur, Low Eff-High Pur]\n") ; |
1233 | printf(" PCA 5x4 [5 ellipse parametres and 4 parametres to calculate them: A/Sqrt(E) + B* E + C * E^2 + D]\n") ; |
1234 | Printf(" Pi0 PCA 5x3 [5 ellipse parametres and 3 parametres to calculate them: A + B* E + C * E^2]\n") ; |
50739f15 |
1235 | fParameters->Print() ; |
09fc14a0 |
1236 | } |
1237 | |
a496c46c |
1238 | |
69183710 |
1239 | |
7acf6008 |
1240 | //____________________________________________________________________________ |
a4e98857 |
1241 | void AliPHOSPIDv1::PrintRecParticles(Option_t * option) |
1242 | { |
dd5c4038 |
1243 | // Print table of reconstructed particles |
1244 | |
88cb7938 |
1245 | AliPHOSGetter *gime = AliPHOSGetter::Instance() ; |
bf8f1fbd |
1246 | |
88cb7938 |
1247 | TClonesArray * recParticles = gime->RecParticles() ; |
21cd0c07 |
1248 | |
1249 | TString message ; |
3bf72d32 |
1250 | message = "\nevent " ; |
1251 | message += gAlice->GetEvNumber() ; |
1252 | message += " found " ; |
1253 | message += recParticles->GetEntriesFast(); |
1254 | message += " RecParticles\n" ; |
1255 | |
7acf6008 |
1256 | if(strstr(option,"all")) { // printing found TS |
3bf72d32 |
1257 | message += "\n PARTICLE Index \n" ; |
7acf6008 |
1258 | |
1259 | Int_t index ; |
7b7c1533 |
1260 | for (index = 0 ; index < recParticles->GetEntries() ; index++) { |
21cd0c07 |
1261 | AliPHOSRecParticle * rp = (AliPHOSRecParticle * ) recParticles->At(index) ; |
3bf72d32 |
1262 | message += "\n" ; |
1263 | message += rp->Name().Data() ; |
1264 | message += " " ; |
1265 | message += rp->GetIndexInList() ; |
1266 | message += " " ; |
1267 | message += rp->GetType() ; |
7acf6008 |
1268 | } |
3bf72d32 |
1269 | } |
351dd634 |
1270 | AliInfo(message.Data() ) ; |
69183710 |
1271 | } |
88cb7938 |
1272 | |
1273 | //____________________________________________________________________________ |
1274 | void AliPHOSPIDv1::SetParameters() |
1275 | { |
1276 | // PCA : To do the Principal Components Analysis it is necessary |
1277 | // the Principal file, which is opened here |
1278 | fX = new double[7]; // Data for the PCA |
1279 | fPPhoton = new double[7]; // Eigenvalues of the PCA |
1280 | fPPi0 = new double[7]; // Eigenvalues of the Pi0 PCA |
1281 | |
1282 | // Read photon principals from the photon file |
1283 | |
1284 | fFileNamePrincipalPhoton = "$ALICE_ROOT/PHOS/PCA8pa15_0.5-100.root" ; |
1285 | TFile f( fFileNamePrincipalPhoton.Data(), "read" ) ; |
1286 | fPrincipalPhoton = dynamic_cast<TPrincipal*> (f.Get("principal")) ; |
1287 | f.Close() ; |
1288 | |
1289 | // Read pi0 principals from the pi0 file |
1290 | |
1291 | fFileNamePrincipalPi0 = "$ALICE_ROOT/PHOS/PCA_pi0_40-120.root" ; |
1292 | TFile fPi0( fFileNamePrincipalPi0.Data(), "read" ) ; |
1293 | fPrincipalPi0 = dynamic_cast<TPrincipal*> (fPi0.Get("principal")) ; |
1294 | fPi0.Close() ; |
1295 | |
1296 | // Open parameters file and initialization of the Parameters matrix. |
1297 | // In the File Parameters.dat are all the parameters. These are introduced |
1298 | // in a matrix of 16x4 |
1299 | // |
1300 | // All the parameters defined in this file are, in order of row: |
1301 | // line 0 : calibration |
1302 | // lines 1,2 : CPV rectangular cat for X and Z |
1303 | // line 3 : TOF cut |
1304 | // lines 4-8 : parameters to calculate photon PCA ellipse |
1305 | // lines 9-13: parameters to calculate pi0 PCA ellipse |
1306 | // lines 14-15: parameters to calculate border for high-pt photons and pi0 |
1307 | |
1308 | fFileNameParameters = gSystem->ExpandPathName("$ALICE_ROOT/PHOS/Parameters.dat"); |
1309 | fParameters = new TMatrix(16,4) ; |
c947e71a |
1310 | const Int_t kMaxLeng=255; |
1311 | char string[kMaxLeng]; |
88cb7938 |
1312 | |
1313 | // Open a text file with PID parameters |
1314 | FILE *fd = fopen(fFileNameParameters.Data(),"r"); |
1315 | if (!fd) |
351dd634 |
1316 | AliFatal(Form("File %s with a PID parameters cannot be opened\n", |
1317 | fFileNameParameters.Data())); |
88cb7938 |
1318 | |
1319 | Int_t i=0; |
1320 | // Read parameter file line-by-line and skip empty line and comments |
c947e71a |
1321 | while (fgets(string,kMaxLeng,fd) != NULL) { |
88cb7938 |
1322 | if (string[0] == '\n' ) continue; |
1323 | if (string[0] == '!' ) continue; |
1324 | sscanf(string, "%f %f %f %f", |
1325 | &(*fParameters)(i,0), &(*fParameters)(i,1), |
1326 | &(*fParameters)(i,2), &(*fParameters)(i,3)); |
1327 | i++; |
351dd634 |
1328 | AliDebug(1, Form("SetParameters", "line %d: %s",i,string)); |
88cb7938 |
1329 | } |
1330 | fclose(fd); |
1331 | } |
1332 | |
1333 | //____________________________________________________________________________ |
1334 | void AliPHOSPIDv1::SetParameterCalibration(Int_t i,Float_t param) |
1335 | { |
1336 | // Set parameter "Calibration" i to a value param |
351dd634 |
1337 | if(i>2 || i<0) { |
1338 | AliError(Form("Invalid parameter number: %d",i)); |
1339 | } else |
88cb7938 |
1340 | (*fParameters)(0,i) = param ; |
1341 | } |
1342 | |
1343 | //____________________________________________________________________________ |
1344 | void AliPHOSPIDv1::SetParameterCpv2Emc(Int_t i, TString axis, Float_t cut) |
1345 | { |
1346 | // Set the parameters to calculate Cpv-to-Emc Distance Cut depending on |
1347 | // Purity-Efficiency point i |
1348 | |
351dd634 |
1349 | if(i>2 || i<0) { |
1350 | AliError(Form("Invalid parameter number: %d",i)); |
1351 | } else { |
88cb7938 |
1352 | axis.ToLower(); |
1353 | if (axis == "x") (*fParameters)(1,i) = cut; |
1354 | else if (axis == "z") (*fParameters)(2,i) = cut; |
351dd634 |
1355 | else { |
1356 | AliError(Form("Invalid axis name: %s",axis.Data())); |
1357 | } |
88cb7938 |
1358 | } |
1359 | } |
1360 | |
1361 | //____________________________________________________________________________ |
1362 | void AliPHOSPIDv1::SetParameterPhotonBoundary(Int_t i,Float_t param) |
1363 | { |
1364 | // Set parameter "Hard photon boundary" i to a value param |
351dd634 |
1365 | if(i>4 || i<0) { |
1366 | AliError(Form("Invalid parameter number: %d",i)); |
1367 | } else |
88cb7938 |
1368 | (*fParameters)(14,i) = param ; |
1369 | } |
1370 | |
1371 | //____________________________________________________________________________ |
1372 | void AliPHOSPIDv1::SetParameterPi0Boundary(Int_t i,Float_t param) |
1373 | { |
1374 | // Set parameter "Hard pi0 boundary" i to a value param |
351dd634 |
1375 | if(i>1 || i<0) { |
1376 | AliError(Form("Invalid parameter number: %d",i)); |
1377 | } else |
88cb7938 |
1378 | (*fParameters)(15,i) = param ; |
1379 | } |
1380 | |
1381 | //_____________________________________________________________________________ |
1382 | void AliPHOSPIDv1::SetParameterTimeGate(Int_t i, Float_t gate) |
1383 | { |
1384 | // Set the parameter TimeGate depending on Purity-Efficiency point i |
351dd634 |
1385 | if (i>2 || i<0) { |
1386 | AliError(Form("Invalid Efficiency-Purity choice %d",i)); |
1387 | } else |
88cb7938 |
1388 | (*fParameters)(3,i)= gate ; |
1389 | } |
1390 | |
1391 | //_____________________________________________________________________________ |
1392 | void AliPHOSPIDv1::SetParameterToCalculateEllipse(TString particle, TString param, Int_t i, Float_t par) |
1393 | { |
1394 | // Set the parameter "i" that is needed to calculate the ellipse |
1395 | // parameter "param" for a particle "particle" |
1396 | |
1397 | particle.ToLower(); |
1398 | param. ToLower(); |
1399 | Int_t p= -1; |
1400 | Int_t offset=0; |
1401 | |
1402 | if (particle == "photon") offset=0; |
1403 | else if (particle == "pi0") offset=5; |
1404 | else |
351dd634 |
1405 | AliError(Form("Wrong particle name: %s (choose from pi0/photon)\n", |
1406 | particle.Data())); |
88cb7938 |
1407 | |
1408 | if (param.Contains("a")) p=4+offset; |
1409 | else if(param.Contains("b")) p=5+offset; |
1410 | else if(param.Contains("c")) p=6+offset; |
1411 | else if(param.Contains("x0"))p=7+offset; |
1412 | else if(param.Contains("y0"))p=8+offset; |
351dd634 |
1413 | if((i>4)||(i<0)) { |
1414 | AliError(Form("No parameter with index %d", i)) ; |
1415 | } else if(p==-1) { |
1416 | AliError(Form("No parameter with name %s", param.Data() )) ; |
1417 | } else |
88cb7938 |
1418 | (*fParameters)(p,i) = par ; |
1419 | } |
1420 | |
1421 | //____________________________________________________________________________ |
1422 | void AliPHOSPIDv1::Unload() |
1423 | { |
c947e71a |
1424 | //Unloads RecPoints, Tracks and RecParticles |
88cb7938 |
1425 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
1426 | gime->PhosLoader()->UnloadRecPoints() ; |
1427 | gime->PhosLoader()->UnloadTracks() ; |
1428 | gime->PhosLoader()->UnloadRecParticles() ; |
1429 | } |
1430 | |
1431 | //____________________________________________________________________________ |
90cceaf6 |
1432 | void AliPHOSPIDv1::WriteRecParticles() |
88cb7938 |
1433 | { |
c947e71a |
1434 | //It writes reconstructed particles and pid to file |
1435 | |
88cb7938 |
1436 | AliPHOSGetter *gime = AliPHOSGetter::Instance() ; |
1437 | |
1438 | TClonesArray * recParticles = gime->RecParticles() ; |
1439 | recParticles->Expand(recParticles->GetEntriesFast() ) ; |
adcca1e6 |
1440 | if(fWrite){ |
1441 | TTree * treeP = gime->TreeP(); |
1442 | |
1443 | //First rp |
1444 | Int_t bufferSize = 32000 ; |
1445 | TBranch * rpBranch = treeP->Branch("PHOSRP",&recParticles,bufferSize); |
1446 | rpBranch->SetTitle(BranchName()); |
1447 | |
1448 | rpBranch->Fill() ; |
1449 | |
1450 | gime->WriteRecParticles("OVERWRITE"); |
1451 | gime->WritePID("OVERWRITE"); |
1452 | } |
88cb7938 |
1453 | } |
1454 | |
35adb638 |
1455 | |
1456 | //_______________________________________________________________________ |
1457 | void AliPHOSPIDv1::SetInitPID(const Double_t *p) { |
1458 | // Sets values for the initial population of each particle type |
1459 | for (Int_t i=0; i<AliESDtrack::kSPECIESN; i++) fInitPID[i] = p[i]; |
1460 | } |
1461 | //_______________________________________________________________________ |
1462 | void AliPHOSPIDv1::GetInitPID(Double_t *p) const { |
1463 | // Gets values for the initial population of each particle type |
1464 | for (Int_t i=0; i<AliESDtrack::kSPECIESN; i++) p[i] = fInitPID[i]; |
1465 | } |