1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 // An analysis task to check the TRD data in simulated data
18 //*-- Sylwester Radomski
19 //////////////////////////////////////////////////////////////////////////////
24 // tpcz = kTPCout && !kTRDout
27 // trdz = kTRDout && !kTRDref
30 #include "AliTRDQATask.h"
43 //______________________________________________________________________________
44 AliTRDQATask::AliTRDQATask(const char *name) :
45 AliAnalysisTask(name,""),
50 // Input slot #0 works with an Ntuple
51 DefineInput(0, TChain::Class());
52 // Output slot #0 writes into a TH1 container
53 DefineOutput(0, TObjArray::Class()) ;
56 //______________________________________________________________________________
57 void AliTRDQATask::Init(const Option_t *)
59 // Initialisation of branch container and histograms
61 AliInfo(Form("*** Initialization of %s", GetName())) ;
64 fChain = dynamic_cast<TChain *>(GetInputData(0)) ;
66 AliError(Form("Input 0 for %s not found\n", GetName()));
71 // One should first check if the branch address was taken by some other task
72 char ** address = (char **)GetBranchAddress(0, "ESD");
74 fESD = (AliESD *)(*address);
75 AliInfo("Old ESD found.");
79 SetBranchAddress(0, "ESD", &fESD);
80 if (fESD) AliInfo("ESD connected.");
83 // The output objects will be written to
84 TDirectory * cdir = gDirectory ;
85 OpenFile(0, Form("%s.root", GetName()), "RECREATE");
91 fNTracks = new TH1D("ntracks", ";number of all tracks", 500, -0.5, 499.5);
92 fEventSize = new TH1D("evSize", ";event size (MB)", 100, 0, 5);
94 fTrackStatus = new TH1D("trackStatus", ";status bit", 32, -0.5, 31.5);
95 fKinkIndex = new TH1D("kinkIndex", ";kink index", 41, -20.5, 20.5);
97 fParIn = new TH1D("parIn", "Inner Plane", 2, -0.5, 1.5);
98 fParOut = new TH1D("parOut", "Outer Plane", 2, -0.5, 1.5);
100 fXIn = new TH1D("xIn", ";X at the inner plane (cm)", 200, 50, 250);
101 fXOut = new TH1D("xOut", ";X at the outer plane (cm)", 300, 50, 400);
103 const int nNameAlpha = 4;
104 const char *namesAlpha[nNameAlpha] = {"alphaTPCi", "alphaTPCo", "alphaTRDo", "alphaTRDr"};
106 for(int i=0; i<nNameAlpha; i++) {
107 fAlpha[i] = new TH1D(namesAlpha[i], "alpha", 100, -4, 4);
109 fSectorTRD = new TH1D ("sectorTRD", ";sector TRD", 20, -0.5, 19.5);
114 const char *suf[nbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
115 for(int i=0; i<nbits; i++) {
116 fPt[i] = new TH1D(Form("pt%s",suf[i]), ";p_{T} (GeV/c);entries TPC", 50, 0, 10);
117 fTheta[i] = new TH1D(Form("theta%s", suf[i]), "theta (rad)", 100, -4, 4);
118 fSigmaY[i] = new TH1D(Form("sigmaY%s",suf[i]), ";sigma Y (cm)", 200, 0, 1);
119 fChi2[i] = new TH1D(Form("Chi2%s", suf[i]), ";#chi2 / ndf", 100, 0, 10);
120 fPlaneYZ[i] = new TH2D(Form("planeYZ%s", suf[i]), Form("%sy (cm);z (cm)", suf[i]),
121 100, -60, 60, 500, -500, 500);
125 fEffPt[0] = (TH1D*) fPt[0]->Clone(Form("eff_%s_%s", suf[0], suf[1]));
126 fEffPt[1] = (TH1D*) fPt[0]->Clone(Form("eff_%s_%s", suf[1], suf[3]));
127 fEffPt[2] = (TH1D*) fPt[0]->Clone(Form("eff_%s_%s", suf[3], suf[4]));
128 fEffPt[3] = (TH1D*) fPt[0]->Clone(Form("eff_%s_%s", suf[1], suf[4]));
130 for(int i=0; i<4; i++) {
132 fEffPt[i]->SetMarkerStyle(20);
133 fEffPt[i]->SetMinimum(0);
134 fEffPt[i]->SetMaximum(1.1);
138 fClustersTRD[0] = new TH1D("clsTRDo", "TRDo;number of clusters", 130, -0.5, 129.5);;
139 fClustersTRD[1] = new TH1D("clsTRDr", "TRDr;number of clusters", 130, -0.5, 129.5);;
140 fClustersTRD[2] = new TH1D("clsTRDz", "TRDz;number of clusters", 130, -0.5, 129.5);;
142 // for good refitted tracks only
143 fTime = new TH1D("time", ";time bin", 25, -0.5, 24.5);
144 fBudget = new TH1D("budget", ";material budget", 100, 0, 100);
145 fQuality = new TH1D("quality", ";track quality", 100, 0, 1.1);
146 fSignal = new TH1D("signal", ";signal", 100, 0, 1e3);
149 fTrdSigMom = new TH2D("trdSigMom", ";momentum (GeV/c);signal", 100, 0, 3, 100, 0, 1e3);
150 fTpcSigMom = new TH2D("tpcSigMom", ";momentum (GeV/c);signal", 100, 0, 3, 100, 0, 200);
152 const char *pidName[6] = {"El", "Mu", "Pi", "K", "P", "Ch"};
153 for(int i=0; i<6; i++) {
156 fTpcPID[i] = new TH1D(Form("tpcPid%s",pidName[i]), pidName[i], 100, 0, 1.5);
157 fTpcPID[i]->GetXaxis()->SetTitle("probability");
159 fTpcSigMomPID[i] = new TH2D(Form("tpcSigMom%s",pidName[i]), "", 100, 0, 3, 100, 0, 200);
160 fTpcSigMomPID[i]->SetTitle(Form("%s;momentum (GeV/c);signal",pidName[i]));
163 fTrdPID[i] = new TH1D(Form("trdPid%s",pidName[i]), pidName[i], 100, 0, 1.5);
164 fTrdPID[i]->GetXaxis()->SetTitle("probability");
166 fTrdSigMomPID[i] = new TH2D(Form("trdSigMom%s",pidName[i]), "", 100, 0, 3, 100, 0, 1e3);
167 fTrdSigMomPID[i]->SetTitle(Form("%s;momentum (GeV/c);signal",pidName[i]));
171 // create output container
172 fOutputContainer = new TObjArray(80);
174 // register histograms to the container
175 TIter next(gDirectory->GetList());
179 while (obj = next.Next()) {
180 if (obj->InheritsFrom("TH1")) fOutputContainer->AddAt(obj, counter++);
183 AliInfo(Form("Number of histograms = %d", counter));
187 //______________________________________________________________________________
188 void AliTRDQATask::Exec(Option_t *)
192 Long64_t entry = fChain->GetReadEntry() ;
194 // Processing of one event
197 AliError("fESD is not connected to the input!") ;
201 if ( !((entry-1)%100) )
202 AliInfo(Form("%s ----> Processing event # %lld", (dynamic_cast<TChain *>(fChain))->GetFile()->GetName(), entry)) ;
204 int nTracks = fESD->GetNumberOfTracks();
205 fNTracks->Fill(nTracks);
208 for(int i=0; i<nTracks; i++) {
210 AliESDtrack *track = fESD->GetTrack(i);
211 const AliExternalTrackParam *paramOut = track->GetOuterParam();
212 const AliExternalTrackParam *paramIn = track->GetInnerParam();
214 fParIn->Fill(!!paramIn);
215 if (!paramIn) continue;
216 fXIn->Fill(paramIn->GetX());
218 fParOut->Fill(!!paramOut);
219 if (!paramOut) continue;
220 fXOut->Fill(paramOut->GetX());
222 int sector = GetSector(paramOut->GetAlpha());
223 if (!CheckSector(sector)) continue;
224 fSectorTRD->Fill(sector);
226 fKinkIndex->Fill(track->GetKinkIndex(0));
227 if (track->GetKinkIndex(0)) continue;
230 UInt_t status = track->GetStatus();
231 for(int bit=0; bit<32; bit++)
232 if (u<<bit & status) fTrackStatus->Fill(bit);
235 int bit[6] = {0,0,0,0,0,0};
236 bit[0] = status & AliESDtrack::kTPCin;
237 bit[1] = status & AliESDtrack::kTPCout;
238 bit[2] = (status & AliESDtrack::kTPCout) && !(status & AliESDtrack::kTRDout);
239 bit[3] = status & AliESDtrack::kTRDout;
240 bit[4] = status & AliESDtrack::kTRDrefit;
241 bit[5] = (status & AliESDtrack::kTRDout) && !(status & AliESDtrack::kTRDrefit);
244 // transverse momentum
245 const double *val = track->GetParameter(); // parameters at the vertex
246 double pt = 1./TMath::Abs(val[4]);
248 for(int b=0; b<nbits; b++) {
251 fTheta[b]->Fill(val[3]);
252 fSigmaY[b]->Fill(TMath::Sqrt(paramOut->GetSigmaY2()));
253 fChi2[b]->Fill(track->GetTRDchi2()/track->GetTRDncls());
254 fPlaneYZ[b]->Fill(paramOut->GetY(), paramOut->GetZ());
260 fAlpha[0]->Fill(paramIn->GetAlpha());
261 fAlpha[1]->Fill(paramOut->GetAlpha());
264 if (bit[3]) fAlpha[2]->Fill(paramOut->GetAlpha());
265 if (bit[4]) fAlpha[3]->Fill(paramOut->GetAlpha());
268 for(int b=0; b<3; b++)
269 if (bit[3+b]) fClustersTRD[b]->Fill(track->GetTRDncls());
272 if (!bit[4]) continue;
274 fQuality->Fill(track->GetTRDQuality());
275 fBudget->Fill(track->GetTRDBudget());
276 fSignal->Fill(track->GetTRDsignal());
278 fTrdSigMom->Fill(track->GetP(), track->GetTRDsignal());
279 fTpcSigMom->Fill(track->GetP(), track->GetTPCsignal());
282 if (status & AliESDtrack::kTRDpid) {
284 for(int l=0; l<6; l++) fTime->Fill(track->GetTRDTimBin(l));
286 // fill pid histograms
287 double trdr0 = 0, tpcr0 = 0;
288 int trdBestPid = 5, tpcBestPid = 5; // charged
289 const double minPidValue = 0.9;
292 track->GetTPCpid(pp); // ESD inconsequence
294 for(int pid=0; pid<5; pid++) {
296 trdr0 += track->GetTRDpid(pid);
299 fTrdPID[pid]->Fill(track->GetTRDpid(pid));
300 fTpcPID[pid]->Fill(pp[pid]);
302 if (track->GetTRDpid(pid) > minPidValue) trdBestPid = pid;
303 if (pp[pid] > minPidValue) tpcBestPid = pid;
306 fTrdPID[5]->Fill(trdr0); // check unitarity
307 fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
309 fTpcPID[5]->Fill(tpcr0); // check unitarity
310 fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
316 PostData(0, fOutputContainer);
319 //______________________________________________________________________________
320 void AliTRDQATask::Terminate(Option_t *)
322 // Processing when the event loop is ended
323 AliInfo("TRD QA module");
325 // create efficiency histograms
328 PostData(0, fOutputContainer);
336 //______________________________________________________________________________
337 int AliTRDQATask::GetSector(double alpha)
339 // Gets the sector number
341 double size = TMath::DegToRad() * 20.;
342 int sector = (int)((alpha + TMath::Pi())/size);
346 //______________________________________________________________________________
347 int AliTRDQATask::CheckSector(int sector)
349 // Checks the sector number
351 int sec[] = {2,3,5,6,11,12,13,15};
353 for(int i=0; i<nSec; i++)
354 if (sector == sec[i]) return 1;
359 //______________________________________________________________________________
360 void AliTRDQATask::CalculateEff()
362 // calculates the efficiency
364 for(int i=0; i<4; i++) fEffPt[i]->Reset();
366 fEffPt[0]->Add(fPt[1]);
367 fEffPt[0]->Divide(fPt[0]);
369 fEffPt[1]->Add(fPt[3]);
370 fEffPt[1]->Divide(fPt[1]);
372 fEffPt[2]->Add(fPt[4]);
373 fEffPt[2]->Divide(fPt[3]);
375 fEffPt[3]->Add(fPt[4]);
376 fEffPt[3]->Divide(fPt[1]);
379 //______________________________________________________________________________
380 void AliTRDQATask::DrawESD()
384 AliInfo("Plotting....") ;
386 gROOT->SetStyle("Plain");
387 gStyle->SetPalette(1);
388 gStyle->SetOptStat(0);
390 TGaxis::SetMaxDigits(3);
392 gStyle->SetLabelFont(52, "XYZ");
393 gStyle->SetTitleFont(62, "XYZ");
394 gStyle->SetPadRightMargin(0.02);
398 const int nplots = 18;
399 const int nover[nplots] = {1,1,1,4,1,1,1,1,1,1,2,1,1,3,1,1,1,1};
400 const int nnames = 24;
401 const char *names[nnames] = {
402 "ntracks", "kinkIndex", "trackStatus",
403 "ptTPCi", "ptTPCo", "ptTRDo", "ptTRDr", "ptTPCz", "ptTRDz",
404 "eff_TPCi_TPCo", "eff_TPCo_TRDo", "eff_TRDo_TRDr", "eff_TPCo_TRDr",
405 "clsTRDo", "clsTRDr", "clsTRDz",
406 "alphaTPCi", "alphaTPCo", "alphaTRDo", "alphaTRDr", "sectorTRD",
407 "time", "budget", "signal"
410 const int logy[nnames] = {
420 for(int i=0; i<nplots; i++) {
422 new TCanvas(names[i], names[nhist], 500, 300);
423 gPad->SetLogy(logy[i]);
425 for(int j=0; j<nover[i]; j++) {
426 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[nhist++]));
429 if (strstr(hist->GetName(), "eff")) {
430 hist->SetMarkerStyle(20);
432 hist->SetMaximum(1.2);
435 if (!j) hist->Draw();
436 else hist->Draw("SAME");
439 gPad->Print(Form("%s.gif", names[i]));
443 //______________________________________________________________________________
444 void AliTRDQATask::DrawGeoESD()
448 AliInfo("Plotting....") ;
450 gStyle->SetOptStat(0);
451 TGaxis::SetMaxDigits(3);
453 gStyle->SetLabelFont(52, "XYZ");
454 gStyle->SetTitleFont(62, "XYZ");
456 gStyle->SetPadTopMargin(0.06);
457 gStyle->SetTitleBorderSize(0);
460 const int nnames = 7;
461 const char *names[nnames] = {
463 "planeYZTPCo", "planeYZTPCz", "planeYZTRDo", "planeYZTRDr", "planeYZTRDz",
466 const char *opt[nnames] = {
468 "colz","colz", "colz", "colz", "colz"
471 const int logy[nnames] = {
476 for(int i=0; i<nnames; i++) {
478 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[i]));
481 if (i<2) new TCanvas(names[i], names[i], 500, 300);
482 else new TCanvas(names[i], names[i], 300, 900);
484 gPad->SetLogy(logy[i]);
485 if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
488 AliInfo(Form("%s\t%d", names[i], hist->GetEntries()));
490 gPad->Print(Form("%s.gif", names[i]));
494 //______________________________________________________________________________
495 void AliTRDQATask::DrawConvESD()
499 AliInfo("Plotting....") ;
501 gROOT->SetStyle("Plain");
503 gStyle->SetPalette(1);
505 TGaxis::SetMaxDigits(3);
507 gStyle->SetLabelFont(52, "XYZ");
508 gStyle->SetTitleFont(62, "XYZ");
509 gStyle->SetPadRightMargin(0.02);
511 const int nnames = 9;
512 const int nplots = 5;
513 const int nover[nplots] = {3,1,1,3,1};
515 const char *names[nnames] = {
516 "sigmaYTPCo","sigmaYTRDo", "sigmaYTRDr", "sigmaYTPCz", "sigmaYTRDz",
517 "Chi2TPCo", "Chi2TRDo", "Chi2TRDr", "Chi2TRDz"
520 const char *opt[nplots] = {
524 const int logy[nplots] = {
529 for(int i=0; i<nplots; i++) {
531 new TCanvas(names[i], names[i], 500, 300);
532 gPad->SetLogy(logy[i]);
533 if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
535 for(int j=0; j<nover[i]; j++) {
536 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[nhist++]));
537 if (!j) hist->Draw(opt[i]);
538 else hist->Draw("same");
541 gPad->Print(Form("%s.eps", names[i]));
545 //______________________________________________________________________________
546 void AliTRDQATask::DrawPidESD()
550 AliInfo("Plotting....") ;
552 gROOT->SetStyle("Plain");
554 gStyle->SetPalette(1);
555 gStyle->SetOptStat(0);
557 TGaxis::SetMaxDigits(3);
559 gStyle->SetLabelFont(52, "XYZ");
560 gStyle->SetTitleFont(62, "XYZ");
562 gStyle->SetPadTopMargin(0.05);
563 gStyle->SetPadRightMargin(0.02);
567 const int nnames = 27;
568 const char *names[nnames] = {
570 "signal", "trdSigMom", "tpcSigMom",
572 "trdPidEl", "trdPidMu", "trdPidPi", "trdPidK", "trdPidP", "trdPidCh",
573 "trdSigMomEl", "trdSigMomMu", "trdSigMomPi", "trdSigMomK", "trdSigMomP", "trdSigMomCh",
575 "tpcPidEl", "tpcPidMu", "tpcPidPi", "tpcPidK", "tpcPidP", "tpcPidCh",
576 "tpcSigMomEl", "tpcSigMomMu", "tpcSigMomPi", "tpcSigMomK", "tpcSigMomP", "tpcSigMomCh"
580 const char *opt[nnames] = {
584 "", "", "", "", "", "" ,
585 "colz", "colz", "colz", "colz", "colz", "colz",
587 "", "", "", "", "", "" ,
588 "colz", "colz", "colz", "colz", "colz", "colz"
591 const int logy[nnames] = {
602 for(int i=0; i<nnames; i++) {
604 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[i]));
607 new TCanvas(names[i], names[i], 500, 300);
608 gPad->SetLogy(logy[i]);
609 if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
611 if (strstr(names[i],"sigMom")) gPad->SetLogz(1);
612 if (strstr(names[i],"SigMom")) gPad->SetLogz(1);
615 AliInfo(Form("%s\t%d", names[i], hist->GetEntries()));
617 gPad->Print(Form("%s.gif", names[i]));