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