Offsets are now handled properly for the lists corrsponding to different
[u/mrichter/AliRoot.git] / ITS / AliITSQASPDDataMakerRec.cxx
1 /**************************************************************************
2  * Copyright(c) 2007-2009, 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 /* $Id$  */
16 //  *************************************************************
17 //  Checks the quality assurance 
18 //  by comparing with reference data
19 //  contained in a DB
20 //  -------------------------------------------------------------
21 //  W. Ferrarese + P. Cerello Feb 2008
22 //  INFN Torino
23 //  M. Nicassio D. Elia INFN Bari March 2008
24 //  maria.nicassio@ba.infn.it
25     
26
27 // --- ROOT system ---
28 #include <TTree.h>
29 #include <TH1.h>
30 #include <TH2.h>
31 #include <TMath.h>
32 // --- Standard library ---
33
34 // --- AliRoot header files ---
35 #include "AliITSQADataMakerRec.h"
36 #include "AliITSQASPDDataMakerRec.h"
37 #include "AliLog.h"
38 #include "AliQAv1.h"
39 #include "AliRawReader.h"
40 #include "AliITSRawStreamSPD.h"
41 #include "AliITSRawStreamSPDErrorLog.h"
42 #include "AliITSdigitSPD.h"
43 #include "AliITSRecPoint.h"
44
45 ClassImp(AliITSQASPDDataMakerRec)
46
47 //____________________________________________________________________________
48 AliITSQASPDDataMakerRec::AliITSQASPDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc, AliITSRawStreamSPDErrorLog *aliITSRawStreamSPDErrorLog) :
49 TObject(),
50 fAliITSQADataMakerRec(aliITSQADataMakerRec),
51 fkOnline(kMode),
52 fLDC(ldc),
53 fSPDhRawsTask(0),
54 fSPDhDigitsTask(0),
55 fSPDhRecPointsTask(0),
56 fGenRawsOffset(0),
57 fGenDigitsOffset(0),
58 fGenRecPointsOffset(0),
59 fAdvLogger(aliITSRawStreamSPDErrorLog) 
60 {
61   //ctor used to discriminate OnLine-Offline analysis  
62   //AliInfo(Form("AliRecoParam::kNSpecies %d\n",AliRecoParam::kNSpecies));
63         fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
64         fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
65         for(Int_t i=0; i<AliRecoParam::kNSpecies;i++) {
66                 fGenRawsOffset[i] = 0;
67                 fGenRecPointsOffset[i] = 0;
68         }
69 }
70
71 //____________________________________________________________________________ 
72 AliITSQASPDDataMakerRec::AliITSQASPDDataMakerRec(const AliITSQASPDDataMakerRec& qadm) :
73 TObject(),
74 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
75 fkOnline(qadm.fkOnline),
76 fLDC(qadm.fLDC),
77 fSPDhRawsTask(qadm.fSPDhRawsTask),
78 fSPDhDigitsTask(qadm.fSPDhDigitsTask),
79 fSPDhRecPointsTask(qadm.fSPDhRecPointsTask),
80 fGenRawsOffset(qadm.fGenRawsOffset),
81 fGenDigitsOffset(qadm.fGenDigitsOffset),
82 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
83 fAdvLogger(qadm.fAdvLogger)
84 {
85   //copy ctor 
86   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
87   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
88   }
89
90 //__________________________________________________________________
91 AliITSQASPDDataMakerRec::~AliITSQASPDDataMakerRec(){
92   // destructor
93 //  delete fAdvLogger;
94 }
95 //__________________________________________________________________
96
97 AliITSQASPDDataMakerRec& AliITSQASPDDataMakerRec::operator = (const AliITSQASPDDataMakerRec& qac )
98 {
99   // Equal operator.
100   this->~AliITSQASPDDataMakerRec();
101   new(this) AliITSQASPDDataMakerRec(qac);
102   return *this;
103 }
104
105 //____________________________________________________________________________ 
106 void AliITSQASPDDataMakerRec::StartOfDetectorCycle()
107 {
108   //Detector specific actions at start of cycle
109   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SPD Cycle\n");
110 }
111
112 //____________________________________________________________________________ 
113 void AliITSQASPDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t /*task*/, TObjArray* /*list*/)
114 {
115   // launch the QA checking
116   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
117   
118   //AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
119 }
120
121 //____________________________________________________________________________ 
122 Int_t AliITSQASPDDataMakerRec::InitRaws()
123
124   // Initialization for RAW data - SPD -
125   const Bool_t expert   = kTRUE ; 
126   const Bool_t saveCorr = kTRUE ; 
127   const Bool_t image    = kTRUE ; 
128   Int_t rv = 0 ; 
129 //  fGenRawsOffset = (fAliITSQADataMakerRec->fRawsQAList[AliRecoParam::kDefault])->GetEntries();
130   fAdvLogger = new AliITSRawStreamSPDErrorLog();  
131   AliDebug(AliQAv1::GetQADebugLevel(), "Book Offline Histograms for SPD\n ");
132
133   Char_t name[50];
134   Char_t title[50];
135
136   TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
137   hlayer->GetXaxis()->SetTitle("Layer number");
138   hlayer->GetYaxis()->SetTitle("Entries");
139   rv = fAliITSQADataMakerRec->Add2RawsList(hlayer, 0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
140   fSPDhRawsTask++;
141
142   TH1F **hmod = new TH1F*[2];
143   TH2F **hhitMap = new TH2F*[20];
144   TH1F **herrors = new TH1F*[20];
145   for (Int_t iLay=0; iLay<2; iLay++) {
146     sprintf(name,"SPDModPattern_SPD%d",iLay+1);
147     sprintf(title,"Module map - SPD Layer %d",iLay+1);
148     hmod[iLay]=new TH1F(name,title,fgknSPDmodules,0,fgknSPDmodules);
149     hmod[iLay]->GetXaxis()->SetTitle("Module number");
150     hmod[iLay]->GetYaxis()->SetTitle("Entries");
151     rv = fAliITSQADataMakerRec->Add2RawsList(hmod[iLay], 1+iLay+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, !saveCorr);
152     fSPDhRawsTask++;
153   }
154   for (Int_t iDDL=0; iDDL<20; iDDL++) {
155     sprintf(name,"SPDHitMap_SPD_DDL%d",iDDL+1);
156     sprintf(title,"Hit map - SPD DDL %d",iDDL+1);
157     hhitMap[iDDL]=new TH2F(name,title,320,0,10*32,1536,0,6*256);
158     hhitMap[iDDL]->GetXaxis()->SetTitle("Column");
159     hhitMap[iDDL]->GetYaxis()->SetTitle("Row");
160     rv = fAliITSQADataMakerRec->Add2RawsList(hhitMap[iDDL], 3+(2*iDDL)+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
161     fSPDhRawsTask++;
162     sprintf(name,"SPDErrors_SPD_DDL%d",iDDL+1);
163     sprintf(title,"Error codes - SPD DDL %d",iDDL+1);
164     herrors[iDDL] = new TH1F (name,title,fAdvLogger->GetNrErrorCodes(),0,fAdvLogger->GetNrErrorCodes());
165     herrors[iDDL]->SetXTitle("Error Code");
166     herrors[iDDL]->SetYTitle("Nr of errors");
167     rv = fAliITSQADataMakerRec->Add2RawsList(herrors[iDDL], 4+(2*iDDL)+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
168     fSPDhRawsTask++;
169   }
170
171   TH1F** hMultSPDhits = new TH1F*[2];
172   for (Int_t iLay=0; iLay<2; iLay++) {
173     sprintf(name,"SPDHitsMultiplicity_SPD%d",iLay+1);
174     sprintf(title,"Hit multiplicity - SPD Layer %d",iLay+1);
175     hMultSPDhits[iLay]=new TH1F(name,title,200,0.,200.);
176     hMultSPDhits[iLay]->GetXaxis()->SetTitle("Hit multiplicity");
177     hMultSPDhits[iLay]->GetYaxis()->SetTitle("Entries");
178     rv = fAliITSQADataMakerRec->Add2RawsList(hMultSPDhits[iLay], 43+iLay+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
179     fSPDhRawsTask++;
180   }
181
182   TH2F *hMultSPDhits2MultSPDhits1 
183          = new TH2F("SPDHitMultCorrelation_SPD","Hit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
184   hMultSPDhits2MultSPDhits1->GetXaxis()->SetTitle("Hit multiplicity (Layer 1)");
185   hMultSPDhits2MultSPDhits1->GetYaxis()->SetTitle("Hit multiplicity (Layer 2)");
186   rv = fAliITSQADataMakerRec->Add2RawsList(hMultSPDhits2MultSPDhits1, 45+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, !saveCorr);
187   fSPDhRawsTask++;
188  
189   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Raws histograms booked\n",fSPDhRawsTask));
190   return rv ; 
191 }
192
193 //____________________________________________________________________________
194 Int_t AliITSQASPDDataMakerRec::MakeRaws(AliRawReader* rawReader)
195
196   // Fill QA for RAW - SPD -
197   Int_t rv = 0 ; 
198   
199   rawReader->Reset();
200   AliITSRawStreamSPD *rawStreamSPD = new AliITSRawStreamSPD(rawReader);
201   rawStreamSPD->ActivateAdvancedErrorLog(kTRUE,fAdvLogger);
202
203   Int_t nDigitsL1 = 0;
204   Int_t nDigitsL2 = 0;
205   Int_t iEq;
206   Int_t iLayer;
207   Int_t iHalfStave, iChip;
208   Int_t col, row; 
209   UInt_t module, colM, rowM;
210   while(rawStreamSPD->Next()) {
211
212     iEq = rawReader->GetDDLID();
213     if (iEq>=0 && iEq<20) {
214       iHalfStave = rawStreamSPD->GetHalfStaveNr();
215       iChip = rawStreamSPD->GetChipAddr();
216       col  = rawStreamSPD->GetChipCol();
217       row  = rawStreamSPD->GetChipRow();
218
219       rawStreamSPD->OnlineToOffline(iEq, iHalfStave, iChip, col, row, module, colM, rowM);
220
221       if (iHalfStave>=0 && iHalfStave<2) iLayer=0;
222       else iLayer=1;
223       
224       fAliITSQADataMakerRec->GetRawsData(0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iLayer);
225       if (iLayer==0) {
226         fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(module);
227         nDigitsL1++;
228       } else {
229         fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(module);
230         nDigitsL2++;
231       }
232       
233       fAliITSQADataMakerRec->GetRawsData((2*iEq)+3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(colM+(module%2)*160,rowM+iHalfStave*256);
234     }
235
236   }
237   for (Int_t ieq=0; ieq<20; ieq++) {
238     for (UInt_t ierr=0; ierr<fAdvLogger->GetNrErrorCodes(); ierr++) 
239       fAliITSQADataMakerRec->GetRawsData((2*ieq)+4+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ierr,fAdvLogger->GetNrErrors(ierr,ieq));
240         }
241
242   fAdvLogger->Reset();
243   fAliITSQADataMakerRec->GetRawsData(43+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nDigitsL1);
244   fAliITSQADataMakerRec->GetRawsData(44+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nDigitsL2);
245   fAliITSQADataMakerRec->GetRawsData(45+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nDigitsL1,nDigitsL2);
246   
247   delete rawStreamSPD;  
248   AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",nDigitsL1+nDigitsL2));
249   return rv ; 
250 }
251
252 //____________________________________________________________________________ 
253 Int_t AliITSQASPDDataMakerRec::InitDigits()
254
255   // Initialization for DIGIT data - SPD -
256   const Bool_t expert   = kTRUE ; 
257   const Bool_t image    = kTRUE ;
258   Int_t rv = 0 ; 
259 //  fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
260   //fSPDhDigitsTask must be incremented by one unit every time a histogram is ADDED to the QA List
261   
262   Char_t name[50];
263   Char_t title[50];
264   
265   TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
266   hlayer->GetXaxis()->SetTitle("Layer number");
267   hlayer->GetYaxis()->SetTitle("Entries");
268   rv = fAliITSQADataMakerRec->Add2DigitsList(hlayer,fGenDigitsOffset, expert, !image);
269   fSPDhDigitsTask++;
270   
271   TH1F **hmod = new TH1F*[2];
272   for (Int_t iLay=0; iLay<2; iLay++) {
273     sprintf(name,"SPDModPattern_SPD%d",iLay+1);
274     sprintf(title,"Module map - SPD Layer %d",iLay+1);
275     hmod[iLay]=new TH1F(name,title,240,0,240);
276     hmod[iLay]->GetXaxis()->SetTitle("Module number");
277     hmod[iLay]->GetYaxis()->SetTitle("Entries");
278     rv = fAliITSQADataMakerRec->Add2DigitsList(hmod[iLay],1+iLay+fGenDigitsOffset, !expert, image);
279     fSPDhDigitsTask++;
280   }
281   
282   TH1F *hcolumns = new TH1F("SPDColumns_SPD","Columns - SPD",160,0.,160.);
283   hcolumns->GetXaxis()->SetTitle("Column number");
284   hcolumns->GetYaxis()->SetTitle("Entries");
285   rv = fAliITSQADataMakerRec->Add2DigitsList(hcolumns,3+fGenDigitsOffset, expert, !image);
286   fSPDhDigitsTask++;
287   
288   TH1F *hrows = new TH1F("SPDRows_SPD","Rows - SPD",256,0.,256.);
289   hrows->GetXaxis()->SetTitle("Row number");
290   hrows->GetYaxis()->SetTitle("Entries");
291   rv = fAliITSQADataMakerRec->Add2DigitsList(hrows,4+fGenDigitsOffset, expert, !image);
292   fSPDhDigitsTask++;
293   
294   TH1F** hMultSPDdigits = new TH1F*[2];
295   for (Int_t iLay=0; iLay<2; ++iLay) {
296     sprintf(name,"SPDDigitMultiplicity_SPD%d",iLay+1);
297     sprintf(title,"Digit multiplicity - SPD Layer %d",iLay+1);
298     hMultSPDdigits[iLay]=new TH1F(name,title,200,0.,200.);
299     hMultSPDdigits[iLay]->GetXaxis()->SetTitle("Digit multiplicity");
300     hMultSPDdigits[iLay]->GetYaxis()->SetTitle("Entries");
301     rv = fAliITSQADataMakerRec->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenDigitsOffset, !expert, image);
302     fSPDhDigitsTask++;
303   }
304   
305   TH2F *hMultSPDdig2MultSPDdig1 
306     = new TH2F("SPDDigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
307   hMultSPDdig2MultSPDdig1->GetXaxis()->SetTitle("Digit multiplicity (Layer 1)");
308   hMultSPDdig2MultSPDdig1->GetYaxis()->SetTitle("Digit multiplicity (Layer 2)");
309   rv = fAliITSQADataMakerRec->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenDigitsOffset, !expert, image);
310   fSPDhDigitsTask++;
311   
312   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Digits histograms booked\n",fSPDhDigitsTask));
313   return rv ; 
314 }
315
316 //____________________________________________________________________________
317 Int_t AliITSQASPDDataMakerRec::MakeDigits(TTree *digits)
318
319   // Fill QA for DIGIT - SPD -
320   Int_t rv = 0 ; 
321
322 //  AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
323 //  fITS->SetTreeAddress();
324 //  TClonesArray *iITSdigits  = fITS->DigitsAddress(0);  // 0->SPD
325   TBranch *branchD = digits->GetBranch("ITSDigitsSPD");
326   if (!branchD) { 
327     AliError("can't get the branch with the SPD ITS digits !");
328     return rv;
329   }
330   static TClonesArray statDigits("AliITSdigitSPD");
331   TClonesArray *iITSdigits = &statDigits;
332   branchD->SetAddress(&iITSdigits);  
333   Int_t nDigitsL1=0;
334   Int_t nDigitsL2=0;
335   
336   for (Int_t imod=0; imod<240; ++imod){
337     digits->GetEvent(imod);
338     Int_t ndigits = iITSdigits->GetEntries();
339     if (imod<80) {
340       fAliITSQADataMakerRec->GetDigitsData(0+fGenDigitsOffset)->Fill(0.5,ndigits);
341       fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset)->Fill(imod,ndigits);
342       nDigitsL1+=ndigits;
343     }
344     else {
345       fAliITSQADataMakerRec->GetDigitsData(0+fGenDigitsOffset)->Fill(1,ndigits);
346       fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset)->Fill(imod,ndigits);
347       nDigitsL2+=ndigits;
348     }
349     for (Int_t idig=0; idig<ndigits; ++idig) {
350       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
351       Int_t col=dig->GetCoord1();  // cell number z
352       Int_t row=dig->GetCoord2();  // cell number x
353       fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset)->Fill(col);
354       fAliITSQADataMakerRec->GetDigitsData(4+fGenDigitsOffset)->Fill(row);
355     }
356   }
357   fAliITSQADataMakerRec->GetDigitsData(5+fGenDigitsOffset)->Fill(nDigitsL1);
358   fAliITSQADataMakerRec->GetDigitsData(6+fGenDigitsOffset)->Fill(nDigitsL2);
359   fAliITSQADataMakerRec->GetDigitsData(7+fGenDigitsOffset)->Fill(nDigitsL1,nDigitsL2);
360   return rv ; 
361 }
362
363 //____________________________________________________________________________ 
364 Int_t AliITSQASPDDataMakerRec::InitRecPoints()
365 {
366   // Initialization for RECPOINTS - SPD -
367   const Bool_t expert   = kTRUE ; 
368   const Bool_t image    = kTRUE ; 
369   Int_t rv = 0 ; 
370   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
371   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
372 //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
373   TH1F* hlayer= new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
374   hlayer->GetXaxis()->SetTitle("Layer number");
375   hlayer->GetYaxis()->SetTitle("Entries");
376   rv = fAliITSQADataMakerRec->Add2RecPointsList(hlayer, 0+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
377   fSPDhRecPointsTask++;
378
379   TH1F** hmod = new TH1F*[2];
380   TH1F** hxl  = new TH1F*[2];
381   TH1F** hzl  = new TH1F*[2];
382   TH1F** hxg  = new TH1F*[2];
383   TH1F** hyg  = new TH1F*[2];
384   TH1F** hzg  = new TH1F*[2];
385   TH1F** hr   = new TH1F*[2];
386   TH1F** hphi = new TH1F*[2];
387   TH1F** hMultSPDcl = new TH1F*[2];
388   TH2F** hNyNz = new TH2F*[2];  // y and z cluster length
389   TH2F** hPhiZ = new TH2F*[2];
390
391   Float_t xlim[2]={4.5,8.};
392   Float_t zlim[2]={15.,15.};
393
394   Char_t name[50];
395   Char_t title[50];
396   for (Int_t iLay=0;iLay<2;iLay++) {
397     sprintf(name,"SPDModPattern_SPD%d",iLay+1);
398     sprintf(title,"Module map - SPD Layer %d",iLay+1);
399     hmod[iLay]=new TH1F(name,title,fgknSPDmodules,0,fgknSPDmodules);
400     hmod[iLay]->GetXaxis()->SetTitle("Module number");
401     hmod[iLay]->GetYaxis()->SetTitle("Entries");
402     rv = fAliITSQADataMakerRec->Add2RecPointsList(hmod[iLay], 1+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
403     fSPDhRecPointsTask++;
404
405     sprintf(name,"SPDxLoc_SPD%d",iLay+1);
406     sprintf(title,"Local x coordinate - SPD Layer %d",iLay+1);
407     hxl[iLay]=new TH1F(name,title,100,-4.,4.);
408     hxl[iLay]->GetXaxis()->SetTitle("Local x [cm]");
409     hxl[iLay]->GetYaxis()->SetTitle("Entries");
410     rv = fAliITSQADataMakerRec->Add2RecPointsList(hxl[iLay], 2+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
411     fSPDhRecPointsTask++;
412
413     sprintf(name,"SPDzLoc_SPD%d",iLay+1);
414     sprintf(title,"Local z coordinate - SPD Layer %d",iLay+1);
415     hzl[iLay]=new TH1F(name,title,100,-4.,4.);
416     hzl[iLay]->GetXaxis()->SetTitle("Local z [cm]");
417     hzl[iLay]->GetYaxis()->SetTitle("Entries");
418     rv = fAliITSQADataMakerRec->Add2RecPointsList(hzl[iLay], 3+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
419     fSPDhRecPointsTask++;
420
421     sprintf(name,"SPDxGlob_SPD%d",iLay+1);
422     sprintf(title,"Global x coordinate - SPD Layer %d",iLay+1);
423     hxg[iLay]=new TH1F(name,title,100,-xlim[iLay],xlim[iLay]);
424     hxg[iLay]->GetXaxis()->SetTitle("Global x [cm]");
425     hxg[iLay]->GetYaxis()->SetTitle("Entries");
426     rv = fAliITSQADataMakerRec->Add2RecPointsList(hxg[iLay],4+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);  
427     fSPDhRecPointsTask++;
428
429     sprintf(name,"SPDyGlob_SPD%d",iLay+1);
430     sprintf(title,"Global y coordinate - SPD Layer %d",iLay+1);
431     hyg[iLay]=new TH1F(name,title,100,-xlim[iLay],xlim[iLay]);
432     hyg[iLay]->GetXaxis()->SetTitle("Global y [cm]");
433     hyg[iLay]->GetYaxis()->SetTitle("Entries");
434     rv = fAliITSQADataMakerRec->Add2RecPointsList(hyg[iLay], 5+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
435     fSPDhRecPointsTask++;
436
437     sprintf(name,"SPDzGlob_SPD%d",iLay+1);
438     sprintf(title,"Global z coordinate - SPD Layer %d",iLay+1);
439     hzg[iLay]=new TH1F(name,title,150,-zlim[iLay],zlim[iLay]);
440     hzg[iLay]->GetXaxis()->SetTitle("Global z [cm]");
441     hzg[iLay]->GetYaxis()->SetTitle("Entries");
442     rv = fAliITSQADataMakerRec->Add2RecPointsList(hzg[iLay], 6+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
443     fSPDhRecPointsTask++;
444
445     sprintf(name,"SPDr_SPD%d",iLay+1);
446     sprintf(title,"Radius - SPD Layer %d",iLay+1);
447     hr[iLay]=new TH1F(name,title,100,0.,10.);
448     hr[iLay]->GetXaxis()->SetTitle("r [cm]");
449     hr[iLay]->GetYaxis()->SetTitle("Entries");
450     rv = fAliITSQADataMakerRec->Add2RecPointsList(hr[iLay], 7+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);  
451     fSPDhRecPointsTask++;
452
453     sprintf(name,"SPDphi_SPD%d",iLay+1);
454     sprintf(title,"#varphi - SPD Layer %d",iLay+1);
455     hphi[iLay]=new TH1F(name,title,1000,0.,2*TMath::Pi());
456     hphi[iLay]->GetXaxis()->SetTitle("#varphi [rad]");
457     hphi[iLay]->GetYaxis()->SetTitle("Entries");
458     rv = fAliITSQADataMakerRec->Add2RecPointsList(hphi[iLay], 8+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
459     fSPDhRecPointsTask++;
460     
461     sprintf(name,"SPDSizeYvsZ_SPD%d",iLay+1);
462     sprintf(title,"Cluster dimension - SPD Layer %d",iLay+1);
463     hNyNz[iLay]=new TH2F(name,title,100,0.,100.,100,0.,100.);
464     hNyNz[iLay]->GetXaxis()->SetTitle("z length");
465     hNyNz[iLay]->GetYaxis()->SetTitle("y length");
466     rv = fAliITSQADataMakerRec->Add2RecPointsList(hNyNz[iLay], 9+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
467     fSPDhRecPointsTask++;
468
469     sprintf(name,"SPDphi_z_SPD%d",iLay+1);
470     sprintf(title,"#varphi vs z - SPD Layer %d",iLay+1);
471     hPhiZ[iLay]=new TH2F(name,title,150,-zlim[iLay],zlim[iLay],200,0.,2*TMath::Pi());
472     hPhiZ[iLay]->GetXaxis()->SetTitle("Global z [cm]");
473     hPhiZ[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
474     rv = fAliITSQADataMakerRec->Add2RecPointsList(hPhiZ[iLay], 10+(10*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
475     fSPDhRecPointsTask++;
476
477   }
478
479   TH2F *hrPhi=new TH2F("SPDr_phi_SPD","#varphi vs r - SPD",100,0.,10.,100,0.,2*TMath::Pi());
480   hrPhi->GetXaxis()->SetTitle("r [cm]");
481   hrPhi->GetYaxis()->SetTitle("#varphi [rad]");
482   rv = fAliITSQADataMakerRec->Add2RecPointsList(hrPhi, 21+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
483   fSPDhRecPointsTask++;
484
485   TH2F *hxy=new TH2F("SPDx_y_SPD","Global y vs x - SPD",200,-10.,10.,200,-10.,10.);
486   hxy->GetXaxis()->SetTitle("Global x [cm]");
487   hxy->GetYaxis()->SetTitle("Global y [cm]");
488   rv = fAliITSQADataMakerRec->Add2RecPointsList(hxy, 22+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
489   fSPDhRecPointsTask++;
490
491   for (Int_t iLay=0;iLay<2;iLay++) {
492     sprintf(name,"SPDMultiplicity_SPD%d",iLay+1);
493     sprintf(title,"Cluster multiplicity - SPD Layer %d",iLay+1);
494     hMultSPDcl[iLay]=new TH1F(name,title,200,0.,200.);
495     hMultSPDcl[iLay]->GetXaxis()->SetTitle("Cluster multiplicity");
496     hMultSPDcl[iLay]->GetYaxis()->SetTitle("Entries");
497     rv = fAliITSQADataMakerRec->Add2RecPointsList(hMultSPDcl[iLay], 23+iLay+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
498     fSPDhRecPointsTask++;
499   } 
500
501   TH2F *hMultSPDcl2MultSPDcl1 =
502         new TH2F("SPDMultCorrelation_SPD","Cluster multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
503   hMultSPDcl2MultSPDcl1->GetXaxis()->SetTitle("Clusters multiplicity (Layer 1)");
504   hMultSPDcl2MultSPDcl1->GetYaxis()->SetTitle("Clusters multiplicity (Layer 2)"); 
505   rv = fAliITSQADataMakerRec->Add2RecPointsList(hMultSPDcl2MultSPDcl1, 25+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
506   fSPDhRecPointsTask++;
507
508   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Recs histograms booked\n",fSPDhRecPointsTask));
509
510   return rv ; 
511 }
512
513 //____________________________________________________________________________ 
514 Int_t AliITSQASPDDataMakerRec::MakeRecPoints(TTree * clusterTree)
515 {
516   // Fill QA for RecPoints - SPD -
517   Int_t rv = 0 ; 
518   static TClonesArray statITSCluster("AliITSRecPoint");
519   TClonesArray *ITSCluster = &statITSCluster;
520   TBranch* itsClusterBranch=clusterTree->GetBranch("ITSRecPoints");
521   if (!itsClusterBranch) {
522     AliError("can't get the branch with the ITS clusters !");
523     return rv;
524   }
525   
526   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
527   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
528   itsClusterBranch->SetAddress(&ITSCluster);
529   Int_t nItsMods = (Int_t)clusterTree->GetEntries();
530   
531   Float_t cluGlo[3] = {0.,0.,0.};
532   Int_t nClusters[2] = {0,0};
533   
534   for (Int_t iIts=0; iIts < nItsMods; iIts++) {
535     
536     if (!clusterTree->GetEvent(iIts))    continue;
537     Int_t nCluster = ITSCluster->GetEntriesFast();
538     // loop over clusters
539     while(nCluster--) {
540       AliITSRecPoint* cluster = (AliITSRecPoint*)ITSCluster->UncheckedAt(nCluster);
541       
542       if (cluster->GetLayer()>1)        continue;
543       Int_t lay=cluster->GetLayer();
544       fAliITSQADataMakerRec->GetRecPointsData(0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lay);
545       cluster->GetGlobalXYZ(cluGlo);
546       Float_t rad=TMath::Sqrt(cluGlo[0]*cluGlo[0]+cluGlo[1]*cluGlo[1]);
547         Float_t phi= TMath::Pi() + TMath::ATan2(-cluGlo[1],-cluGlo[0]);
548         if (lay==0) {
549           fAliITSQADataMakerRec->GetRecPointsData(1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iIts);
550           fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalX());
551           fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalZ());
552           fAliITSQADataMakerRec->GetRecPointsData(4 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[0]);
553           fAliITSQADataMakerRec->GetRecPointsData(5 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[1]);
554           fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2]);
555           fAliITSQADataMakerRec->GetRecPointsData(7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);
556           fAliITSQADataMakerRec->GetRecPointsData(8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);
557           fAliITSQADataMakerRec->GetRecPointsData(9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetNz(),cluster->GetNy());
558           fAliITSQADataMakerRec->GetRecPointsData(10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2],phi);
559         } else  {
560           fAliITSQADataMakerRec->GetRecPointsData(11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iIts);
561           fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalX());
562           fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalZ());
563           fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[0]);
564           fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[1]);
565           fAliITSQADataMakerRec->GetRecPointsData(16 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2]);
566           fAliITSQADataMakerRec->GetRecPointsData(17 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);
567           fAliITSQADataMakerRec->GetRecPointsData(18 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);
568           fAliITSQADataMakerRec->GetRecPointsData(19 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetNz(),cluster->GetNy());
569           fAliITSQADataMakerRec->GetRecPointsData(20 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2],phi);
570         }
571         fAliITSQADataMakerRec->GetRecPointsData(21 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad,phi);
572         fAliITSQADataMakerRec->GetRecPointsData(22 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[0],cluGlo[1]);
573         
574         nClusters[lay]++; 
575     } // end of cluster loop
576   } // end of its "subdetector" loop
577   
578   for (Int_t iLay=0; iLay<2; iLay++)
579     fAliITSQADataMakerRec->GetRecPointsData(23+iLay +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nClusters[iLay]);
580   
581   fAliITSQADataMakerRec->GetRecPointsData(25 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nClusters[0],nClusters[1]);
582   
583   statITSCluster.Clear();
584   return rv ;
585 }
586
587
588
589 //_______________________________________________________________
590
591 Int_t AliITSQASPDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task) {
592   // Returns offset number according to the specified task
593   Int_t offset=0;
594   if( task == AliQAv1::kRAWS ) {
595     offset=fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
596   }
597   else if( task == AliQAv1::kDIGITSR ) {
598     offset=fGenDigitsOffset;
599   }
600   else if( task == AliQAv1::kRECPOINTS ) {
601     offset=fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
602   }
603   else if( task == AliQAv1::kDIGITS ) {
604     offset=fGenDigitsOffset;
605   }
606
607   return offset;
608 }
609
610 //_______________________________________________________________
611
612 void AliITSQASPDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
613   // Returns offset number according to the specified task
614   if( task == AliQAv1::kRAWS ) {
615     fGenRawsOffset[specie]=offset;
616   }
617   else if( task == AliQAv1::kDIGITSR ) {
618     fGenDigitsOffset=offset;
619   }
620   else if( task == AliQAv1::kRECPOINTS ) {
621     fGenRecPointsOffset[specie]=offset;
622   }
623 }
624
625 //_______________________________________________________________
626
627 Int_t AliITSQASPDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
628   // Returns the number of histograms associated to the specified task
629
630   Int_t histotot=0;
631
632   if( task == AliQAv1::kRAWS ) {
633     histotot=fSPDhRawsTask;
634   }
635   else if( task == AliQAv1::kDIGITSR ) {
636     histotot=fSPDhDigitsTask;
637   }
638   else if( task == AliQAv1::kRECPOINTS ){
639     histotot=fSPDhRecPointsTask;
640   }
641   else if( task == AliQAv1::kDIGITS ){
642     histotot=fSPDhDigitsTask;
643   }
644   else {
645     AliInfo("No task has been selected. TaskHisto set to zero.\n");
646   }
647   return histotot;
648 }