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