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