]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/CheckESD.C
Execution time printout via AliInfo
[u/mrichter/AliRoot.git] / STEER / CheckESD.C
CommitLineData
5e00415f 1#if !defined( __CINT__) || defined(__MAKECINT__)
2#include <TFile.h>
3#include <TError.h>
4#include <TH1.h>
5#include <TH2.h>
6#include <TF1.h>
7#include <TCanvas.h>
8#include <TVector3.h>
9#include <TPDGCode.h>
8b462fd8 10#include <TParticle.h>
5e00415f 11
12#include "AliRunLoader.h"
13#include "AliLoader.h"
14#include "AliESD.h"
15#include "AliRun.h"
16#include "AliStack.h"
17#include "AliHeader.h"
18#include "AliGenEventHeader.h"
5fed899a 19#include "AliPID.h"
f0cfab93 20#else
21const Int_t kXiMinus = 3312;
22const Int_t kOmegaMinus = 3334;
5e00415f 23#endif
24
25
26TH1F* CreateHisto(const char* name, const char* title,
27 Int_t nBins, Double_t xMin, Double_t xMax,
28 const char* xLabel = NULL, const char* yLabel = NULL)
29{
30// create a histogram
31
32 TH1F* result = new TH1F(name, title, nBins, xMin, xMax);
33 result->SetOption("E");
34 if (xLabel) result->GetXaxis()->SetTitle(xLabel);
35 if (yLabel) result->GetYaxis()->SetTitle(yLabel);
36 result->SetMarkerStyle(kFullCircle);
37 return result;
38}
39
40TH1F* CreateEffHisto(TH1F* hGen, TH1F* hRec)
41{
42// create an efficiency histogram
43
44 Int_t nBins = hGen->GetNbinsX();
45 TH1F* hEff = (TH1F*) hGen->Clone("hEff");
46 hEff->SetTitle("");
47 hEff->SetStats(kFALSE);
48 hEff->SetMinimum(0.);
49 hEff->SetMaximum(110.);
50 hEff->GetYaxis()->SetTitle("#epsilon [%]");
51
52 for (Int_t iBin = 0; iBin <= nBins; iBin++) {
53 Double_t nGen = hGen->GetBinContent(iBin);
54 Double_t nRec = hRec->GetBinContent(iBin);
55 if (nGen > 0) {
56 Double_t eff = nRec/nGen;
57 hEff->SetBinContent(iBin, 100. * eff);
58 Double_t error = sqrt(eff*(1.-eff) / nGen);
59 if (error == 0) error = 0.0001;
60 hEff->SetBinError(iBin, 100. * error);
61 } else {
62 hEff->SetBinContent(iBin, -100.);
63 hEff->SetBinError(iBin, 0);
64 }
65 }
66
67 return hEff;
68}
69
70Bool_t FitHisto(TH1* histo, Double_t& res, Double_t& resError)
71{
72// fit a gaussian to a histogram
73
74 static TF1* fitFunc = new TF1("fitFunc", "gaus");
75 fitFunc->SetLineWidth(2);
76 fitFunc->SetFillStyle(0);
77 Double_t maxFitRange = 2;
78
79 if (histo->Integral() > 50) {
80 Float_t mean = histo->GetMean();
81 Float_t rms = histo->GetRMS();
82 fitFunc->SetRange(mean - maxFitRange*rms, mean + maxFitRange*rms);
83 fitFunc->SetParameters(mean, rms);
84 histo->Fit(fitFunc, "QRI0");
85 histo->GetFunction("fitFunc")->ResetBit(1<<9);
86 res = TMath::Abs(fitFunc->GetParameter(2));
87 resError = TMath::Abs(fitFunc->GetParError(2));
88 return kTRUE;
89 }
90
91 return kFALSE;
92}
93
94
95Bool_t CheckESD(const char* gAliceFileName = "galice.root",
96 const char* esdFileName = "AliESDs.root")
97{
98// check the content of the ESD
99
100 // check values
101 Int_t checkNGenLow = 1;
102
103 Double_t checkEffLow = 0.5;
104 Double_t checkEffSigma = 3;
105 Double_t checkFakeHigh = 0.5;
106 Double_t checkFakeSigma = 3;
107
108 Double_t checkResPtInvHigh = 5;
109 Double_t checkResPtInvSigma = 3;
110 Double_t checkResPhiHigh = 10;
111 Double_t checkResPhiSigma = 3;
112 Double_t checkResThetaHigh = 10;
113 Double_t checkResThetaSigma = 3;
114
115 Double_t checkPIDEffLow = 0.5;
116 Double_t checkPIDEffSigma = 3;
117 Double_t checkResTOFHigh = 500;
118 Double_t checkResTOFSigma = 3;
119
120 Double_t checkPHOSNLow = 5;
121 Double_t checkPHOSEnergyLow = 0.3;
122 Double_t checkPHOSEnergyHigh = 1.0;
123 Double_t checkEMCALNLow = 50;
124 Double_t checkEMCALEnergyLow = 0.05;
125 Double_t checkEMCALEnergyHigh = 1.0;
126
127 Double_t checkMUONNLow = 1;
128 Double_t checkMUONPtLow = 0.5;
129 Double_t checkMUONPtHigh = 10.;
130
131 Double_t cutPtV0 = 0.3;
132 Double_t checkV0EffLow = 0.02;
133 Double_t checkV0EffSigma = 3;
134 Double_t cutPtCascade = 0.5;
135 Double_t checkCascadeEffLow = 0.01;
136 Double_t checkCascadeEffSigma = 3;
137
138 // open run loader and load gAlice, kinematics and header
139 AliRunLoader* runLoader = AliRunLoader::Open(gAliceFileName);
140 if (!runLoader) {
141 Error("CheckESD", "getting run loader from file %s failed",
142 gAliceFileName);
143 return kFALSE;
144 }
145 runLoader->LoadgAlice();
146 gAlice = runLoader->GetAliRun();
147 if (!gAlice) {
148 Error("CheckESD", "no galice object found");
149 return kFALSE;
150 }
151 runLoader->LoadKinematics();
152 runLoader->LoadHeader();
153
154 // open the ESD file
155 TFile* esdFile = TFile::Open(esdFileName);
156 if (!esdFile || !esdFile->IsOpen()) {
157 Error("CheckESD", "opening ESD file %s failed", esdFileName);
158 return kFALSE;
159 }
8b462fd8 160 AliESD* esd = new AliESD;
161 TTree* tree = (TTree*) esdFile->Get("esdTree");
162 if (!tree) {
163 Error("CheckESD", "no ESD tree found");
164 return kFALSE;
165 }
166 tree->SetBranchAddress("ESD", &esd);
5e00415f 167
168 // efficienc and resolution histograms
169 Int_t nBinsPt = 15;
170 Float_t minPt = 0.1;
171 Float_t maxPt = 3.1;
172 TH1F* hGen = CreateHisto("hGen", "generated tracks",
173 nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
174 TH1F* hRec = CreateHisto("hRec", "reconstructed tracks",
175 nBinsPt, minPt, maxPt, "p_{t} [GeV/c]", "N");
176 Int_t nGen = 0;
177 Int_t nRec = 0;
178 Int_t nFake = 0;
179
180 TH1F* hResPtInv = CreateHisto("hResPtInv", "", 100, -10, 10,
181 "(p_{t,rec}^{-1}-p_{t,sim}^{-1}) / p_{t,sim}^{-1} [%]", "N");
182 TH1F* hResPhi = CreateHisto("hResPhi", "", 100, -20, 20,
183 "#phi_{rec}-#phi_{sim} [mrad]", "N");
184 TH1F* hResTheta = CreateHisto("hResTheta", "", 100, -20, 20,
185 "#theta_{rec}-#theta_{sim} [mrad]", "N");
186
187 // PID
5fed899a 188 Int_t partCode[AliPID::kSPECIES] =
5e00415f 189 {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
5fed899a 190 const char* partName[AliPID::kSPECIES+1] =
5e00415f 191 {"electron", "muon", "pion", "kaon", "proton", "other"};
5fed899a 192 Double_t partFrac[AliPID::kSPECIES] =
5e00415f 193 {0.01, 0.01, 0.85, 0.10, 0.05};
5fed899a 194 Int_t identified[AliPID::kSPECIES+1][AliPID::kSPECIES];
195 for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
196 for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
5e00415f 197 identified[iGen][iRec] = 0;
198 }
199 }
200 Int_t nIdentified = 0;
201
202 // dE/dx and TOF
203 TH2F* hDEdxRight = new TH2F("hDEdxRight", "", 300, 0, 3, 100, 0, 400);
204 hDEdxRight->SetStats(kFALSE);
205 hDEdxRight->GetXaxis()->SetTitle("p [GeV/c]");
206 hDEdxRight->GetYaxis()->SetTitle("dE/dx_{TPC}");
207 hDEdxRight->SetMarkerStyle(kFullCircle);
208 hDEdxRight->SetMarkerSize(0.4);
209 TH2F* hDEdxWrong = new TH2F("hDEdxWrong", "", 300, 0, 3, 100, 0, 400);
210 hDEdxWrong->SetStats(kFALSE);
211 hDEdxWrong->GetXaxis()->SetTitle("p [GeV/c]");
212 hDEdxWrong->GetYaxis()->SetTitle("dE/dx_{TPC}");
213 hDEdxWrong->SetMarkerStyle(kFullCircle);
214 hDEdxWrong->SetMarkerSize(0.4);
215 hDEdxWrong->SetMarkerColor(kRed);
216 TH1F* hResTOFRight = CreateHisto("hResTOFRight", "", 100, -1000, 1000,
217 "t_{TOF}-t_{track} [ps]", "N");
218 TH1F* hResTOFWrong = CreateHisto("hResTOFWrong", "", 100, -1000, 1000,
219 "t_{TOF}-t_{track} [ps]", "N");
220 hResTOFWrong->SetLineColor(kRed);
221
222 // calorimeters
223 TH1F* hEPHOS = CreateHisto("hEPHOS", "PHOS", 100, 0, 5, "E [GeV]", "N");
f04585c3 224 TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 50, "E [GeV]", "N");
5e00415f 225
226 // muons
227 TH1F* hPtMUON = CreateHisto("hPtMUON", "MUON", 100, 0, 20,
228 "p_{t} [GeV/c]", "N");
229
230 // V0s and cascades
231 TH1F* hMassK0 = CreateHisto("hMassK0", "K^{0}", 100, 0.4, 0.6,
232 "M(#pi^{+}#pi^{-}) [GeV/c^{2}]", "N");
233 TH1F* hMassLambda = CreateHisto("hMassLambda", "#Lambda", 100, 1.0, 1.2,
234 "M(p#pi^{-}) [GeV/c^{2}]", "N");
235 TH1F* hMassLambdaBar = CreateHisto("hMassLambdaBar", "#bar{#Lambda}",
236 100, 1.0, 1.2,
237 "M(#bar{p}#pi^{+}) [GeV/c^{2}]", "N");
238 Int_t nGenV0s = 0;
239 Int_t nRecV0s = 0;
240 TH1F* hMassXi = CreateHisto("hMassXi", "#Xi", 100, 1.2, 1.5,
241 "M(#Lambda#pi) [GeV/c^{2}]", "N");
242 TH1F* hMassOmega = CreateHisto("hMassOmega", "#Omega", 100, 1.5, 1.8,
243 "M(#LambdaK) [GeV/c^{2}]", "N");
244 Int_t nGenCascades = 0;
245 Int_t nRecCascades = 0;
246
247 // loop over events
248 for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) {
249 runLoader->GetEvent(iEvent);
250
251 // select simulated primary particles, V0s and cascades
252 AliStack* stack = gAlice->Stack();
253 Int_t nParticles = stack->GetNtrack();
254 TArrayF vertex(3);
255 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vertex);
256 TObjArray selParticles;
257 TObjArray selV0s;
258 TObjArray selCascades;
259 for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
260 TParticle* particle = stack->Particle(iParticle);
261 if (!particle) continue;
262 if (particle->Pt() < 0.001) continue;
263 if (TMath::Abs(particle->Eta()) > 0.9) continue;
264 TVector3 dVertex(particle->Vx() - vertex[0],
265 particle->Vy() - vertex[1],
266 particle->Vz() - vertex[2]);
267 if (dVertex.Mag() > 0.0001) continue;
268
269 switch (TMath::Abs(particle->GetPdgCode())) {
270 case kElectron:
271 case kMuonMinus:
272 case kPiPlus:
273 case kKPlus:
274 case kProton: {
275 if (particle->Pt() > minPt) {
276 selParticles.Add(particle);
277 nGen++;
278 hGen->Fill(particle->Pt());
279 }
280 break;
281 }
282 case kK0Short:
283 case kLambda0: {
284 if (particle->Pt() > cutPtV0) {
285 nGenV0s++;
286 selV0s.Add(particle);
287 }
288 break;
289 }
290 case kXiMinus:
291 case kOmegaMinus: {
292 if (particle->Pt() > cutPtCascade) {
293 nGenCascades++;
294 selCascades.Add(particle);
295 }
296 break;
297 }
298 default: break;
299 }
300 }
301
302 // get the event summary data
8b462fd8 303 tree->GetEvent(iEvent);
5e00415f 304 if (!esd) {
305 Error("CheckESD", "no ESD object found for event %d", iEvent);
306 return kFALSE;
307 }
308
309 // loop over tracks
310 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfTracks(); iTrack++) {
311 AliESDtrack* track = esd->GetTrack(iTrack);
312
313 // select tracks of selected particles
314 Int_t label = TMath::Abs(track->GetLabel());
315 if (label > stack->GetNtrack()) continue; // background
316 TParticle* particle = stack->Particle(label);
317 if (!selParticles.Contains(particle)) continue;
318 if ((track->GetStatus() & AliESDtrack::kITSrefit) == 0) continue;
319 if (track->GetConstrainedChi2() > 1e9) continue;
320 selParticles.Remove(particle); // don't count multiple tracks
321
322 nRec++;
323 hRec->Fill(particle->Pt());
324 if (track->GetLabel() < 0) nFake++;
325
326 // resolutions
327 Double_t p[3];
328 track->GetConstrainedPxPyPz(p);
329 TVector3 pTrack(p);
330 hResPtInv->Fill(100. * (1./pTrack.Pt() - 1./particle->Pt()) *
331 particle->Pt());
332 hResPhi->Fill(1000. * (pTrack.Phi() - particle->Phi()));
333 hResTheta->Fill(1000. * (pTrack.Theta() - particle->Theta()));
334
335 // PID
336 if ((track->GetStatus() & AliESDtrack::kESDpid) == 0) continue;
337 Int_t iGen = 5;
5fed899a 338 for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
5e00415f 339 if (TMath::Abs(particle->GetPdgCode()) == partCode[i]) iGen = i;
340 }
5fed899a 341 Double_t probability[AliPID::kSPECIES];
5e00415f 342 track->GetESDpid(probability);
343 Double_t pMax = 0;
344 Int_t iRec = 0;
5fed899a 345 for (Int_t i = 0; i < AliPID::kSPECIES; i++) {
5e00415f 346 probability[i] *= partFrac[i];
347 if (probability[i] > pMax) {
348 pMax = probability[i];
349 iRec = i;
350 }
351 }
352 identified[iGen][iRec]++;
353 if (iGen == iRec) nIdentified++;
354
355 // dE/dx and TOF
5fed899a 356 Double_t time[AliPID::kSPECIES];
5e00415f 357 track->GetIntegratedTimes(time);
358 if (iGen == iRec) {
359 hDEdxRight->Fill(pTrack.Mag(), track->GetTPCsignal());
360 if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
361 hResTOFRight->Fill(track->GetTOFsignal() - time[iRec]);
362 }
363 } else {
364 hDEdxWrong->Fill(pTrack.Mag(), track->GetTPCsignal());
365 if ((track->GetStatus() & AliESDtrack::kTOFpid) != 0) {
366 hResTOFWrong->Fill(track->GetTOFsignal() - time[iRec]);
367 }
368 }
369 }
370
5e00415f 371 // loop over muon tracks
f0cfab93 372 {
5e00415f 373 for (Int_t iTrack = 0; iTrack < esd->GetNumberOfMuonTracks(); iTrack++) {
f0cfab93 374 AliESDMuonTrack* muonTrack = esd->GetMuonTrack(iTrack);
375 Double_t ptInv = TMath::Abs(muonTrack->GetInverseBendingMomentum());
5e00415f 376 if (ptInv > 0.001) {
377 hPtMUON->Fill(1./ptInv);
378 }
379 }
f0cfab93 380 }
5e00415f 381
382 // loop over V0s
383 for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
384 AliESDv0* v0 = esd->GetV0(iV0);
d6a49f20 385 if (v0->GetOnFlyStatus()) continue;
f980f8fb 386 v0->ChangeMassHypothesis(kK0Short);
387 hMassK0->Fill(v0->GetEffMass());
388 v0->ChangeMassHypothesis(kLambda0);
389 hMassLambda->Fill(v0->GetEffMass());
390 v0->ChangeMassHypothesis(kLambda0Bar);
391 hMassLambdaBar->Fill(v0->GetEffMass());
5e00415f 392
393 Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel());
394 if (negLabel > stack->GetNtrack()) continue; // background
395 Int_t negMother = stack->Particle(negLabel)->GetMother(0);
396 if (negMother < 0) continue;
f980f8fb 397 Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel());
5e00415f 398 if (posLabel > stack->GetNtrack()) continue; // background
399 Int_t posMother = stack->Particle(posLabel)->GetMother(0);
400 if (negMother != posMother) continue;
401 TParticle* particle = stack->Particle(negMother);
402 if (!selV0s.Contains(particle)) continue;
403 selV0s.Remove(particle);
404 nRecV0s++;
405 }
406
407 // loop over Cascades
408 for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades();
409 iCascade++) {
410 AliESDcascade* cascade = esd->GetCascade(iCascade);
f980f8fb 411 Double_t v0q;
412 cascade->ChangeMassHypothesis(v0q,kXiMinus);
413 hMassXi->Fill(cascade->GetEffMass());
414 cascade->ChangeMassHypothesis(v0q,kOmegaMinus);
415 hMassOmega->Fill(cascade->GetEffMass());
5e00415f 416
417 Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex())
418 ->GetLabel());
419 if (negLabel > stack->GetNtrack()) continue; // background
420 Int_t negMother = stack->Particle(negLabel)->GetMother(0);
421 if (negMother < 0) continue;
f980f8fb 422 Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex())
5e00415f 423 ->GetLabel());
424 if (posLabel > stack->GetNtrack()) continue; // background
425 Int_t posMother = stack->Particle(posLabel)->GetMother(0);
426 if (negMother != posMother) continue;
427 Int_t v0Mother = stack->Particle(negMother)->GetMother(0);
428 if (v0Mother < 0) continue;
429 Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex())
430 ->GetLabel());
431 if (bacLabel > stack->GetNtrack()) continue; // background
432 Int_t bacMother = stack->Particle(bacLabel)->GetMother(0);
433 if (v0Mother != bacMother) continue;
434 TParticle* particle = stack->Particle(v0Mother);
435 if (!selCascades.Contains(particle)) continue;
436 selCascades.Remove(particle);
437 nRecCascades++;
438 }
f04585c3 439
440 // loop over the PHOS clusters
441 {
442 Int_t firstPHOSCluster = esd->GetFirstPHOSCluster();
443 Int_t lastPHOSCluster = firstPHOSCluster + esd->GetNumberOfPHOSClusters();
444 for (Int_t iCluster=firstPHOSCluster; iCluster<lastPHOSCluster; iCluster++)
445 hEPHOS->Fill(esd->GetCaloCluster(iCluster)->GetClusterEnergy());
446 }
447
448 // loop over the EMCAL clusters
449 {
450 Int_t firstEMCALCluster = esd->GetFirstEMCALCluster();
451 Int_t lastEMCALCluster = firstEMCALCluster + esd->GetNumberOfEMCALClusters();
452 for (Int_t iCluster=firstEMCALCluster; iCluster<lastEMCALCluster; iCluster++)
453 hEEMCAL->Fill(esd->GetCaloCluster(iCluster)->GetClusterEnergy());
454 }
5e00415f 455 }
456
457 // perform checks
458 if (nGen < checkNGenLow) {
459 Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen));
460 }
461
462 TH1F* hEff = CreateEffHisto(hGen, hRec);
463
464 Info("CheckESD", "%d out of %d tracks reconstructed including %d "
465 "fake tracks", nRec, nGen, nFake);
466 if (nGen > 0) {
467 // efficiency
468 Double_t eff = nRec*1./nGen;
469 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen);
470 Double_t fake = nFake*1./nGen;
471 Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen);
472 Info("CheckESD", "eff = (%.1f +- %.1f) %% fake = (%.1f +- %.1f) %%",
473 100.*eff, 100.*effError, 100.*fake, 100.*fakeError);
474
475 if (eff < checkEffLow - checkEffSigma*effError) {
476 Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%",
477 100.*eff, 100.*effError);
478 }
479 if (fake > checkFakeHigh + checkFakeSigma*fakeError) {
480 Warning("CheckESD", "high fake: (%.1f +- %.1f) %%",
481 100.*fake, 100.*fakeError);
482 }
483
484 // resolutions
485 Double_t res, resError;
486 if (FitHisto(hResPtInv, res, resError)) {
487 Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%",
488 res, resError);
489 if (res > checkResPtInvHigh + checkResPtInvSigma*resError) {
490 Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%",
491 res, resError);
492 }
493 }
494
495 if (FitHisto(hResPhi, res, resError)) {
496 Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError);
497 if (res > checkResPhiHigh + checkResPhiSigma*resError) {
498 Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad",
499 res, resError);
500 }
501 }
502
503 if (FitHisto(hResTheta, res, resError)) {
504 Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad",
505 res, resError);
506 if (res > checkResThetaHigh + checkResThetaSigma*resError) {
507 Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad",
508 res, resError);
509 }
510 }
511
512 // PID
513 if (nRec > 0) {
514 Double_t eff = nIdentified*1./nRec;
515 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec);
516 Info("CheckESD", "PID eff = (%.1f +- %.1f) %%",
517 100.*eff, 100.*effError);
518 if (eff < checkPIDEffLow - checkPIDEffSigma*effError) {
519 Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%",
520 100.*eff, 100.*effError);
521 }
522 }
523
524 printf("%9s:", "gen\\rec");
5fed899a 525 for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
5e00415f 526 printf("%9s", partName[iRec]);
527 }
528 printf("\n");
5fed899a 529 for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
5e00415f 530 printf("%9s:", partName[iGen]);
5fed899a 531 for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
5e00415f 532 printf("%9d", identified[iGen][iRec]);
533 }
534 printf("\n");
535 }
536
537 if (FitHisto(hResTOFRight, res, resError)) {
538 Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError);
539 if (res > checkResTOFHigh + checkResTOFSigma*resError) {
540 Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps",
541 res, resError);
542 }
543 }
544
545 // calorimeters
546 if (hEPHOS->Integral() < checkPHOSNLow) {
547 Warning("CheckESD", "low number of PHOS particles: %d",
548 Int_t(hEPHOS->Integral()));
549 } else {
550 Double_t mean = hEPHOS->GetMean();
551 if (mean < checkPHOSEnergyLow) {
552 Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean);
553 } else if (mean > checkPHOSEnergyHigh) {
554 Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean);
555 }
556 }
557
558 if (hEEMCAL->Integral() < checkEMCALNLow) {
559 Warning("CheckESD", "low number of EMCAL particles: %d",
560 Int_t(hEEMCAL->Integral()));
561 } else {
562 Double_t mean = hEEMCAL->GetMean();
563 if (mean < checkEMCALEnergyLow) {
564 Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean);
565 } else if (mean > checkEMCALEnergyHigh) {
566 Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean);
567 }
568 }
569
570 // muons
571 if (hPtMUON->Integral() < checkMUONNLow) {
572 Warning("CheckESD", "low number of MUON particles: %d",
573 Int_t(hPtMUON->Integral()));
574 } else {
575 Double_t mean = hPtMUON->GetMean();
576 if (mean < checkMUONPtLow) {
577 Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean);
578 } else if (mean > checkMUONPtHigh) {
579 Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean);
580 }
581 }
582
583 // V0s
584 if (nGenV0s > 0) {
585 Double_t eff = nRecV0s*1./nGenV0s;
586 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s);
587 if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s);
588 Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%",
589 100.*eff, 100.*effError);
590 if (eff < checkV0EffLow - checkV0EffSigma*effError) {
591 Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%",
592 100.*eff, 100.*effError);
593 }
594 }
595
596 // Cascades
597 if (nGenCascades > 0) {
598 Double_t eff = nRecCascades*1./nGenCascades;
599 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades);
600 if (effError == 0) effError = checkV0EffLow /
601 TMath::Sqrt(1.*nGenCascades);
602 Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%",
603 100.*eff, 100.*effError);
604 if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) {
605 Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%",
606 100.*eff, 100.*effError);
607 }
608 }
609 }
610
611 // draw the histograms if not in batch mode
612 if (!gROOT->IsBatch()) {
613 new TCanvas;
614 hEff->DrawCopy();
615 new TCanvas;
616 hResPtInv->DrawCopy("E");
617 new TCanvas;
618 hResPhi->DrawCopy("E");
619 new TCanvas;
620 hResTheta->DrawCopy("E");
621 new TCanvas;
622 hDEdxRight->DrawCopy();
623 hDEdxWrong->DrawCopy("SAME");
624 new TCanvas;
625 hResTOFRight->DrawCopy("E");
626 hResTOFWrong->DrawCopy("SAME");
627 new TCanvas;
628 hEPHOS->DrawCopy("E");
629 new TCanvas;
630 hEEMCAL->DrawCopy("E");
631 new TCanvas;
632 hPtMUON->DrawCopy("E");
633 new TCanvas;
634 hMassK0->DrawCopy("E");
635 new TCanvas;
636 hMassLambda->DrawCopy("E");
637 new TCanvas;
638 hMassLambdaBar->DrawCopy("E");
639 new TCanvas;
640 hMassXi->DrawCopy("E");
641 new TCanvas;
642 hMassOmega->DrawCopy("E");
643 }
644
645 // write the output histograms to a file
646 TFile* outputFile = TFile::Open("check.root", "recreate");
647 if (!outputFile || !outputFile->IsOpen()) {
648 Error("CheckESD", "opening output file check.root failed");
649 return kFALSE;
650 }
651 hEff->Write();
652 hResPtInv->Write();
653 hResPhi->Write();
654 hResTheta->Write();
655 hDEdxRight->Write();
656 hDEdxWrong->Write();
657 hResTOFRight->Write();
658 hResTOFWrong->Write();
659 hEPHOS->Write();
660 hEEMCAL->Write();
661 hPtMUON->Write();
662 hMassK0->Write();
663 hMassLambda->Write();
664 hMassLambdaBar->Write();
665 hMassXi->Write();
666 hMassOmega->Write();
667 outputFile->Close();
668 delete outputFile;
669
670 // clean up
671 delete hGen;
672 delete hRec;
673 delete hEff;
674 delete hResPtInv;
675 delete hResPhi;
676 delete hResTheta;
677 delete hDEdxRight;
678 delete hDEdxWrong;
679 delete hResTOFRight;
680 delete hResTOFWrong;
681 delete hEPHOS;
682 delete hEEMCAL;
683 delete hPtMUON;
684 delete hMassK0;
685 delete hMassLambda;
686 delete hMassLambdaBar;
687 delete hMassXi;
688 delete hMassOmega;
689
8b462fd8 690 delete esd;
5e00415f 691 esdFile->Close();
692 delete esdFile;
693
694 runLoader->UnloadHeader();
695 runLoader->UnloadKinematics();
696 delete runLoader;
697
698 // result of check
699 Info("CheckESD", "check of ESD was successfull");
700 return kTRUE;
701}