]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASDDDataMakerRec.cxx
Rename method Dump to DumpPayLoad to avoid compilation warning since mother class...
[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 <TGaxis.h>
35 #include <TMath.h>
36 #include <TF1.h>
37 #include <TDirectory.h>
38 #include <TSystem.h>
39 #include <TObjArray.h>
40
41 // --- Standard library ---
42
43 // --- AliRoot header files ---
44 #include "AliITSQASDDDataMakerRec.h"
45 #include "AliLog.h"
46 #include "AliQAv1.h"
47 #include "AliQAChecker.h"
48 #include "AliRawReader.h"
49 #include "AliITSRawStream.h"
50 #include "AliITSRawStreamSDD.h"
51 #include "AliITSRawStreamSDDCompressed.h"
52 #include "AliITSDetTypeRec.h"
53 #include "AliITSdigit.h"
54 #include "AliITSRecPoint.h"
55 #include "AliITSRecPointContainer.h"
56 #include "AliITSgeomTGeo.h"
57 #include "AliCDBManager.h"
58 #include "AliCDBStorage.h"
59 #include "AliCDBEntry.h"
60 #include "Riostream.h"
61 #include "AliITSdigitSDD.h"
62 #include "AliITS.h"
63 #include "AliRunLoader.h"
64 #include "AliITSLoader.h"
65 #include "AliITSDetTypeRec.h"
66 #include "AliITSCalibrationSDD.h"
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 fGenRawsOffset(0),
81 fGenDigitsOffset(0),
82 fGenRecPointsOffset(0),
83 fTimeBinSize(1),
84 fNEvent(0),
85 fNEventRP(0),
86 fDDLModuleMap(0),
87 fCalibration(0),
88 fHistoCalibration(0)
89 {
90   //ctor used to discriminate OnLine-Offline analysis
91   if(fLDC < 0 || fLDC > 6) {
92         AliError("Error: LDC number out of range; return\n");
93   }
94         fGenRawsOffset = new Int_t[AliRecoParam::kNSpecies];
95         fGenRecPointsOffset = new Int_t[AliRecoParam::kNSpecies];
96         fGenDigitsOffset = new Int_t[AliRecoParam::kNSpecies];
97         for(Int_t i=0; i<AliRecoParam::kNSpecies; i++) {
98                 fGenRawsOffset[i] = 0;
99                 fGenRecPointsOffset[i] = 0;
100                 fGenDigitsOffset[i]=0;
101         }
102 }
103
104 //____________________________________________________________________________ 
105 AliITSQASDDDataMakerRec::AliITSQASDDDataMakerRec(const AliITSQASDDDataMakerRec& qadm) :
106 TObject(),
107 fAliITSQADataMakerRec(qadm.fAliITSQADataMakerRec),
108 fkOnline(qadm.fkOnline),
109 fLDC(qadm.fLDC),
110 fSDDhRawsTask(qadm.fSDDhRawsTask),
111 fSDDhDigitsTask(qadm.fSDDhDigitsTask),
112 fSDDhRecPointsTask(qadm.fSDDhRecPointsTask),
113 fGenRawsOffset(qadm.fGenRawsOffset),
114 fGenDigitsOffset(qadm.fGenDigitsOffset),
115 fGenRecPointsOffset(qadm.fGenRecPointsOffset),
116 fTimeBinSize(qadm.fTimeBinSize),
117 fNEvent(qadm.fNEvent),
118 fNEventRP(qadm.fNEventRP),
119 fDDLModuleMap(qadm.fDDLModuleMap),
120 fCalibration(qadm.fCalibration),
121 fHistoCalibration(qadm.fHistoCalibration)
122 {
123   //copy ctor 
124   fAliITSQADataMakerRec->SetName((const char*)qadm.fAliITSQADataMakerRec->GetName()) ; 
125   fAliITSQADataMakerRec->SetTitle((const char*)qadm.fAliITSQADataMakerRec->GetTitle());
126   fDDLModuleMap=NULL;
127 }
128
129 //____________________________________________________________________________ 
130 AliITSQASDDDataMakerRec::~AliITSQASDDDataMakerRec(){
131   // destructor
132   //if(fDDLModuleMap) delete fDDLModuleMap;
133   if(fHistoCalibration){delete fHistoCalibration; fHistoCalibration=NULL;}
134 }
135 //__________________________________________________________________
136 AliITSQASDDDataMakerRec& AliITSQASDDDataMakerRec::operator = (const AliITSQASDDDataMakerRec& qac )
137 {
138   // Equal operator.
139   this->~AliITSQASDDDataMakerRec();
140   new(this) AliITSQASDDDataMakerRec(qac);
141   return *this;
142 }
143
144 //____________________________________________________________________________ 
145 void AliITSQASDDDataMakerRec::StartOfDetectorCycle()
146 {
147   //Detector specific actions at start of cycle
148   AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQADM::Start of SDD Cycle\n");
149   if(fAliITSQADataMakerRec->GetRawsData(0)!=NULL){
150     fAliITSQADataMakerRec->GetRawsData(3+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
151     fAliITSQADataMakerRec->GetRawsData(4+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
152     fAliITSQADataMakerRec->GetRawsData(5+ fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
153   }
154
155   if(fAliITSQADataMakerRec->GetRecPointsData(0)!=NULL){
156     fAliITSQADataMakerRec->GetRecPointsData(9+  fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
157     fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
158     fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
159   }
160 }
161
162 //____________________________________________________________________________ 
163 void AliITSQASDDDataMakerRec::EndOfDetectorCycle(AliQAv1::TASKINDEX_t task, TObjArray* /*list*/)
164 {
165         AliDebug(AliQAv1::GetQADebugLevel(),"AliITSDM instantiates checker with Run(AliQAv1::kITS, task, list)\n"); 
166         if(task==AliQAv1::kRAWS){
167           printf("fNevent %d \n",fNEvent);
168           if(fNEvent!=0){
169             ((TH1D*)fAliITSQADataMakerRec->GetRawsData(3 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRawsData(0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEvent);
170           
171             ((TH2D*)fAliITSQADataMakerRec->GetRawsData(4 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEvent);
172             
173             ((TH2D*)fAliITSQADataMakerRec->GetRawsData(5 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRawsData(2 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEvent);
174           }       
175         }//end raws
176         
177         if(task==AliQAv1::kRECPOINTS){
178           printf("fNeventRP %d \n",fNEventRP);
179           if(fNEventRP!=0){
180             ((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(9 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH1D*)fAliITSQADataMakerRec->GetRecPointsData(6 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH1D*) (fHistoCalibration->At(0))),1.,(Double_t)fNEventRP);
181             
182             ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(10+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(7 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(1))),1.,(Double_t)fNEventRP);
183             
184             ((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(11+ fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]))->Divide((TH2D*)fAliITSQADataMakerRec->GetRecPointsData(8 + fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]),((TH2D*)(fHistoCalibration->At(2))),1.,(Double_t)fNEventRP);
185           }
186         }//end recpoints
187         
188 }
189
190 //____________________________________________________________________________ 
191 Int_t AliITSQASDDDataMakerRec::InitRaws()
192
193   // Initialization for RAW data - SDD -
194   const Bool_t expert   = kTRUE ; 
195   const Bool_t saveCorr = kTRUE ; 
196   const Bool_t image    = kTRUE ; 
197
198   Int_t rv = 0 ; 
199   Int_t lay, lad, det;
200   Int_t indexlast = 0;
201   Int_t index1 = 0;
202
203   if(fkOnline){AliInfo("Book Online Histograms for SDD\n");}
204   else {AliInfo("Book Offline Histograms for SDD\n ");}
205   TH1D *h0 = new TH1D("SDDModPattern","HW Modules pattern",fgknSDDmodules,239.5,499.5); //0
206   h0->GetXaxis()->SetTitle("Module Number");
207   h0->GetYaxis()->SetTitle("Counts");
208   rv = fAliITSQADataMakerRec->Add2RawsList(h0,0+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
209   fSDDhRawsTask++;
210   
211   //zPhi distribution using ladder and modules numbers
212   TH2D *hphil3 = new TH2D("SDDphizL3","SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//1
213   hphil3->GetXaxis()->SetTitle("z[Module Number L3 ]");
214   hphil3->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
215   rv = fAliITSQADataMakerRec->Add2RawsList(hphil3,1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
216   fSDDhRawsTask++;
217   
218   TH2D *hphil4 = new TH2D("SDDphizL4","SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //2
219   hphil4->GetXaxis()->SetTitle("z[Module Number L4]");
220   hphil4->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
221    rv = fAliITSQADataMakerRec->Add2RawsList(hphil4,2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image, saveCorr); 
222   fSDDhRawsTask++;
223   
224   //normalized histograms
225   TH1D *h0norm = new TH1D("SDDModPatternNORM","NORM HW Modules pattern",fgknSDDmodules,239.5,499.5); //3
226   h0norm->GetXaxis()->SetTitle("Module Number");
227   h0norm->GetYaxis()->SetTitle("Counts");
228   rv = fAliITSQADataMakerRec->Add2RawsList(h0norm,3+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
229   fSDDhRawsTask++;
230   
231   //zPhi distribution using ladder and modules numbers
232   TH2D *hphil3norm = new TH2D("SDDphizL3NORM","NORM SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);//4
233   hphil3norm->GetXaxis()->SetTitle("z[Module Number L3 ]");
234   hphil3norm->GetYaxis()->SetTitle("#varphi[ Ladder Number L3]");
235   rv = fAliITSQADataMakerRec->Add2RawsList(hphil3norm,4+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
236   fSDDhRawsTask++;
237   
238   TH2D *hphil4norm = new TH2D("SDDphizL4NORM","NORM SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5); //5
239   hphil4norm->GetXaxis()->SetTitle("z[Module Number L4]");
240   hphil4norm->GetYaxis()->SetTitle("#varphi[Ladder Number L4]");
241    rv = fAliITSQADataMakerRec->Add2RawsList(hphil4norm,5+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr); 
242   fSDDhRawsTask++;
243
244   if(fkOnline){
245       //DDL Pattern 
246       TH2D *hddl = new TH2D("SDDDDLPattern","SDD DDL Pattern ",24,-0.5,11.5,24,-0.5,23.5); //6
247       hddl->GetXaxis()->SetTitle("Channel");
248       hddl->GetYaxis()->SetTitle("DDL Number");
249       rv = fAliITSQADataMakerRec->Add2RawsList(hddl,6+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
250       fSDDhRawsTask++;
251       Int_t indexlast1 = 0;
252   
253       fTimeBinSize = 4;
254       indexlast = 0;
255       index1 = 0;
256       indexlast1 = fSDDhRawsTask;
257       char *hname[3];
258       for(Int_t i=0; i<3; i++) hname[i]= new char[50];
259       for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
260         for(Int_t iside=0;iside<fgknSide;iside++){
261           AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
262           sprintf(hname[0],"SDDchargeMapFSE_L%d_%d_%d_%d",lay,lad,det,iside);
263           sprintf(hname[1],"SDDChargeMapForSingleEvent_L%d_%d_%d_%d",lay,lad,det,iside);
264           //      sprintf(hname[2],"SDDhmonoDMap_L%d_%d_%d_%d",lay,lad,det,iside);
265           TProfile2D *fModuleChargeMapFSE = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
266           fModuleChargeMapFSE->GetXaxis()->SetTitle("Time Bin");
267           fModuleChargeMapFSE->GetYaxis()->SetTitle("Anode");
268            rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMapFSE,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);        
269           fSDDhRawsTask++;
270           index1++;      
271         }
272       }
273       
274       for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
275         for(Int_t iside=0;iside<fgknSide;iside++){
276           AliITSgeomTGeo::GetModuleId(moduleSDD+fgkmodoffset, lay, lad, det);
277           sprintf(hname[0],"SDDchargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
278           sprintf(hname[1],"SDDChargeMap_L%d_%d_%d_%d",lay,lad,det,iside);
279           TProfile2D *fModuleChargeMap = new TProfile2D(hname[0],hname[1],256/fTimeBinSize,-0.5,255.5,256,-0.5,255.5);
280           fModuleChargeMap->GetXaxis()->SetTitle("Time Bin");
281           fModuleChargeMap->GetYaxis()->SetTitle("Anode Number");
282            rv = fAliITSQADataMakerRec->Add2RawsList(fModuleChargeMap,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
283           fSDDhRawsTask++;
284           index1++;      
285         }
286       }
287       
288       //Event Size 
289       TH1F *hsize = new TH1F("SDDEventSize","SDD Event Size ",500,-0.5,199.5); 
290       hsize->SetBit(TH1::kCanRebin);
291       hsize->GetXaxis()->SetTitle("Event Size [kB]");
292       hsize->GetYaxis()->SetTitle("Entries");
293       rv = fAliITSQADataMakerRec->Add2RawsList(hsize,indexlast1 + index1 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image, !saveCorr);
294       fSDDhRawsTask++;
295           
296     }  // kONLINE
297   InitCalibrationArray();
298   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Raws histograms booked\n",fSDDhRawsTask));
299   return rv ; 
300 }
301
302
303 //____________________________________________________________________________
304 Int_t AliITSQASDDDataMakerRec::MakeRaws(AliRawReader* rawReader)
305
306   // Fill QA for RAW - SDD -
307   Int_t rv = 0;
308   // Check id histograms already created for this Event Specie
309   fNEvent++;
310   if(!fDDLModuleMap){CreateTheMap();}
311   if(!fCalibration) {CreateTheCalibration();}
312   if(rawReader->GetType() != 7) return rv;  // skips non physical triggers
313   AliDebug(AliQAv1::GetQADebugLevel(),"entering MakeRaws\n");                 
314   rawReader->Reset();       
315   rawReader->Select("ITSSDD");
316   AliITSRawStream *stream=AliITSRawStreamSDD::CreateRawStreamSDD(rawReader);
317    stream->SetDDLModuleMap(fDDLModuleMap);
318   
319   Int_t lay, lad, det; 
320   
321   Int_t index=0;
322   if(fkOnline) {
323     for(Int_t moduleSDD =0; moduleSDD<fgknSDDmodules; moduleSDD++){
324       for(Int_t iside=0;iside<fgknSide;iside++) {
325                 if(fSDDhRawsTask > 7 + index) fAliITSQADataMakerRec->GetRawsData(7 + index +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();   
326         // 4  because the 2D histos for single events start after the fourth position
327         index++;
328       }
329     }
330   }
331   
332   Int_t cnt = 0;
333   Int_t ildcID = -1;
334   Int_t iddl = -1;
335   Int_t isddmod = -1;
336   Int_t coord1, coord2, signal, moduleSDD, activeModule, index1; 
337   //if(fkOnline)
338   //{
339       Int_t prevDDLID = -1;
340       UInt_t size = 0;
341       int totalddl=static_cast<int>(fDDLModuleMap->GetNDDLs());
342       Bool_t *ddldata=new Bool_t[totalddl];
343       for(Int_t jddl=0;jddl<totalddl;jddl++){ddldata[jddl]=kFALSE;}
344       //}
345   while(stream->Next()) {
346     ildcID = rawReader->GetLDCId();
347     iddl = rawReader->GetDDLID();// - fgkDDLIDshift;
348     //printf("----------------------iddl %i\n",iddl);
349
350     isddmod = fDDLModuleMap->GetModuleNumber(iddl,stream->GetCarlosId());
351     if(isddmod==-1){
352       AliDebug(AliQAv1::GetQADebugLevel(),Form("Found module with iddl: %d, stream->GetCarlosId: %d \n",iddl,stream->GetCarlosId()));
353       continue;
354     }
355     if(stream->IsCompletedModule()) {
356       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedModule == KTRUE\n"));
357       continue;
358     } 
359     if(stream->IsCompletedDDL()) {
360       if(fkOnline){
361         if ((rawReader->GetDDLID() != prevDDLID)&&(ddldata[iddl])==kFALSE){
362           size += rawReader->GetDataSize();//in bytes
363           prevDDLID = rawReader->GetDDLID();
364           ddldata[iddl]=kTRUE;
365         }
366       }
367       AliDebug(AliQAv1::GetQADebugLevel(),Form("IsCompletedDDL == KTRUE\n"));
368       continue;
369     } 
370     
371     coord1 = stream->GetCoord1();
372     coord2 = stream->GetCoord2();
373     signal = stream->GetSignal();
374     
375     moduleSDD = isddmod - fgkmodoffset;
376     
377     if(isddmod <fgkmodoffset|| isddmod>fgknSDDmodules+fgkmodoffset-1) {
378       AliDebug(AliQAv1::GetQADebugLevel(),Form( "Module SDD = %d, resetting it to 1 \n",isddmod));
379       isddmod = 1;
380     }
381     
382     AliITSgeomTGeo::GetModuleId(isddmod, lay, lad, det);
383     Short_t iside = stream->GetChannel();
384
385     //printf(" \n%i %i %i %i \n ",lay, lad, det,iside );
386     fAliITSQADataMakerRec->GetRawsData( 0 + fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()] )->Fill(isddmod);   
387     if(lay==3)    fAliITSQADataMakerRec->GetRawsData(1+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad); 
388     if(lay==4) {fAliITSQADataMakerRec->GetRawsData(2+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);}  
389  
390     if(fkOnline) {
391
392       fAliITSQADataMakerRec->GetRawsData(6+fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill((stream->GetCarlosId())+0.5*iside -0.5,iddl);
393       //  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));
394       //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));
395       activeModule = moduleSDD;
396       index1 = activeModule * 2 + iside;
397       
398       if(index1<0){
399         AliDebug(AliQAv1::GetQADebugLevel(),Form("Wrong index number %d - patched to 0\n",index1));
400         index1 = 0;
401       }      
402
403       if(fSDDhRawsTask > 7 + index1) {                                  
404         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(7 + index1 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal);     
405         ((TProfile2D *)(fAliITSQADataMakerRec->GetRawsData(7 + index1 + 260*2 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(coord2, coord1, signal); 
406       }
407     }//online
408     cnt++;
409     if(!(cnt%10000)) AliDebug(AliQAv1::GetQADebugLevel(),Form(" %d raw digits read",cnt));
410   }//end next()
411   if(fkOnline){((TH1F*)(fAliITSQADataMakerRec->GetRawsData(7 + 260*4 +fGenRawsOffset[fAliITSQADataMakerRec->GetEventSpecie()])))->Fill(size/1024.);//KB
412   }
413   AliDebug(AliQAv1::GetQADebugLevel(),Form("Event completed, %d raw digits read",cnt)); 
414   delete stream;
415   stream = NULL; 
416
417 //      if(fkOnline) {
418 //              AnalyseBNG(); // Analyse Baseline, Noise, Gain
419 //              AnalyseINJ(); // Analyse Injectors
420 //      }
421
422   delete []ddldata;
423   ddldata=NULL;
424   return rv ; 
425 }
426
427 //____________________________________________________________________________ 
428 Int_t AliITSQASDDDataMakerRec::InitDigits()
429
430   // Initialization for DIGIT data - SDD -  
431   const Bool_t expert   = kTRUE ; 
432   const Bool_t image    = kTRUE ;
433   Int_t rv = 0 ; 
434 //  fGenDigitsOffset = (fAliITSQADataMakerRec->fDigitsQAList[AliRecoParam::kDefault])->GetEntries();
435   //fSDDhTask must be incremented by one unit every time a histogram is ADDED to the QA List
436   TH1F* h0=new TH1F("SDD DIGITS Module Pattern","SDD DIGITS Module Pattern",260,239.5,499.5);       //hmod
437   h0->GetXaxis()->SetTitle("SDD Module Number");
438   h0->GetYaxis()->SetTitle("# DIGITS");
439   rv = fAliITSQADataMakerRec->Add2DigitsList(h0,fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
440   fSDDhDigitsTask ++;
441   // printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
442   TH1F* h1=new TH1F("SDD Anode Distribution","DIGITS Anode Distribution",512,-0.5,511.5);      //hanocc
443   h1->GetXaxis()->SetTitle("Anode Number");
444   h1->GetYaxis()->SetTitle("# DIGITS");
445   rv = fAliITSQADataMakerRec->Add2DigitsList(h1,1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
446   fSDDhDigitsTask ++;
447   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
448   TH1F* h2=new TH1F("SDD Tbin Distribution","DIGITS Tbin Distribution",256,-0.5,255.5);      //htbocc
449   h2->GetXaxis()->SetTitle("Tbin Number");
450   h2->GetYaxis()->SetTitle("# DIGITS");
451   rv = fAliITSQADataMakerRec->Add2DigitsList(h2,2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
452   fSDDhDigitsTask ++;
453   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
454   TH1F* h3=new TH1F("SDD ADC Counts Distribution","DIGITS ADC Counts Distribution",200,0.,1024.);          //hsig
455   h3->GetXaxis()->SetTitle("ADC Value");
456   h3->GetYaxis()->SetTitle("# DIGITS");
457   rv = fAliITSQADataMakerRec->Add2DigitsList(h3,3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);
458   fSDDhDigitsTask ++;
459   //printf("Add %s \t the task offset is %i\n",fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->GetName() , fSDDhDigitsTask );
460   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Digits histograms booked\n",fSDDhDigitsTask));
461   return rv ; 
462 }
463
464 //____________________________________________________________________________
465 Int_t AliITSQASDDDataMakerRec::MakeDigits(TTree * digits)
466
467
468   // Fill QA for DIGIT - SDD -
469   //AliITS *fITS  = (AliITS*)gAlice->GetModule("ITS");
470   //fITS->SetTreeAddress();
471   //TClonesArray *iITSdigits  = fITS->DigitsAddress(1);
472
473
474   Int_t rv = 0 ; 
475
476   TBranch *branchD = digits->GetBranch("ITSDigitsSDD");
477
478   if (!branchD) {
479     AliError("can't get the branch with the ITS SDD digits !");
480     return rv ;
481   }
482   // Check id histograms already created for this Event Specie
483 //  if ( ! fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset) )
484 //    rv = InitDigits() ;
485   
486   static TClonesArray statDigits("AliITSdigitSDD");
487   TClonesArray *iITSdigits = &statDigits;
488   branchD->SetAddress(&iITSdigits);
489
490   for(Int_t i=0; i<260; i++){
491     Int_t nmod=i+240;
492     digits->GetEvent(nmod);
493     Int_t ndigits = iITSdigits->GetEntries();
494     fAliITSQADataMakerRec->GetDigitsData(fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(nmod,ndigits);
495
496     for (Int_t idig=0; idig<ndigits; idig++) {
497       AliITSdigit *dig=(AliITSdigit*)iITSdigits->UncheckedAt(idig);
498       Int_t iz=dig->GetCoord1();  // cell number z
499       Int_t ix=dig->GetCoord2();  // cell number x
500       Int_t sig=dig->GetSignal();
501       fAliITSQADataMakerRec->GetDigitsData(1+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(iz);
502       fAliITSQADataMakerRec->GetDigitsData(2+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(ix);
503       fAliITSQADataMakerRec->GetDigitsData(3+fGenDigitsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(sig);
504     }
505   }
506   return rv ; 
507 }
508
509 //____________________________________________________________________________ 
510 Int_t AliITSQASDDDataMakerRec::InitRecPoints()
511 {
512
513         //AliInfo("Initialize SDD recpoints histos\n");
514   // Initialization for RECPOINTS - SDD -
515   const Bool_t expert   = kTRUE ; 
516   const Bool_t image    = kTRUE ; 
517   Int_t rv = 0 ; 
518 //  fGenRecPointsOffset = (fAliITSQADataMakerRec->fRecPointsQAList[AliRecoParam::kDefault])->GetEntries();
519
520   Int_t  nOnline=1;
521   Int_t  nOnline2=1;
522   Int_t  nOnline3=1; 
523   Int_t  nOnline4=1;
524   Int_t  nOnline5=1;
525   Int_t  nOnline6=1;
526   if(fkOnline){
527       nOnline=4;
528       nOnline2=28;
529       nOnline3=46;
530       nOnline4=14;
531       nOnline5=2;
532       nOnline6=62;
533     }
534
535   //AliInfo(Form("fAliITSQADataMakerRec->GetEventSpecie() %d\n",fAliITSQADataMakerRec->GetEventSpecie()));
536   //AliInfo(Form("fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()] %d\n",fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()]));
537   TH1F *h0 = new TH1F("SDDLay3TotCh","Layer 3 total charge",1000/nOnline,-0.5, 499.5); //position number 0
538   //h0->SetBit(TH1::kCanRebin);
539   h0->GetXaxis()->SetTitle("ADC value");
540   h0->GetYaxis()->SetTitle("Entries");
541   rv = fAliITSQADataMakerRec->Add2RecPointsList(h0, 0 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
542   fSDDhRecPointsTask++;
543  
544   TH1F *h1 = new TH1F("SDDLay4TotCh","Layer 4 total charge",1000/nOnline,-0.5, 499.5);//position number 1
545   //h1->SetBit(TH1::kCanRebin);
546   h1->GetXaxis()->SetTitle("ADC value");
547   h1->GetYaxis()->SetTitle("Entries");
548   rv = fAliITSQADataMakerRec->Add2RecPointsList(h1, 1 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
549   fSDDhRecPointsTask++;
550
551   char hisnam[50];
552   TH2F *h2 = new TH2F("SDDGlobalCoordDistribYX","YX Global Coord Distrib",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 2
553   h2->GetYaxis()->SetTitle("Y[cm]");
554   h2->GetXaxis()->SetTitle("X[cm]");
555   rv = fAliITSQADataMakerRec->Add2RecPointsList(h2,2+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
556   fSDDhRecPointsTask++;
557
558   TH2F *h3 = new TH2F("SDDGlobalCoordDistribRZ","RZ Global Coord Distrib",6400/nOnline3,-32,32,1400/nOnline4,12,26);//position number 3
559   h3->GetYaxis()->SetTitle("R[cm]");
560   h3->GetXaxis()->SetTitle("Z[cm]");
561   rv = fAliITSQADataMakerRec->Add2RecPointsList(h3,3+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert image
562   fSDDhRecPointsTask++;
563   
564   TH2F *h4 = new TH2F("SDDGlobalCoordDistribL3PHIZ","#varphi Z Global Coord Distrib L3",4600/nOnline3,-23,23,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 4
565   h4->GetYaxis()->SetTitle("#phi[rad]");
566   h4->GetXaxis()->SetTitle("Z[cm]");
567   rv = fAliITSQADataMakerRec->Add2RecPointsList(h4,4+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
568   fSDDhRecPointsTask++;
569
570   TH2F *h5 = new TH2F("SDDGlobalCoordDistribL4PHIZ","#varphi Z Global Coord Distrib L4",6200/nOnline6,-31,31,360/nOnline,-TMath::Pi(),TMath::Pi());//position number 5
571   h5->GetYaxis()->SetTitle("#phi[rad]");
572   h5->GetXaxis()->SetTitle("Z[cm]");
573   rv = fAliITSQADataMakerRec->Add2RecPointsList(h5,5+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);//NON expert image
574   fSDDhRecPointsTask++;
575   
576   TH1D *h6 = new TH1D("SDDModPatternRP","Modules pattern RP",fgknSDDmodules,239.5,499.5); //position number 6
577   h6->GetXaxis()->SetTitle("Module number"); //spd offset = 240
578   h6->GetYaxis()->SetTitle("Entries");
579   rv = fAliITSQADataMakerRec->Add2RecPointsList(h6,6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
580   fSDDhRecPointsTask++;
581
582   
583   TH2D *h7 = new TH2D("SDDModPatternL3RP","Modules pattern L3 RP",12,0.5,6.5,14,0.5,14.5);  //position number 7
584   h7->GetXaxis()->SetTitle("z[#Module L3 ]");
585   h7->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
586   rv = fAliITSQADataMakerRec->Add2RecPointsList(h7,7 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
587   fSDDhRecPointsTask++;
588
589   TH2D *h8 = new TH2D("SDDModPatternL4RP","Modules pattern L4 RP",16,0.5,8.5,22,0.5,22.5); //position number 8
590   h8->GetXaxis()->SetTitle("[#Module L3 ]");
591   h8->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
592   rv = fAliITSQADataMakerRec->Add2RecPointsList(h8,8 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
593   fSDDhRecPointsTask++;
594
595   //------------------------norm--------------------------//
596
597
598   TH1D *h9 = new TH1D("SDDModPatternRPNORM","Modules pattern RP NORM",fgknSDDmodules,239.5,499.5); //position number 9
599   h9->GetXaxis()->SetTitle("Module number"); //spd offset = 240
600   h9->GetYaxis()->SetTitle("Entries");
601   rv = fAliITSQADataMakerRec->Add2RecPointsList(h9,9 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
602   fSDDhRecPointsTask++;
603
604   
605   TH2D *h10 = new TH2D("SDDModPatternL3RPNORM","Modules pattern L3 RP NORM",12,0.5,6.5,14,0.5,14.5);  //position number 10
606   h10->GetXaxis()->SetTitle("z[#Module L3 ]");
607   h10->GetYaxis()->SetTitle("#varphi[#Ladder L3]");
608   rv = fAliITSQADataMakerRec->Add2RecPointsList(h10,10 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO  image
609   fSDDhRecPointsTask++;
610
611   TH2D *h11 = new TH2D("SDDModPatternL4RPNORM","Modules pattern L4 RP NORM",16,0.5,8.5,22,0.5,22.5); //position number 11
612   h11->GetXaxis()->SetTitle("[#Module L3 ]");
613   h10->GetYaxis()->SetTitle("#varphi[#Ladder L4]");
614   rv = fAliITSQADataMakerRec->Add2RecPointsList(h11,11 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert NO image
615   fSDDhRecPointsTask++;
616
617   //--------------------------------------------------------//
618
619   TH2F *h12 = new TH2F("SDDLocalCoordDistrib","Local Coord Distrib",1000/nOnline,-4,4,1000/nOnline,-4,4);//position number 12
620   h12->GetXaxis()->SetTitle("X local coord, drift, cm");
621   h12->GetYaxis()->SetTitle("Z local coord, anode, cm");
622   rv = fAliITSQADataMakerRec->Add2RecPointsList(h12,12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);//  expert  NO image
623   fSDDhRecPointsTask++;
624   
625   //AliInfo("Create SDD recpoints histos\n");
626   
627   TH1F *h13 = new TH1F("SDDrdistrib_Layer3" ,"SDD r distribution Layer3" ,100,14.,16.5);//position number 13 (L3)
628   h13->SetBit(TH1::kCanRebin);
629   h13->GetXaxis()->SetTitle("r[cm]");
630   h13->GetXaxis()->CenterTitle();
631   h13->GetYaxis()->SetTitle("Entries");
632   rv = fAliITSQADataMakerRec->Add2RecPointsList(h13,13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
633   fSDDhRecPointsTask++;
634   
635   TH1F *h14 = new TH1F("SDDrdistrib_Layer4" ,"SDD r distribution Layer4" ,100,23.,25.);// and position number 14 (L4)
636   h14->SetBit(TH1::kCanRebin);
637   h14->GetXaxis()->SetTitle("r[cm]");
638   h14->GetXaxis()->CenterTitle();
639   h14->GetYaxis()->SetTitle("Entries");
640   rv = fAliITSQADataMakerRec->Add2RecPointsList(h14,14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
641   fSDDhRecPointsTask++;
642   
643   for(Int_t iLay=0; iLay<=1; iLay++){
644     sprintf(hisnam,"SDDphidistrib_Layer%d",iLay+3);
645     TH1F *h15 = new TH1F(hisnam,hisnam,180,-TMath::Pi(),TMath::Pi());//position number 15 (L3) and position number 16 (L4)
646     h15->GetXaxis()->SetTitle("#varphi[rad]");
647     h15->GetXaxis()->CenterTitle();
648     h15->GetYaxis()->SetTitle("Entries");
649     rv = fAliITSQADataMakerRec->Add2RecPointsList(h15,iLay+15+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
650     fSDDhRecPointsTask++;
651   }
652   
653   for(Int_t iLay=0; iLay<=1; iLay++){
654     sprintf(hisnam,"SDDdrifttime_Layer%d",iLay+3);
655     TH1F *h17 = new TH1F(hisnam,hisnam,90/nOnline5,-0.5,4499.5);//position number 17 (L3) and position number 18 (L4)
656     h17->SetBit(TH1::kCanRebin);
657     h17->GetXaxis()->SetTitle("drift time[#mus]");
658     h17->GetXaxis()->CenterTitle();
659     h17->GetYaxis()->SetTitle("Entries");
660     rv = fAliITSQADataMakerRec->Add2RecPointsList(h17,iLay+17+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], !expert, image);// NON expert  image
661     fSDDhRecPointsTask++;
662   }
663   
664   if(fkOnline){
665       TH2F *h19 = new TH2F("SDDGlobalCoordDistribYXFSE","YX Global Coord Distrib FSE",5600/nOnline2,-28,28,5600/nOnline2,-28,28);//position number 19
666       h19->GetYaxis()->SetTitle("Y[cm]");
667       h19->GetXaxis()->SetTitle("X[cm]");
668       rv = fAliITSQADataMakerRec->Add2RecPointsList(h19,19+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
669       fSDDhRecPointsTask++;
670       
671       TH2F *h20 = new TH2F("SDDGlobalCoordDistribRZFSE","RZ Global Coord Distrib FSE",Int_t(6400/nOnline3),-32,32,1400/nOnline4,12,26);//position number 20
672       h20->GetYaxis()->SetTitle("R[cm]");
673       h20->GetXaxis()->SetTitle("Z[cm]");
674       rv = fAliITSQADataMakerRec->Add2RecPointsList(h20,20+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()], expert, !image);// expert NO image
675       fSDDhRecPointsTask++;      
676     }//online
677   
678   AliDebug(AliQAv1::GetQADebugLevel(),Form("%d SDD Recs histograms booked\n",fSDDhRecPointsTask));
679   
680   return rv ; 
681 }
682
683 //____________________________________________________________________________ 
684 Int_t AliITSQASDDDataMakerRec::MakeRecPoints(TTree * clustersTree)
685 {
686  // Fill QA for RecPoints - SDD -
687   Int_t rv = 0 ;
688   fNEventRP++; 
689   Int_t lay, lad, det; 
690   //AliInfo("get the branch with the ITS clusters !\n");
691   AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
692   TClonesArray *recpoints=NULL; 
693   if(fkOnline){recpoints = rpcont->FetchClusters(0,clustersTree,fAliITSQADataMakerRec->GetEventNumber());}
694   else{recpoints = rpcont->FetchClusters(0,clustersTree);}
695   if(!rpcont->GetStatusOK() || !rpcont->IsSDDActive()){
696     AliError("can't get SDD clusters !");
697     return rv;
698   }
699
700   Int_t npoints = 0;      
701   Float_t cluglo[3]={0.,0.,0.}; 
702   if(fkOnline){
703       for(Int_t i=19;i<21;i++){
704           fAliITSQADataMakerRec->GetRecPointsData(i+fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Reset();
705         }
706     }
707   Int_t firMod=AliITSgeomTGeo::GetModuleIndex(3,1,1);
708   Int_t lasMod=AliITSgeomTGeo::GetModuleIndex(5,1,1);
709   for(Int_t module=firMod; module<lasMod;module++){
710     //AliInfo(Form("Module %d\n",module));
711     recpoints = rpcont->UncheckedGetClusters(module);
712     npoints += recpoints->GetEntries();
713     //AliInfo(Form("modnumb %d, npoints %d, total points %d\n",module, recpoints->GetEntries(),npoints));
714     //AliITSgeomTGeo::GetModuleId(module, lay, lad, det);
715     //AliInfo(Form("modnumb %d, lay %d, lad %d, det %d \n",module, lay, lad, det));
716     
717     //AliInfo(Form("modnumb %d, entries %d\n",module, recpoints->GetEntries()));
718     for(Int_t j=0;j<recpoints->GetEntries();j++){
719       //AliInfo(Form("modnumb %d, entry %d \n",module, j));
720       AliITSRecPoint *recp = (AliITSRecPoint*)recpoints->At(j); 
721       Int_t index = recp->GetDetectorIndex();
722       lay=recp->GetLayer();
723       Int_t modnumb=index+AliITSgeomTGeo::GetModuleIndex(lay+1,1,1);
724       //printf("modnumb  %i\n",modnumb);  
725       AliITSgeomTGeo::GetModuleId(modnumb, lay, lad, det);  
726       fAliITSQADataMakerRec->GetRecPointsData(6 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(modnumb);//modpatternrp
727       recp->GetGlobalXYZ(cluglo);
728       Float_t rad=TMath::Sqrt(cluglo[0]*cluglo[0]+cluglo[1]*cluglo[1]); 
729       Float_t phi=TMath::ATan2(cluglo[1],cluglo[0]);
730       Float_t drifttime=recp->GetDriftTime();
731       fAliITSQADataMakerRec->GetRecPointsData(12 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetDetLocalX(),recp->GetDetLocalZ());//local distribution
732       if(lay==3||lay==4)fAliITSQADataMakerRec->GetRecPointsData(2 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX
733       fAliITSQADataMakerRec->GetRecPointsData(3 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz
734       if(fkOnline) {
735         fAliITSQADataMakerRec->GetRecPointsData(19 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[0],cluglo[1]);//global distribution YX FSE
736         fAliITSQADataMakerRec->GetRecPointsData(20 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],rad);//global distribution rz FSE
737       }
738       if(recp->GetLayer() == 2) {
739         fAliITSQADataMakerRec->GetRecPointsData(0  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge of layer 3
740         //fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//lad pattern layer 3
741         Int_t iside=recp->GetDriftSide();
742         //printf("iside =%d\n",iside);
743         fAliITSQADataMakerRec->GetRecPointsData(7  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 3
744         fAliITSQADataMakerRec->GetRecPointsData(13 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution layer 3
745         fAliITSQADataMakerRec->GetRecPointsData(15 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);// phi distribution layer 3
746         fAliITSQADataMakerRec->GetRecPointsData(4  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer
747         fAliITSQADataMakerRec->GetRecPointsData(17  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 3
748       } else if(recp->GetLayer() == 3) {
749         fAliITSQADataMakerRec->GetRecPointsData(1  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(recp->GetQ()) ;//total charge layer 4
750         //fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(lad);//ladpatternlayer4
751         Int_t iside=recp->GetDriftSide();
752         //printf("iside =%d\n",iside);
753         fAliITSQADataMakerRec->GetRecPointsData(8  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(det+0.5*iside-0.5,lad);//mod pattern layer 4
754         fAliITSQADataMakerRec->GetRecPointsData(14 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(rad);//r distribution
755         fAliITSQADataMakerRec->GetRecPointsData(16 +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(phi);//phi distribution
756         fAliITSQADataMakerRec->GetRecPointsData(5  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(cluglo[2],phi);// zphi distribution layer 4
757         fAliITSQADataMakerRec->GetRecPointsData(18  +fGenRecPointsOffset[fAliITSQADataMakerRec->GetEventSpecie()])->Fill(drifttime);// time distribution layer 4
758       }
759     }
760   }
761   return rv ; 
762 }
763
764 //_______________________________________________________________
765
766 Int_t AliITSQASDDDataMakerRec::GetOffset(AliQAv1::TASKINDEX_t task, Int_t specie)
767 {
768   Int_t offset=0;
769   if( task == AliQAv1::kRAWS ){offset=fGenRawsOffset[specie];}
770   else if(task == AliQAv1::kDIGITSR ){offset=fGenDigitsOffset[specie];}
771   else if( task == AliQAv1::kRECPOINTS ){offset=fGenRecPointsOffset[specie];}
772   return offset;
773 }
774
775 //_______________________________________________________________
776
777 void AliITSQASDDDataMakerRec::SetOffset(AliQAv1::TASKINDEX_t task, Int_t offset, Int_t specie) {
778   // Returns offset number according to the specified task
779   if( task == AliQAv1::kRAWS ) {fGenRawsOffset[specie]=offset;}
780   else if( task == AliQAv1::kDIGITSR ) {fGenDigitsOffset[specie]=offset;}
781   else if( task == AliQAv1::kRECPOINTS ) {fGenRecPointsOffset[specie]=offset;}
782 }
783
784 //_______________________________________________________________
785
786 Int_t AliITSQASDDDataMakerRec::GetTaskHisto(AliQAv1::TASKINDEX_t task)
787 {
788   Int_t histotot=0;
789   if( task == AliQAv1::kRAWS ){ histotot=fSDDhRawsTask ;}
790   else if(task == AliQAv1::kDIGITSR) { histotot=fSDDhDigitsTask;}
791   else if( task == AliQAv1::kRECPOINTS ){ histotot=fSDDhRecPointsTask;}
792   else {AliInfo("No task has been selected. TaskHisto set to zero.\n");}
793   return histotot;
794 }
795
796
797 //_______________________________________________________________
798
799
800 void AliITSQASDDDataMakerRec::CreateTheMap()
801 {
802
803   AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
804   Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
805   if(!ddlMapSDD){
806       AliError("Calibration object retrieval failed! SDD will not be processed");
807       fDDLModuleMap = NULL;
808       //return rv;
809     }
810   fDDLModuleMap = (AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
811   if(!cacheStatus)ddlMapSDD->SetObject(NULL);
812   ddlMapSDD->SetOwner(kTRUE);
813   if(!cacheStatus){ delete ddlMapSDD;}
814   AliInfo("DDL Map Created\n ");
815 }
816
817 //_______________________________________________________________
818
819
820 void AliITSQASDDDataMakerRec::CreateTheCalibration()
821 {
822
823     AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
824     Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
825     if(!calibSDD)
826       {
827         AliError("Calibration object retrieval failed! SDD will not be processed");
828         fCalibration = NULL;;
829       }
830     fCalibration = (TObjArray *)calibSDD->GetObject();
831     
832     if(!cacheStatus)calibSDD->SetObject(NULL);
833     calibSDD->SetOwner(kTRUE);
834     if(!cacheStatus){delete calibSDD;}
835
836     AliITSCalibrationSDD * cal=NULL;
837     for(Int_t imod=0;imod<fgknSDDmodules;imod++)
838       {
839         //cal=NULL;
840         Int_t fillmodhisto1=fgkTotalNumberSDDAnodes;
841         Int_t fillmodhisto2side0=fgkNumberOfSDDAnodesperSide;
842         Int_t fillmodhisto2side1=fgkNumberOfSDDAnodesperSide;
843         Int_t fillmodhisto3side0=fgkNumberOfSDDAnodesperSide;
844         Int_t fillmodhisto3side1=fgkNumberOfSDDAnodesperSide;
845         
846         Int_t badmodhisto1=0;
847         Int_t badmodhisto2side0=0;
848         Int_t badmodhisto2side1=0;
849         Int_t badmodhisto3side0=0;
850         Int_t badmodhisto3side1=0;
851         //printf("imod %i\t ==== \t",imod);
852         Int_t module=imod + 240;
853         //printf("module %i\t ==== \t",module);
854         cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
855         Int_t lay,lad,det;
856         AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
857         Int_t index=1+(det-1)*2;
858         if(cal==0){continue;}
859         if (cal->IsBad()){continue;}//bad module check
860         else{
861           for(Int_t i=0;i<8;i++) //check on bad chips in good modules
862             {
863               if(lay==3){
864                 if(cal->IsChipBad(i)){
865                   if(i<4){badmodhisto2side0+=64;}
866                   if(i>=4){badmodhisto2side1+=64;}
867                 }//end if chip
868               }//end if  layer3
869               else if(lay==4){
870                 if(cal->IsChipBad(i)){
871                   if(i<4){badmodhisto3side0+=64;}
872                   if(i>=4){badmodhisto3side1+=64;}               
873                 }//end if  chip
874               }//ens if layer4
875             }//end for  chip
876           for(Int_t iAn=0; iAn<512; iAn++){//anodes loop 
877             Int_t ic=cal->GetChip(iAn);//chip with this anode number
878             if(!cal->IsChipBad(ic) && !cal->IsBad() && cal->IsBadChannel(iAn)){// good chip   good module   bad channel 
879               if(lay==3){
880                   if(ic<4) badmodhisto2side0++;
881                   else if(ic>=4)badmodhisto2side1++;
882                 }//end if layer 3
883               else if(lay==4){
884                   if(ic<4) badmodhisto3side0++;
885                   else if(ic>=4)badmodhisto3side1++;
886                 }//end if layer 4
887             }//end if chip module channel
888           }//end for anodes
889           if(lay==3){
890             badmodhisto1=badmodhisto2side0+badmodhisto2side1;
891             fillmodhisto1-=badmodhisto1;
892             fillmodhisto2side0-=badmodhisto2side0;
893             fillmodhisto2side1-=badmodhisto2side1;
894             ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
895             ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index,lad,fillmodhisto2side0);
896             ((TH2D*)(fHistoCalibration->At(1)))->SetBinContent(index+1,lad,fillmodhisto2side1);
897           }//end layer 3
898           else if(lay==4){
899             badmodhisto1=badmodhisto3side0+badmodhisto3side1;
900             fillmodhisto1-=badmodhisto1;
901             fillmodhisto3side0-=badmodhisto3side0;
902             fillmodhisto3side1-=badmodhisto3side1;
903             ((TH1D*)(fHistoCalibration->At(0)))->SetBinContent(imod+1,fillmodhisto1);
904             ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index,lad,fillmodhisto3side0);
905             ((TH2D*)(fHistoCalibration->At(2)))->SetBinContent(index+1,lad,fillmodhisto2side1);
906           }//end layer 4
907         }//end else bad module
908       }//end module for
909
910 }
911
912 //____________________________________________________________________
913
914 void AliITSQASDDDataMakerRec::InitCalibrationArray()
915 {
916
917     TH1D *pattern1  = new TH1D("CALSDDModPattern","Calibration HW Modules pattern",fgknSDDmodules,239.5,499.5);
918     TH2D *patternl3 = new TH2D("CALSDDphizL3","Calibration SDD #varphiz Layer3 ",12,0.5,6.5,14,0.5,14.5);
919     TH2D *patternl4 = new TH2D("CALSDDphizL4"," Calibration SDD #varphiz Layer4 ",16,0.5,8.5,22,0.5,22.5);
920
921     fHistoCalibration = new TObjArray(3); 
922     fHistoCalibration->AddAtAndExpand(pattern1,0);
923     fHistoCalibration->AddAtAndExpand(patternl3,1);
924     fHistoCalibration->AddAtAndExpand(patternl4,2);
925
926     printf("Calibration Histograms created!\n");
927 }
928
929 //____________________________________________________________________
930
931 void AliITSQASDDDataMakerRec::ResetDetector(AliQAv1::TASKINDEX_t task)
932 {
933   
934   AliInfo(Form("Reset detector in SDD called for task index %i", task));
935   if(task== AliQAv1::kRAWS ){
936   fDDLModuleMap=NULL;
937   fCalibration=NULL;
938   ((TH1D*)(fHistoCalibration->At(0)))->Reset();
939   ((TH2D*)(fHistoCalibration->At(1)))->Reset();
940   ((TH2D*)(fHistoCalibration->At(2)))->Reset();
941   }
942 }