]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASDDDataMakerRec.cxx
55cb472c592a6942599c4f8f794803867a8b054f
[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) {CreateTheCalibration();}
158
159   if(fAliITSQADataMakerRec->GetEventSpecie()==0) return;//not the kDefault EventSpecie
160     //Detector specific actions at start of cycle
161     if(fAliITSQADataMakerRec->GetTaskIndexSelected()==AliQAv1::kRAWS){
162       AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
163       if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRAWS)==kFALSE)return;
164
165         AliDebug(AliQAv1::GetQADebugLevel(),Form("Reset of Raw Data normalized histograms with eventspecie %s ",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie())));
166
167         fAliITSQADataMakerRec->GetRawsData(3+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
168         fAliITSQADataMakerRec->GetRawsData(4+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
169         fAliITSQADataMakerRec->GetRawsData(5+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
170       
171     }
172     if(fAliITSQADataMakerRec->GetTaskIndexSelected()==AliQAv1::kRECPOINTS){
173       if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRECPOINTS)==kFALSE)return;
174
175         AliDebug(AliQAv1::GetQADebugLevel(),Form("Reset of RecPoints normalized histograms with eventspecie %s ",AliRecoParam::GetEventSpecieName(fAliITSQADataMakerRec->GetEventSpecie())));
176
177         fAliITSQADataMakerRec->GetRecPointsData(9+  fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
178         fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
179         fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
180       }
181 }
182
183 //____________________________________________________________________________ 
184 void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray* /*list*/)
185 {
186   //end of a QA cycle
187         AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
188         if(task==AliQAv1::kRAWS){
189           //      printf("fNevent %d \n",fNEvent);
190           if(fNEvent!=0){
191             ((TH1D*)fAliITSQADataMakerRec->GetRawsData(3 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRawsData(0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEvent);
192           
193             ((TH2D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEvent);
194             
195             ((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(2 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEvent);
196           }       
197
198                 Int_t xbin3 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
199                 Int_t ybin3 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
200                 
201                 for(Int_t i=0; i<xbin3; i++) {
202                         for(Int_t j=0; j<ybin3; j++) {
203                                 ((TH1D*)fAliITSQADataMakerRec->GetRawsData(6 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
204                         }
205                 }
206                 
207                 Int_t xbin4 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
208                 Int_t ybin4 = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
209                 
210                 for(Int_t i=0; i<xbin4; i++) {
211                         for(Int_t j=0; j<ybin4; j++) {
212                                 ((TH1D*)fAliITSQADataMakerRec->GetRawsData(7 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
213                         }
214                 }
215                         
216         }//end raws
217         
218         if(task==AliQAv1::kRECPOINTS){
219           //      printf("fNeventRP %d \n",fNEventRP);
220           if(fNEventRP!=0){
221             ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(9 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(6 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEventRP);
222             
223                   ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEventRP);
224                   
225                   ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEventRP);
226
227                   ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(21+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEventRP);
228                   
229                   ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEventRP);
230           }
231                 Int_t xbin3 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
232                 Int_t ybin3 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
233                 
234                 for(Int_t i=0; i<xbin3; i++) {
235                         for(Int_t j=0; j<ybin3; j++) {
236                                 ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(19 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(10 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
237                         }
238                 }
239                 
240                 Int_t xbin4 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
241                 Int_t ybin4 = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
242                 
243                 for(Int_t i=0; i<xbin4; i++) {
244                         for(Int_t j=0; j<ybin4; j++) {
245                                 ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(20 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(11 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
246                         }
247                 }
248
249                 // RecPoints 2 Raws Ratio
250                 if(fAliITSQADataMakerRec->ListExists(AliQAv1::kRAWS)==kTRUE)
251                   {
252                     Int_t xbin3RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
253                     Int_t ybin3RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
254                     Int_t xbin3R  = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
255                     Int_t ybin3R  = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
256                     if((xbin3RP == xbin3R) && (ybin3RP == ybin3R)) {
257                       ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide(((TH2D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])));
258                       for(Int_t i=0; i<xbin3R; i++) {
259                         for(Int_t j=0; j<ybin3R; j++) {
260                           ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(23 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(21 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
261                         }
262                       }
263                     } else 
264                       AliWarning("Number of bins for Raws and RecPoints (Layer 3) do not match\n");
265                     
266                     Int_t xbin4RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
267                     Int_t ybin4RP = ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
268                     Int_t xbin4R = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsX();
269                     Int_t ybin4R = ((TH1D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetNbinsY();
270                     if((xbin4RP == xbin4R) && (ybin4RP == ybin4R)) {
271                       ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide(((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])));
272                       for(Int_t i=0; i<xbin4R; i++) {
273                         for(Int_t j=0; j<ybin4R; j++) {
274                           ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(24 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Fill(((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(22 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->GetBinContent(i,j));
275                         }
276                       }
277                     } else 
278                       AliWarning("Number of bins for Raws and RecPoints (Layer 4) do not match\n");
279                   }
280                 else{AliWarning("Ratio between RecPoints and Raws not executed because the raw list has not been created\n");}
281         }//end recpoints
282         
283 }
284
285 //____________________________________________________________________________ 
286 Int_t AliITSQASDDDataMakerRec::InitRaws()
287
288
289   // Initialization for RAW data - SDD -
290   const Bool_t expert   = kTRUE ; 
291   const Bool_t saveCorr = kTRUE ; 
292   const Bool_t image    = kTRUE ; 
293
294   Int_t rv = 0 ; 
295   Int_t lay, lad, det;
296   Int_t indexlast = 0;
297   Int_t index1 = 0;
298
299         fSDDhRawsTask = 0;
300         if(fkOnline){AliInfo("Book Online Histograms for SDD\n");}
301   else {AliInfo("Book Offline Histograms for SDD\n ");}
302   TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5); //0
303   h0->GetXaxis()->SetTitle("Module Number");
304   h0->GetYaxis()->SetTitle("Counts");
305   rv = fAliITSQADataMakerRec->Add2RawsList(h0,0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
306   fSDDhRawsTask++;
307   
308   //zPhi distribution using ladder and modules numbers
309   TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//1
310   hphil3->GetXaxis()->SetTitle("z[Module Number L3 ]");
311   hphil3->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
312   rv = fAliITSQADataMakerRec->Add2RawsList(hphil3,1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
313   fSDDhRawsTask++;
314   
315   TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //2
316   hphil4->GetXaxis()->SetTitle("z[Module Number L4]");
317   hphil4->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
318    rv = fAliITSQADataMakerRec->Add2RawsList(hphil4,2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
319   fSDDhRawsTask++;
320   
321   //normalized histograms
322   TH1D *h0norm = new TH1D("SDDModPatternNORM","NORM HW Modules pattern",fgknSDDmodules,239.5,499.5); //3
323   h0norm->GetXaxis()->SetTitle("Module Number");
324   h0norm->GetYaxis()->SetTitle("Counts");
325   rv = fAliITSQADataMakerRec->Add2RawsList(h0norm,3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
326   fSDDhRawsTask++;
327   
328   //zPhi distribution using ladder and modules numbers
329   TH2D *hphil3norm = new TH2D("SDDphizL3NORM","NORM SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//4
330   hphil3norm->GetXaxis()->SetTitle("z[Module Number L3 ]");
331   hphil3norm->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
332   rv = fAliITSQADataMakerRec->Add2RawsList(hphil3norm,4+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
333   fSDDhRawsTask++;
334   
335   TH2D *hphil4norm = new TH2D("SDDphizL4NORM","NORM SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //5
336   hphil4norm->GetXaxis()->SetTitle("z[Module Number L4]");
337   hphil4norm->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
338    rv = fAliITSQADataMakerRec->Add2RawsList(hphil4norm,5+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
339   fSDDhRawsTask++;
340
341         
342         Float_t hMax = 0.2;
343         
344         TH1F *oL3 = new TH1F("SDDL3_RelativeOccupancy","Layer 3 Relative Occupancy",200,0.,hMax);
345         rv = fAliITSQADataMakerRec->Add2RawsList(oL3,6+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); //6  
346         fSDDhRawsTask++;
347         
348         TH1F *oL4 = new TH1F("SDDL4_RelativeOccupancy","Layer 4 Relative Occupancy",200,0.,hMax);
349         rv = fAliITSQADataMakerRec->Add2RawsList(oL4,7+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); //7   
350         fSDDhRawsTask++;
351         
352         fOnlineOffsetRaws = fSDDhRawsTask;
353         if(fkOnline){
354       //DDL Pattern 
355       TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,11.5,24,-0.5,23.5); //8
356       hddl->GetXaxis()->SetTitle("Channel");
357       hddl->GetYaxis()->SetTitle("DDL Number");
358       rv = fAliITSQADataMakerRec->Add2RawsList(hddl,fOnlineOffsetRaws+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
359       fSDDhRawsTask++;
360       Int_t indexlast1 = 0;
361   
362       fTimeBinSize = 4;
363       indexlast = 0;
364       index1 = 0;
365       indexlast1 = fSDDhRawsTask;
366       for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
367                   for(Int_t iside=0;iside<fgknSide;iside++){
368                           AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
369                           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);
370                           fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
371                           fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
372                           rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMapFSE,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);         
373                           fSDDhRawsTask++;
374                           index1++;      
375                   }
376       }
377       
378       for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
379                   for(Int_t iside=0;iside<fgknSide;iside++){
380                           AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
381                           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);
382                           fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
383                           fModuleChargeMap->GetYaxis()->SetTitle("Anode Number");
384                           rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMap,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
385                           fSDDhRawsTask++;
386                           index1++;      
387                   }
388       }
389       
390       //Event Size 
391       TH1F *hsize = new TH1F("SDDEventSize","SDD Event Size ",500,-0.5,199.5); 
392       hsize->SetBit(TH1::kCanRebin);
393       hsize->GetXaxis()->SetTitle("Event Size [kB]");
394       hsize->GetYaxis()->SetTitle("Entries");
395       rv = fAliITSQADataMakerRec->Add2RawsList(hsize,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
396       fSDDhRawsTask++;
397           
398     }  // kONLINE
399         
400         cout << fSDDhRawsTask << " SDD Raws histograms booked" << endl;
401         
402         AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Raws histograms booked\n",fSDDhRawsTask));
403         return rv ; 
404 }
405
406
407 //____________________________________________________________________________
408 Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
409
410   // Fill QA for RAW - SDD -
411   Int_t rv = 0;
412   // Check id histograms already created for this Event Specie
413   fNEvent++;
414   if(!fDDLModuleMap){CreateTheMap();}
415   if(rawReader->GetType() != 7) return rv;  // skips non physical triggers
416   AliDebug(AliQAv1::GetQADebugLevel(),"entering MakeRaws\n");                 
417   rawReader->Reset();       
418   rawReader->Select("ITSSDD");
419   AliITSRawStream *stream=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
420    stream->SetDDLModuleMap(fDDLModuleMap);
421   
422   Int_t lay, lad, det; 
423   
424   Int_t index=0;
425   if(fkOnline) {
426     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
427       for(Int_t iside=0;iside<fgknSide;iside++) {
428                 if(fSDDhRawsTask > fOnlineOffsetRaws + 1 + index) fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws + 1 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();   
429         // 4  because the 2D histos for single events start after the fourth position
430         index++;
431       }
432     }
433   }
434   
435   Int_t cnt = 0;
436   Int_t ildcID = -1;
437   Int_t iddl = -1;
438   Int_t isddmod = -1;
439   Int_t coord1, coord2, signal, moduleSDD, activeModule, index1; 
440   //if(fkOnline)
441   //{
442       Int_t prevDDLID = -1;
443       UInt_t size = 0;
444       int totalddl=static_cast<int>(fDDLModuleMap->GetNDDLs());
445       Bool_t *ddldata=new Bool_t[totalddl];
446       for(Int_t jddl=0;jddl<totalddl;jddl++){ddldata[jddl]=kFALSE;}
447       //}
448   while(stream->Next()) {
449     ildcID = rawReader->GetLDCId();
450     iddl = rawReader->GetDDLID();// - fgkDDLIDshift;
451     if(iddl<0)isddmod=-1;
452     //printf("----------------------iddl %i\n",iddl);
453     else isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
454
455     if(isddmod==-1){
456       AliDebug(AliQAv1::GetQADebugLevel(),Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId()));
457       continue;
458     }
459     if(stream->IsCompletedModule()) {
460       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedModule == KTRUE\n"));
461       continue;
462     } 
463     if(stream->IsCompletedDDL()) {
464       if(fkOnline){
465         if ((rawReader->GetDDLID() != prevDDLID)&&(ddldata[iddl])==kFALSE){
466           size += rawReader->GetDataSize();//in bytes
467           prevDDLID = rawReader->GetDDLID();
468           ddldata[iddl]=kTRUE;
469         }
470       }
471       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedDDL == KTRUE\n"));
472       continue;
473     } 
474     
475     coord1 = stream->GetCoord1();
476     coord2 = stream->GetCoord2();
477     signal = stream->GetSignal();
478     
479     moduleSDD = isddmod - fgkmodoffset;
480     
481     if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
482       AliDebug(AliQAv1::GetQADebugLevel(),Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
483       isddmod = 1;
484     }
485     
486     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
487     Short_t iside = stream->GetChannel();
488
489     //printf(" \n%i %i %i %i \n ",lay, lad, det,iside );
490     fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);   
491     if(lay==3) fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.25,lad); 
492     if(lay==4) fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.25,lad);
493  
494     if(fkOnline) {
495
496       fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill((stream->GetCarlosId())+0.5*iside -0.5,iddl);
497       //  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));
498       //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));
499       activeModule = moduleSDD;
500       index1 = activeModule * 2 + iside;
501       
502       if(index1<0){
503         AliDebug(AliQAv1::GetQADebugLevel(),Form("Wrong index number %d - patched to 0\n",index1));
504                   index1 = 0;
505       }      
506
507       if(fSDDhRawsTask > fOnlineOffsetRaws +1 + index1) {                                  
508         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws +1 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);     
509         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws +1 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal); 
510       }
511     }//online
512     cnt++;
513     if(!(cnt%10000)) AliDebug(AliQAv1::GetQADebugLevel(),Form(" %d raw digits read",cnt));
514   }//end next()
515   if(fkOnline){((TH1F*)(fAliITSQADataMakerRec->GetRawsData(fOnlineOffsetRaws +1 + 260*4 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(size/1024.);//KB
516   }
517         
518   AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",cnt)); 
519   delete stream;
520   stream = NULL; 
521
522 //      if(fkOnline) {
523 //              AnalyseBNG(); // Analyse Baseline, Noise, Gain
524 //              AnalyseINJ(); // Analyse Injectors
525 //      }
526
527   delete []ddldata;
528   ddldata=NULL;
529   return rv ; 
530 }
531
532 //____________________________________________________________________________ 
533 Int_t AliITSQASDDDataMakerRec::InitDigits()
534
535   //  if(!fHistoCalibration)InitCalibrationArray();
536   // Initialization for DIGIT data - SDD -  
537   const Bool_t expert   = kTRUE ; 
538   const Bool_t image    = kTRUE ;
539   Int_t rv = 0 ; 
540 //  fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
541   //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
542   TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5);       //hmod
543   h0->GetXaxis()->SetTitle("SDD Module Number");
544   h0->GetYaxis()->SetTitle("# DIGITS");
545   rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
546   fSDDhDigitsTask ++;
547   // printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
548   TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5);      //hanocc
549   h1->GetXaxis()->SetTitle("Anode Number");
550   h1->GetYaxis()->SetTitle("# DIGITS");
551   rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
552   fSDDhDigitsTask ++;
553   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
554   TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5);      //htbocc
555   h2->GetXaxis()->SetTitle("Tbin Number");
556   h2->GetYaxis()->SetTitle("# DIGITS");
557   rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
558   fSDDhDigitsTask ++;
559   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
560   TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.);          //hsig
561   h3->GetXaxis()->SetTitle("ADC Value");
562   h3->GetYaxis()->SetTitle("# DIGITS");
563   rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
564   fSDDhDigitsTask ++;
565   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
566   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDigitsTask));
567   return rv ; 
568 }
569
570 //____________________________________________________________________________
571 Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
572
573
574   // Fill QA for DIGIT - SDD -
575   //AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
576   //fITS->SetTreeAddress();
577   //TClonesArray *iITSdigits  = fITS->DigitsAddress(1);
578
579
580   Int_t rv = 0 ; 
581
582   TBranch *branchD = digits->GetBranch("ITSDigitsSDD");
583
584   if (!branchD) {
585     AliError("can't get the branch with the ITS SDD digits !");
586     return rv ;
587   }
588   // Check id histograms already created for this Event Specie
589 //  if ( ! fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset) )
590 //    rv = InitDigits() ;
591   
592   static TClonesArray statDigits("AliITSdigitSDD");
593   TClonesArray *iITSdigits = &statDigits;
594   branchD->SetAddress(&iITSdigits);
595
596   for(Int_t i=0; i<260; i++){
597     Int_t nmod=i+240;
598     digits->GetEvent(nmod);
599     Int_t ndigits = iITSdigits->GetEntries();
600     fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nmod,ndigits);
601
602     for (Int_t idig=0; idig<ndigits; idig++) {
603       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
604       Int_t iz=dig->GetCoord1();  // cell number z
605       Int_t ix=dig->GetCoord2();  // cell number x
606       Int_t sig=dig->GetSignal();
607       fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iz);
608       fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ix);
609       fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(sig);
610     }
611   }
612   return rv ; 
613 }
614
615 //____________________________________________________________________________ 
616 Int_t AliITSQASDDDataMakerRec::InitRecPoints()
617 {
618   //if(!fHistoCalibration)InitCalibrationArray();
619         //AliInfo("Initialize SDD recpoints histos\n");
620   // Initialization for RECPOINTS - SDD -
621   const Bool_t expert   = kTRUE ; 
622   const Bool_t image    = kTRUE ; 
623   Int_t rv = 0 ; 
624 //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
625
626   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
627   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
628   TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",250,-0.5, 499.5); //position number 0
629   //h0->SetBit(TH1::kCanRebin);
630   h0->GetXaxis()->SetTitle("KeV");
631   h0->GetYaxis()->SetTitle("Entries");
632   rv = fAliITSQADataMakerRec->Add2RecPointsList(h0, 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
633   fSDDhRecPointsTask++;
634  
635   TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",250,-0.5, 499.5);//position number 1
636   //h1->SetBit(TH1::kCanRebin);
637   h1->GetXaxis()->SetTitle("Kev");
638   h1->GetYaxis()->SetTitle("Entries");
639   rv = fAliITSQADataMakerRec->Add2RecPointsList(h1, 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
640   fSDDhRecPointsTask++;
641
642   TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",56,-28,28,56,-28,28);//position number 2
643   h2->GetYaxis()->SetTitle("Y[cm]");
644   h2->GetXaxis()->SetTitle("X[cm]");
645   rv = fAliITSQADataMakerRec->Add2RecPointsList(h2,2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
646   fSDDhRecPointsTask++;
647
648   TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",128,-32,32,56,12,26);//position number 3
649   h3->GetYaxis()->SetTitle("R[cm]");
650   h3->GetXaxis()->SetTitle("Z[cm]");
651   rv = fAliITSQADataMakerRec->Add2RecPointsList(h3,3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
652   fSDDhRecPointsTask++;
653   
654   TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",96,-23,23,112,-TMath::Pi(),TMath::Pi());//position number 4
655   h4->GetYaxis()->SetTitle("#phi[rad]");
656   h4->GetXaxis()->SetTitle("Z[cm]");
657   rv = fAliITSQADataMakerRec->Add2RecPointsList(h4,4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
658   fSDDhRecPointsTask++;
659
660   TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",128,-31,31,176,-TMath::Pi(),TMath::Pi());//position number 5
661   h5->GetYaxis()->SetTitle("#phi[rad]");
662   h5->GetXaxis()->SetTitle("Z[cm]");
663   rv = fAliITSQADataMakerRec->Add2RecPointsList(h5,5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
664   fSDDhRecPointsTask++;
665   
666   TH1D *h6 = new TH1D("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
667   h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
668   h6->GetYaxis()->SetTitle("Entries");
669   rv = fAliITSQADataMakerRec->Add2RecPointsList(h6,6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
670   fSDDhRecPointsTask++;
671
672   
673   TH2D *h7 = new TH2D("SDDModPatternL3RP","Modules pattern L3 RP",12,0.5,6.5,14,0.5,14.5);  //position number 7
674   h7->GetXaxis()->SetTitle("z[#Module L3 ]");
675   h7->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
676   rv = fAliITSQADataMakerRec->Add2RecPointsList(h7,7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
677   fSDDhRecPointsTask++;
678
679   TH2D *h8 = new TH2D("SDDModPatternL4RP","Modules pattern L4 RP",16,0.5,8.5,22,0.5,22.5); //position number 8
680   h8->GetXaxis()->SetTitle("[#Module L3 ]");
681   h8->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
682   rv = fAliITSQADataMakerRec->Add2RecPointsList(h8,8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
683   fSDDhRecPointsTask++;
684
685   //------------------------norm--------------------------//
686
687
688   TH1D *h9 = new TH1D("SDDModPatternRPNORM","Modules pattern RP NORM",fgknSDDmodules,239.5,499.5); //position number 9
689   h9->GetXaxis()->SetTitle("Module number"); //spd offset = 240
690   h9->GetYaxis()->SetTitle("Entries");
691   rv = fAliITSQADataMakerRec->Add2RecPointsList(h9,9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
692   fSDDhRecPointsTask++;
693
694   
695   TH2D *h10 = new TH2D("SDDModPatternL3RPNORM","Modules pattern L3 RP NORM",12,0.5,6.5,14,0.5,14.5);  //position number 10
696   h10->GetXaxis()->SetTitle("z[#Module L3 ]");
697   h10->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
698   rv = fAliITSQADataMakerRec->Add2RecPointsList(h10,10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO  image
699   fSDDhRecPointsTask++;
700
701   TH2D *h11 = new TH2D("SDDModPatternL4RPNORM","Modules pattern L4 RP NORM",16,0.5,8.5,22,0.5,22.5); //position number 11
702   h11->GetXaxis()->SetTitle("[#Module L4 ]");
703   h10->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
704   rv = fAliITSQADataMakerRec->Add2RecPointsList(h11,11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert NO image
705   fSDDhRecPointsTask++;
706
707   //--------------------------------------------------------//
708
709   TH2F *h12 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",160,-4,4,160,-4,4);//position number 12
710   h12->GetXaxis()->SetTitle("X local coord, drift, cm");
711   h12->GetYaxis()->SetTitle("Z local coord, anode, cm");
712   rv = fAliITSQADataMakerRec->Add2RecPointsList(h12,12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert  NO image
713   fSDDhRecPointsTask++;
714   
715   //AliInfo("Create SDD recpoints histos\n");
716   
717   TH1F *h13 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,16.5);//position number 13 (L3)
718   h13->SetBit(TH1::kCanRebin);
719   h13->GetXaxis()->SetTitle("r[cm]");
720   h13->GetXaxis()->CenterTitle();
721   h13->GetYaxis()->SetTitle("Entries");
722   rv = fAliITSQADataMakerRec->Add2RecPointsList(h13,13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
723   fSDDhRecPointsTask++;
724   
725   TH1F *h14 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,23.,25.);// and position number 14 (L4)
726   h14->SetBit(TH1::kCanRebin);
727   h14->GetXaxis()->SetTitle("r[cm]");
728   h14->GetXaxis()->CenterTitle();
729   h14->GetYaxis()->SetTitle("Entries");
730   rv = fAliITSQADataMakerRec->Add2RecPointsList(h14,14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
731   fSDDhRecPointsTask++;
732   
733   for(Int_t iLay=0; iLay<=1; iLay++){
734     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)
735     h15->GetXaxis()->SetTitle("#varphi[rad]");
736     h15->GetXaxis()->CenterTitle();
737     h15->GetYaxis()->SetTitle("Entries");
738     rv = fAliITSQADataMakerRec->Add2RecPointsList(h15,iLay+15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
739     fSDDhRecPointsTask++;
740   }
741   
742   for(Int_t iLay=0; iLay<=1; iLay++){
743     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)
744     h17->SetBit(TH1::kCanRebin);
745     h17->GetXaxis()->SetTitle("drift time[ns]");
746     h17->GetXaxis()->CenterTitle();
747     h17->GetYaxis()->SetTitle("Entries");
748     rv = fAliITSQADataMakerRec->Add2RecPointsList(h17,iLay+17+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert  image
749     fSDDhRecPointsTask++;
750   }
751   
752         Float_t hMax = 0.2;
753         
754         TH1F *oL3 = new TH1F("SDDL3_RelativeOccupancy","Layer 3 Relative Occupancy (RecPoints)",200,0.,hMax);
755         rv = fAliITSQADataMakerRec->Add2RecPointsList(oL3,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 19
756         fSDDhRecPointsTask++;
757         
758         TH1F *oL4 = new TH1F("SDDL4_RelativeOccupancy","Layer 4 Relative Occupancy (RecPoints)",200,0.,hMax);
759         rv = fAliITSQADataMakerRec->Add2RecPointsList(oL4,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 20
760         fSDDhRecPointsTask++;
761         
762         
763         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
764         h21->GetXaxis()->SetTitle("z[#Module L3 ]");
765         h21->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
766         rv = fAliITSQADataMakerRec->Add2RecPointsList(h21,21 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO  image
767         fSDDhRecPointsTask++;
768         
769         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
770         h22->GetXaxis()->SetTitle("[#Module L4 ]");
771         h22->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
772         rv = fAliITSQADataMakerRec->Add2RecPointsList(h22,22 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert NO image
773         fSDDhRecPointsTask++;
774
775         hMax = 0.3;     
776         TH1F *R2RL3 = new TH1F("SDDL3_Rec2Raw","L3 RecPoints to Raws ratio",150,0.,hMax);
777         rv = fAliITSQADataMakerRec->Add2RecPointsList(R2RL3,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 23
778         fSDDhRecPointsTask++;
779         
780         TH1F *R2RL4 = new TH1F("SDDL4_Rec2Raw","L4 RecPoints to Raws ratio",150,0.,hMax);
781         rv = fAliITSQADataMakerRec->Add2RecPointsList(R2RL4,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 24
782         fSDDhRecPointsTask++;
783
784         TH1F *dedxL3 = new TH1F("SDDL3_dedx","L3 dE/dX",100,0.,1.);
785         rv = fAliITSQADataMakerRec->Add2RecPointsList(dedxL3,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 25
786         fSDDhRecPointsTask++;
787         
788         TH1F *dedxL4 = new TH1F("SDDL4_dedx","L4 dE/dX",100,0.,1.);
789         rv = fAliITSQADataMakerRec->Add2RecPointsList(dedxL4,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image); // 26
790         fSDDhRecPointsTask++;
791         
792         fOnlineOffsetRecPoints = fSDDhRecPointsTask;
793         if(fkOnline){
794       TH2F *h19 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",112,-28,28,112,-28,28);//position number 27
795       h19->GetYaxis()->SetTitle("Y[cm]");
796       h19->GetXaxis()->SetTitle("X[cm]");
797       rv = fAliITSQADataMakerRec->Add2RecPointsList(h19,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
798       fSDDhRecPointsTask++;
799       
800       TH2F *h20 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",128,-32,32,56,12,26);//position number 28
801       h20->GetYaxis()->SetTitle("R[cm]");
802       h20->GetXaxis()->SetTitle("Z[cm]");
803       rv = fAliITSQADataMakerRec->Add2RecPointsList(h20,fSDDhRecPointsTask+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
804       fSDDhRecPointsTask++;      
805     }//online
806   
807   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Recs histograms booked\n",fSDDhRecPointsTask));
808   
809   return rv ; 
810 }
811
812 //____________________________________________________________________________ 
813 Int_t AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
814 {
815  // Fill QA for RecPoints - SDD -
816   Int_t rv = 0 ;
817   fNEventRP++; 
818   Int_t lay, lad, det; 
819   //AliInfo("get the branch with the ITS clusters !\n");
820   AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
821   TClonesArray *recpoints=NULL; 
822   if(fkOnline){recpoints = rpcont->FetchClusters(0,clustersTree,fAliITSQADataMakerRec->GetEventNumber());}
823   else{recpoints = rpcont->FetchClusters(0,clustersTree);}
824   AliDebug(10,Form("Fetched RecPoints for %d SDD modules",recpoints->GetEntriesFast()));
825   if(!rpcont->GetStatusOK() || !rpcont->IsSDDActive()){
826     AliError("can't get SDD clusters !");
827     return rv;
828   }
829
830   Int_t npoints = 0;      
831   Float_t cluglo[3]={0.,0.,0.}; 
832   if(fkOnline){
833       for(Int_t i=27;i<29;i++){
834           fAliITSQADataMakerRec->GetRecPointsData(i+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
835         }
836     }
837   // AliITSgeomTGeo::GetModuleIndex() issues an error in case the arguments
838   // are illegal and returns -1
839   Int_t firMod=TMath::Max(0,AliITSgeomTGeo::GetModuleIndex(3,1,1));
840   Int_t lasMod=AliITSgeomTGeo::GetModuleIndex(5,1,1);
841   for(Int_t module=firMod; module<lasMod;module++){
842     //AliInfo(Form("Module %d\n",module));
843     recpoints = rpcont->UncheckedGetClusters(module);
844     npoints += recpoints->GetEntries();
845     for(Int_t j=0;j<recpoints->GetEntries();j++){
846       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j); 
847       Int_t index = recp->GetDetectorIndex();
848       lay=recp->GetLayer();
849                 if(lay < 2 || lay > 3) continue;
850                 Int_t modnumb=index+AliITSgeomTGeo::GetModuleIndex(lay+1,1,1);
851                 AliITSgeomTGeo::GetModuleId(modnumb, lay, lad, det);  
852 //              AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
853       fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(modnumb);//modpatternrp
854       recp->GetGlobalXYZ(cluglo);
855       Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
856       Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
857       Float_t drifttime=recp->GetDriftTime();
858                 fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
859                 fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
860                 fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
861                 if(fkOnline) {
862                         fAliITSQADataMakerRec->GetRecPointsData(27 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
863                         fAliITSQADataMakerRec->GetRecPointsData(28 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
864                 }
865                 Int_t iside=recp->GetDriftSide();
866                 lay=recp->GetLayer();
867                 if(lay == 2) {
868                         fAliITSQADataMakerRec->GetRecPointsData(0  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
869                         fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 3
870                         fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
871                         fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
872                         fAliITSQADataMakerRec->GetRecPointsData(4  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer
873                         fAliITSQADataMakerRec->GetRecPointsData(17  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 3
874                         fAliITSQADataMakerRec->GetRecPointsData(25  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetdEdX());// charge distribution layer 3
875                 } else if(lay == 3) {
876                         fAliITSQADataMakerRec->GetRecPointsData(1  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
877                         fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 4
878                         fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
879                         fAliITSQADataMakerRec->GetRecPointsData(16 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
880                         fAliITSQADataMakerRec->GetRecPointsData(5  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer 4
881                         fAliITSQADataMakerRec->GetRecPointsData(18  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 4
882                         fAliITSQADataMakerRec->GetRecPointsData(26  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetdEdX());// charge distribution layer 4
883       }
884     }
885   }
886   return rv ; 
887 }
888
889 //_______________________________________________________________
890
891 Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task, Int_t specie)const
892 {
893   // Returns offset number according to the specified task
894   Int_t offset=0;
895   if( task == AliQAv1::kRAWS ){offset=fGenRawsOffset[specie];}
896   else if(task == AliQAv1::kDIGITSR ){offset=fGenDigitsOffset[specie];}
897   else if( task == AliQAv1::kRECPOINTS ){offset=fGenRecPointsOffset[specie];}
898   return offset;
899 }
900
901 //_______________________________________________________________
902
903 void AliITSQASDDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
904   // Set offset number according to the specified task
905   if( task == AliQAv1::kRAWS ) {fGenRawsOffset[specie]=offset;}
906   else if( task == AliQAv1::kDIGITSR ) {fGenDigitsOffset[specie]=offset;}
907   else if( task == AliQAv1::kRECPOINTS ) {fGenRecPointsOffset[specie]=offset;}
908 }
909
910 //_______________________________________________________________
911
912 Int_t AliITSQASDDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task)
913 {
914   //return the number of histo booked for a given Task
915   Int_t histotot=0;
916   if( task == AliQAv1::kRAWS ){ histotot=fSDDhRawsTask ;}
917   else if(task == AliQAv1::kDIGITSR) { histotot=fSDDhDigitsTask;}
918   else if( task == AliQAv1::kRECPOINTS ){ histotot=fSDDhRecPointsTask;}
919   else {AliInfo("No task has been selected. TaskHisto set to zero.\n");}
920   return histotot;
921 }
922
923
924 //_______________________________________________________________
925
926
927 void AliITSQASDDDataMakerRec::CreateTheMap()
928 {
929   //Create the SDD DDL Module Map
930   AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
931   Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
932   if(!ddlMapSDD){
933       AliError("Calibration object retrieval failed! SDD will not be processed");
934       fDDLModuleMap = NULL;
935       //return rv;
936     }
937   else{
938     fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
939     if(!cacheStatus)ddlMapSDD->SetObject(NULL);
940     ddlMapSDD->SetOwner(kTRUE);
941     if(!cacheStatus){ delete ddlMapSDD;}
942     AliInfo("DDL Map Created\n ");
943   }
944 }
945
946 //_______________________________________________________________
947
948
949 void AliITSQASDDDataMakerRec::CreateTheCalibration()
950 {
951   //Take from the OCDB the calibration information for the SDD 
952     AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
953     Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
954     if(!calibSDD)
955       {
956         AliError("Calibration object retrieval failed! SDD will not be processed");
957         fCalibration = NULL;
958       }
959     else{
960       fCalibration = (TObjArray *)calibSDD->GetObject();
961       
962       if(!cacheStatus)calibSDD->SetObject(NULL);
963       calibSDD->SetOwner(kTRUE);
964       if(!cacheStatus){delete calibSDD;}
965       
966       AliITSCalibrationSDD * cal=NULL;
967       for(Int_t imod=0;imod<fgknSDDmodules;imod++)
968         {
969           //cal=NULL;
970           Int_t fillmodhisto1=fgkTotalNumberSDDAnodes;
971           Int_t fillmodhisto2side0=fgkNumberOfSDDAnodesperSide;
972           Int_t fillmodhisto2side1=fgkNumberOfSDDAnodesperSide;
973           Int_t fillmodhisto3side0=fgkNumberOfSDDAnodesperSide;
974           Int_t fillmodhisto3side1=fgkNumberOfSDDAnodesperSide;
975           
976           Int_t badmodhisto1=0;
977           Int_t badmodhisto2side0=0;
978           Int_t badmodhisto2side1=0;
979           Int_t badmodhisto3side0=0;
980           Int_t badmodhisto3side1=0;
981           //printf("imod %i\t ==== \t",imod);
982           Int_t module=imod + 240;
983           //printf("module %i\t ==== \t",module);
984           cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
985           Int_t lay,lad,det;
986           AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
987           Int_t index=1+(det-1)*2;
988           if(cal==0){continue;}
989           if (cal->IsBad()){continue;}//bad module check
990           else{
991             for(Int_t i=0;i<8;i++) //check on bad chips in good modules
992               {
993                 if(lay==3){
994                   if(cal->IsChipBad(i)){
995                     if(i<4){badmodhisto2side0+=64;}
996                     if(i>=4){badmodhisto2side1+=64;}
997                   }//end if chip
998                 }//end if  layer3
999                 else if(lay==4){
1000                   if(cal->IsChipBad(i)){
1001                     if(i<4){badmodhisto3side0+=64;}
1002                     if(i>=4){badmodhisto3side1+=64;}             
1003                   }//end if  chip
1004                 }//ens if layer4
1005               }//end for  chip
1006             for(Int_t iAn=0; iAn<512; iAn++){//anodes loop 
1007               Int_t ic=cal->GetChip(iAn);//chip with this anode number
1008               if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){// good chip   good module   bad channel 
1009                 if(lay==3){
1010                   if(ic<4) badmodhisto2side0++;
1011                   else if(ic>=4)badmodhisto2side1++;
1012                 }//end if layer 3
1013                 else if(lay==4){
1014                   if(ic<4) badmodhisto3side0++;
1015                   else if(ic>=4)badmodhisto3side1++;
1016                 }//end if layer 4
1017               }//end if chip module channel
1018             }//end for anodes
1019             if(lay==3){
1020               badmodhisto1=badmodhisto2side0+badmodhisto2side1;
1021               fillmodhisto1-=badmodhisto1;
1022               fillmodhisto2side0-=badmodhisto2side0;
1023               fillmodhisto2side1-=badmodhisto2side1;
1024               ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
1025               ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index,lad,fillmodhisto2side0);
1026               ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index+1,lad,fillmodhisto2side1);
1027             }//end layer 3
1028             else if(lay==4){
1029               badmodhisto1=badmodhisto3side0+badmodhisto3side1;
1030               fillmodhisto1-=badmodhisto1;
1031               fillmodhisto3side0-=badmodhisto3side0;
1032               fillmodhisto3side1-=badmodhisto3side1;
1033               ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
1034               ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index,lad,fillmodhisto3side0);
1035               ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index+1,lad,fillmodhisto2side1);
1036             }//end layer 4
1037           }//end else bad module
1038         }//end module for
1039     }
1040 }
1041
1042 //____________________________________________________________________
1043
1044 void AliITSQASDDDataMakerRec::InitCalibrationArray()
1045 {
1046   //create the histograms with the calibration informations. The histograms are stored in a TObjArray
1047     TH1D *pattern1  = new TH1D("CALSDDModPattern","Calibration HW Modules pattern",fgknSDDmodules,239.5,499.5);
1048     pattern1->SetDirectory(0) ;
1049     TH2D *patternl3 = new TH2D("CALSDDphizL3","Calibration SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);
1050     patternl3->SetDirectory(0) ;
1051     TH2D *patternl4 = new TH2D("CALSDDphizL4"," Calibration SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5);
1052     patternl4->SetDirectory(0) ;
1053
1054     if(!fHistoCalibration)fHistoCalibration = new TObjArray(3);
1055     fHistoCalibration->AddAtAndExpand(pattern1,0);
1056     fHistoCalibration->AddAtAndExpand(patternl3,1);
1057     fHistoCalibration->AddAtAndExpand(patternl4,2);
1058     fHistoCalibration->SetOwner(kTRUE); 
1059     //    printf("Calibration Histograms created!\n");
1060 }
1061
1062 //____________________________________________________________________
1063
1064 void AliITSQASDDDataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
1065 {
1066   //reset the SDD calibration histograms
1067   AliInfo(Form("Reset detector in SDD called for task index %i", task));
1068   if(task== AliQAv1::kRAWS ){
1069     fDDLModuleMap=NULL;
1070   }
1071
1072   fCalibration=NULL;
1073
1074   ((TH1D*)(fHistoCalibration->At(0)))->Reset();
1075   ((TH2D*)(fHistoCalibration->At(1)))->Reset();
1076   ((TH2D*)(fHistoCalibration->At(2)))->Reset();
1077   //delete fHistoCalibration;
1078   //fHistoCalibration=NULL;
1079   
1080 }
1081