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