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