]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALPID.cxx
Track matching and PID parameters added to AliEMCALRecParam
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALPID.cxx
CommitLineData
dc293ae9 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17/* History of cvs commits:
18 *
19 * $Log$
8ba062b1 20 * Revision 1.15 2007/10/09 08:46:10 hristov
21 * The data members fEMCALClusterCluster and fPHOSCluster are removed from AliESDCaloCluster, the fClusterType is used to select PHOS or EMCAL clusters. Changes, needed to use correctly the new AliESDCaloCluster. (Christian)
22 *
8ada0ffe 23 * Revision 1.14 2007/07/26 16:54:53 morsch
24 * Changes in AliESDEvent fwd declarartions.
25 *
89ffc0b0 26 * Revision 1.13 2007/07/11 13:43:29 hristov
27 * New class AliESDEvent, backward compatibility with the old AliESD (Christian)
28 *
af885e0f 29 * Revision 1.12 2007/06/11 20:43:06 hristov
30 * Changes required by the updated AliESDCaloCluster (Gustavo)
31 *
7592dfc4 32 * Revision 1.11 2007/03/30 13:50:34 gustavo
33 * PID for particles with E < 5 GeV was not done, temporal solution found (Guenole)
34 *
4ce73a00 35 * Revision 1.10 2007/03/09 14:34:11 gustavo
36 * Correct probability calculation, added missing initialization of data members
37 *
4cfd8ef9 38 * Revision 1.9 2007/02/20 20:17:43 hristov
39 * Corrected array size, removed warnings (icc)
40 *
d69ab345 41 * Revision 1.8 2006/12/19 08:49:35 gustavo
42 * New PID class for EMCAL, bayesian analysis done with ESD data, PID information filled when calling AliEMCALPID in AliEMCALReconstructor::FillESD()
43 *
dc293ae9 44 *
45 */
46// to compute PID for all the clusters in ESDs.root file
47// the ESDs.root have to be in the same directory as the class
48//
49//
50//
51//
52//
53// AliEMCALPID::CalculPID(Energy,Lambda0)
54// Calcul PID for all clusters in AliESDs.root file
55// keep this function for the moment for a simple verification, could be removed
56//
57//
58//
59// AliEMCALPID::CalculPID(Energy,Lambda0)
60// calcul PID Weght for a cluster with Energy, Lambda0 .
61// Double_t PIDFinal[AliPID::kSPECIESN] is the standard PID for :
62//
63//
64//
65// kElectron : fPIDFinal[0]
66// kMuon : fPIDFinal[1]
67// kPion : fPIDFinal[2]
68// kKaon : fPIDFinal[3]
69// kProton : fPIDFinal[4]
70// kPhoton : fPIDFinal[5]
71// kPi0 : fPIDFinal[6]
72// kNeutron : fPIDFinal[7]
73// kKaon0 : fPIDFinal[8]
74// kEleCon : fPIDFinal[9]
75// kUnknown : fPIDFinal[10]
76//
77//
78// PID[3] is a simple PID for
79// Electron & Photon PID[0]
80// Pi0 PID[1]
81// Hadron PID[2]
82//
83//
84//
85//
86//
87// --- ROOT system ---
88
89// standard C++ includes
90#include <Riostream.h>
91// #include <cstdlib>
92// #include <cmath>
93
94// ROOT includes
95#include "TTree.h"
96#include "TStyle.h"
97#include "TVector3.h"
98#include "TBranch.h"
99#include "TClonesArray.h"
100#include "TCanvas.h"
101#include "TLorentzVector.h"
102#include "TMath.h"
103#include "TFile.h"
104#include "TH1.h"
105#include "TH2.h"
106#include "TParticle.h"
107
108// // STEER includes
109// #include "AliRun.h"
110// #include "AliRunLoader.h"
111// #include "AliHeader.h"
112// #include "AliLoader.h"
113// #include "AliStack.h"
114// #include "AliESDtrack.h"
af885e0f 115// #include "AliESDEvent.h"
dc293ae9 116#include "AliLog.h"
117#include "AliEMCALPID.h"
89ffc0b0 118#include "AliESDCaloCluster.h"
8ba062b1 119#include "AliEMCALRecParam.h"
120#include "AliEMCALReconstructor.h"
121
dc293ae9 122
123ClassImp(AliEMCALPID)
124
4cfd8ef9 125//______________________________________________
126 AliEMCALPID::AliEMCALPID():
127 fPrintInfo(kFALSE), fProbGamma(0.),fProbPiZero(0.),fProbHadron(0.),fReconstructor(kFALSE)
dc293ae9 128{
4cfd8ef9 129 //
130 // Constructor.
131 // Initialize all constant values which have to be used
132 // during PID algorithm execution
133 //
134
135 // set flag for printing to FALSE by default
136 fPrintInfo = kFALSE;
8ba062b1 137
4cfd8ef9 138 fPIDWeight[0] = -1;
139 fPIDWeight[1] = -1;
140 fPIDWeight[2] = -1;
141 fReconstructor = kFALSE;
8ba062b1 142
143 const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
144if(!recParam) {
145 AliFatal("Reconstruction parameters for EMCAL not set!");
146 }
147 else {
148 for(Int_t i=0; i<6; i++){
149 for(Int_t j=0; i<6; i++){
150 fGamma[i][j] = recParam->GetGamma(i,j);
151 fHadron[i][j] = recParam->GetHadron(i,j);
152 fPiZero5to10[i][j] = recParam->GetPiZero5to10(i,j);
153 fPiZero10to60[i][j] = recParam->GetPiZero10to60(i,j);
154 AliDebug(1,Form("PID parameters: fGamma=%.3f, fPi=%.3f, fHAdron=%.3f",
155 fGamma[1][1],fPiZero5to10[1][1],fHadron[1][1] ));
156 }
157 }
158
159 }
160
161
dc293ae9 162}
4cfd8ef9 163
164//______________________________________________
af885e0f 165void AliEMCALPID::RunPID(AliESDEvent *esd)
dc293ae9 166{
167//
168// Make the PID for all the EMCAL clusters containedin the ESDs File
169// but just gamma/PiO/Hadron
170//
171 // trivial check against NULL object passed
8ba062b1 172
dc293ae9 173 if (esd == 0x0) {
4ce73a00 174 AliInfo("NULL ESD object passed !!" );
dc293ae9 175 return ;
176 }
4cfd8ef9 177
dc293ae9 178 Int_t nClusters = esd->GetNumberOfEMCALClusters();
179 Int_t firstCluster = esd->GetFirstEMCALCluster();
180 Double_t energy, lambda0;
181 for (Int_t iCluster = firstCluster; iCluster < (nClusters + firstCluster); iCluster++) {
8ba062b1 182
dc293ae9 183 AliESDCaloCluster *clust = esd->GetCaloCluster(iCluster);
7592dfc4 184 energy = clust->E();
dc293ae9 185 lambda0 = clust->GetM02();
186 // verify cluster type
187 Int_t clusterType= clust->GetClusterType();
8ada0ffe 188 if (clusterType == AliESDCaloCluster::kEMCALClusterv1 && lambda0 != 0 && energy < 1000) {
4ce73a00 189
190
dc293ae9 191 // reject clusters with lambda0 = 0
4ce73a00 192
193
dc293ae9 194 ComputePID(energy, lambda0);
4ce73a00 195
196
dc293ae9 197 if (fPrintInfo) {
198 AliInfo("___________________________________________________");
199 AliInfo(Form( "Particle Energy = %f",energy));
200 AliInfo(Form( "Particle Lambda0 of the particle = %f", lambda0) );
201 AliInfo("PIDWeight of the particle :" );
202 AliInfo(Form( " GAMMA : %f",fPID[0] ));
203 AliInfo(Form( " PiZero : %f",fPID[1] ));
204 AliInfo(Form( " HADRON : %f", fPID[2] ));
205 AliInfo("_________________________________________");
206 AliInfo(Form( " kElectron : %f", fPIDFinal[0]) );
207 AliInfo(Form( " kMuon : %f", fPIDFinal[1] ));
208 AliInfo(Form( " kPion : %f", fPIDFinal[2] ));
209 AliInfo(Form( " kKaon : %f", fPIDFinal[3] ));
210 AliInfo(Form( " kProton : %f", fPIDFinal[4] ));
211 AliInfo(Form( " kPhoton : %f", fPIDFinal[5] ));
212 AliInfo(Form( " kPi0 : %f", fPIDFinal[6] ));
213 AliInfo(Form( " kNeutron : %f", fPIDFinal[7] ));
214 AliInfo(Form( " kKaon0 : %f", fPIDFinal[8] ));
215 AliInfo(Form( " kEleCon : %f", fPIDFinal[9] ));
216 AliInfo(Form( " kUnknown : %f", fPIDFinal[10] ));
217 AliInfo("___________________________________________________");
218 }
4cfd8ef9 219
dc293ae9 220 if(fReconstructor) // In case it is called during reconstruction.
221 clust->SetPid(fPIDFinal);
222 } // end if (clusterType...)
223 } // end for (iCluster...)
224}
4cfd8ef9 225
226//__________________________________________________________
dc293ae9 227void AliEMCALPID::ComputePID(Double_t energy, Double_t lambda0)
228{
229//
230// This is the main command, which uses the distributions computed and parametrised,
231// and gives the PID by the bayesian method.
232//
4ce73a00 233
234if (energy<5){energy =6;}
235
236
4cfd8ef9 237 TArrayD paramDistribGamma = DistLambda0(energy, 1);
238 TArrayD paramDistribPiZero = DistLambda0(energy, 2);
239 TArrayD paramDistribHadron = DistLambda0(energy, 3);
240
241 Bool_t norm = kFALSE;
242
243 fProbGamma = TMath::Gaus(lambda0, paramDistribGamma[1], paramDistribGamma[2], norm) * paramDistribGamma[0];
244 fProbGamma += TMath::Landau(lambda0, paramDistribGamma[4], paramDistribGamma[5], norm) * paramDistribGamma[3];
245 fProbPiZero = TMath::Gaus(lambda0, paramDistribPiZero[1], paramDistribPiZero[2], norm) * paramDistribPiZero[0];
246 fProbPiZero += TMath::Landau(lambda0, paramDistribPiZero[4], paramDistribPiZero[5], norm) * paramDistribPiZero[3];
247 fProbHadron = TMath::Gaus(lambda0, paramDistribHadron[1], paramDistribHadron[2], norm) * paramDistribHadron[0];
248 fProbHadron += TMath::Landau(lambda0, paramDistribHadron[4], paramDistribHadron[5], norm) * paramDistribHadron[3];
249
250 // compute PID Weight
251 fPIDWeight[0] = fProbGamma / (fProbGamma + fProbPiZero + fProbHadron);
252 fPIDWeight[1] = fProbPiZero / (fProbGamma+fProbPiZero+fProbHadron);
253 fPIDWeight[2] = fProbHadron / (fProbGamma+fProbPiZero+fProbHadron);
254
255 SetPID(fPIDWeight[0], 0);
256 SetPID(fPIDWeight[1], 1);
257 SetPID(fPIDWeight[2], 2);
258
259 // sortie ecran pid Weight only for control (= in english ???)
260 if (fPrintInfo) {
261 AliInfo(Form( "Energy in loop = %f", energy) );
262 AliInfo(Form( "Lambda0 in loop = %f", lambda0) );
263 AliInfo(Form( "fProbGamma in loop = %f", fProbGamma) );
264 // AliInfo(Form( "fParametresDistribGamma[2] = %f", fParamDistribGamma[2]) );
265 AliInfo(Form( "fProbaPiZero = %f", fProbPiZero ));
266 AliInfo(Form( "fProbaHadron = %f", fProbHadron) );
267 AliInfo(Form( "PIDWeight in loop = %f ||| %f ||| %f", fPIDWeight[0] , fPIDWeight[1], fPIDWeight[2]) );
268 AliInfo(Form( "fGamma[2][2] = %f", fGamma[2][2] ));
269 AliInfo("********************************************************" );
270 }
271
272 fPIDFinal[0] = fPIDWeight[0]/2;
273 fPIDFinal[1] = fPIDWeight[2]/8;
274 fPIDFinal[2] = fPIDWeight[2]/8;
275 fPIDFinal[3] = fPIDWeight[2]/8;
276 fPIDFinal[4] = fPIDWeight[2]/8;
277 fPIDFinal[5] = fPIDWeight[0]/2;
278 fPIDFinal[6] = fPIDWeight[1] ;
279 fPIDFinal[7] = fPIDWeight[2]/8;
280 fPIDFinal[8] = fPIDWeight[2]/8;
281 fPIDFinal[9] = fPIDWeight[2]/8;
282 fPIDFinal[10] = fPIDWeight[2]/8;
dc293ae9 283}
4cfd8ef9 284
285//________________________________________________________
dc293ae9 286TArrayD AliEMCALPID::DistLambda0(Double_t energy, Int_t type)
287{
4cfd8ef9 288 //
289 // Compute the values of the parametrised distributions using the data initialised before.
290 //
291 Double_t constGauss = 0., meanGauss = 0., sigmaGauss = 0.;
292 Double_t constLandau=0., mpvLandau=0., sigmaLandau=0.;
293 TArrayD distributionParam(6);
294
295 switch (type) {
296 case 1:
297 constGauss = Polynomial(energy, fGamma[0]);
298 meanGauss = Polynomial(energy, fGamma[1]);
299 sigmaGauss = Polynomial(energy, fGamma[2]);
300 constLandau = Polynomial(energy, fGamma[3]);
301 mpvLandau = Polynomial(energy, fGamma[4]);
302 sigmaLandau = Polynomial(energy, fGamma[5]);
303 break;
304 case 2:
305 if (energy < 10) {
306 constGauss = Polynomial(energy, fPiZero5to10[0]);
307 meanGauss = Polynomial(energy, fPiZero5to10[1]);
308 sigmaGauss = Polynomial(energy, fPiZero5to10[2]);
309 constLandau = Polynomial(energy, fPiZero5to10[3]);
310 mpvLandau = Polynomial(energy, fPiZero5to10[4]);
311 sigmaLandau = Polynomial(energy, fPiZero5to10[5]);
312 }
313 else {
314 constGauss = Polynomial(energy, fPiZero10to60[0]);
315 meanGauss = Polynomial(energy, fPiZero10to60[1]);
316 sigmaGauss = Polynomial(energy, fPiZero10to60[2]);
317 constLandau = Polynomial(energy, fPiZero10to60[3]);
318 mpvLandau = Polynomial(energy, fPiZero10to60[4]);
319 sigmaLandau = Polynomial(energy, fPiZero10to60[5]);
320 }
321 break;
322 case 3:
323 constGauss = Polynomial(energy, fHadron[0]);
324 meanGauss = Polynomial(energy, fHadron[1]);
325 sigmaGauss = Polynomial(energy, fHadron[2]);
326 constLandau = Polynomial(energy, fHadron[3]);
327 mpvLandau = Polynomial(energy, fHadron[4]);
328 sigmaLandau = Polynomial(energy, fHadron[5]);
329 break;
330 }
331
332 distributionParam[0] = constGauss;
333 distributionParam[1] = meanGauss;
334 distributionParam[2] = sigmaGauss;
335 distributionParam[3] = constLandau;
336 distributionParam[4] = mpvLandau;
337 distributionParam[5] = sigmaLandau;
338
339 return distributionParam;
dc293ae9 340}
4cfd8ef9 341
342//_______________________________________________________
dc293ae9 343Double_t AliEMCALPID::Polynomial(Double_t x, Double_t *params)
344{
4cfd8ef9 345 //
346 // Compute a polynomial for a given value of 'x'
347 // with the array of parameters passed as the second arg
348 //
349 Double_t y;
350 y = params[0];
351 y += params[1] * x;
352 y += params[2] * x * x;
353 y += params[3] * x * x * x;
354 y += params[4] * x * x * x * x;
355 y += params[5] * x * x * x * x * x;
356
357 return y;
dc293ae9 358}