]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASDDDataMakerRec.cxx
Coverity (Melinda)
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDDataMakerRec.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
16 /* $Id$ */
17
18 //  *************************************************************
19 //  Checks the quality assurance 
20 //  by comparing with reference data
21 //  contained in a DB
22 //  -------------------------------------------------------------
23 //  W. Ferrarese + P. Cerello Feb 2008
24 //  M.Siciliano Aug 2008 QA RecPoints 
25 //  INFN Torino
26
27 // --- ROOT system ---
28
29 #include <TProfile2D.h>
30 #include <TH2D.h>
31 #include <TH1F.h>
32 #include <TBranch.h>
33 #include <TTree.h>
34 #include <TMath.h>
35 //#include <TObjArray.h>
36
37 // --- Standard library ---
38
39 // --- AliRoot header files ---
40 #include "AliITSQASDDDataMakerRec.h"
41 #include "AliQAv1.h"
42 #include "AliRawReader.h"
43 #include "AliITSRawStream.h"
44 #include "AliITSRawStreamSDD.h"
45 #include "AliITSdigit.h"
46 #include "AliITSRecPoint.h"
47 #include "AliITSRecPointContainer.h"
48 #include "AliITSgeomTGeo.h"
49 #include "AliCDBManager.h"
50 #include "AliCDBEntry.h"
51 #include "AliITSCalibrationSDD.h"
52
53 class TGaxis;
54 class TF1;
55 class TSystem;
56 class AliLog;
57 class AliQAChecker;
58 class AliITSRawStreamSDDCompressed;
59 class AliCDBStorage;
60 class Riostream;
61 class AliITSdigitSDD;
62 class AliITS;
63 class AliRunLoader;
64 class AliITSLoader;
65 class AliITSDetTypeRec;
66
67
68
69 ClassImp(AliITSQASDDDataMakerRec)
70
71 //____________________________________________________________________________ 
72 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(AliITSQADataMakerRec *aliITSQADataMakerRec, Bool_t kMode, Short_t ldc) :
73 TObject(),
74 fAliITSQADataMakerRec(aliITSQADataMakerRec),
75 fkOnline(kMode),
76 fLDC(ldc),
77 fSDDhRawsTask(0),
78 fSDDhDigitsTask(0),
79 fSDDhRecPointsTask(0),
80 fOnlineOffsetRaws(0),
81 fOnlineOffsetRecPoints(0),
82 fGenRawsOffset(0),
83 fGenDigitsOffset(0),
84 fGenRecPointsOffset(0),
85 fTimeBinSize(1),
86 fNEvent(0),
87 fNEventRP(0),
88 fDDLModuleMap(0),
89 fCalibration(0),
90 fHistoCalibration(0)
91 {
92   //ctor used to discriminate OnLine-Offline analysis
93   if(fLDC < 0 || fLDC > 6) {
94         AliError("Error: LDC number out of range; return\n");
95   }
96         fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
97         fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
98         fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
99         for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
100                 fGenRawsOffset[i] = 0;
101                 fGenRecPointsOffset[i] = 0;
102                 fGenDigitsOffset[i]=0;
103         }
104
105         InitCalibrationArray();
106 }
107
108 //____________________________________________________________________________ 
109 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(const AliITSQASDDDataMakerRec& qadm) :
110 TObject(),
111 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
112 fkOnline(qadm.fkOnline),
113 fLDC(qadm.fLDC),
114 fSDDhRawsTask(qadm.fSDDhRawsTask),
115 fSDDhDigitsTask(qadm.fSDDhDigitsTask),
116 fSDDhRecPointsTask(qadm.fSDDhRecPointsTask),
117 fOnlineOffsetRaws(qadm.fOnlineOffsetRaws),
118 fOnlineOffsetRecPoints(qadm.fOnlineOffsetRecPoints),
119 fGenRawsOffset(qadm.fGenRawsOffset),
120 fGenDigitsOffset(qadm.fGenDigitsOffset),
121 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
122 fTimeBinSize(qadm.fTimeBinSize),
123 fNEvent(qadm.fNEvent),
124 fNEventRP(qadm.fNEventRP),
125 fDDLModuleMap(qadm.fDDLModuleMap),
126 fCalibration(qadm.fCalibration),
127 fHistoCalibration(qadm.fHistoCalibration)
128 {
129   //copy ctor 
130   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
131   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
132   //fDDLModuleMap=NULL;
133 }
134
135 //____________________________________________________________________________ 
136 AliITSQASDDDataMakerRec::~AliITSQASDDDataMakerRec(){
137   // destructor
138   //if(fDDLModuleMap) delete fDDLModuleMap;
139   if(fHistoCalibration){delete fHistoCalibration; fHistoCalibration=NULL;}
140 }
141 //__________________________________________________________________
142 AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDDataMakerRec& qac )
143 {
144   // Equal operator.
145   this->~AliITSQASDDDataMakerRec();
146   new(this) AliITSQASDDDataMakerRec(qac);
147   return *this;
148 }
149
150 //____________________________________________________________________________ 
151 void AliITSQASDDDataMakerRec::StartOfDetectorCycle()
152 {
153
154   //Start of a QA cycle
155
156   AliDebug(AliQAv1::GetQADebugLevel(),Form("Start of SDD Cycle with event specie %s for task %s\n",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie()),AliQAv1::GetTaskName(fAliITSQADataMakerRec->GetTaskIndexSelected()).Data()));
157   if(!fCalibration) 
158     {
159       //fAliITSQADataMakerRec->GetRawsData(9+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
160       CreateTheCalibration();
161   }
162
163   if(fAliITSQADataMakerRec->GetEventSpecie()==0) return;//not the kDefault EventSpecie
164     //Detector specific actions at start of cycle
165     if(fAliITSQADataMakerRec->GetTaskIndexSelected()==AliQAv1::kRAWS){
166       AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
167       if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRAWS)==kFALSE)return;
168
169         AliDebug(AliQAv1::GetQADebugLevel(),Form("Reset of Raw Data normalized histograms with eventspecie %s ",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie())));
170         fAliITSQADataMakerRec->GetRawsData(10+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();  
171         fAliITSQADataMakerRec->GetRawsData(3+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
172         fAliITSQADataMakerRec->GetRawsData(4+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
173         fAliITSQADataMakerRec->GetRawsData(5+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
174       
175     }
176     if(fAliITSQADataMakerRec->GetTaskIndexSelected()==AliQAv1::kRECPOINTS){
177       if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRECPOINTS)==kFALSE)return;
178
179         AliDebug(AliQAv1::GetQADebugLevel(),Form("Reset of RecPoints normalized histograms with eventspecie %s ",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie())));
180
181         fAliITSQADataMakerRec->GetRecPointsData(9+  fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
182         fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
183         fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
184         fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
185
186       }
187 }
188
189 //____________________________________________________________________________ 
190 void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray* /*list*/)
191 {
192   //end of a QA cycle
193   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
194   
195   Double_t entriescalibration1= 0.;
196   Double_t entriescalibrationL3=0.;
197   Double_t entriescalibrationL4=0.;
198   
199   if(fHistoCalibration){
200     entriescalibration1= ((TH1D*)(fHistoCalibration->At(0)))->GetEntries();
201     entriescalibrationL3=((TH2D*)(fHistoCalibration->At(1)))->GetEntries();
202     entriescalibrationL4=((TH2D*)(fHistoCalibration->At(2)))->GetEntries();
203   }
204   else{ AliWarning("Calibration TObjArray is NULL! No Normalization and calibtaion plot will be filled\n");}
205   if(task==AliQAv1::kRAWS){
206     //    printf("fNevent %d \n",fNEvent);
207     
208     ((TH1F*)fAliITSQADataMakerRec->GetRawsData(10+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(1,fNEvent);
209     
210     if(fNEvent!=0){
211       
212       Double_t entriesmodpattern=((TH1D*)fAliITSQADataMakerRec->GetRawsData(0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetEntries();
213       Double_t entriesL3=((TH2D*)fAliITSQADataMakerRec->GetRawsData(1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetEntries();
214       Double_t entriesL4=((TH2D*)fAliITSQADataMakerRec->GetRawsData(2 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetEntries();
215       
216       Double_t normentriesmodpattern=0.; 
217       Double_t normentriesL3= 0.;       
218       Double_t normentriesL4= 0.;     
219       
220       if(entriescalibration1!=0.)normentriesmodpattern=entriesmodpattern/(entriescalibration1*fNEvent);
221       if(entriesL3!=0.)   normentriesL3= entriesL3/(entriescalibrationL3*fNEvent);
222       if(entriesL4!=0.)   normentriesL4= entriesL4/(entriescalibrationL4*fNEvent);
223       
224       ((TH1F*)fAliITSQADataMakerRec->GetRawsData(10+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(2,normentriesmodpattern);
225       ((TH1F*)fAliITSQADataMakerRec->GetRawsData(10+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(3,normentriesL3);
226       ((TH1F*)fAliITSQADataMakerRec->GetRawsData(10+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(4,normentriesL4);
227       
228       if(fHistoCalibration){
229         ((TH1D*)fAliITSQADataMakerRec->GetRawsData(3 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRawsData(0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEvent);
230         
231         ((TH2D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEvent);
232         
233         ((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(2 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEvent);
234       }
235     }     
236     Int_t xbin3 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
237     Int_t ybin3 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
238     
239     for(Int_t i=0; i<xbin3; i++) {
240       for(Int_t j=0; j<ybin3; j++) {
241         ((TH1D*)fAliITSQADataMakerRec->GetRawsData(6 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
242       }
243     }
244     
245     Int_t xbin4 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
246     Int_t ybin4 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
247     
248     for(Int_t i=0; i<xbin4; i++) {
249       for(Int_t j=0; j<ybin4; j++) {
250         ((TH1D*)fAliITSQADataMakerRec->GetRawsData(7 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
251       }
252     }
253     
254     if(fHistoCalibration){
255       for(Int_t inumb=8;inumb<10;inumb++)
256         {
257           for(Int_t ii=1; ii<fAliITSQADataMakerRec->GetRawsData(inumb + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetNbinsX()+1;ii++)
258             {
259               for(Int_t jj=1; jj<fAliITSQADataMakerRec->GetRawsData(inumb+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetNbinsY()+1;jj++)
260                 {
261                   
262                   if(((TH1D*)(fHistoCalibration->At(inumb-7)))->GetBinContent(ii,jj) != 0. )
263                     {
264                       fAliITSQADataMakerRec->GetRawsData(inumb+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->SetBinContent(ii,jj,1);
265                     }
266                   else if(((TH1D*)(fHistoCalibration->At(inumb-7)))->GetBinContent(ii,jj) == 0. )
267                     {
268                       fAliITSQADataMakerRec->GetRawsData(inumb+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->SetBinContent(ii,jj,0);
269                     }   
270                   //printf("%d \t %d \t %d \t %02f \n",inumb,ii,jj,fAliITSQADataMakerRec->GetRawsData(inumb+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetBinContent(ii,jj));
271                 }//end x axis
272             }//end y axis
273         }//end for inumb
274     }
275     
276     
277   }//end raws
278   
279   if(task==AliQAv1::kRECPOINTS){
280     
281     
282     Double_t chargeL3=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(0+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMean();
283     Double_t errchargeL3=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(0+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMeanError();
284     
285     Double_t chargeL4=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(1+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMean();
286     Double_t errchargeL4=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(1+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMeanError();
287     
288     
289     Double_t radiusL3=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(13+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMean();
290     Double_t errradiusL3=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(13+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMeanError();
291     
292     Double_t radiusL4=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(14+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMean();
293     Double_t errradiusL4=((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(14+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetMeanError();
294     
295     
296     
297     //    printf("fNeventRP %d \n",fNEventRP);
298     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(1,fNEventRP);
299     
300     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(31,chargeL3);
301     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinError(31,errchargeL3);
302     
303     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(47,chargeL4);
304     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinError(47,errchargeL4);
305     
306     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(32,radiusL3);
307     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinError(32,errradiusL3);
308     
309     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(48,radiusL4);
310     ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinError(48,errradiusL4);
311     
312     
313     Double_t entriesmodpattern=((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(6 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetEntries();
314     Double_t entriesL3=((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetEntries();
315     Double_t entriesL4=((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetEntries();
316     
317     //printf("entries modpatternrp = %02f \t L3= %02f \t L4 =%02f \n",entriesmodpattern,entriesL3,entriesL4 );
318     
319     if(fNEventRP!=0){
320       
321       
322       
323       Double_t normentriesmodpattern=0.; 
324       Double_t normentriesL3= 0.;       
325       Double_t normentriesL4= 0.;     
326       
327       if(entriescalibration1!=0.)normentriesmodpattern=entriesmodpattern/(entriescalibration1*fNEventRP);
328       if(entriesL3!=0.)   normentriesL3= entriesL3/(entriescalibrationL3*fNEventRP);
329       if(entriesL4!=0.)   normentriesL4= entriesL4/(entriescalibrationL4*fNEventRP);
330       
331       ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(2,normentriesmodpattern);
332       ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(3,normentriesL3);
333       ((TH1F*)fAliITSQADataMakerRec->GetRecPointsData(27+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->SetBinContent(4,normentriesL4);             
334       
335       // printf("NORM entries modpatternrp = %02f \t L3= %02f \t L4 =%02f \n",normentriesmodpattern,normentriesL3,normentriesL4 );
336       
337       if(fHistoCalibration){
338         ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(9 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(6 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEventRP);
339         
340         ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEventRP);
341         
342         ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEventRP);
343       
344       //  ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(21+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEventRP);
345       
346       // ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEventRP);
347       }
348     }
349     Int_t xbin3 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
350     Int_t ybin3 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
351     
352     for(Int_t i=0; i<xbin3; i++) {
353       for(Int_t j=0; j<ybin3; j++) {
354         ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(19 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
355       }
356     }
357     
358     Int_t xbin4 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
359     Int_t ybin4 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
360     
361     for(Int_t i=0; i<xbin4; i++) {
362       for(Int_t j=0; j<ybin4; j++) {
363         ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(20 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
364       }
365     }
366     
367     // RecPoints 2 Raws Ratio
368     if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRAWS)==kTRUE)
369       {
370         Int_t xbin3RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
371         Int_t ybin3RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
372         Int_t xbin3R  = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
373         Int_t ybin3R  = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
374         if((xbin3RP == xbin3R) && (ybin3RP == ybin3R)) {
375           ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide(((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])),((TH2D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])));
376           for(Int_t i=0; i<xbin3R; i++) {
377             for(Int_t j=0; j<ybin3R; j++) {
378               ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(23 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
379             }
380           }
381         } else 
382           AliWarning("Number of bins for Raws and RecPoints (Layer 3) do not match\n");
383         
384         Int_t xbin4RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
385         Int_t ybin4RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
386         Int_t xbin4R = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
387         Int_t ybin4R = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
388         if((xbin4RP == xbin4R) && (ybin4RP == ybin4R)) {
389           ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide(((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])),((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])));
390           //                  ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide(((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])));
391           for(Int_t i=0; i<xbin4R; i++) {
392             for(Int_t j=0; j<ybin4R; j++) {
393               ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(24 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
394             }
395           }
396         } else 
397           AliWarning("Number of bins for Raws and RecPoints (Layer 4) do not match\n");
398       }
399     else{AliWarning("Ratio between RecPoints and Raws not executed because the raw list has not been created\n");}
400   }//end recpoints
401   
402 }
403
404 //____________________________________________________________________________ 
405 Int_t AliITSQASDDDataMakerRec::InitRaws()
406
407
408   // Initialization for RAW data - SDD -
409   const Bool_t expert   = kTRUE ; 
410   const Bool_t saveCorr = kTRUE ; 
411   const Bool_t image    = kTRUE ; 
412
413   Int_t rv = 0 ; 
414   Int_t lay, lad, det;
415   Int_t indexlast = 0;
416   Int_t index1 = 0;
417
418         fSDDhRawsTask = 0;
419         if(fkOnline){AliInfo("Book Online Histograms for SDD\n");}
420   else {AliInfo("Book Offline Histograms for SDD\n ");}
421   TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5); //0
422   h0->GetXaxis()->SetTitle("Module Number");
423   h0->GetYaxis()->SetTitle("Counts");
424   h0->SetOption("bar1");
425   h0->SetBarOffset(0.01);
426   h0->SetBarWidth(0.95);
427   h0->SetFillColor(45);
428   rv = fAliITSQADataMakerRec->Add2RawsList(h0,0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
429   fSDDhRawsTask++;
430   
431   //zPhi distribution using ladder and modules numbers
432   TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//1
433   hphil3->GetXaxis()->SetTitle("z[Module Number L3 ]");
434   hphil3->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
435   hphil3->SetStats(0);
436   rv = fAliITSQADataMakerRec->Add2RawsList(hphil3,1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, !saveCorr); 
437   fSDDhRawsTask++;
438   
439   TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //2
440   hphil4->GetXaxis()->SetTitle("z[Module Number L4]");
441   hphil4->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
442   hphil4->SetStats(0);
443    rv = fAliITSQADataMakerRec->Add2RawsList(hphil4,2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, !saveCorr); 
444   fSDDhRawsTask++;
445   
446   //normalized histograms
447   TH1D *h0norm = new TH1D("SDDModPatternNORM","NORM HW Modules pattern",fgknSDDmodules,239.5,499.5); //3
448   h0norm->GetXaxis()->SetTitle("Module Number");
449   h0norm->GetYaxis()->SetTitle("Counts");
450   h0norm->SetOption("bar1");
451   h0norm->SetBarOffset(0.01);
452   h0norm->SetBarWidth(0.95);
453   h0norm->SetFillColor(46);
454   //h0norm->SetStats(0);
455   rv = fAliITSQADataMakerRec->Add2RawsList(h0norm,3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
456   fSDDhRawsTask++;
457   
458   //zPhi distribution using ladder and modules numbers
459   TH2D *hphil3norm = new TH2D("SDDphizL3NORM","NORM SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//4
460   hphil3norm->GetXaxis()->SetTitle("z[Module Number L3 ]");
461   hphil3norm->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
462   hphil3norm->SetStats(0);
463   rv = fAliITSQADataMakerRec->Add2RawsList(hphil3norm,4+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
464   fSDDhRawsTask++;
465   
466   TH2D *hphil4norm = new TH2D("SDDphizL4NORM","NORM SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //5
467   hphil4norm->GetXaxis()->SetTitle("z[Module Number L4]");
468   hphil4norm->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
469   hphil4norm->SetStats(0);
470   rv = fAliITSQADataMakerRec->Add2RawsList(hphil4norm,5+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
471   fSDDhRawsTask++;
472
473         
474   Float_t hMax = 0.2;
475   
476   TH1F *oL3 = new TH1F("SDDL3_RelativeOccupancy","Layer 3 Relative Occupancy",200,0.,hMax);
477   rv = fAliITSQADataMakerRec->Add2RawsList(oL3,6+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); //6  
478   fSDDhRawsTask++;
479   
480   TH1F *oL4 = new TH1F("SDDL4_RelativeOccupancy","Layer 4 Relative Occupancy",200,0.,hMax);
481   rv = fAliITSQADataMakerRec->Add2RawsList(oL4,7+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); //7   
482   fSDDhRawsTask++;
483   
484   //zPhi distribution using ladder and modules numbers
485   TH2D *hcalibl3 = new TH2D("SDDphizCalibL3","SDDCalibL3 ",12,0.5,6.5,14,0.5,14.5);//8
486   hcalibl3->GetXaxis()->SetTitle("z[Module Number L3]");
487   hcalibl3->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
488   hcalibl3->SetStats(0);
489   hcalibl3->SetMaximum(2);
490   rv = fAliITSQADataMakerRec->Add2RawsList(hcalibl3,8+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, !saveCorr); 
491   fSDDhRawsTask++;
492   
493   TH2D *hcalibl4 = new TH2D("SDDphizCalibL4","SDDCalibL4 ",16,0.5,8.5,22,0.5,22.5); //9
494   hcalibl4->GetXaxis()->SetTitle("z[Module Number L4]");
495   hcalibl4->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
496   hcalibl4->SetStats(0);
497   hcalibl4->SetMaximum(2);
498   rv = fAliITSQADataMakerRec->Add2RawsList(hcalibl4,9+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, !saveCorr); 
499   fSDDhRawsTask++;
500
501   TH1F *hsummarydata = new TH1F("SDDRawDataCheck","SDDRawDataCheck",46,-0.5,45.5);//10 summary of raw data checks
502   hsummarydata->GetXaxis()->SetLabelSize(0.02);
503   hsummarydata->GetXaxis()->SetTickLength(0.01);
504   hsummarydata->GetXaxis()->SetNdivisions(110);
505   hsummarydata->GetXaxis()->SetTicks("-");
506   hsummarydata->GetYaxis()->SetLabelSize(0.02);
507   hsummarydata->GetYaxis()->SetTitleSize(0.02);
508   hsummarydata->GetYaxis()->SetTitleOffset(1.5);
509   hsummarydata->GetYaxis()->SetTitle("#events(norm) or #modules (m) or #drift regions (dr)");
510   hsummarydata->SetStats(0);
511   hsummarydata->SetMaximum(272);
512   hsummarydata->SetMinimum(0.);
513
514   hsummarydata->SetOption("textbar1");
515   hsummarydata->SetBarOffset(0.01);
516   hsummarydata->SetBarWidth(0.95);
517   hsummarydata->SetFillColor(8);
518
519   //information about the events
520   hsummarydata->GetXaxis()->SetBinLabel(1,"Events");
521   hsummarydata->GetXaxis()->SetBinLabel(2,"Ent_NORM");
522   hsummarydata->GetXaxis()->SetBinLabel(3,"Ent_NORML3");
523   hsummarydata->GetXaxis()->SetBinLabel(4,"Ent_NORML4");
524   //all
525
526   hsummarydata->GetXaxis()->SetBinLabel(5,"m_act");
527   hsummarydata->GetXaxis()->SetBinLabel(6,"m_fil");
528   hsummarydata->GetXaxis()->SetBinLabel(7,"dr_act");
529   hsummarydata->GetXaxis()->SetBinLabel(8,"dr_fil");
530   hsummarydata->GetXaxis()->SetBinLabel(9,"m_exc");
531   hsummarydata->GetXaxis()->SetBinLabel(10,"m_emp");
532   hsummarydata->GetXaxis()->SetBinLabel(11,"dr_exc");
533   hsummarydata->GetXaxis()->SetBinLabel(12,"dr_emp");
534   hsummarydata->GetXaxis()->SetBinLabel(13,"m_exc-act");
535   hsummarydata->GetXaxis()->SetBinLabel(14,"m_act-emp");
536   hsummarydata->GetXaxis()->SetBinLabel(15,"dr_exc-act");
537   hsummarydata->GetXaxis()->SetBinLabel(16,"dr_act-emp");
538   hsummarydata->GetXaxis()->SetBinLabel(17,"m_overth");
539   hsummarydata->GetXaxis()->SetBinLabel(18,"dr_overth");
540
541   //l3
542
543   hsummarydata->GetXaxis()->SetBinLabel(19,"m_actl3");
544   hsummarydata->GetXaxis()->SetBinLabel(20,"m_fill3");
545   hsummarydata->GetXaxis()->SetBinLabel(21,"dr_actl3");
546   hsummarydata->GetXaxis()->SetBinLabel(22,"dr_fill3");
547   hsummarydata->GetXaxis()->SetBinLabel(23,"m_excl3");
548   hsummarydata->GetXaxis()->SetBinLabel(24,"m_empl3");
549   hsummarydata->GetXaxis()->SetBinLabel(25,"dr_excl3");
550   hsummarydata->GetXaxis()->SetBinLabel(26,"dr_empl3");
551   hsummarydata->GetXaxis()->SetBinLabel(27,"m_exc-actl3");
552   hsummarydata->GetXaxis()->SetBinLabel(28,"m_act-empl3");
553   hsummarydata->GetXaxis()->SetBinLabel(29,"dr_exc-actl3");
554   hsummarydata->GetXaxis()->SetBinLabel(30,"dr_act-empl3");
555   hsummarydata->GetXaxis()->SetBinLabel(31,"m_overthl3");
556   hsummarydata->GetXaxis()->SetBinLabel(32,"dr_overthl3");
557
558   //l4
559
560   hsummarydata->GetXaxis()->SetBinLabel(33,"m_actl4");
561   hsummarydata->GetXaxis()->SetBinLabel(34,"m_fill4");
562   hsummarydata->GetXaxis()->SetBinLabel(35,"dr_actl4");
563   hsummarydata->GetXaxis()->SetBinLabel(36,"dr_fill4");
564   hsummarydata->GetXaxis()->SetBinLabel(37,"m_excl4");
565   hsummarydata->GetXaxis()->SetBinLabel(38,"m_empl4");
566   hsummarydata->GetXaxis()->SetBinLabel(39,"dr_excl4");
567   hsummarydata->GetXaxis()->SetBinLabel(40,"dr_empl4");
568   hsummarydata->GetXaxis()->SetBinLabel(41,"m_exc-actl4");
569   hsummarydata->GetXaxis()->SetBinLabel(42,"m_act-empl4");
570   hsummarydata->GetXaxis()->SetBinLabel(43,"dr_exc-actl4");
571   hsummarydata->GetXaxis()->SetBinLabel(44,"dr_act-empl4");
572   hsummarydata->GetXaxis()->SetBinLabel(45,"m_overthl4");
573   hsummarydata->GetXaxis()->SetBinLabel(46,"dr_overthl4");
574   hsummarydata->GetXaxis()->LabelsOption("v");
575
576   rv = fAliITSQADataMakerRec->Add2RawsList(hsummarydata,10+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
577   fSDDhRawsTask++;
578   fOnlineOffsetRaws = fSDDhRawsTask;
579
580   //online part
581   if(fkOnline){
582       //DDL Pattern 
583     TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,11.5,24,-0.5,23.5); //11
584     hddl->GetXaxis()->SetTitle("Channel");
585     hddl->GetYaxis()->SetTitle("DDL Number");
586     rv = fAliITSQADataMakerRec->Add2RawsList(hddl,fOnlineOffsetRaws+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
587     fSDDhRawsTask++;
588     Int_t indexlast1 = 0;
589     
590     fTimeBinSize = 4;
591     indexlast = 0;
592     index1 = 0;
593     indexlast1 = fSDDhRawsTask;
594     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
595       for(Int_t iside=0;iside<fgknSide;iside++){
596         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
597         TProfile2D *fModuleChargeMapFSE = new TProfile2D(Form("SDDchargeMapFSE_L%d_%d_%d_%d",lay,lad,det,iside),Form("SDDChargeMapForSingleEvent_L%d_%d_%d_%d",lay,lad,det,iside)  ,256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
598         fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
599         fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
600         rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMapFSE,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);   
601         fSDDhRawsTask++;
602         index1++;        
603       }
604     }
605       
606     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
607       for(Int_t iside=0;iside<fgknSide;iside++){
608         AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
609         TProfile2D *fModuleChargeMap = new TProfile2D(Form("SDDchargeMap_L%d_%d_%d_%d",lay,lad,det,iside),Form("SDDChargeMap_L%d_%d_%d_%d",lay,lad,det,iside),256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
610         fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
611         fModuleChargeMap->GetYaxis()->SetTitle("Anode Number");
612         rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMap,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
613         fSDDhRawsTask++;
614         index1++;        
615       }
616     }
617     
618     //Event Size 
619     TH1F *hsize = new TH1F("SDDEventSize","SDD Event Size ",500,-0.5,199.5); 
620     hsize->SetBit(TH1::kCanRebin);
621     hsize->GetXaxis()->SetTitle("Event Size [kB]");
622     hsize->GetYaxis()->SetTitle("Entries");
623     rv = fAliITSQADataMakerRec->Add2RawsList(hsize,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
624     fSDDhRawsTask++;
625     
626   }  // kONLINE
627   
628   cout << fSDDhRawsTask << " SDD Raws histograms booked" << endl;
629   
630   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Raws histograms booked\n",fSDDhRawsTask));
631   return rv ; 
632 }
633
634
635 //____________________________________________________________________________
636 Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
637
638   // Fill QA for RAW - SDD -
639   Int_t rv = 0;
640   // Check id histograms already created for this Event Specie
641   fNEvent++;
642   if(!fDDLModuleMap){CreateTheMap();}
643   if(rawReader->GetType() != 7) return rv;  // skips non physical triggers
644   AliDebug(AliQAv1::GetQADebugLevel(),"entering MakeRaws\n");                 
645   rawReader->Reset();       
646   rawReader->Select("ITSSDD");
647   AliITSRawStream *stream=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
648    stream->SetDDLModuleMap(fDDLModuleMap);
649   
650   Int_t lay, lad, det; 
651   
652   Int_t index=0;
653   if(fkOnline) {
654     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
655       for(Int_t iside=0;iside<fgknSide;iside++) {
656                 if(fSDDhRawsTask > fOnlineOffsetRaws + 1 + index) fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws + 1 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();   
657         // 4  because the 2D histos for single events start after the fourth position
658         index++;
659       }
660     }
661   }
662   
663   Int_t cnt = 0;
664   Int_t ildcID = -1;
665   Int_t iddl = -1;
666   Int_t isddmod = -1;
667   Int_t coord1, coord2, signal, moduleSDD, activeModule, index1; 
668   //if(fkOnline)
669   //{
670       Int_t prevDDLID = -1;
671       UInt_t size = 0;
672       int totalddl=static_cast<int>(fDDLModuleMap->GetNDDLs());
673       Bool_t *ddldata=new Bool_t[totalddl];
674       for(Int_t jddl=0;jddl<totalddl;jddl++){ddldata[jddl]=kFALSE;}
675       //}
676   while(stream->Next()) {
677     ildcID = rawReader->GetLDCId();
678     iddl = rawReader->GetDDLID();// - fgkDDLIDshift;
679     if(iddl<0)isddmod=-1;
680     //printf("----------------------iddl %i\n",iddl);
681     else isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
682
683     if(isddmod==-1){
684       AliDebug(AliQAv1::GetQADebugLevel(),Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId()));
685       continue;
686     }
687     if(stream->IsCompletedModule()) {
688       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedModule == KTRUE\n"));
689       continue;
690     } 
691     if(stream->IsCompletedDDL()) {
692       if(fkOnline){
693         if ((rawReader->GetDDLID() != prevDDLID)&&(ddldata[iddl])==kFALSE){
694           size += rawReader->GetDataSize();//in bytes
695           prevDDLID = rawReader->GetDDLID();
696           ddldata[iddl]=kTRUE;
697         }
698       }
699       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedDDL == KTRUE\n"));
700       continue;
701     } 
702     
703     coord1 = stream->GetCoord1();
704     coord2 = stream->GetCoord2();
705     signal = stream->GetSignal();
706     
707     moduleSDD = isddmod - fgkmodoffset;
708     
709     if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
710       AliDebug(AliQAv1::GetQADebugLevel(),Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
711       isddmod = 1;
712     }
713     
714     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
715     Short_t iside = stream->GetChannel();
716
717     //printf(" \n%i %i %i %i \n ",lay, lad, det,iside );
718     fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);   
719     if(lay==3) fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.25,lad); //phiz l3 not norm
720     if(lay==4) fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.25,lad); //phiz l4 not norm
721  
722     if(fkOnline) {
723
724       fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill((stream->GetCarlosId())+0.5*iside -0.5,iddl);
725       //  printf("content ddlmap %d, %d = %f \n",(stream->GetCarlosId()+0.5*iside -0.5),iddl,fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetBinContent(1+(det-1)*2;lad));
726       //printf("content ddlmap %d, %d = %f \n",(stream->GetCarlosId())+0.5*iside -0.5,iddl,fAliITSQADataMakerRec->GetRawsData(3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetBinContent(1+(stream->GetCarlosId()-1)*2,iddl));
727       activeModule = moduleSDD;
728       index1 = activeModule * 2 + iside;
729       
730       if(index1<0){
731         AliDebug(AliQAv1::GetQADebugLevel(),Form("Wrong index number %d - patched to 0\n",index1));
732                   index1 = 0;
733       }      
734
735       if(fSDDhRawsTask > fOnlineOffsetRaws +1 + index1) {                                  
736         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws +1 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);     
737         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws +1 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal); 
738       }
739     }//online
740     cnt++;
741     if(!(cnt%10000)) AliDebug(AliQAv1::GetQADebugLevel(),Form(" %d raw digits read",cnt));
742   }//end next()
743   if(fkOnline){((TH1F*)(fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws +1 + 260*4 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(size/1024.);//KB
744   }
745         
746   AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",cnt)); 
747   delete stream;
748   stream = NULL; 
749
750 //      if(fkOnline) {
751 //              AnalyseBNG(); // Analyse Baseline, Noise, Gain
752 //              AnalyseINJ(); // Analyse Injectors
753 //      }
754
755   delete []ddldata;
756   ddldata=NULL;
757   return rv ; 
758 }
759
760 //____________________________________________________________________________ 
761 Int_t AliITSQASDDDataMakerRec::InitDigits()
762
763   //  if(!fHistoCalibration)InitCalibrationArray();
764   // Initialization for DIGIT data - SDD -  
765   const Bool_t expert   = kTRUE ; 
766   const Bool_t image    = kTRUE ;
767   Int_t rv = 0 ; 
768 //  fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
769   //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
770   TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5);       //hmod
771   h0->GetXaxis()->SetTitle("SDD Module Number");
772   h0->GetYaxis()->SetTitle("# DIGITS");
773   rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
774   fSDDhDigitsTask ++;
775   // printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
776   TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5);      //hanocc
777   h1->GetXaxis()->SetTitle("Anode Number");
778   h1->GetYaxis()->SetTitle("# DIGITS");
779   rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
780   fSDDhDigitsTask ++;
781   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
782   TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5);      //htbocc
783   h2->GetXaxis()->SetTitle("Tbin Number");
784   h2->GetYaxis()->SetTitle("# DIGITS");
785   rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
786   fSDDhDigitsTask ++;
787   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
788   TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.);          //hsig
789   h3->GetXaxis()->SetTitle("ADC Value");
790   h3->GetYaxis()->SetTitle("# DIGITS");
791   rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
792   fSDDhDigitsTask ++;
793   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
794   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDigitsTask));
795   return rv ; 
796 }
797
798 //____________________________________________________________________________
799 Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
800
801
802   // Fill QA for DIGIT - SDD -
803   //AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
804   //fITS->SetTreeAddress();
805   //TClonesArray *iITSdigits  = fITS->DigitsAddress(1);
806
807
808   Int_t rv = 0 ; 
809
810   TBranch *branchD = digits->GetBranch("ITSDigitsSDD");
811
812   if (!branchD) {
813     AliError("can't get the branch with the ITS SDD digits !");
814     return rv ;
815   }
816   // Check id histograms already created for this Event Specie
817 //  if ( ! fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset) )
818 //    rv = InitDigits() ;
819   
820   static TClonesArray statDigits("AliITSdigitSDD");
821   TClonesArray *iITSdigits = &statDigits;
822   branchD->SetAddress(&iITSdigits);
823
824   for(Int_t i=0; i<260; i++){
825     Int_t nmod=i+240;
826     digits->GetEvent(nmod);
827     Int_t ndigits = iITSdigits->GetEntries();
828     fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nmod,ndigits);
829
830     for (Int_t idig=0; idig<ndigits; idig++) {
831       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
832       Int_t iz=dig->GetCoord1();  // cell number z
833       Int_t ix=dig->GetCoord2();  // cell number x
834       Int_t sig=dig->GetSignal();
835       fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iz);
836       fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ix);
837       fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(sig);
838     }
839   }
840   return rv ; 
841 }
842
843 //____________________________________________________________________________ 
844 Int_t AliITSQASDDDataMakerRec::InitRecPoints()
845 {
846   //if(!fHistoCalibration)InitCalibrationArray();
847         //AliInfo("Initialize SDD recpoints histos\n");
848   // Initialization for RECPOINTS - SDD -
849   const Bool_t expert   = kTRUE ; 
850   const Bool_t image    = kTRUE ; 
851   Int_t rv = 0 ; 
852 //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
853
854   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
855   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
856   TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",250,-0.5, 499.5); //position number 0
857   //h0->SetBit(TH1::kCanRebin);
858   h0->GetXaxis()->SetTitle("KeV");
859   h0->GetYaxis()->SetTitle("Entries");
860   rv = fAliITSQADataMakerRec->Add2RecPointsList(h0, 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
861   fSDDhRecPointsTask++;
862  
863   TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",250,-0.5, 499.5);//position number 1
864   //h1->SetBit(TH1::kCanRebin);
865   h1->GetXaxis()->SetTitle("Kev");
866   h1->GetYaxis()->SetTitle("Entries");
867   rv = fAliITSQADataMakerRec->Add2RecPointsList(h1, 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
868   fSDDhRecPointsTask++;
869
870   TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",56,-28,28,56,-28,28);//position number 2
871   h2->GetYaxis()->SetTitle("Y[cm]");
872   h2->GetXaxis()->SetTitle("X[cm]");
873   rv = fAliITSQADataMakerRec->Add2RecPointsList(h2,2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
874   fSDDhRecPointsTask++;
875
876   TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",128,-32,32,56,12,26);//position number 3
877   h3->GetYaxis()->SetTitle("R[cm]");
878   h3->GetXaxis()->SetTitle("Z[cm]");
879   rv = fAliITSQADataMakerRec->Add2RecPointsList(h3,3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
880   fSDDhRecPointsTask++;
881   
882   TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",96,-23,23,112,-TMath::Pi(),TMath::Pi());//position number 4
883   h4->GetYaxis()->SetTitle("#phi[rad]");
884   h4->GetXaxis()->SetTitle("Z[cm]");
885   rv = fAliITSQADataMakerRec->Add2RecPointsList(h4,4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
886   fSDDhRecPointsTask++;
887
888   TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",128,-31,31,176,-TMath::Pi(),TMath::Pi());//position number 5
889   h5->GetYaxis()->SetTitle("#phi[rad]");
890   h5->GetXaxis()->SetTitle("Z[cm]");
891   rv = fAliITSQADataMakerRec->Add2RecPointsList(h5,5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
892   fSDDhRecPointsTask++;
893   
894   TH1D *h6 = new TH1D("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
895   h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
896   h6->GetYaxis()->SetTitle("Entries");
897   h6->SetOption("bar1");
898   h6->SetBarOffset(0.01);
899   h6->SetBarWidth(0.95);
900   h6->SetFillColor(39);
901   rv = fAliITSQADataMakerRec->Add2RecPointsList(h6,6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
902   fSDDhRecPointsTask++;
903
904   
905   TH2D *h7 = new TH2D("SDDModPatternL3RP","Modules pattern L3 RP",12,0.5,6.5,14,0.5,14.5);  //position number 7
906   h7->GetXaxis()->SetTitle("z[#Module L3 ]");
907   h7->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
908   rv = fAliITSQADataMakerRec->Add2RecPointsList(h7,7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
909   fSDDhRecPointsTask++;
910
911   TH2D *h8 = new TH2D("SDDModPatternL4RP","Modules pattern L4 RP",16,0.5,8.5,22,0.5,22.5); //position number 8
912   h8->GetXaxis()->SetTitle("[#Module L3 ]");
913   h8->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
914   rv = fAliITSQADataMakerRec->Add2RecPointsList(h8,8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
915   fSDDhRecPointsTask++;
916
917   //------------------------norm--------------------------//
918
919
920   TH1D *h9 = new TH1D("SDDModPatternRPNORM","Modules pattern RP NORM",fgknSDDmodules,239.5,499.5); //position number 9
921   h9->GetXaxis()->SetTitle("Module number"); //spd offset = 240
922   h9->GetYaxis()->SetTitle("Entries");
923   h9->SetOption("bar1");
924   h9->SetBarOffset(0.01);
925   h9->SetBarWidth(0.95);
926   h9->SetFillColor(49);
927   rv = fAliITSQADataMakerRec->Add2RecPointsList(h9,9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
928   fSDDhRecPointsTask++;
929
930   
931   TH2D *h10 = new TH2D("SDDModPatternL3RPNORM","Modules pattern L3 RP NORM",12,0.5,6.5,14,0.5,14.5);  //position number 10
932   h10->GetXaxis()->SetTitle("z[#Module L3 ]");
933   h10->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
934   rv = fAliITSQADataMakerRec->Add2RecPointsList(h10,10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO  image
935   fSDDhRecPointsTask++;
936
937   TH2D *h11 = new TH2D("SDDModPatternL4RPNORM","Modules pattern L4 RP NORM",16,0.5,8.5,22,0.5,22.5); //position number 11
938   h11->GetXaxis()->SetTitle("[#Module L4 ]");
939   h10->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
940   rv = fAliITSQADataMakerRec->Add2RecPointsList(h11,11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert NO image
941   fSDDhRecPointsTask++;
942
943   //--------------------------------------------------------//
944
945   TH2F *h12 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",160,-4,4,160,-4,4);//position number 12
946   h12->GetXaxis()->SetTitle("X local coord, drift, cm");
947   h12->GetYaxis()->SetTitle("Z local coord, anode, cm");
948   rv = fAliITSQADataMakerRec->Add2RecPointsList(h12,12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert  NO image
949   fSDDhRecPointsTask++;
950   
951   //AliInfo("Create SDD recpoints histos\n");
952   
953   TH1F *h13 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,16.5);//position number 13 (L3)
954   h13->SetBit(TH1::kCanRebin);
955   h13->GetXaxis()->SetTitle("r[cm]");
956   h13->GetXaxis()->CenterTitle();
957   h13->GetYaxis()->SetTitle("Entries");
958   rv = fAliITSQADataMakerRec->Add2RecPointsList(h13,13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
959   fSDDhRecPointsTask++;
960   
961   TH1F *h14 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,23.,25.);// and position number 14 (L4)
962   h14->SetBit(TH1::kCanRebin);
963   h14->GetXaxis()->SetTitle("r[cm]");
964   h14->GetXaxis()->CenterTitle();
965   h14->GetYaxis()->SetTitle("Entries");
966   rv = fAliITSQADataMakerRec->Add2RecPointsList(h14,14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
967   fSDDhRecPointsTask++;
968   
969   for(Int_t iLay=0; iLay<=1; iLay++){
970     TH1F *h15 = new TH1F(Form("SDDphidistrib_Layer%d",iLay+3),Form("SDDphidistrib_Layer%d",iLay+3) ,180,-TMath::Pi(),TMath::Pi());//position number 15 (L3) and position number 16 (L4)
971     h15->GetXaxis()->SetTitle("#varphi[rad]");
972     h15->GetXaxis()->CenterTitle();
973     h15->GetYaxis()->SetTitle("Entries");
974     rv = fAliITSQADataMakerRec->Add2RecPointsList(h15,iLay+15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
975     fSDDhRecPointsTask++;
976   }
977   
978   for(Int_t iLay=0; iLay<=1; iLay++){
979     TH1F *h17 = new TH1F(Form("SDDdrifttime_Layer%d",iLay+3),Form("SDDdrifttime_Layer%d",iLay+3),45,-0.5,4499.5);//position number 17 (L3) and position number 18 (L4)
980     h17->SetBit(TH1::kCanRebin);
981     h17->GetXaxis()->SetTitle("drift time[ns]");
982     h17->GetXaxis()->CenterTitle();
983     h17->GetYaxis()->SetTitle("Entries");
984     rv = fAliITSQADataMakerRec->Add2RecPointsList(h17,iLay+17+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert  image
985     fSDDhRecPointsTask++;
986   }
987   
988         Float_t hMax = 0.2;
989         
990         TH1F *oL3 = new TH1F("SDDL3_RelativeOccupancy","Layer 3 Relative Occupancy (RecPoints)",200,0.,hMax);
991         rv = fAliITSQADataMakerRec->Add2RecPointsList(oL3,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 19
992         fSDDhRecPointsTask++;
993         
994         TH1F *oL4 = new TH1F("SDDL4_RelativeOccupancy","Layer 4 Relative Occupancy (RecPoints)",200,0.,hMax);
995         rv = fAliITSQADataMakerRec->Add2RecPointsList(oL4,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 20
996         fSDDhRecPointsTask++;
997         
998         
999         TH2D *h21 = new TH2D("SDDL3_Rec2Raw_2D","L3 RecPoints to Raws 2D",12,0.5,6.5,14,0.5,14.5);  //position number 21
1000         h21->GetXaxis()->SetTitle("z[#Module L3 ]");
1001         h21->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
1002         rv = fAliITSQADataMakerRec->Add2RecPointsList(h21,21 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO  image
1003         fSDDhRecPointsTask++;
1004         
1005         TH2D *h22 = new TH2D("SDDL4_Rec2Raw_2D","L4 RecPoints to Raws 2D",16,0.5,8.5,22,0.5,22.5); //position number 22
1006         h22->GetXaxis()->SetTitle("[#Module L4 ]");
1007         h22->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
1008         rv = fAliITSQADataMakerRec->Add2RecPointsList(h22,22 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert NO image
1009         fSDDhRecPointsTask++;
1010
1011         hMax = 0.3;     
1012         TH1F *R2RL3 = new TH1F("SDDL3_Rec2Raw","L3 RecPoints to Raws ratio",150,0.,hMax);
1013         rv = fAliITSQADataMakerRec->Add2RecPointsList(R2RL3,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 23
1014         fSDDhRecPointsTask++;
1015         
1016         TH1F *R2RL4 = new TH1F("SDDL4_Rec2Raw","L4 RecPoints to Raws ratio",150,0.,hMax);
1017         rv = fAliITSQADataMakerRec->Add2RecPointsList(R2RL4,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 24
1018         fSDDhRecPointsTask++;
1019
1020         TH1F *dedxL3 = new TH1F("SDDL3_dedx","L3 dE/dX",100,0.,1.);
1021         rv = fAliITSQADataMakerRec->Add2RecPointsList(dedxL3,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 25
1022         fSDDhRecPointsTask++;
1023         
1024         TH1F *dedxL4 = new TH1F("SDDL4_dedx","L4 dE/dX",100,0.,1.);
1025         rv = fAliITSQADataMakerRec->Add2RecPointsList(dedxL4,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 26
1026         fSDDhRecPointsTask++;
1027         
1028
1029   TH1F *hsummarydatarp = new TH1F("SDDRecPointCheck","SDDRecPointCheck",50,-0.5,49.5);//27 summary of recpoint checks
1030   hsummarydatarp->GetXaxis()->SetLabelSize(0.02);
1031   hsummarydatarp->GetXaxis()->SetTickLength(0.01);
1032   hsummarydatarp->GetXaxis()->SetNdivisions(110);
1033   hsummarydatarp->GetXaxis()->SetTicks("-");
1034   hsummarydatarp->GetYaxis()->SetLabelSize(0.02);
1035   hsummarydatarp->GetYaxis()->SetTitleSize(0.02);
1036   hsummarydatarp->GetYaxis()->SetTitleOffset(1.5);
1037   hsummarydatarp->GetYaxis()->SetTitle("#events(norm) or #modules (m) or #drift regions (dr)");
1038   hsummarydatarp->SetStats(0);
1039   hsummarydatarp->SetMaximum(272);
1040
1041   hsummarydatarp->SetOption("text bar1 hist");
1042   hsummarydatarp->SetBarOffset(0.05);
1043   hsummarydatarp->SetBarWidth(0.95);
1044   hsummarydatarp->SetFillColor(32);
1045   hsummarydatarp->SetMinimum(0.);
1046
1047   //information about the events
1048   hsummarydatarp->GetXaxis()->SetBinLabel(1,"Events");
1049   hsummarydatarp->GetXaxis()->SetBinLabel(2,"Ent_NORM");
1050   hsummarydatarp->GetXaxis()->SetBinLabel(3,"Ent_NORML3");
1051   hsummarydatarp->GetXaxis()->SetBinLabel(4,"Ent_NORML4");
1052   //all
1053
1054   hsummarydatarp->GetXaxis()->SetBinLabel(5, "m_act");
1055   hsummarydatarp->GetXaxis()->SetBinLabel(6, "m_fil");
1056   hsummarydatarp->GetXaxis()->SetBinLabel(7, "dr_act");
1057   hsummarydatarp->GetXaxis()->SetBinLabel(8, "dr_fil");
1058   hsummarydatarp->GetXaxis()->SetBinLabel(9, "m_exc");
1059   hsummarydatarp->GetXaxis()->SetBinLabel(10,"m_emp");
1060   hsummarydatarp->GetXaxis()->SetBinLabel(11,"dr_exc");
1061   hsummarydatarp->GetXaxis()->SetBinLabel(12,"dr_emp");
1062   hsummarydatarp->GetXaxis()->SetBinLabel(13,"m_exc-act");
1063   hsummarydatarp->GetXaxis()->SetBinLabel(14,"m_act-emp");
1064   hsummarydatarp->GetXaxis()->SetBinLabel(15,"dr_exc-act");
1065   hsummarydatarp->GetXaxis()->SetBinLabel(16,"dr_act-emp");
1066   hsummarydatarp->GetXaxis()->SetBinLabel(17,"m_overth");
1067   hsummarydatarp->GetXaxis()->SetBinLabel(18,"dr_overth");
1068
1069   //l3
1070
1071   hsummarydatarp->GetXaxis()->SetBinLabel(19,"m_actl3");
1072   hsummarydatarp->GetXaxis()->SetBinLabel(20,"m_fill3");
1073   hsummarydatarp->GetXaxis()->SetBinLabel(21,"dr_actl3");
1074   hsummarydatarp->GetXaxis()->SetBinLabel(22,"dr_fill3");
1075   hsummarydatarp->GetXaxis()->SetBinLabel(23,"m_excl3");
1076   hsummarydatarp->GetXaxis()->SetBinLabel(24,"m_empl3");
1077   hsummarydatarp->GetXaxis()->SetBinLabel(25,"dr_excl3");
1078   hsummarydatarp->GetXaxis()->SetBinLabel(26,"dr_empl3");
1079   hsummarydatarp->GetXaxis()->SetBinLabel(27,"m_exc-actl3");
1080   hsummarydatarp->GetXaxis()->SetBinLabel(28,"m_act-empl3");
1081   hsummarydatarp->GetXaxis()->SetBinLabel(29,"dr_exc-actl3");
1082   hsummarydatarp->GetXaxis()->SetBinLabel(30,"dr_act-empl3");
1083   hsummarydatarp->GetXaxis()->SetBinLabel(31,"meanch_l3");
1084   hsummarydatarp->GetXaxis()->SetBinLabel(32,"meanrad_l3");
1085   hsummarydatarp->GetXaxis()->SetBinLabel(33,"m_overthl3");
1086   hsummarydatarp->GetXaxis()->SetBinLabel(34,"dr_overthl3");
1087
1088   //l4
1089
1090   hsummarydatarp->GetXaxis()->SetBinLabel(35,"m_actl4");
1091   hsummarydatarp->GetXaxis()->SetBinLabel(36,"m_fill4");
1092   hsummarydatarp->GetXaxis()->SetBinLabel(37,"dr_actl4");
1093   hsummarydatarp->GetXaxis()->SetBinLabel(38,"dr_fill4");
1094   hsummarydatarp->GetXaxis()->SetBinLabel(39,"m_excl4");
1095   hsummarydatarp->GetXaxis()->SetBinLabel(40,"m_empl4");
1096   hsummarydatarp->GetXaxis()->SetBinLabel(41,"dr_excl4");
1097   hsummarydatarp->GetXaxis()->SetBinLabel(42,"dr_empl4");
1098   hsummarydatarp->GetXaxis()->SetBinLabel(43,"m_exc-actl4");
1099   hsummarydatarp->GetXaxis()->SetBinLabel(44,"m_act-empl4");
1100   hsummarydatarp->GetXaxis()->SetBinLabel(45,"dr_exc-actl4");
1101   hsummarydatarp->GetXaxis()->SetBinLabel(46,"dr_act-empl4");
1102   hsummarydatarp->GetXaxis()->SetBinLabel(47,"meanch_l4");
1103   hsummarydatarp->GetXaxis()->SetBinLabel(48,"meanrad_l4");
1104   hsummarydatarp->GetXaxis()->SetBinLabel(49,"m_overthl4");
1105   hsummarydatarp->GetXaxis()->SetBinLabel(50,"dr_overthl4");
1106
1107   hsummarydatarp->GetXaxis()->LabelsOption("v");
1108
1109   rv = fAliITSQADataMakerRec->Add2RecPointsList(hsummarydatarp,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
1110
1111
1112
1113   fSDDhRecPointsTask++;
1114
1115         fOnlineOffsetRecPoints = fSDDhRecPointsTask;
1116         if(fkOnline){
1117       TH2F *h19 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",112,-28,28,112,-28,28);//position number 27
1118       h19->GetYaxis()->SetTitle("Y[cm]");
1119       h19->GetXaxis()->SetTitle("X[cm]");
1120       rv = fAliITSQADataMakerRec->Add2RecPointsList(h19,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
1121       fSDDhRecPointsTask++;
1122       
1123       TH2F *h20 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",128,-32,32,56,12,26);//position number 28
1124       h20->GetYaxis()->SetTitle("R[cm]");
1125       h20->GetXaxis()->SetTitle("Z[cm]");
1126       rv = fAliITSQADataMakerRec->Add2RecPointsList(h20,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
1127       fSDDhRecPointsTask++;      
1128     }//online
1129   
1130   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Recs histograms booked\n",fSDDhRecPointsTask));
1131   
1132   return rv ; 
1133 }
1134
1135 //____________________________________________________________________________ 
1136 Int_t AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
1137 {
1138  // Fill QA for RecPoints - SDD -
1139   Int_t rv = 0 ;
1140   fNEventRP++; 
1141   Int_t lay, lad, det; 
1142   //AliInfo("get the branch with the ITS clusters !\n");
1143   AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
1144   TClonesArray *recpoints=NULL; 
1145   if(fkOnline){recpoints = rpcont->FetchClusters(0,clustersTree,fAliITSQADataMakerRec->GetEventNumber());}
1146   else{recpoints = rpcont->FetchClusters(0,clustersTree);}
1147   AliDebug(10,Form("Fetched RecPoints for %d SDD modules",recpoints->GetEntriesFast()));
1148   if(!rpcont->GetStatusOK() || !rpcont->IsSDDActive()){
1149     AliError("can't get SDD clusters !");
1150     return rv;
1151   }
1152
1153   Int_t npoints = 0;      
1154   Float_t cluglo[3]={0.,0.,0.}; 
1155   if(fkOnline){
1156       for(Int_t i=28;i<30;i++){
1157           fAliITSQADataMakerRec->GetRecPointsData(i+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
1158         }
1159     }
1160   // AliITSgeomTGeo::GetModuleIndex() issues an error in case the arguments
1161   // are illegal and returns -1
1162   Int_t firMod=TMath::Max(0,AliITSgeomTGeo::GetModuleIndex(3,1,1));
1163   Int_t lasMod=AliITSgeomTGeo::GetModuleIndex(5,1,1);
1164   for(Int_t module=firMod; module<lasMod;module++){
1165     //AliInfo(Form("Module %d\n",module));
1166     recpoints = rpcont->UncheckedGetClusters(module);
1167     npoints += recpoints->GetEntries();
1168     for(Int_t j=0;j<recpoints->GetEntries();j++){
1169       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j); 
1170       Int_t index = recp->GetDetectorIndex();
1171       lay=recp->GetLayer();
1172                 if(lay < 2 || lay > 3) continue;
1173                 Int_t modnumb=index+AliITSgeomTGeo::GetModuleIndex(lay+1,1,1);
1174                 AliITSgeomTGeo::GetModuleId(modnumb, lay, lad, det);  
1175 //              AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
1176       fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(modnumb);//modpatternrp
1177       recp->GetGlobalXYZ(cluglo);
1178       Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
1179       Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
1180       Float_t drifttime=recp->GetDriftTime();
1181                 fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
1182                 fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
1183                 fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
1184                 if(fkOnline) {
1185                         fAliITSQADataMakerRec->GetRecPointsData(28 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
1186                         fAliITSQADataMakerRec->GetRecPointsData(29 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
1187                 }
1188                 Int_t iside=recp->GetDriftSide();
1189                 lay=recp->GetLayer();
1190                 if(lay == 2) {
1191                         fAliITSQADataMakerRec->GetRecPointsData(0  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
1192                         fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 3
1193                         fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
1194                         fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
1195                         fAliITSQADataMakerRec->GetRecPointsData(4  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer
1196                         fAliITSQADataMakerRec->GetRecPointsData(17  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 3
1197                         fAliITSQADataMakerRec->GetRecPointsData(25  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetdEdX());// charge distribution layer 3
1198                 } else if(lay == 3) {
1199                         fAliITSQADataMakerRec->GetRecPointsData(1  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
1200                         fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 4
1201                         fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
1202                         fAliITSQADataMakerRec->GetRecPointsData(16 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
1203                         fAliITSQADataMakerRec->GetRecPointsData(5  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer 4
1204                         fAliITSQADataMakerRec->GetRecPointsData(18  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 4
1205                         fAliITSQADataMakerRec->GetRecPointsData(26  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetdEdX());// charge distribution layer 4
1206       }
1207     }
1208   }
1209   return rv ; 
1210 }
1211
1212 //_______________________________________________________________
1213
1214 Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task, Int_t specie)const
1215 {
1216   // Returns offset number according to the specified task
1217   Int_t offset=0;
1218   if( task == AliQAv1::kRAWS ){offset=fGenRawsOffset[specie];}
1219   else if(task == AliQAv1::kDIGITSR ){offset=fGenDigitsOffset[specie];}
1220   else if( task == AliQAv1::kRECPOINTS ){offset=fGenRecPointsOffset[specie];}
1221   return offset;
1222 }
1223
1224 //_______________________________________________________________
1225
1226 void AliITSQASDDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
1227   // Set offset number according to the specified task
1228   if( task == AliQAv1::kRAWS ) {fGenRawsOffset[specie]=offset;}
1229   else if( task == AliQAv1::kDIGITSR ) {fGenDigitsOffset[specie]=offset;}
1230   else if( task == AliQAv1::kRECPOINTS ) {fGenRecPointsOffset[specie]=offset;}
1231 }
1232
1233 //_______________________________________________________________
1234
1235 Int_t AliITSQASDDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task)
1236 {
1237   //return the number of histo booked for a given Task
1238   Int_t histotot=0;
1239   if( task == AliQAv1::kRAWS ){ histotot=fSDDhRawsTask ;}
1240   else if(task == AliQAv1::kDIGITSR) { histotot=fSDDhDigitsTask;}
1241   else if( task == AliQAv1::kRECPOINTS ){ histotot=fSDDhRecPointsTask;}
1242   else {AliInfo("No task has been selected. TaskHisto set to zero.\n");}
1243   return histotot;
1244 }
1245
1246
1247 //_______________________________________________________________
1248
1249
1250 void AliITSQASDDDataMakerRec::CreateTheMap()
1251 {
1252   //Create the SDD DDL Module Map
1253   AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
1254   Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
1255   if(!ddlMapSDD){
1256       AliError("Calibration object retrieval failed! SDD will not be processed");
1257       fDDLModuleMap = NULL;
1258       //return rv;
1259     }
1260   else{
1261     fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
1262     if(!cacheStatus)ddlMapSDD->SetObject(NULL);
1263     ddlMapSDD->SetOwner(kTRUE);
1264     if(!cacheStatus){ delete ddlMapSDD;}
1265     AliInfo("DDL Map Created\n ");
1266   }
1267 }
1268
1269 //_______________________________________________________________
1270
1271
1272 void AliITSQASDDDataMakerRec::CreateTheCalibration()
1273 {
1274   //Take from the OCDB the calibration information for the SDD 
1275     AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
1276     Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
1277     if(!calibSDD)
1278       {
1279         AliError("Calibration object retrieval failed! SDD will not be processed");
1280         fCalibration = NULL;
1281       }
1282     else{
1283       fCalibration = (TObjArray *)calibSDD->GetObject();
1284       
1285       if(!cacheStatus)calibSDD->SetObject(NULL);
1286       calibSDD->SetOwner(kTRUE);
1287       if(!cacheStatus){delete calibSDD;}
1288       
1289       AliITSCalibrationSDD * cal=NULL;
1290       for(Int_t imod=0;imod<fgknSDDmodules;imod++)
1291         {
1292           //cal=NULL;
1293           Int_t fillmodhisto1=fgkTotalNumberSDDAnodes;
1294           Int_t fillmodhisto2side0=fgkNumberOfSDDAnodesperSide;
1295           Int_t fillmodhisto2side1=fgkNumberOfSDDAnodesperSide;
1296           Int_t fillmodhisto3side0=fgkNumberOfSDDAnodesperSide;
1297           Int_t fillmodhisto3side1=fgkNumberOfSDDAnodesperSide;
1298           
1299           Int_t badmodhisto1=0;
1300           Int_t badmodhisto2side0=0;
1301           Int_t badmodhisto2side1=0;
1302           Int_t badmodhisto3side0=0;
1303           Int_t badmodhisto3side1=0;
1304           //printf("imod %i\t ==== \t",imod);
1305           Int_t module=imod + 240;
1306           //printf("module %i\t ==== \t",module);
1307           cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
1308           Int_t lay,lad,det;
1309           AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
1310           Int_t index=1+(det-1)*2;
1311           if(cal==0){continue;}
1312           if (cal->IsBad()){continue;}//bad module check
1313           else{
1314             for(Int_t i=0;i<8;i++) //check on bad chips in good modules
1315               {
1316                 if(lay==3){
1317                   if(cal->IsChipBad(i)){
1318                     if(i<4){badmodhisto2side0+=64;}
1319                     if(i>=4){badmodhisto2side1+=64;}
1320                   }//end if chip
1321                 }//end if  layer3
1322                 else if(lay==4){
1323                   if(cal->IsChipBad(i)){
1324                     if(i<4){badmodhisto3side0+=64;}
1325                     if(i>=4){badmodhisto3side1+=64;}             
1326                   }//end if  chip
1327                 }//ens if layer4
1328               }//end for  chip
1329             for(Int_t iAn=0; iAn<512; iAn++){//anodes loop 
1330               Int_t ic=cal->GetChip(iAn);//chip with this anode number
1331               if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){// good chip   good module   bad channel 
1332                 if(lay==3){
1333                   if(ic<4) badmodhisto2side0++;
1334                   else if(ic>=4)badmodhisto2side1++;
1335                 }//end if layer 3
1336                 else if(lay==4){
1337                   if(ic<4) badmodhisto3side0++;
1338                   else if(ic>=4)badmodhisto3side1++;
1339                 }//end if layer 4
1340               }//end if chip module channel
1341             }//end for anodes
1342             if(lay==3){
1343               badmodhisto1=badmodhisto2side0+badmodhisto2side1;
1344               fillmodhisto1-=badmodhisto1;
1345               fillmodhisto2side0-=badmodhisto2side0;
1346               fillmodhisto2side1-=badmodhisto2side1;
1347               ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
1348               ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index,lad,fillmodhisto2side0);
1349               ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index+1,lad,fillmodhisto2side1);
1350             }//end layer 3
1351             else if(lay==4){
1352               badmodhisto1=badmodhisto3side0+badmodhisto3side1;
1353               fillmodhisto1-=badmodhisto1;
1354               fillmodhisto3side0-=badmodhisto3side0;
1355               fillmodhisto3side1-=badmodhisto3side1;
1356               ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
1357               ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index,lad,fillmodhisto3side0);
1358               ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index+1,lad,fillmodhisto3side1);
1359             }//end layer 4
1360           }//end else bad module
1361         }//end module for
1362     }
1363
1364 }
1365
1366 //____________________________________________________________________
1367
1368 void AliITSQASDDDataMakerRec::InitCalibrationArray()
1369 {
1370   //create the histograms with the calibration informations. The histograms are stored in a TObjArray
1371     TH1D *pattern1  = new TH1D("CALSDDModPattern","Calibration HW Modules pattern",fgknSDDmodules,239.5,499.5);
1372     pattern1->SetDirectory(0) ;
1373     TH2D *patternl3 = new TH2D("CALSDDphizL3","Calibration SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);
1374     patternl3->SetDirectory(0) ;
1375     TH2D *patternl4 = new TH2D("CALSDDphizL4"," Calibration SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5);
1376     patternl4->SetDirectory(0) ;
1377
1378     if(!fHistoCalibration)fHistoCalibration = new TObjArray(3);
1379     fHistoCalibration->AddAtAndExpand(pattern1,0);
1380     fHistoCalibration->AddAtAndExpand(patternl3,1);
1381     fHistoCalibration->AddAtAndExpand(patternl4,2);
1382     fHistoCalibration->SetOwner(kTRUE); 
1383     //    printf("Calibration Histograms created!\n");
1384 }
1385
1386 //____________________________________________________________________
1387
1388 void AliITSQASDDDataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
1389 {
1390   //reset the SDD calibration histograms
1391   AliInfo(Form("Reset detector in SDD called for task index %i", task));
1392   if(task== AliQAv1::kRAWS ){
1393     fDDLModuleMap=NULL;
1394   }
1395
1396   fCalibration=NULL;
1397
1398   ((TH1D*)(fHistoCalibration->At(0)))->Reset();
1399   ((TH2D*)(fHistoCalibration->At(1)))->Reset();
1400   ((TH2D*)(fHistoCalibration->At(2)))->Reset();
1401   //delete fHistoCalibration;
1402   //fHistoCalibration=NULL;
1403   
1404 }
1405
1406 //____________________________________________________________________
1407
1408 Int_t AliITSQASDDDataMakerRec::GetNumberOfEvents(AliQAv1::TASKINDEX_t task)
1409 {
1410   //return the number of the processed events for a given task fod SDD only
1411
1412   if(task==AliQAv1::kRAWS){return fNEvent;}
1413   else if(task==AliQAv1::kRECPOINTS){return fNEventRP;}
1414   else{ AliWarning("The selected TASKINDEX is not valid!! return 0\n"); return 0;}
1415
1416
1417 }