]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDQADataMaker.cxx
Bug fix by Yves
[u/mrichter/AliRoot.git] / TRD / AliTRDQADataMaker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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 /* $Id$ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
20 // Produces the data needed to calculate the quality assurance.           //
21 // All data must be mergeable objects.                                    //
22 // S.Radomski Uni-Heidelberg October 2007                                 //
23 //                                                                        //
24 ////////////////////////////////////////////////////////////////////////////
25
26 // --- ROOT system ---
27 #include <TClonesArray.h>
28 #include <TFile.h> 
29 #include <TH1D.h> 
30 #include <TH2D.h>
31 #include <TProfile.h>
32
33 // --- AliRoot header files ---
34 #include "AliESDEvent.h"
35 #include "AliLog.h"
36 #include "AliTRDdigit.h"
37 #include "AliTRDhit.h"
38 #include "AliTRDcluster.h"
39 #include "AliTRDQADataMaker.h"
40 #include "AliTRDdigitsManager.h"
41 #include "AliTRDgeometry.h"
42 #include "AliTRDdataArrayI.h"
43 #include "AliTRDRawStreamV2.h"
44
45 ClassImp(AliTRDQADataMaker)
46            
47 //____________________________________________________________________________ 
48   AliTRDQADataMaker::AliTRDQADataMaker() : 
49   AliQADataMaker(AliQA::GetDetName(AliQA::kTRD), "TRD Quality Assurance Data Maker")
50 {
51   // ctor
52 }
53
54 //____________________________________________________________________________ 
55 AliTRDQADataMaker::AliTRDQADataMaker(const AliTRDQADataMaker& qadm) :
56   AliQADataMaker()
57 {
58   //copy ctor 
59   SetName((const char*)qadm.GetName()) ; 
60   SetTitle((const char*)qadm.GetTitle()); 
61 }
62
63 //__________________________________________________________________
64 AliTRDQADataMaker& AliTRDQADataMaker::operator = (const AliTRDQADataMaker& qadm )
65 {
66   // Equal operator.
67   this->~AliTRDQADataMaker();
68   new(this) AliTRDQADataMaker(qadm);
69   return *this;
70 }
71  
72 //____________________________________________________________________________ 
73 void AliTRDQADataMaker::EndOfDetectorCycle()
74 {
75   //Detector specific actions at end of cycle
76
77   // Rec points
78   
79 }
80
81 //____________________________________________________________________________ 
82 void AliTRDQADataMaker::InitESDs()
83 {
84   //
85   // create ESDs histograms in ESDs subdir
86   //
87
88   const Int_t nhist = 21;
89   TH1 *hist[nhist];
90   Int_t histoCounter = -1 ;   
91
92   hist[++histoCounter] = new TH1D("qaTRD_esd_ntracks", ":Number of tracks", 300, -0.5, 299.5);
93   hist[++histoCounter] = new TH1D("qaTRD_esd_sector", ":Sector", 18, -0.5, 17.7);
94   hist[++histoCounter] = new TH1D("qaTRD_esd_bits", ";Bits", 64, -0.5, 63.5);
95
96   const Int_t knbits = 6;
97   const char *suf[knbits] = {"TPCi", "TPCo", "TPCz", "TRDo", "TRDr", "TRDz"};
98
99   
100   for(Int_t i=0; i<knbits; i++) {
101     hist[++histoCounter] = new TH1D(Form("qaTRD_esd_pt%s",suf[i]), ";p_{T} (GeV/c);", 50, 0, 10);
102     hist[++histoCounter] = new TH1D(Form("qaTRD_esd_trdz%s", suf[i]), ";z (cm)", 200, -400, 400); 
103   }
104
105   // 3 + 14 = 17
106   hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDo", "TRDo;number of clusters", 130, -0.5, 129.5);;
107   hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDr", "TRDr;number of clusters", 130, -0.5, 129.5);;
108   hist[++histoCounter] = new TH1D("qaTRD_esd_clsTRDz", "TRDz;number of clusters", 130, -0.5, 129.5);;
109   hist[++histoCounter] = new TH1D("qaTRD_esd_clsRatio", ";cluster ratio", 100, 0., 1.3);;
110
111   hist[++histoCounter] = new TH2D("qaTRD_esd_sigMom", ";momentum (GeV/c);signal", 100, 0, 5, 200, 0, 1e3);
112
113   for(Int_t i=0; i<=histoCounter; i++) {
114     //hist[i]->Sumw2();
115     Add2ESDsList(hist[i], i);
116   }
117 }
118
119 //____________________________________________________________________________ 
120 void AliTRDQADataMaker::InitHits()
121 {
122   // create Hits histograms in Hits subdir
123   const Int_t nhist = 4;
124   TH1D *hist[nhist];
125   
126   hist[0] = new TH1D("qaTRD_hits_det", ";Detector Id of the hit", 540, -0.5, 539.5) ; 
127   
128   hist[1] = new TH1D("qaTRD_hist_Qdrift", ";Charge from tracks", 100, 0, 100);
129   hist[2] = new TH1D("qaTRD_hist_Qamp", ";Charge from TRD photon", 100, 0, 100);
130   hist[3] = new TH1D("qaTRD_hist_Qphoton", ";Charge from TRD photon", 100, 0, 100);
131
132   for(Int_t i=0; i<nhist; i++) {
133     //hist[i]->Sumw2();
134     Add2HitsList(hist[i], i);
135   }
136 }
137
138 //____________________________________________________________________________ 
139 void AliTRDQADataMaker::InitDigits()
140 {
141   // create Digits histograms in Digits subdir
142   
143   const Int_t nhist = 3;
144   TH1D *hist[nhist];
145   
146   hist[0] = new TH1D("qaTRD_digits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
147   hist[1] = new TH1D("qaTRD_digits_time", ";Time bin", 40, -0.5, 39.5);
148   hist[2] = new TH1D("qaTRD_digits_amp", ";Amplitude", 100, 0, 100.);
149
150   for(Int_t i=0; i<nhist; i++) {
151     hist[i]->Sumw2();
152     Add2DigitsList(hist[i], i);
153   }
154
155 }
156
157 //____________________________________________________________________________ 
158 void AliTRDQADataMaker::InitRecPoints()
159 {
160   // create Reconstructed Points histograms in RecPoints subdir
161   const Int_t nhist = 12;
162   TH1 *hist[nhist];
163
164   hist[0] = new TH1D("qaTRD_recPoints_det", ";Detector ID of the cluster", 540, -0.5, 539.5);
165   hist[1] = new TH2D("qaTRD_recPoints_amp", ";Amplitude", 540, -0.5, 539, 200, -0.5, 199.5);
166   hist[2] = new TH1D("qaTRD_recPoints_npad", ";Number of Pads", 12, -0.5, 11.5);
167  
168   hist[3] = new TH1D("qaTRD_recPoints_dist2", ";residuals [2pad]", 100, -1, 1);
169   hist[4] = new TH1D("qaTRD_recPoints_dist3", ";residuals [3pad]", 100, -1, 1);
170   hist[5] = new TH1D("qaTRD_recPoints_dist4", ";residuals [4pad]", 100, -1, 1);
171   hist[6] = new TH1D("qaTRD_recPoints_dist5", ";residuals [5pad]", 100, -1, 1);
172
173   hist[7] = new TH2D("qaTRD_recPoints_rowCol", ";row;col", 16, -0.5, 15.5, 145, -0.5, 144.5);
174   hist[8] = new TH1D("qaTRD_recPoints_time", ";time bin", 35, -0.5, 34.5);
175   hist[9] = new TH1D("qaTRD_recPoints_nCls", ";number of clusters", 500, -0.5, 499.5);
176
177   hist[10] = new TProfile("qaTRD_recPoints_sigTime", ";time bin;signal", 35, -0.5, 34.5, 0, 200, "");
178   hist[11] = new TProfile("qaTRD_recPoints_prf", ";distance;center of gravity", 120, -0.6, 0.6, -1.2, 1.2, "");
179
180   hist[12] = new TH1D("qaTRD_recPoints_ampDist", ";amplitude MPV", 100, 0, 100);
181
182
183   for(Int_t i=0; i<nhist; i++) {
184     //hist[i]->Sumw2();
185     Add2RecPointsList(hist[i], i);
186   }
187 }
188
189 //____________________________________________________________________________ 
190 void AliTRDQADataMaker::InitRaws()
191 {
192   // create Raws histograms in Raws subdir
193   const Int_t kSM = 18;
194   const Int_t nhist = 6+kSM;
195   TH1D *hist[nhist];
196  
197   hist[0] = new TH1D("qaTRD_raws_det", ";detector", 540, -0.5, 539.5);
198   hist[1] = new TH1D("qaTRD_raws_sig", ";signal", 100, -0.5, 99.5);
199   hist[2] = new TH1D("qaTRD_raws_sigCentral", "; signal central bin", 100, -0.5, 99.5);
200   hist[3] = new TH1D("qaTRD_raws_sigTail", ";signal cluster", 100, -0.5, 99.5);
201   hist[4] = new TH1D("qaTRD_raws_tiemBin", ";time bin", 40, -0.5, 39.5); 
202   hist[5] = new TH1D("qaTRD_rows_smId", ";supermodule", 18, -0.5, 17.5);
203
204   // one char per ADC chanell
205   const Int_t nADC = 30 * 8 * 16 * 22;
206   for(Int_t i=0; i<kSM; i++)
207     hist[6+i] = new TH1D(Form("qaTRD_raws_sm%d",i),"",nADC, -0.5, nADC-0.5); 
208
209   for(Int_t i=0; i<nhist; i++) {
210     //hist[i]->Sumw2();
211     Add2RawsList(hist[i], i);
212   }
213 }
214
215 //____________________________________________________________________________ 
216 void AliTRDQADataMaker::InitSDigits()
217 {
218   // create SDigits histograms in SDigits subdir
219   
220   const Int_t nhist = 3;
221   TH1D *hist[nhist];
222   
223   hist[0] = new TH1D("qaTRD_sdigits_det", ";Detector Id of the digit", 540, -0.5, 539.5);
224   hist[1] = new TH1D("qaTRD_sdigits_time", ";Time bin", 40, -0.5, 39.5);
225   hist[2] = new TH1D("qaTRD_sdigits_amp", ";Amplitude", 100, 0, 1e7);
226
227   for(Int_t i=0; i<nhist; i++) {
228     hist[i]->Sumw2();
229     Add2SDigitsList(hist[i], i);
230   }
231 }
232
233 //____________________________________________________________________________
234 void AliTRDQADataMaker::MakeESDs(AliESDEvent * esd)
235 {
236   // make QA data from ESDs
237   Int_t nTracks = esd->GetNumberOfTracks();
238   GetESDsData(0)->Fill(nTracks);
239   
240   // track loop
241   for(Int_t i=0; i<nTracks; i++) {
242     
243     AliESDtrack *track = esd->GetTrack(i);
244     const AliExternalTrackParam *paramOut = track->GetOuterParam();
245     const AliExternalTrackParam *paramIn = track->GetInnerParam();
246
247     // long track ..
248     if (!paramIn) continue;
249     if (!paramOut) continue;
250
251     // not a kink
252     if (track->GetKinkIndex(0) > 0) continue; 
253
254     Double_t extZ = GetExtZ(paramIn);
255     if (TMath::Abs(extZ) > 320) continue; // acceptance cut
256
257     // .. in the acceptance
258     Int_t sector = GetSector(paramOut->GetAlpha());
259     GetESDsData(1)->Fill(sector);
260
261     UInt_t u = 1;
262     UInt_t status = track->GetStatus();
263     for(Int_t bit=0; bit<32; bit++) 
264       if (u<<bit & status) GetESDsData(2)->Fill(bit);
265
266     const Int_t knbits = 6; 
267     Int_t bit[6] = {0,0,0,0,0,0};    
268     bit[0] = status & AliESDtrack::kTPCin;
269     bit[1] = status & AliESDtrack::kTPCout;
270     bit[2] = (status & AliESDtrack::kTPCout) && !(status & AliESDtrack::kTRDout);
271     bit[3] = status & AliESDtrack::kTRDout;
272     bit[4] = status & AliESDtrack::kTRDrefit;
273     bit[5] = (status & AliESDtrack::kTRDout) && !(status & AliESDtrack::kTRDrefit);
274
275     // transverse momentum
276     //const Double_t *val = paramOut->GetParameter(); // parameters at the Outer plane
277     Double_t pt = paramOut->Pt(); //1./TMath::Abs(val[4]);
278
279     for(Int_t b=0; b<knbits; b++) {
280       if (bit[b]) {
281         GetESDsData(2*b+3)->Fill(pt); 
282         GetESDsData(2*b+4)->Fill(extZ);
283       }
284     }
285
286     // clusters
287     for(Int_t b=0; b<3; b++) 
288       if (bit[3+b]) GetESDsData(b+15)->Fill(track->GetTRDncls());
289
290     // refitted only
291     if (!bit[4]) continue;
292
293     //fQuality->Fill(track->GetTRDQuality());
294     //fBudget->Fill(track->GetTRDBudget());
295     //fSignal->Fill(track->GetTRDsignal());
296         
297     GetESDsData(18)->Fill(track->GetP(), track->GetTRDsignal());
298
299     /*
300     // PID only
301     if (status & AliESDtrack::kTRDpid) {
302       
303       for(Int_t l=0; l<6; l++) fTime->Fill(track->GetTRDTimBin(l));
304
305       // fill pid histograms
306       Double_t trdr0 = 0; //, tpcr0 = 0;
307       Int_t trdBestPid = 5; //, tpcBestPid = 5;  // charged
308       const Double_t kminPidValue = 0.9;
309
310       //Double_t pp[5];
311       //track->GetTPCpid(pp); // ESD inconsequence
312
313       for(Int_t pid=0; pid<5; pid++) {
314         
315         trdr0 += track->GetTRDpid(pid);
316         //tpcr0 += pp[pid];
317         
318         fTrdPID[pid]->Fill(track->GetTRDpid(pid));
319         //fTpcPID[pid]->Fill(pp[pid]);
320         
321         if (track->GetTRDpid(pid) > kminPidValue) trdBestPid = pid;
322         //if (pp[pid] > kminPidValue) tpcBestPid = pid;
323       }
324       
325       fTrdPID[5]->Fill(trdr0); // check unitarity
326       fTrdSigMomPID[trdBestPid]->Fill(track->GetP(), track->GetTRDsignal());
327       
328       //fTpcPID[5]->Fill(tpcr0); // check unitarity
329       //fTpcSigMomPID[tpcBestPid]->Fill(track->GetP(), track->GetTPCsignal());
330     }
331     */
332     
333   }
334
335
336
337 }
338
339 //______________________________________________________________________________
340 Int_t AliTRDQADataMaker::GetSector(const Double_t alpha) const {
341   // Gets the sector number 
342
343   Double_t size = TMath::DegToRad() * 20.; // shall use TRDgeo
344   Int_t sector = (Int_t)((alpha + TMath::Pi())/size);
345   return sector;
346 }
347
348 //______________________________________________________________________________
349 Double_t AliTRDQADataMaker::GetExtZ(const AliExternalTrackParam *in) const {
350   //
351   // returns the Z position at the entry to TRD
352   // using parameters from the TPC in
353   //
354
355   const Double_t x0 = 300;
356
357   Double_t x = in->GetX();
358   const Double_t *par = in->GetParameter();
359   Double_t theta = par[3];
360   Double_t z = in->GetZ();
361   
362   Double_t zz = z + (x0-x) * TMath::Tan(theta);
363   return zz;
364 }
365
366 //____________________________________________________________________________
367 void AliTRDQADataMaker::MakeHits(TClonesArray * hits)
368 {
369   //make QA data from Hits
370   //printf("making QA for TRD hits from an array %d\n", hits->GetEntriesFast());
371
372   TIter next(hits); 
373   AliTRDhit * hit; 
374   
375   while ( (hit = dynamic_cast<AliTRDhit *>(next())) ) {
376     GetHitsData(0)->Fill(hit->GetDetector());
377     Double_t q = TMath::Abs(hit->GetCharge());
378     
379     if (hit->FromDrift()) GetHitsData(1)->Fill(q);
380     if (hit->FromAmplification()) GetHitsData(2)->Fill(q);
381     if (hit->FromTRphoton()) GetHitsData(3)->Fill(q);
382   }
383
384 }
385
386 //____________________________________________________________________________
387 void AliTRDQADataMaker::MakeHits(TTree * hitTree)
388 {
389   //make QA data from Hits
390   //printf("making QA for TRD hits from a tree\n");
391   
392   if (!CheckPointer(hitTree, "TRD hits tree")) return;
393  
394   TBranch *branch = hitTree->GetBranch("TRD");
395   if (!CheckPointer(branch, "TRD hits branch")) return;
396  
397   Int_t nhits = (Int_t)(hitTree->GetTotBytes()/sizeof(AliTRDhit));
398   TClonesArray *hits = new TClonesArray("AliTRDhit", nhits+1000);
399   TClonesArray *tmp = new TClonesArray("AliTRDhit", 1000);
400   branch->SetAddress(&tmp);
401   
402   Int_t index = 0;
403   Int_t nEntries = (Int_t)branch->GetEntries();
404   for(Int_t i = 0; i < nEntries; i++) {
405     branch->GetEntry(i);
406     Int_t nHits = (Int_t)tmp->GetEntries();
407     for(Int_t j=0; j<nHits; j++) {
408       AliTRDhit *hit = (AliTRDhit*)tmp->At(j);
409       new((*hits)[index++]) AliTRDhit(*hit);
410     }
411   }
412
413   tmp->Delete();
414   delete tmp;
415   MakeHits(hits);
416 }
417
418 //____________________________________________________________________________
419 void AliTRDQADataMaker::MakeDigits(TClonesArray * digits)
420 {
421   // makes data from Digits
422   
423   TIter next(digits) ; 
424   AliTRDdigit * digit ; 
425   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
426     GetDigitsData(0)->Fill(digit->GetDetector());
427     GetDigitsData(1)->Fill(digit->GetTime());
428     GetDigitsData(2)->Fill(digit->GetAmp());
429   }  
430 }
431
432 //____________________________________________________________________________
433 void AliTRDQADataMaker::MakeDigits(TTree * digits)
434 {
435
436   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
437   digitsManager->CreateArrays();
438   digitsManager->ReadDigits(digits);
439
440   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
441     
442     AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
443     
444     // This is to take care of switched off super modules
445     if (digitsIn->GetNtime() == 0) continue;
446     
447     digitsIn->Expand();
448     
449     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
450     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
451     
452     Int_t nRows = digitsIn->GetNrow();
453     Int_t nCols = digitsIn->GetNcol();
454     Int_t nTbins = digitsIn->GetNtime();
455
456     for(Int_t row = 0; row < nRows; row++) 
457       for(Int_t col = 0; col < nCols; col++) 
458         for(Int_t time = 0; time < nTbins; time++) {
459
460           Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
461           GetDigitsData(0)->Fill(i);
462           GetDigitsData(1)->Fill(time);
463           GetDigitsData(2)->Fill(signal);
464         }
465     
466     //delete digitsIn;
467   }
468   delete digitsManager;
469 }
470
471 //____________________________________________________________________________
472 void AliTRDQADataMaker::MakeSDigits(TClonesArray * sdigits)
473 {
474   // makes data from Digits
475   
476   TIter next(sdigits) ; 
477   AliTRDdigit * digit ; 
478   while ( (digit = dynamic_cast<AliTRDdigit *>(next())) ) {
479     GetDigitsData(0)->Fill(digit->GetDetector());
480     GetDigitsData(1)->Fill(digit->GetTime());
481     GetDigitsData(2)->Fill(digit->GetAmp());
482   }  
483 }
484
485 //____________________________________________________________________________
486 void AliTRDQADataMaker::MakeSDigits(TTree * digits)
487 {
488
489   AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager();
490   digitsManager->CreateArrays();
491   digitsManager->ReadDigits(digits);
492
493   for (Int_t i = 0; i < AliTRDgeometry::kNdet; i++) {
494     
495     AliTRDdataArrayI *digitsIn = digitsManager->GetDigits(i);      
496     
497     // This is to take care of switched off super modules
498     if (digitsIn->GetNtime() == 0) continue;
499     
500     digitsIn->Expand();
501     
502     //AliTRDSignalIndex* indexes = digitsManager->GetIndexes(i);
503     //if (indexes->IsAllocated() == kFALSE) digitsManager->BuildIndexes(i);
504     
505     Int_t nRows = digitsIn->GetNrow();
506     Int_t nCols = digitsIn->GetNcol();
507     Int_t nTbins = digitsIn->GetNtime();
508
509     for(Int_t row = 0; row < nRows; row++) 
510       for(Int_t col = 0; col < nCols; col++) 
511         for(Int_t time = 0; time < nTbins; time++) {
512
513           Float_t signal = digitsIn->GetDataUnchecked(row,col,time);
514           if (signal <= 0) continue;
515           GetSDigitsData(0)->Fill(i);
516           GetSDigitsData(1)->Fill(time);
517           GetSDigitsData(2)->Fill(signal);
518         }
519     
520     // delete digitsIn;
521   }
522
523   delete digitsManager;
524 }
525
526 //____________________________________________________________________________
527 void AliTRDQADataMaker::MakeRaws(AliRawReader* rawReader)
528 {
529   // 157
530   // T9 -- T10
531
532   //const Int_t kSM  = 18;
533   //const Int_t kROC = 30;
534   //const Int_t kLayer = 6;
535   //const Int_t kStack = 5;
536   const Int_t kROB = 8;
537   const Int_t kMCM = 16;
538   const Int_t kADC = 22;
539
540   AliTRDRawStreamV2 *raw = new AliTRDRawStreamV2(rawReader);
541   
542   raw->SetRawVersion(3);
543   raw->Init();
544   
545   while (raw->Next()) {
546     
547     GetRawsData(0)->Fill(raw->GetDet());
548     
549     Int_t *sig = raw->GetSignals();
550     for(Int_t i=0; i<3; i++) GetRawsData(1)->Fill(sig[i]);
551     
552     GetRawsData(2)->Fill(sig[1]);
553     GetRawsData(3)->Fill(sig[0]);
554     GetRawsData(3)->Fill(sig[2]);
555     
556     GetRawsData(4)->Fill(raw->GetTimeBin());
557     
558     // calculate the index;
559     Int_t sm = raw->GetSM();
560     Int_t roc = raw->GetROC();
561     Int_t rob = raw->GetROB();
562     Int_t mcm = raw->GetMCM();
563     Int_t adc = raw->GetADC();
564     
565     Int_t index = roc * (kROB*kMCM*kADC) + rob * (kMCM*kADC) + mcm * kADC + adc;
566     GetRawsData(5)->Fill(sm);
567     //printf("SM = %d\n", sm);
568     GetRawsData(6+sm)->Fill(index);
569   }
570 }
571
572 //____________________________________________________________________________
573 void AliTRDQADataMaker::MakeRecPoints(TTree * clustersTree)
574 {
575   
576   // makes data from RecPoints
577   // 
578   
579   Int_t nsize = Int_t(clustersTree->GetTotBytes() / (sizeof(AliTRDcluster))); 
580   TObjArray *clusterArray = new TObjArray(nsize+1000); 
581   
582   TBranch *branch = clustersTree->GetBranch("TRDcluster");
583   if (!branch) {
584     AliError("Can't get the branch !");
585     return;
586   }
587   branch->SetAddress(&clusterArray); 
588   
589   // Loop through all entries in the tree
590   Int_t nEntries   = (Int_t) clustersTree->GetEntries();
591   Int_t nbytes     = 0;
592   AliTRDcluster *c = 0;
593   Int_t nDet[540];
594   for (Int_t i=0; i<540; i++) nDet[i] = 0;
595   
596   for (Int_t iEntry = 0; iEntry < nEntries; iEntry++) {    
597     
598     // Import the tree
599     nbytes += clustersTree->GetEvent(iEntry);  
600     
601     // Get the number of points in the detector
602     Int_t nCluster = clusterArray->GetEntriesFast();  
603     
604     // Loop through all TRD digits
605     for (Int_t iCluster = 0; iCluster < nCluster; iCluster++) { 
606       c = (AliTRDcluster *) clusterArray->UncheckedAt(iCluster);
607       
608       Int_t iDet = c->GetDetector();
609       nDet[iDet]++;
610       GetRecPointsData(0)->Fill(iDet);
611       GetRecPointsData(1)->Fill(iDet, c->GetQ());
612       GetRecPointsData(2)->Fill(c->GetNPads());
613       if (c->GetNPads() < 6)
614         GetRecPointsData(1+c->GetNPads())->Fill(c->GetCenter());
615
616       //if (c->GetPadTime() < 5)
617       ((TH2D*)GetRecPointsData(7))->Fill(c->GetPadRow(), c->GetPadCol());
618       GetRecPointsData(8)->Fill(c->GetPadTime());
619       
620       ((TProfile*)GetRecPointsData(10))->Fill(c->GetPadTime(), c->GetQ());
621       
622       // PRF for 2pad
623       //if (c->GetNPads() == 2) {
624       Short_t *sig = c->GetSignals();
625       Double_t frac = -10;
626       
627       if (sig[0] == 0 && sig[1] == 0 && sig[2] == 0 && sig[5] == 0 && sig[6] == 0) 
628         frac = 1. * sig[4] / (sig[3] + sig[4]);
629       
630       
631       if (sig[0] == 0 && sig[1] == 0 && sig[4] == 0 && sig[5] == 0 && sig[6] == 0)
632         frac = -1. * sig[2] / (sig[2] + sig[3]);
633       
634       if (frac > -10)  ((TProfile*)GetRecPointsData(11))->Fill(c->GetCenter(), frac);
635         
636       //}
637     }
638   }
639   
640   for(Int_t i=0; i<540; i++) 
641     if (nDet[i] > 0) GetRecPointsData(9)->Fill(nDet[i]);
642
643
644   delete clusterArray;
645 }
646
647 //____________________________________________________________________________ 
648 void AliTRDQADataMaker::StartOfDetectorCycle()
649 {
650   //Detector specific actions at start of cycle
651
652 }
653
654 //__________________________________________________________________________
655 Int_t AliTRDQADataMaker::CheckPointer(TObject *obj, const char *name) {
656
657   if (!obj) AliWarning(Form("null pointer: %s", name));
658   return !!obj;
659 }
660 //__________________________________________________________________________