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 TCanvas * cTRD = new TCanvas("cTRD", "TRD ESD Test", 400, 10, 600, 700) ;
389 gROOT->SetStyle("Plain");
390 gStyle->SetPalette(1);
391 gStyle->SetOptStat(0);
393 TGaxis::SetMaxDigits(3);
395 gStyle->SetLabelFont(52, "XYZ");
396 gStyle->SetTitleFont(62, "XYZ");
397 gStyle->SetPadRightMargin(0.02);
401 const int nplots = 18;
402 const int nover[nplots] = {1,1,1,4,1,1,1,1,1,1,2,1,1,3,1,1,1,1};
403 const int nnames = 24;
404 const char *names[nnames] = {
405 "ntracks", "kinkIndex", "trackStatus",
406 "ptTPCi", "ptTPCo", "ptTRDo", "ptTRDr", "ptTPCz", "ptTRDz",
407 "eff_TPCi_TPCo", "eff_TPCo_TRDo", "eff_TRDo_TRDr", "eff_TPCo_TRDr",
408 "clsTRDo", "clsTRDr", "clsTRDz",
409 "alphaTPCi", "alphaTPCo", "alphaTRDo", "alphaTRDr", "sectorTRD",
410 "time", "budget", "signal"
413 const int logy[nnames] = {
423 for(int i=0; i<nplots; i++) {
426 // new TCanvas(names[i], names[nhist], 500, 300);
427 gPad->SetLogy(logy[i]);
429 for(int j=0; j<nover[i]; j++) {
430 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[nhist++]));
433 if (strstr(hist->GetName(), "eff")) {
434 hist->SetMarkerStyle(20);
436 hist->SetMaximum(1.2);
439 if (!j) hist->Draw();
440 else hist->Draw("SAME");
443 cTRD->Print("TRD_ESD.gif");
446 //______________________________________________________________________________
447 void AliTRDQATask::DrawGeoESD()
451 AliInfo("Plotting....") ;
453 TCanvas * cTRDGeo = new TCanvas("cTRDGeo", "TRD ESDGeo Test", 400, 10, 600, 700) ;
454 cTRDGeo->Divide(4,2) ;
456 gStyle->SetOptStat(0);
457 TGaxis::SetMaxDigits(3);
459 gStyle->SetLabelFont(52, "XYZ");
460 gStyle->SetTitleFont(62, "XYZ");
462 gStyle->SetPadTopMargin(0.06);
463 gStyle->SetTitleBorderSize(0);
466 const int nnames = 7;
467 const char *names[nnames] = {
469 "planeYZTPCo", "planeYZTPCz", "planeYZTRDo", "planeYZTRDr", "planeYZTRDz",
472 const char *opt[nnames] = {
474 "colz","colz", "colz", "colz", "colz"
477 const int logy[nnames] = {
482 for(int i=0; i<nnames; i++) {
484 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[i]));
487 //if (i<2) new TCanvas(names[i], names[i], 500, 300);
488 //else new TCanvas(names[i], names[i], 300, 900);
490 gPad->SetLogy(logy[i]);
491 if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
494 AliInfo(Form("%s\t%d", names[i], hist->GetEntries()));
497 cTRDGeo->Print("TRD_Geo.gif");
500 //______________________________________________________________________________
501 void AliTRDQATask::DrawConvESD()
505 AliInfo("Plotting....") ;
506 TCanvas * cTRDConv = new TCanvas("cTRDConv", "TRD ESDConv Test", 400, 10, 600, 700) ;
507 cTRDConv->Divide(3,2) ;
509 gROOT->SetStyle("Plain");
511 gStyle->SetPalette(1);
513 TGaxis::SetMaxDigits(3);
515 gStyle->SetLabelFont(52, "XYZ");
516 gStyle->SetTitleFont(62, "XYZ");
517 gStyle->SetPadRightMargin(0.02);
519 const int nnames = 9;
520 const int nplots = 5;
521 const int nover[nplots] = {3,1,1,3,1};
523 const char *names[nnames] = {
524 "sigmaYTPCo","sigmaYTRDo", "sigmaYTRDr", "sigmaYTPCz", "sigmaYTRDz",
525 "Chi2TPCo", "Chi2TRDo", "Chi2TRDr", "Chi2TRDz"
528 const char *opt[nplots] = {
532 const int logy[nplots] = {
537 for(int i=0; i<nplots; i++) {
539 //new TCanvas(names[i], names[i], 500, 300);
540 gPad->SetLogy(logy[i]);
541 if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
543 for(int j=0; j<nover[i]; j++) {
544 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[nhist++]));
545 if (!j) hist->Draw(opt[i]);
546 else hist->Draw("same");
550 cTRDConv->Print("TRD_Conv.eps");
553 //______________________________________________________________________________
554 void AliTRDQATask::DrawPidESD()
558 AliInfo("Plotting....") ;
559 TCanvas * cTRDPid = new TCanvas("cTRDPid", "TRD ESDPid Test", 400, 10, 600, 700) ;
560 cTRDPid->Divide(9,3) ;
562 gROOT->SetStyle("Plain");
564 gStyle->SetPalette(1);
565 gStyle->SetOptStat(0);
567 TGaxis::SetMaxDigits(3);
569 gStyle->SetLabelFont(52, "XYZ");
570 gStyle->SetTitleFont(62, "XYZ");
572 gStyle->SetPadTopMargin(0.05);
573 gStyle->SetPadRightMargin(0.02);
577 const int nnames = 27;
578 const char *names[nnames] = {
580 "signal", "trdSigMom", "tpcSigMom",
582 "trdPidEl", "trdPidMu", "trdPidPi", "trdPidK", "trdPidP", "trdPidCh",
583 "trdSigMomEl", "trdSigMomMu", "trdSigMomPi", "trdSigMomK", "trdSigMomP", "trdSigMomCh",
585 "tpcPidEl", "tpcPidMu", "tpcPidPi", "tpcPidK", "tpcPidP", "tpcPidCh",
586 "tpcSigMomEl", "tpcSigMomMu", "tpcSigMomPi", "tpcSigMomK", "tpcSigMomP", "tpcSigMomCh"
590 const char *opt[nnames] = {
594 "", "", "", "", "", "" ,
595 "colz", "colz", "colz", "colz", "colz", "colz",
597 "", "", "", "", "", "" ,
598 "colz", "colz", "colz", "colz", "colz", "colz"
601 const int logy[nnames] = {
612 for(int i=0; i<nnames; i++) {
615 TH1D *hist = dynamic_cast<TH1D*>(gDirectory->FindObject(names[i]));
618 //new TCanvas(names[i], names[i], 500, 300);
619 gPad->SetLogy(logy[i]);
620 if (strstr(opt[i],"colz")) gPad->SetRightMargin(0.1);
622 if (strstr(names[i],"sigMom")) gPad->SetLogz(1);
623 if (strstr(names[i],"SigMom")) gPad->SetLogz(1);
626 AliInfo(Form("%s\t%d", names[i], hist->GetEntries()));
628 cTRDPid->Print("TRD_Pid.gif");