Changing once more (hopefully we get it correct this time...) the logic to trig the...
[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 #include "AliITSRecPointContainer.h"
45
46 ClassImp(AliITSQASPDDataMakerRec)
47
48 //____________________________________________________________________________
49 AliITSQASPDDataMakerRec::AliITSQASPDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc, AliITSRawStreamSPDErrorLog *aliITSRawStreamSPDErrorLog) :
50 TObject(),
51 fAliITSQADataMakerRec(aliITSQADataMakerRec),
52 fkOnline(kMode),
53 fLDC(ldc),
54 fSPDhRawsTask(0),
55 fSPDhDigitsTask(0),
56 fSPDhRecPointsTask(0),
57 fGenRawsOffset(0),
58 fGenDigitsOffset(0),
59 fGenRecPointsOffset(0),
60 fAdvLogger(aliITSRawStreamSPDErrorLog) 
61 {
62   //ctor used to discriminate OnLine-Offline analysis  
63   //AliInfo(Form("AliRecoParam::kNSpecies %d\n",AliRecoParam::kNSpecies));
64         fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
65         fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
66         fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
67         for(Int_t i=0; i<AliRecoParam::kNSpecies;i++) {
68                 fGenRawsOffset[i] = 0;
69                 fGenRecPointsOffset[i] = 0;
70                 fGenDigitsOffset[i]=0;
71         }
72 }
73
74 //____________________________________________________________________________ 
75 AliITSQASPDDataMakerRec::AliITSQASPDDataMakerRec(const AliITSQASPDDataMakerRec& qadm) :
76 TObject(),
77 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
78 fkOnline(qadm.fkOnline),
79 fLDC(qadm.fLDC),
80 fSPDhRawsTask(qadm.fSPDhRawsTask),
81 fSPDhDigitsTask(qadm.fSPDhDigitsTask),
82 fSPDhRecPointsTask(qadm.fSPDhRecPointsTask),
83 fGenRawsOffset(qadm.fGenRawsOffset),
84 fGenDigitsOffset(qadm.fGenDigitsOffset),
85 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
86 fAdvLogger(qadm.fAdvLogger)
87 {
88   //copy ctor 
89   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
90   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
91   }
92
93 //__________________________________________________________________
94 AliITSQASPDDataMakerRec::~AliITSQASPDDataMakerRec(){
95   // destructor
96 //  delete fAdvLogger;
97 }
98 //__________________________________________________________________
99
100 AliITSQASPDDataMakerRec& AliITSQASPDDataMakerRec::operator = (const AliITSQASPDDataMakerRec& qac )
101 {
102   // Equal operator.
103   this->~AliITSQASPDDataMakerRec();
104   new(this) AliITSQASPDDataMakerRec(qac);
105   return *this;
106 }
107
108 //____________________________________________________________________________ 
109 void AliITSQASPDDataMakerRec::StartOfDetectorCycle()
110 {
111   //Detector specific actions at start of cycle
112   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SPD Cycle\n");
113 }
114
115 //____________________________________________________________________________ 
116 void AliITSQASPDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray* /*list*/)
117 {
118   // launch the QA checking
119   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
120   
121   Int_t shift = fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
122   
123   if(task == AliQAv1::kRAWS) {
124    if(fAliITSQADataMakerRec->GetRawsData(1+shift)){ // check if the fired chip histograms is available
125    fAliITSQADataMakerRec->GetRawsData(5+shift)->Divide(fAliITSQADataMakerRec->GetRawsData(0+shift),fAliITSQADataMakerRec->GetRawsData(1+shift)); // FO efficiency
126    fAliITSQADataMakerRec->GetRawsData(6+shift)->Divide(fAliITSQADataMakerRec->GetRawsData(2+shift),fAliITSQADataMakerRec->GetRawsData(1+shift)); // mising FO
127    fAliITSQADataMakerRec->GetRawsData(7+shift)->Divide(fAliITSQADataMakerRec->GetRawsData(3+shift),fAliITSQADataMakerRec->GetRawsData(1+shift)); // Noisy FO
128    }  
129   }
130   //AliQAChecker::Instance()->Run( AliQAv1::kITS , task, list);
131 }
132
133 //____________________________________________________________________________ 
134 Int_t AliITSQASPDDataMakerRec::InitRaws()
135
136   // Initialization for RAW data - SPD -
137   const Bool_t expert   = kTRUE ; 
138   const Bool_t saveCorr = kTRUE ; 
139   const Bool_t image    = kTRUE ; 
140   Int_t rv = 0 ; 
141 //  fGenRawsOffset = (fAliITSQADataMakerRec->fRawsQAList[AliRecoParam::kDefault])->GetEntries();
142
143   if(!fAdvLogger) fAdvLogger = new AliITSRawStreamSPDErrorLog();  
144   AliDebug(AliQAv1::GetQADebugLevel(), "Book Offline Histograms for SPD\n ");
145
146   Char_t name[50];
147   Char_t title[50];
148   // offset for online histogram numbering
149   Int_t shift = fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
150   
151  
152   Float_t range[2] = {-0.5,1199.};
153
154 // **********  online histo booking (shift is added)   *********************
155
156  // 0
157   TH1F *hFastOrFiredChips = new TH1F("SPDFastOrFiredChips_SPD","FastOr-Fired Chips (if pixel hit present) - SPD",fgkSPDchips,range[0],range[1]);
158   hFastOrFiredChips->GetXaxis()->SetTitle("chip index (eq*60 + hs*10 + chip)");
159   hFastOrFiredChips->GetYaxis()->SetTitle("FastOr-Fired Chip yield");
160   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrFiredChips, 0+shift, expert, !image, !saveCorr);
161   fSPDhRawsTask++;
162 // 1
163   TH1F *hFiredChips = new TH1F("SPDFiredChips_SPD","FiredChips - SPD",fgkSPDchips,range[0],range[1]);
164   hFiredChips->GetXaxis()->SetTitle("chip index (eq*60 + hs*10 + chip)");
165   hFiredChips->GetYaxis()->SetTitle("Fired Chip yield");
166   rv = fAliITSQADataMakerRec->Add2RawsList(hFiredChips, 1+shift, expert, !image, !saveCorr);
167   fSPDhRawsTask++;
168 // 2
169   TH1F *hFastOrMissing = new TH1F("SPDFastOrMissing_SPD","Missing FastOr signal - SPD",fgkSPDchips,range[0],range[1]);
170   hFastOrMissing->GetXaxis()->SetTitle("chip index (eq*60 + hs*10 + chip)");
171   hFastOrMissing->GetYaxis()->SetTitle("Missing Fast Or yield");
172   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrMissing, 2+shift, expert, !image, !saveCorr);
173   fSPDhRawsTask++;
174 // 3
175   TH1F *hFastOrNoisy = new TH1F("SPDFastOrNoisy_SPD","Noisy (no pixel hit present) FastOr signal - SPD",fgkSPDchips,range[0],range[1]);
176   hFastOrNoisy->GetXaxis()->SetTitle("chipkey");
177   hFastOrNoisy->GetYaxis()->SetTitle("Noisy Fast Or");
178   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrNoisy, 3+shift, expert, !image, !saveCorr);
179   fSPDhRawsTask++;
180 // 4
181   TH2F *hFastOrCorrelation = new TH2F("SPDFastOrCorrelation_SPD","Fast Or multiplicity correlation - SPD",100,0.,100.,100,0,100);
182   hFastOrCorrelation->GetXaxis()->SetTitle("Layer 1");
183   hFastOrCorrelation->GetYaxis()->SetTitle("Layer 2");
184   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrCorrelation, 4+shift, expert, !image, !saveCorr);
185   fSPDhRawsTask++;   
186 // 5
187   TH1F *hFastOrEfficiency = new TH1F("SPDFastOrEfficiency_SPD","Fast Or Efficiency : Good FastOr / fired chips (per event) - SPD",fgkSPDchips,range[0],range[1]);
188   hFastOrEfficiency->SetMaximum(1.05);
189   hFastOrEfficiency->GetXaxis()->SetTitle("chip index");
190   hFastOrEfficiency->GetYaxis()->SetTitle("FastOr efficiency");
191   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrEfficiency, 5+shift, expert, !image, !saveCorr);
192   fSPDhRawsTask++; 
193 // 6
194   TH1F *hFastOrMissingRatio = new TH1F("SPDFastOrMissingRatio_SPD"," Missing Fast Or / fired chips (per event) - SPD",fgkSPDchips,range[0],range[1]);
195   hFastOrMissingRatio->SetMaximum(1.05);
196   hFastOrMissingRatio->GetXaxis()->SetTitle("Layer 1");
197   hFastOrMissingRatio->GetYaxis()->SetTitle("Layer 2");
198   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrMissingRatio, 6+shift, expert, !image, !saveCorr);
199   fSPDhRawsTask++;  
200 // 7
201   TH1F *hFastOrNoisyRatio = new TH1F("SPDFastOrNoisyRatio_SPD","Noisy Fast Or / fired chips (per event) - SPD",fgkSPDchips,range[0],range[1]);
202   hFastOrNoisyRatio->SetMaximum(1.05);
203   hFastOrNoisyRatio->GetXaxis()->SetTitle("Layer 1");
204   hFastOrNoisyRatio->GetYaxis()->SetTitle("Layer 2");
205   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrNoisyRatio, 7+shift, expert, !image, !saveCorr);
206   fSPDhRawsTask++;  
207 // 8
208   TH1F *herrorsAll = new TH1F("SPDErrorsAll_SPD","Error codes - SPD",20,0.,20.);
209   herrorsAll->GetXaxis()->SetTitle("DDL");
210   herrorsAll->GetYaxis()->SetTitle("Entries");
211   rv = fAliITSQADataMakerRec->Add2RawsList(herrorsAll, kAmoreFoOffset+shift, !expert, image, !saveCorr);
212   fSPDhRawsTask++;
213
214 //9-28
215   TH1F **herrors = new TH1F*[20];
216   for (Int_t iEq=0; iEq<20; iEq++) {
217     sprintf(name,"SPDErrors_SPD_Eq%d",iEq+1);
218     sprintf(title,"Error codes - SPD Eq %d",iEq+1);
219     herrors[iEq] = new TH1F (name,title,fAdvLogger->GetNrErrorCodes(),0,fAdvLogger->GetNrErrorCodes());
220     herrors[iEq]->SetXTitle("Error Code");
221     herrors[iEq]->SetYTitle("Nr of errors");
222     rv = fAliITSQADataMakerRec->Add2RawsList(herrors[iEq], (kAmoreFoOffset+1)+iEq+shift, expert, !image, !saveCorr);
223     fSPDhRawsTask++;
224   }
225   
226 //   *********   offline histo booking  (offset is added) ****************************  
227
228  // offset for offline histogram numbering
229   Int_t offset = fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + kAmoreFoOffset + kAmoreErrorsOffset;
230 // 0
231   TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
232   hlayer->GetXaxis()->SetTitle("Layer number");
233   hlayer->GetYaxis()->SetTitle("Entries");
234   rv = fAliITSQADataMakerRec->Add2RawsList(hlayer, 0+offset, expert, !image, !saveCorr);
235   fSPDhRawsTask++;
236
237   TH1F **hmod = new TH1F*[2];
238   TH2F **hhitMap = new TH2F*[20];
239
240   
241 // 1-2
242   for (Int_t iLay=0; iLay<2; iLay++) {
243     sprintf(name,"SPDModPattern_SPD%d",iLay+1);
244     sprintf(title,"Module map - SPD Layer %d",iLay+1);
245     hmod[iLay]=new TH1F(name,title,fgknSPDmodules,0,fgknSPDmodules);
246     hmod[iLay]->GetXaxis()->SetTitle("Module number");
247     hmod[iLay]->GetYaxis()->SetTitle("Entries");
248     rv = fAliITSQADataMakerRec->Add2RawsList(hmod[iLay], 1+iLay+offset, expert, !image, !saveCorr);
249     fSPDhRawsTask++;
250   }
251 // 3
252   TH2F *hHitMapHalfStaveChipSideA 
253      = new TH2F("SPDHitMapHalfStaveChipSideA_SPD","Hit map per HalfStave per Chip Side A - SPD",60,0.,60.,10,0.,10.);
254   hHitMapHalfStaveChipSideA->GetXaxis()->SetTitle("HalfStave");
255   hHitMapHalfStaveChipSideA->GetYaxis()->SetTitle("Chip");
256   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapHalfStaveChipSideA, 3+offset, expert, !image, !saveCorr);
257   fSPDhRawsTask++;
258 // 4
259   TH2F *hHitMapHalfStaveChipSideC 
260      = new TH2F("SPDHitMapHalfStaveChipSideC_SPD","Hit map per HalfStave per Chip Side C - SPD",60,0.,60.,10,0.,10.);
261   hHitMapHalfStaveChipSideC->GetXaxis()->SetTitle("HalfStave");
262   hHitMapHalfStaveChipSideC->GetYaxis()->SetTitle("Chip");
263   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapHalfStaveChipSideC, 4+offset, expert, !image, !saveCorr);
264   fSPDhRawsTask++;
265  //5-24
266   for (Int_t iDDL=0; iDDL<20; iDDL++) {
267     sprintf(name,"SPDHitMap_SPD_DDL%d",iDDL+1);
268     sprintf(title,"Hit map - SPD DDL %d",iDDL+1);
269     hhitMap[iDDL]=new TH2F(name,title,320,0,10*32,1536,0,6*256);
270     hhitMap[iDDL]->GetXaxis()->SetTitle("Column");
271     hhitMap[iDDL]->GetYaxis()->SetTitle("Row");
272     rv = fAliITSQADataMakerRec->Add2RawsList(hhitMap[iDDL], 5+iDDL+offset, expert, !image, !saveCorr);
273     fSPDhRawsTask++;
274     }
275 // 25-26
276   TH1F** hMultSPDhits = new TH1F*[2];
277   for (Int_t iLay=0; iLay<2; iLay++) {
278     sprintf(name,"SPDHitsMultiplicity_SPD%d",iLay+1);
279     sprintf(title,"Hit multiplicity - SPD Layer %d",iLay+1);
280     hMultSPDhits[iLay]=new TH1F(name,title,200,0.,200.);
281     hMultSPDhits[iLay]->GetXaxis()->SetTitle("Hit multiplicity");
282     hMultSPDhits[iLay]->GetYaxis()->SetTitle("Entries");
283     rv = fAliITSQADataMakerRec->Add2RawsList(hMultSPDhits[iLay], 25+iLay+offset, expert, !image, !saveCorr);
284     fSPDhRawsTask++;
285   }
286 // 27
287   TH2F *hMultSPDhits2MultSPDhits1 
288          = new TH2F("SPDHitMultCorrelation_SPD","Hit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
289   hMultSPDhits2MultSPDhits1->GetXaxis()->SetTitle("Hit multiplicity (Layer 1)");
290   hMultSPDhits2MultSPDhits1->GetYaxis()->SetTitle("Hit multiplicity (Layer 2)");
291   rv = fAliITSQADataMakerRec->Add2RawsList(hMultSPDhits2MultSPDhits1, 27+offset, !expert, image, !saveCorr);
292   fSPDhRawsTask++;
293 // 28
294   TH2F *hFastOrMapHalfStaveChip 
295          = new TH2F("SPDFastOrMapHalfStaveChip_SPD","FastOr map per HalfStave per Chip - SPD",120,0.,120.,10,0.,10.);
296   hFastOrMapHalfStaveChip->GetXaxis()->SetTitle("HalfStave");
297   hFastOrMapHalfStaveChip->GetYaxis()->SetTitle("Chip");
298   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrMapHalfStaveChip, 28+offset, !expert, image, !saveCorr);
299   fSPDhRawsTask++;
300 // 29
301   TH1F *hFastOrFiredMap = new TH1F("SPDFastOrPattern_SPD","FastOrFiredChip map - SPD",1200,0.,1200.);
302   hFastOrFiredMap->GetXaxis()->SetTitle("Chip number");
303   hFastOrFiredMap->GetYaxis()->SetTitle("Entries");
304   rv = fAliITSQADataMakerRec->Add2RawsList(hFastOrFiredMap, 29+offset, expert, !image, !saveCorr);
305   fSPDhRawsTask++;
306 // 30
307   TH2F *hHitMapHalfStaveChipInner 
308      = new TH2F("SPDHitMapHalfStaveChipInner_SPD","Hit map per HalfStave per Chip Inner - SPD",20,0.,20.,20,0.,20.);
309   hHitMapHalfStaveChipInner->GetXaxis()->SetTitle("Chip");
310   hHitMapHalfStaveChipInner->GetYaxis()->SetTitle("HalfStave");
311   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapHalfStaveChipInner, 30+offset, !expert, image, !saveCorr);
312   fSPDhRawsTask++;
313 // 31
314   TH2F *hHitMapHalfStaveChipOuter 
315      = new TH2F("SPDHitMapHalfStaveChipOuter_SPD","Hit map per HalfStave per Chip Outer - SPD",20,0.,20.,40,0.,40.);
316   hHitMapHalfStaveChipOuter->GetXaxis()->SetTitle("Chip");
317   hHitMapHalfStaveChipOuter->GetYaxis()->SetTitle("HalfStave");
318   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapHalfStaveChipOuter, 31+offset, !expert, image, !saveCorr);
319   fSPDhRawsTask++;
320 // 32
321   TH1F *hHitMapChipInnerZ = new TH1F("SPDHitMapChipInnerZ_SPD","Hit map per ChipZ Inner - SPD",20,0.,20.);
322   hHitMapChipInnerZ->GetXaxis()->SetTitle("Chip");
323   hHitMapChipInnerZ->GetYaxis()->SetTitle("Entries");
324   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapChipInnerZ, 32+offset, !expert, image, !saveCorr);
325   fSPDhRawsTask++;
326 // 33
327   TH1F *hHitMapChipOuterZ = new TH1F("SPDHitMapChipOuterZ_SPD","Hit map per ChipZ Outer - SPD",20,0.,20.);
328   hHitMapChipOuterZ->GetXaxis()->SetTitle("Chip");
329   hHitMapChipOuterZ->GetYaxis()->SetTitle("Entries");
330   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapChipOuterZ, 33+offset, !expert, image, !saveCorr);
331   fSPDhRawsTask++;
332 // 34
333   TH1F *hHitMapHalfStaveInnerPhi = new TH1F("SPDHitMapChipInnerPhi_SPD","Hit map per HalfStavePhi Inner - SPD",20,0.,20.);
334   hHitMapHalfStaveInnerPhi->GetXaxis()->SetTitle("HalfStave");
335   hHitMapHalfStaveInnerPhi->GetYaxis()->SetTitle("Entries");
336   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapHalfStaveInnerPhi, 34+offset, !expert, image, !saveCorr);
337   fSPDhRawsTask++;
338 // 35
339   TH1F *hHitMapHalfStaveOuterPhi = new TH1F("SPDHitMapChipOuterPhi_SPD","Hit map per HalfStavePhi Outer - SPD",40,0.,40.);
340   hHitMapHalfStaveOuterPhi->GetXaxis()->SetTitle("HalfStave");
341   hHitMapHalfStaveOuterPhi->GetYaxis()->SetTitle("Entries");
342   rv = fAliITSQADataMakerRec->Add2RawsList(hHitMapHalfStaveOuterPhi, 35+offset, !expert, image, !saveCorr);
343   fSPDhRawsTask++;
344    
345   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Raws histograms booked\n",fSPDhRawsTask));
346   return rv ; 
347 }
348
349 //____________________________________________________________________________
350 Int_t AliITSQASPDDataMakerRec::MakeRaws(AliRawReader* rawReader)
351
352   // Fill QA for RAW - SPD -
353   Int_t rv = 0 ; 
354   
355   rawReader->Reset();
356   AliITSRawStreamSPD rawStreamSPD(rawReader);
357   rawStreamSPD.ActivateAdvancedErrorLog(kTRUE,fAdvLogger);
358   
359   // shift for online histos
360   Int_t shift = fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()];
361   
362    // shift for online histos
363   Int_t offset = fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] + kAmoreFoOffset+kAmoreErrorsOffset;
364
365   Int_t nDigitsL1 = 0;
366   Int_t nDigitsL2 = 0;
367   Int_t iEq;
368   Int_t iLayer;
369   Int_t iHalfStave, iChip;
370   Int_t chipKey;
371   Int_t col, row; 
372   UInt_t module, colM, rowM;
373   Bool_t isFiredChip[1200];
374   for(Int_t ichK=0; ichK<1200; ichK++) isFiredChip[ichK] = kFALSE;
375   Bool_t isOnlineFiredChip[1200];
376   for(Int_t iOnlineKey=0; iOnlineKey<1200; iOnlineKey++) isOnlineFiredChip[iOnlineKey] = kFALSE;
377   UInt_t nFastOr[2]={0,0};
378
379   while(rawStreamSPD.Next()) {
380
381     iEq = rawReader->GetDDLID();
382     if (iEq>=0 && iEq<20) {
383       iHalfStave = rawStreamSPD.GetHalfStaveNr();
384       iChip = rawStreamSPD.GetChipAddr();
385       col   = rawStreamSPD.GetChipCol();
386       row   = rawStreamSPD.GetChipRow();
387       isOnlineFiredChip[iEq*60+iHalfStave*10+iChip] = kTRUE;
388       chipKey = rawStreamSPD.GetOfflineChipKeyFromOnline(iEq,iHalfStave,iChip);
389       isFiredChip[chipKey] = kTRUE;
390
391       rawStreamSPD.OnlineToOffline(iEq, iHalfStave, iChip, col, row, module, colM, rowM);
392
393       if (iHalfStave>=0 && iHalfStave<2) iLayer=0;
394       else iLayer=1;
395       
396       fAliITSQADataMakerRec->GetRawsData(0+offset)->Fill(iLayer);
397       if (iLayer==0) {
398         fAliITSQADataMakerRec->GetRawsData(1+offset)->Fill(module);
399         nDigitsL1++;
400       } else {
401         fAliITSQADataMakerRec->GetRawsData(2+offset)->Fill(module);
402         nDigitsL2++;
403       }
404       
405       if(iEq<10) {
406          fAliITSQADataMakerRec->GetRawsData(3+offset)->Fill(iHalfStave+iEq*6,iChip);
407       } 
408       else       {
409          fAliITSQADataMakerRec->GetRawsData(4+offset)->Fill(iHalfStave+(iEq-10)*6,iChip);
410       }
411
412       if(iLayer==0) {
413          if(iEq<10)  { 
414             fAliITSQADataMakerRec->GetRawsData(30+offset)->Fill(19-iChip,1-iHalfStave+iEq*2);
415             fAliITSQADataMakerRec->GetRawsData(32+offset)->Fill(19-iChip);
416             fAliITSQADataMakerRec->GetRawsData(34+offset)->Fill(1-iHalfStave+iEq*2);
417          }
418          else {
419             fAliITSQADataMakerRec->GetRawsData(30+offset)->Fill(iChip,1-iHalfStave+(iEq-10)*2);
420             fAliITSQADataMakerRec->GetRawsData(32+offset)->Fill(iChip);
421             fAliITSQADataMakerRec->GetRawsData(34+offset)->Fill(1-iHalfStave+(iEq-10)*2);
422          }
423       }
424       else         {   
425          if(iEq<10)  { 
426             fAliITSQADataMakerRec->GetRawsData(31+offset)->Fill(19-iChip,iHalfStave-2+iEq*4);
427             fAliITSQADataMakerRec->GetRawsData(33+offset)->Fill(19-iChip);
428             fAliITSQADataMakerRec->GetRawsData(35+offset)->Fill(iHalfStave-2+iEq*4);
429          }
430          else {
431             fAliITSQADataMakerRec->GetRawsData(31+offset)->Fill(iChip,iHalfStave-2+(iEq-10)*4);
432             fAliITSQADataMakerRec->GetRawsData(33+offset)->Fill(iChip);
433             fAliITSQADataMakerRec->GetRawsData(35+offset)->Fill(iHalfStave-2+(iEq-10)*4);
434          }
435       }
436       fAliITSQADataMakerRec->GetRawsData(5+iEq+offset)->Fill(colM+(module%2)*160,rowM+iHalfStave*256); 
437     }
438   }
439
440   UInt_t nErrorsDDL[20];
441
442   for (Int_t ieq=0; ieq<20; ieq++) {
443     nErrorsDDL[ieq] = 0;
444    
445     for (UInt_t ierr=0; ierr<fAdvLogger->GetNrErrorCodes(); ierr++) {
446       fAliITSQADataMakerRec->GetRawsData(ieq+(kAmoreFoOffset+1)+shift)->Fill(ierr,fAdvLogger->GetNrErrors(ierr,ieq));
447       if(ierr>0) nErrorsDDL[ieq] = nErrorsDDL[ieq] + fAdvLogger->GetNrErrors(ierr,ieq);   
448     }  
449     fAliITSQADataMakerRec->GetRawsData(8+shift)->Fill(ieq,nErrorsDDL[ieq]);
450
451     for (Int_t ihs=0; ihs<6; ihs++) {
452       for (Int_t ichip=0; ichip<10; ichip++) {
453       if(isOnlineFiredChip[ieq*60+ihs*10+ichip]) fAliITSQADataMakerRec->GetRawsData(1+shift)->Fill(ieq*60+ihs*10+ichip); // online
454       if(rawStreamSPD.GetFastOrSignal(ieq,ihs,ichip) && isOnlineFiredChip[ieq*60+ihs*10+ichip]) fAliITSQADataMakerRec->GetRawsData(0+shift)->Fill(ieq*60+ihs*10+ichip); // online
455       if(!rawStreamSPD.GetFastOrSignal(ieq,ihs,ichip) && isOnlineFiredChip[ieq*60+ihs*10+ichip]) fAliITSQADataMakerRec->GetRawsData(2+shift)->Fill(ieq*60+ihs*10+ichip); // online
456       if(rawStreamSPD.GetFastOrSignal(ieq,ihs,ichip) && !isOnlineFiredChip[ieq*60+ihs*10+ichip]) fAliITSQADataMakerRec->GetRawsData(3+shift)->Fill(ieq*60+ihs*10+ichip); // online       
457       
458         chipKey = rawStreamSPD.GetOfflineChipKeyFromOnline(ieq,ihs,ichip);
459         
460         if(rawStreamSPD.GetFastOrSignal(ieq,ihs,ichip)) {
461           if(ihs <2) nFastOr[0]++; // online
462           else nFastOr[1]++;       // online
463           fAliITSQADataMakerRec->GetRawsData(28+offset)->Fill(ihs+ieq*6,ichip);
464           fAliITSQADataMakerRec->GetRawsData(29+offset)->Fill(chipKey);
465         }
466       }
467     } 
468
469
470   }
471
472   fAliITSQADataMakerRec->GetRawsData(4+shift)->Fill(nFastOr[0],nFastOr[1]); // online
473
474   fAdvLogger->Reset();
475   fAliITSQADataMakerRec->GetRawsData(25+offset)->Fill(nDigitsL1);
476   fAliITSQADataMakerRec->GetRawsData(26+offset)->Fill(nDigitsL2);
477   fAliITSQADataMakerRec->GetRawsData(27+offset)->Fill(nDigitsL1,nDigitsL2);
478   
479   AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",nDigitsL1+nDigitsL2));
480   return rv ; 
481 }
482
483 //____________________________________________________________________________ 
484 Int_t AliITSQASPDDataMakerRec::InitDigits()
485
486   // Initialization for DIGIT data - SPD -
487   const Bool_t expert   = kTRUE ; 
488   const Bool_t image    = kTRUE ;
489   Int_t rv = 0 ; 
490 //  fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
491   //fSPDhDigitsTask must be incremented by one unit every time a histogram is ADDED to the QA List
492   
493   Char_t name[50];
494   Char_t title[50];
495   
496   TH1F *hlayer = new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
497   hlayer->GetXaxis()->SetTitle("Layer number");
498   hlayer->GetYaxis()->SetTitle("Entries");
499   rv = fAliITSQADataMakerRec->Add2DigitsList(hlayer,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
500   fSPDhDigitsTask++;
501   
502   TH1F **hmod = new TH1F*[2];
503   for (Int_t iLay=0; iLay<2; iLay++) {
504     sprintf(name,"SPDModPattern_SPD%d",iLay+1);
505     sprintf(title,"Module map - SPD Layer %d",iLay+1);
506     hmod[iLay]=new TH1F(name,title,240,0,240);
507     hmod[iLay]->GetXaxis()->SetTitle("Module number");
508     hmod[iLay]->GetYaxis()->SetTitle("Entries");
509     rv = fAliITSQADataMakerRec->Add2DigitsList(hmod[iLay],1+iLay+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
510     fSPDhDigitsTask++;
511   }
512   
513   TH1F *hcolumns = new TH1F("SPDColumns_SPD","Columns - SPD",160,0.,160.);
514   hcolumns->GetXaxis()->SetTitle("Column number");
515   hcolumns->GetYaxis()->SetTitle("Entries");
516   rv = fAliITSQADataMakerRec->Add2DigitsList(hcolumns,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
517   fSPDhDigitsTask++;
518   
519   TH1F *hrows = new TH1F("SPDRows_SPD","Rows - SPD",256,0.,256.);
520   hrows->GetXaxis()->SetTitle("Row number");
521   hrows->GetYaxis()->SetTitle("Entries");
522   rv = fAliITSQADataMakerRec->Add2DigitsList(hrows,4+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
523   fSPDhDigitsTask++;
524   
525   TH1F** hMultSPDdigits = new TH1F*[2];
526   for (Int_t iLay=0; iLay<2; ++iLay) {
527     sprintf(name,"SPDDigitMultiplicity_SPD%d",iLay+1);
528     sprintf(title,"Digit multiplicity - SPD Layer %d",iLay+1);
529     hMultSPDdigits[iLay]=new TH1F(name,title,200,0.,200.);
530     hMultSPDdigits[iLay]->GetXaxis()->SetTitle("Digit multiplicity");
531     hMultSPDdigits[iLay]->GetYaxis()->SetTitle("Entries");
532     rv = fAliITSQADataMakerRec->Add2DigitsList(hMultSPDdigits[iLay], 5+iLay+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
533     fSPDhDigitsTask++;
534   }
535   
536   TH2F *hMultSPDdig2MultSPDdig1 
537     = new TH2F("SPDDigitMultCorrelation_SPD","Digit multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
538   hMultSPDdig2MultSPDdig1->GetXaxis()->SetTitle("Digit multiplicity (Layer 1)");
539   hMultSPDdig2MultSPDdig1->GetYaxis()->SetTitle("Digit multiplicity (Layer 2)");
540   rv = fAliITSQADataMakerRec->Add2DigitsList(hMultSPDdig2MultSPDdig1,7+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
541   fSPDhDigitsTask++;
542   
543   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Digits histograms booked\n",fSPDhDigitsTask));
544   return rv ; 
545 }
546
547 //____________________________________________________________________________
548 Int_t AliITSQASPDDataMakerRec::MakeDigits(TTree *digits)
549
550   // Fill QA for DIGIT - SPD -
551   Int_t rv = 0 ; 
552
553 //  AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
554 //  fITS->SetTreeAddress();
555 //  TClonesArray *iITSdigits  = fITS->DigitsAddress(0);  // 0->SPD
556   TBranch *branchD = digits->GetBranch("ITSDigitsSPD");
557   if (!branchD) { 
558     AliError("can't get the branch with the SPD ITS digits !");
559     return rv;
560   }
561   static TClonesArray statDigits("AliITSdigitSPD");
562   TClonesArray *iITSdigits = &statDigits;
563   branchD->SetAddress(&iITSdigits);  
564   Int_t nDigitsL1=0;
565   Int_t nDigitsL2=0;
566   
567   for (Int_t imod=0; imod<240; ++imod){
568     digits->GetEvent(imod);
569     Int_t ndigits = iITSdigits->GetEntries();
570     if (imod<80) {
571       fAliITSQADataMakerRec->GetDigitsData(0+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(0.5,ndigits);
572       fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(imod,ndigits);
573       nDigitsL1+=ndigits;
574     }
575     else {
576       fAliITSQADataMakerRec->GetDigitsData(0+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(1,ndigits);
577       fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(imod,ndigits);
578       nDigitsL2+=ndigits;
579     }
580     for (Int_t idig=0; idig<ndigits; ++idig) {
581       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
582       Int_t col=dig->GetCoord1();  // cell number z
583       Int_t row=dig->GetCoord2();  // cell number x
584       fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(col);
585       fAliITSQADataMakerRec->GetDigitsData(4+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(row);
586     }
587   }
588   fAliITSQADataMakerRec->GetDigitsData(5+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nDigitsL1);
589   fAliITSQADataMakerRec->GetDigitsData(6+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nDigitsL2);
590   fAliITSQADataMakerRec->GetDigitsData(7+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nDigitsL1,nDigitsL2);
591   return rv ; 
592 }
593
594 //____________________________________________________________________________ 
595 Int_t AliITSQASPDDataMakerRec::InitRecPoints()
596 {
597   // Initialization for RECPOINTS - SPD -
598   const Bool_t expert   = kTRUE ; 
599   const Bool_t image    = kTRUE ; 
600   Int_t rv = 0 ; 
601   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
602   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
603 //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
604   TH1F* hlayer= new TH1F("SPDLayPattern_SPD","Layer map - SPD",6,0.,6.);
605   hlayer->GetXaxis()->SetTitle("Layer number");
606   hlayer->GetYaxis()->SetTitle("Entries");
607   rv = fAliITSQADataMakerRec->Add2RecPointsList(hlayer, 0+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
608   fSPDhRecPointsTask++;
609
610   TH1F** hmod = new TH1F*[2];
611   TH1F** hxl  = new TH1F*[2];
612   TH1F** hzl  = new TH1F*[2];
613   TH1F** hxg  = new TH1F*[2];
614   TH1F** hyg  = new TH1F*[2];
615   TH1F** hzg  = new TH1F*[2];
616   TH1F** hr   = new TH1F*[2];
617   TH1F** hphi = new TH1F*[2];
618   TH1F** hMultSPDcl = new TH1F*[2];
619   TH2F** hNyNz    = new TH2F*[2];  // y and z cluster length
620   TH1F** hNpixels = new TH1F*[2];  // cluster size in number of pixels
621   TH1F** hType    = new TH1F*[2];  // cluster type according to conventional table
622   TH2F** hPhiZ    = new TH2F*[2];
623
624   Float_t xlim[2]={4.5,8.};
625   Float_t zlim[2]={15.,15.};
626
627   Char_t name[50];
628   Char_t title[50];
629   for (Int_t iLay=0;iLay<2;iLay++) {
630     sprintf(name,"SPDModPattern_SPD%d",iLay+1);
631     sprintf(title,"Module map - SPD Layer %d",iLay+1);
632     hmod[iLay]=new TH1F(name,title,fgknSPDmodules,0,fgknSPDmodules);
633     hmod[iLay]->GetXaxis()->SetTitle("Module number");
634     hmod[iLay]->GetYaxis()->SetTitle("Entries");
635     rv = fAliITSQADataMakerRec->Add2RecPointsList(hmod[iLay], 1+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
636     fSPDhRecPointsTask++;
637
638     sprintf(name,"SPDxLoc_SPD%d",iLay+1);
639     sprintf(title,"Local x coordinate - SPD Layer %d",iLay+1);
640     hxl[iLay]=new TH1F(name,title,100,-4.,4.);
641     hxl[iLay]->GetXaxis()->SetTitle("Local x [cm]");
642     hxl[iLay]->GetYaxis()->SetTitle("Entries");
643     rv = fAliITSQADataMakerRec->Add2RecPointsList(hxl[iLay], 2+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
644     fSPDhRecPointsTask++;
645
646     sprintf(name,"SPDzLoc_SPD%d",iLay+1);
647     sprintf(title,"Local z coordinate - SPD Layer %d",iLay+1);
648     hzl[iLay]=new TH1F(name,title,100,-4.,4.);
649     hzl[iLay]->GetXaxis()->SetTitle("Local z [cm]");
650     hzl[iLay]->GetYaxis()->SetTitle("Entries");
651     rv = fAliITSQADataMakerRec->Add2RecPointsList(hzl[iLay], 3+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
652     fSPDhRecPointsTask++;
653
654     sprintf(name,"SPDxGlob_SPD%d",iLay+1);
655     sprintf(title,"Global x coordinate - SPD Layer %d",iLay+1);
656     hxg[iLay]=new TH1F(name,title,100,-xlim[iLay],xlim[iLay]);
657     hxg[iLay]->GetXaxis()->SetTitle("Global x [cm]");
658     hxg[iLay]->GetYaxis()->SetTitle("Entries");
659     rv = fAliITSQADataMakerRec->Add2RecPointsList(hxg[iLay],4+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);  
660     fSPDhRecPointsTask++;
661
662     sprintf(name,"SPDyGlob_SPD%d",iLay+1);
663     sprintf(title,"Global y coordinate - SPD Layer %d",iLay+1);
664     hyg[iLay]=new TH1F(name,title,100,-xlim[iLay],xlim[iLay]);
665     hyg[iLay]->GetXaxis()->SetTitle("Global y [cm]");
666     hyg[iLay]->GetYaxis()->SetTitle("Entries");
667     rv = fAliITSQADataMakerRec->Add2RecPointsList(hyg[iLay], 5+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
668     fSPDhRecPointsTask++;
669
670     sprintf(name,"SPDzGlob_SPD%d",iLay+1);
671     sprintf(title,"Global z coordinate - SPD Layer %d",iLay+1);
672     hzg[iLay]=new TH1F(name,title,150,-zlim[iLay],zlim[iLay]);
673     hzg[iLay]->GetXaxis()->SetTitle("Global z [cm]");
674     hzg[iLay]->GetYaxis()->SetTitle("Entries");
675     rv = fAliITSQADataMakerRec->Add2RecPointsList(hzg[iLay], 6+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
676     fSPDhRecPointsTask++;
677
678     sprintf(name,"SPDr_SPD%d",iLay+1);
679     sprintf(title,"Radius - SPD Layer %d",iLay+1);
680     hr[iLay]=new TH1F(name,title,100,0.,10.);
681     hr[iLay]->GetXaxis()->SetTitle("r [cm]");
682     hr[iLay]->GetYaxis()->SetTitle("Entries");
683     rv = fAliITSQADataMakerRec->Add2RecPointsList(hr[iLay], 7+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);  
684     fSPDhRecPointsTask++;
685
686     sprintf(name,"SPDphi_SPD%d",iLay+1);
687     sprintf(title,"#varphi - SPD Layer %d",iLay+1);
688     hphi[iLay]=new TH1F(name,title,1000,0.,2*TMath::Pi());
689     hphi[iLay]->GetXaxis()->SetTitle("#varphi [rad]");
690     hphi[iLay]->GetYaxis()->SetTitle("Entries");
691     rv = fAliITSQADataMakerRec->Add2RecPointsList(hphi[iLay], 8+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
692     fSPDhRecPointsTask++;
693     
694     sprintf(name,"SPDSizeYvsZ_SPD%d",iLay+1);
695     sprintf(title,"Cluster dimension - SPD Layer %d",iLay+1);
696     hNyNz[iLay]=new TH2F(name,title,100,0.,100.,100,0.,100.);
697     hNyNz[iLay]->GetXaxis()->SetTitle("z length");
698     hNyNz[iLay]->GetYaxis()->SetTitle("y length");
699     rv = fAliITSQADataMakerRec->Add2RecPointsList(hNyNz[iLay], 9+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); 
700     fSPDhRecPointsTask++;
701
702     sprintf(name,"SPDSizeTot_SPD%d",iLay+1);
703     sprintf(title,"Cluster size - SPD Layer %d",iLay+1);
704     hNpixels[iLay]=new TH1F(name,title,100,0.,100.);
705     hNpixels[iLay]->GetXaxis()->SetTitle("Cluster size");
706     hNpixels[iLay]->GetYaxis()->SetTitle("Entries");
707     rv = fAliITSQADataMakerRec->Add2RecPointsList(hNpixels[iLay], 10+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);  
708     fSPDhRecPointsTask++;
709
710     sprintf(name,"SPDType_SPD%d",iLay+1);
711     sprintf(title,"Cluster type - SPD Layer %d",iLay+1);
712     hType[iLay]=new TH1F(name,title,20,0.,20.);
713     hType[iLay]->GetXaxis()->SetTitle("Cluster type");
714     hType[iLay]->GetYaxis()->SetTitle("Entries");
715     rv = fAliITSQADataMakerRec->Add2RecPointsList(hType[iLay], 11+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);  
716     fSPDhRecPointsTask++;
717
718     sprintf(name,"SPDphi_z_SPD%d",iLay+1);
719     sprintf(title,"#varphi vs z - SPD Layer %d",iLay+1);
720     hPhiZ[iLay]=new TH2F(name,title,150,-zlim[iLay],zlim[iLay],200,0.,2*TMath::Pi());
721     hPhiZ[iLay]->GetXaxis()->SetTitle("Global z [cm]");
722     hPhiZ[iLay]->GetYaxis()->SetTitle("#varphi [rad]");
723     rv = fAliITSQADataMakerRec->Add2RecPointsList(hPhiZ[iLay], 12+(12*iLay)+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
724     fSPDhRecPointsTask++;
725
726   }
727
728   TH2F *hrPhi=new TH2F("SPDr_phi_SPD","#varphi vs r - SPD",100,0.,10.,100,0.,2*TMath::Pi());
729   hrPhi->GetXaxis()->SetTitle("r [cm]");
730   hrPhi->GetYaxis()->SetTitle("#varphi [rad]");
731   rv = fAliITSQADataMakerRec->Add2RecPointsList(hrPhi, 25+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);
732   fSPDhRecPointsTask++;
733
734   TH2F *hxy=new TH2F("SPDx_y_SPD","Global y vs x - SPD",200,-10.,10.,200,-10.,10.);
735   hxy->GetXaxis()->SetTitle("Global x [cm]");
736   hxy->GetYaxis()->SetTitle("Global y [cm]");
737   rv = fAliITSQADataMakerRec->Add2RecPointsList(hxy, 26+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
738   fSPDhRecPointsTask++;
739
740   for (Int_t iLay=0;iLay<2;iLay++) {
741     sprintf(name,"SPDMultiplicity_SPD%d",iLay+1);
742     sprintf(title,"Cluster multiplicity - SPD Layer %d",iLay+1);
743     hMultSPDcl[iLay]=new TH1F(name,title,200,0.,200.);
744     hMultSPDcl[iLay]->GetXaxis()->SetTitle("Cluster multiplicity");
745     hMultSPDcl[iLay]->GetYaxis()->SetTitle("Entries");
746     rv = fAliITSQADataMakerRec->Add2RecPointsList(hMultSPDcl[iLay], 27+iLay+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
747     fSPDhRecPointsTask++;
748   } 
749
750   TH2F *hMultSPDcl2MultSPDcl1 =
751         new TH2F("SPDMultCorrelation_SPD","Cluster multiplicity correlation - SPD",200,0.,200.,200,0.,200.);
752   hMultSPDcl2MultSPDcl1->GetXaxis()->SetTitle("Clusters multiplicity (Layer 1)");
753   hMultSPDcl2MultSPDcl1->GetYaxis()->SetTitle("Clusters multiplicity (Layer 2)"); 
754   rv = fAliITSQADataMakerRec->Add2RecPointsList(hMultSPDcl2MultSPDcl1, 29+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
755   fSPDhRecPointsTask++;
756
757   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SPD Recs histograms booked\n",fSPDhRecPointsTask));
758
759   return rv ; 
760 }
761
762 //____________________________________________________________________________ 
763 Int_t AliITSQASPDDataMakerRec::MakeRecPoints(TTree * clusterTree)
764 {
765   // Fill QA for RecPoints - SPD -
766   Int_t rv = 0 ;
767   AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
768   TClonesArray *recpoints = rpcont->FetchClusters(0,clusterTree);
769   if(!rpcont->GetStatusOK() || !rpcont->IsSPDActive()){
770     AliError("can't get SPD clusters !");
771     return rv;
772   }
773
774   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
775   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
776   Int_t nSPDmod = AliITSgeomTGeo::GetModuleIndex(3,1,1);
777
778   Float_t cluGlo[3] = {0.,0.,0.};
779   Int_t nClusters[2] = {0,0};
780
781   for (Int_t iIts=0; iIts < nSPDmod; iIts++) {
782     recpoints = rpcont->UncheckedGetClusters(iIts);
783     Int_t nCluster = recpoints->GetEntriesFast();
784     if(nCluster == 0)continue;
785     // loop over clusters
786     while(nCluster--) {
787       AliITSRecPoint* cluster =
788                       (AliITSRecPoint*)recpoints->UncheckedAt(nCluster);
789       if (cluster->GetLayer()>1)continue;
790       Int_t lay=cluster->GetLayer();
791       fAliITSQADataMakerRec->GetRecPointsData(0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lay);
792       cluster->GetGlobalXYZ(cluGlo);
793       Float_t rad=TMath::Sqrt(cluGlo[0]*cluGlo[0]+cluGlo[1]*cluGlo[1]);
794         Float_t phi= TMath::Pi() + TMath::ATan2(-cluGlo[1],-cluGlo[0]);
795         if (lay==0) {
796           fAliITSQADataMakerRec->GetRecPointsData(1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iIts);
797           fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalX());
798           fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalZ());
799           fAliITSQADataMakerRec->GetRecPointsData(4 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[0]);
800           fAliITSQADataMakerRec->GetRecPointsData(5 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[1]);
801           fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2]);
802           fAliITSQADataMakerRec->GetRecPointsData(7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);
803           fAliITSQADataMakerRec->GetRecPointsData(8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);
804           fAliITSQADataMakerRec->GetRecPointsData(9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetNz(),cluster->GetNy());
805           fAliITSQADataMakerRec->GetRecPointsData(10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetNpixels());
806           fAliITSQADataMakerRec->GetRecPointsData(11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetSPDclusterType());
807           fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2],phi);
808         } else  {
809           fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iIts);
810           fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalX());
811           fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetDetLocalZ());
812           fAliITSQADataMakerRec->GetRecPointsData(16 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[0]);
813           fAliITSQADataMakerRec->GetRecPointsData(17 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[1]);
814           fAliITSQADataMakerRec->GetRecPointsData(18 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2]);
815           fAliITSQADataMakerRec->GetRecPointsData(19 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);
816           fAliITSQADataMakerRec->GetRecPointsData(20 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);
817           fAliITSQADataMakerRec->GetRecPointsData(21 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetNz(),cluster->GetNy());
818           fAliITSQADataMakerRec->GetRecPointsData(22 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetNpixels());
819           fAliITSQADataMakerRec->GetRecPointsData(23 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluster->GetSPDclusterType());
820           fAliITSQADataMakerRec->GetRecPointsData(24 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[2],phi);
821         }
822         fAliITSQADataMakerRec->GetRecPointsData(25 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad,phi);
823         fAliITSQADataMakerRec->GetRecPointsData(26 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluGlo[0],cluGlo[1]);
824
825         nClusters[lay]++;
826     } // end of cluster loop
827   } // end of its "subdetector" loop
828
829   for (Int_t iLay=0; iLay<2; iLay++)
830     fAliITSQADataMakerRec->GetRecPointsData(27 +iLay +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nClusters[iLay]);
831
832   fAliITSQADataMakerRec->GetRecPointsData(29 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nClusters[0],nClusters[1]);
833
834   return rv ;
835 }
836
837
838
839 //_______________________________________________________________
840
841 Int_t AliITSQASPDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task,Int_t specie) {
842   // Returns offset number according to the specified task
843   Int_t offset=0;
844   if( task == AliQAv1::kRAWS ) {
845     offset=fGenRawsOffset[specie];
846   }
847   else if( task == AliQAv1::kDIGITSR ) {
848     offset=fGenDigitsOffset[specie];
849   }
850   else if( task == AliQAv1::kRECPOINTS ) {
851     offset=fGenRecPointsOffset[specie];
852   }
853
854   return offset;
855 }
856
857 //_______________________________________________________________
858
859 void AliITSQASPDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
860   // Returns offset number according to the specified task
861   if( task == AliQAv1::kRAWS ) {
862     fGenRawsOffset[specie]=offset;
863   }
864   else if( task == AliQAv1::kDIGITSR ) {
865     fGenDigitsOffset[specie]=offset;
866   }
867   else if( task == AliQAv1::kRECPOINTS ) {
868     fGenRecPointsOffset[specie]=offset;
869   }
870 }
871
872 //_______________________________________________________________
873
874 Int_t AliITSQASPDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task) {
875   // Returns the number of histograms associated to the specified task
876
877   Int_t histotot=0;
878
879   if( task == AliQAv1::kRAWS ) {
880     histotot=fSPDhRawsTask;
881   }
882   else if( task == AliQAv1::kDIGITSR ) {
883     histotot=fSPDhDigitsTask;
884   }
885   else if( task == AliQAv1::kRECPOINTS ){
886     histotot=fSPDhRecPointsTask;
887   }
888
889   return histotot;
890 }