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