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