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