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