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