Additional protection
[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");
224 TH1F* hEEMCAL = CreateHisto("hEEMCAL", "EMCAL", 100, 0, 2, "E [GeV]", "N");
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);
f980f8fb 385 v0->ChangeMassHypothesis(kK0Short);
386 hMassK0->Fill(v0->GetEffMass());
387 v0->ChangeMassHypothesis(kLambda0);
388 hMassLambda->Fill(v0->GetEffMass());
389 v0->ChangeMassHypothesis(kLambda0Bar);
390 hMassLambdaBar->Fill(v0->GetEffMass());
5e00415f 391
392 Int_t negLabel = TMath::Abs(esd->GetTrack(v0->GetNindex())->GetLabel());
393 if (negLabel > stack->GetNtrack()) continue; // background
394 Int_t negMother = stack->Particle(negLabel)->GetMother(0);
395 if (negMother < 0) continue;
f980f8fb 396 Int_t posLabel = TMath::Abs(esd->GetTrack(v0->GetPindex())->GetLabel());
5e00415f 397 if (posLabel > stack->GetNtrack()) continue; // background
398 Int_t posMother = stack->Particle(posLabel)->GetMother(0);
399 if (negMother != posMother) continue;
400 TParticle* particle = stack->Particle(negMother);
401 if (!selV0s.Contains(particle)) continue;
402 selV0s.Remove(particle);
403 nRecV0s++;
404 }
405
406 // loop over Cascades
407 for (Int_t iCascade = 0; iCascade < esd->GetNumberOfCascades();
408 iCascade++) {
409 AliESDcascade* cascade = esd->GetCascade(iCascade);
f980f8fb 410 Double_t v0q;
411 cascade->ChangeMassHypothesis(v0q,kXiMinus);
412 hMassXi->Fill(cascade->GetEffMass());
413 cascade->ChangeMassHypothesis(v0q,kOmegaMinus);
414 hMassOmega->Fill(cascade->GetEffMass());
5e00415f 415
416 Int_t negLabel = TMath::Abs(esd->GetTrack(cascade->GetNindex())
417 ->GetLabel());
418 if (negLabel > stack->GetNtrack()) continue; // background
419 Int_t negMother = stack->Particle(negLabel)->GetMother(0);
420 if (negMother < 0) continue;
f980f8fb 421 Int_t posLabel = TMath::Abs(esd->GetTrack(cascade->GetPindex())
5e00415f 422 ->GetLabel());
423 if (posLabel > stack->GetNtrack()) continue; // background
424 Int_t posMother = stack->Particle(posLabel)->GetMother(0);
425 if (negMother != posMother) continue;
426 Int_t v0Mother = stack->Particle(negMother)->GetMother(0);
427 if (v0Mother < 0) continue;
428 Int_t bacLabel = TMath::Abs(esd->GetTrack(cascade->GetBindex())
429 ->GetLabel());
430 if (bacLabel > stack->GetNtrack()) continue; // background
431 Int_t bacMother = stack->Particle(bacLabel)->GetMother(0);
432 if (v0Mother != bacMother) continue;
433 TParticle* particle = stack->Particle(v0Mother);
434 if (!selCascades.Contains(particle)) continue;
435 selCascades.Remove(particle);
436 nRecCascades++;
437 }
438 }
439
440 // perform checks
441 if (nGen < checkNGenLow) {
442 Warning("CheckESD", "low number of generated particles: %d", Int_t(nGen));
443 }
444
445 TH1F* hEff = CreateEffHisto(hGen, hRec);
446
447 Info("CheckESD", "%d out of %d tracks reconstructed including %d "
448 "fake tracks", nRec, nGen, nFake);
449 if (nGen > 0) {
450 // efficiency
451 Double_t eff = nRec*1./nGen;
452 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGen);
453 Double_t fake = nFake*1./nGen;
454 Double_t fakeError = TMath::Sqrt(fake*(1.-fake) / nGen);
455 Info("CheckESD", "eff = (%.1f +- %.1f) %% fake = (%.1f +- %.1f) %%",
456 100.*eff, 100.*effError, 100.*fake, 100.*fakeError);
457
458 if (eff < checkEffLow - checkEffSigma*effError) {
459 Warning("CheckESD", "low efficiency: (%.1f +- %.1f) %%",
460 100.*eff, 100.*effError);
461 }
462 if (fake > checkFakeHigh + checkFakeSigma*fakeError) {
463 Warning("CheckESD", "high fake: (%.1f +- %.1f) %%",
464 100.*fake, 100.*fakeError);
465 }
466
467 // resolutions
468 Double_t res, resError;
469 if (FitHisto(hResPtInv, res, resError)) {
470 Info("CheckESD", "relative inverse pt resolution = (%.1f +- %.1f) %%",
471 res, resError);
472 if (res > checkResPtInvHigh + checkResPtInvSigma*resError) {
473 Warning("CheckESD", "bad pt resolution: (%.1f +- %.1f) %%",
474 res, resError);
475 }
476 }
477
478 if (FitHisto(hResPhi, res, resError)) {
479 Info("CheckESD", "phi resolution = (%.1f +- %.1f) mrad", res, resError);
480 if (res > checkResPhiHigh + checkResPhiSigma*resError) {
481 Warning("CheckESD", "bad phi resolution: (%.1f +- %.1f) mrad",
482 res, resError);
483 }
484 }
485
486 if (FitHisto(hResTheta, res, resError)) {
487 Info("CheckESD", "theta resolution = (%.1f +- %.1f) mrad",
488 res, resError);
489 if (res > checkResThetaHigh + checkResThetaSigma*resError) {
490 Warning("CheckESD", "bad theta resolution: (%.1f +- %.1f) mrad",
491 res, resError);
492 }
493 }
494
495 // PID
496 if (nRec > 0) {
497 Double_t eff = nIdentified*1./nRec;
498 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nRec);
499 Info("CheckESD", "PID eff = (%.1f +- %.1f) %%",
500 100.*eff, 100.*effError);
501 if (eff < checkPIDEffLow - checkPIDEffSigma*effError) {
502 Warning("CheckESD", "low PID efficiency: (%.1f +- %.1f) %%",
503 100.*eff, 100.*effError);
504 }
505 }
506
507 printf("%9s:", "gen\\rec");
5fed899a 508 for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
5e00415f 509 printf("%9s", partName[iRec]);
510 }
511 printf("\n");
5fed899a 512 for (Int_t iGen = 0; iGen < AliPID::kSPECIES+1; iGen++) {
5e00415f 513 printf("%9s:", partName[iGen]);
5fed899a 514 for (Int_t iRec = 0; iRec < AliPID::kSPECIES; iRec++) {
5e00415f 515 printf("%9d", identified[iGen][iRec]);
516 }
517 printf("\n");
518 }
519
520 if (FitHisto(hResTOFRight, res, resError)) {
521 Info("CheckESD", "TOF resolution = (%.1f +- %.1f) ps", res, resError);
522 if (res > checkResTOFHigh + checkResTOFSigma*resError) {
523 Warning("CheckESD", "bad TOF resolution: (%.1f +- %.1f) ps",
524 res, resError);
525 }
526 }
527
528 // calorimeters
529 if (hEPHOS->Integral() < checkPHOSNLow) {
530 Warning("CheckESD", "low number of PHOS particles: %d",
531 Int_t(hEPHOS->Integral()));
532 } else {
533 Double_t mean = hEPHOS->GetMean();
534 if (mean < checkPHOSEnergyLow) {
535 Warning("CheckESD", "low mean PHOS energy: %.1f GeV", mean);
536 } else if (mean > checkPHOSEnergyHigh) {
537 Warning("CheckESD", "high mean PHOS energy: %.1f GeV", mean);
538 }
539 }
540
541 if (hEEMCAL->Integral() < checkEMCALNLow) {
542 Warning("CheckESD", "low number of EMCAL particles: %d",
543 Int_t(hEEMCAL->Integral()));
544 } else {
545 Double_t mean = hEEMCAL->GetMean();
546 if (mean < checkEMCALEnergyLow) {
547 Warning("CheckESD", "low mean EMCAL energy: %.1f GeV", mean);
548 } else if (mean > checkEMCALEnergyHigh) {
549 Warning("CheckESD", "high mean EMCAL energy: %.1f GeV", mean);
550 }
551 }
552
553 // muons
554 if (hPtMUON->Integral() < checkMUONNLow) {
555 Warning("CheckESD", "low number of MUON particles: %d",
556 Int_t(hPtMUON->Integral()));
557 } else {
558 Double_t mean = hPtMUON->GetMean();
559 if (mean < checkMUONPtLow) {
560 Warning("CheckESD", "low mean MUON pt: %.1f GeV/c", mean);
561 } else if (mean > checkMUONPtHigh) {
562 Warning("CheckESD", "high mean MUON pt: %.1f GeV/c", mean);
563 }
564 }
565
566 // V0s
567 if (nGenV0s > 0) {
568 Double_t eff = nRecV0s*1./nGenV0s;
569 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenV0s);
570 if (effError == 0) effError = checkV0EffLow / TMath::Sqrt(1.*nGenV0s);
571 Info("CheckESD", "V0 eff = (%.1f +- %.1f) %%",
572 100.*eff, 100.*effError);
573 if (eff < checkV0EffLow - checkV0EffSigma*effError) {
574 Warning("CheckESD", "low V0 efficiency: (%.1f +- %.1f) %%",
575 100.*eff, 100.*effError);
576 }
577 }
578
579 // Cascades
580 if (nGenCascades > 0) {
581 Double_t eff = nRecCascades*1./nGenCascades;
582 Double_t effError = TMath::Sqrt(eff*(1.-eff) / nGenCascades);
583 if (effError == 0) effError = checkV0EffLow /
584 TMath::Sqrt(1.*nGenCascades);
585 Info("CheckESD", "Cascade eff = (%.1f +- %.1f) %%",
586 100.*eff, 100.*effError);
587 if (eff < checkCascadeEffLow - checkCascadeEffSigma*effError) {
588 Warning("CheckESD", "low Cascade efficiency: (%.1f +- %.1f) %%",
589 100.*eff, 100.*effError);
590 }
591 }
592 }
593
594 // draw the histograms if not in batch mode
595 if (!gROOT->IsBatch()) {
596 new TCanvas;
597 hEff->DrawCopy();
598 new TCanvas;
599 hResPtInv->DrawCopy("E");
600 new TCanvas;
601 hResPhi->DrawCopy("E");
602 new TCanvas;
603 hResTheta->DrawCopy("E");
604 new TCanvas;
605 hDEdxRight->DrawCopy();
606 hDEdxWrong->DrawCopy("SAME");
607 new TCanvas;
608 hResTOFRight->DrawCopy("E");
609 hResTOFWrong->DrawCopy("SAME");
610 new TCanvas;
611 hEPHOS->DrawCopy("E");
612 new TCanvas;
613 hEEMCAL->DrawCopy("E");
614 new TCanvas;
615 hPtMUON->DrawCopy("E");
616 new TCanvas;
617 hMassK0->DrawCopy("E");
618 new TCanvas;
619 hMassLambda->DrawCopy("E");
620 new TCanvas;
621 hMassLambdaBar->DrawCopy("E");
622 new TCanvas;
623 hMassXi->DrawCopy("E");
624 new TCanvas;
625 hMassOmega->DrawCopy("E");
626 }
627
628 // write the output histograms to a file
629 TFile* outputFile = TFile::Open("check.root", "recreate");
630 if (!outputFile || !outputFile->IsOpen()) {
631 Error("CheckESD", "opening output file check.root failed");
632 return kFALSE;
633 }
634 hEff->Write();
635 hResPtInv->Write();
636 hResPhi->Write();
637 hResTheta->Write();
638 hDEdxRight->Write();
639 hDEdxWrong->Write();
640 hResTOFRight->Write();
641 hResTOFWrong->Write();
642 hEPHOS->Write();
643 hEEMCAL->Write();
644 hPtMUON->Write();
645 hMassK0->Write();
646 hMassLambda->Write();
647 hMassLambdaBar->Write();
648 hMassXi->Write();
649 hMassOmega->Write();
650 outputFile->Close();
651 delete outputFile;
652
653 // clean up
654 delete hGen;
655 delete hRec;
656 delete hEff;
657 delete hResPtInv;
658 delete hResPhi;
659 delete hResTheta;
660 delete hDEdxRight;
661 delete hDEdxWrong;
662 delete hResTOFRight;
663 delete hResTOFWrong;
664 delete hEPHOS;
665 delete hEEMCAL;
666 delete hPtMUON;
667 delete hMassK0;
668 delete hMassLambda;
669 delete hMassLambdaBar;
670 delete hMassXi;
671 delete hMassOmega;
672
8b462fd8 673 delete esd;
5e00415f 674 esdFile->Close();
675 delete esdFile;
676
677 runLoader->UnloadHeader();
678 runLoader->UnloadKinematics();
679 delete runLoader;
680
681 // result of check
682 Info("CheckESD", "check of ESD was successfull");
683 return kTRUE;
684}