Fixes for Coverity warnings (M. van Leeuwen)
[u/mrichter/AliRoot.git] / ITS / AliITSQASDDChecker.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 //  P. Cerello Apr 2008
22 //  INFN Torino
23
24 // --- ROOT system ---
25 #include "TH1.h"
26 #include <TH1D.h>
27 #include <TH2.h>
28 #include "TCanvas.h"
29 #include "TPaveText.h"
30 #include "TPad.h"
31 //#include "TPaletteAxis.h"
32 // --- AliRoot header files ---
33 #include "AliITSQADataMakerRec.h"
34 #include "AliITSQASDDChecker.h"
35 #include "AliLog.h"
36 #include "AliCDBEntry.h"
37 #include "AliCDBManager.h"
38 #include "AliITSCalibrationSDD.h"
39 #include "AliITSgeomTGeo.h"
40 #include "AliQAManager.h"
41 #include "AliQAv1.h"
42 #include "AliQAChecker.h"
43 #include "AliQACheckerBase.h"
44
45
46 ClassImp(AliITSQASDDChecker)
47 //__________________________________________________________________
48 AliITSQASDDChecker& AliITSQASDDChecker::operator = (const AliITSQASDDChecker& qac ) 
49 {
50   // Equal operator.
51   this->~AliITSQASDDChecker();
52   new(this) AliITSQASDDChecker(qac);
53   return *this;
54 }
55
56 AliITSQASDDChecker::~AliITSQASDDChecker() 
57 {
58
59   //destructor
60   if(fStepBitSDD) 
61     {
62       delete[] fStepBitSDD ;
63       fStepBitSDD = NULL;
64     }
65   if(fLowSDDValue)
66     {
67       delete[]fLowSDDValue;
68       fLowSDDValue=NULL;
69     }
70   if(fHighSDDValue)
71     { 
72       delete[]fHighSDDValue;
73       fHighSDDValue=NULL;
74     }
75   if(fCalibration)
76     {
77       delete fCalibration;
78       fCalibration=NULL;
79     }
80   if(fImage)
81     {
82       delete []fImage; 
83       fImage=NULL;
84     }
85 } // dtor
86
87 //__________________________________________________________________
88 Double_t AliITSQASDDChecker::Check(AliQAv1::ALITASK_t index, const TObjArray * list, const AliDetectorRecoParam * /*recoparam*/) 
89 {
90   //check histograms of the different lists  
91   AliInfo(Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset) );
92
93   AliDebug(1,Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset));
94
95   Double_t SDDQACheckerValue = 0.;
96   TH1 *hdata=NULL;
97   Double_t entries=0.;
98   Double_t entries2[2];
99   for(Int_t i=0;i<2;i++)entries2[i]=0.;
100
101   if(!fCalibration){
102     AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
103     Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
104     if(!calibSDD)
105       {
106         AliError("Calibration object retrieval failed! SDD will not be processed");
107         fCalibration = NULL;
108         SDDQACheckerValue= fHighSDDValue[AliQAv1::kWARNING];
109       }
110     else{
111       fCalibration = (TObjArray *)calibSDD->GetObject();
112       
113       if(!cacheStatus)calibSDD->SetObject(NULL);
114       calibSDD->SetOwner(kTRUE);
115       if(!cacheStatus)
116         {
117           delete calibSDD;
118         }
119     }//end calibsdd 
120   }//end f calibration
121
122   AliInfo("Calib SDD Created\n ");
123
124   TIter next(list);
125
126   switch(index) {
127     case AliQAv1::kRAW:{
128       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index)));
129 //       if(fRawModulePattern) { delete fRawModulePattern; fRawModulePattern = 0; }
130 //       if(fRawL3Pattern) { delete fRawL3Pattern; fRawL3Pattern = 0; }
131 //       if(fRawL4Pattern) { delete fRawL4Pattern; fRawL4Pattern = 0; }
132       if (list->GetEntries() == 0){SDDQACheckerValue += fHighSDDValue[AliQAv1::kFATAL]; break;}
133       TH1 *hmodule=NULL;
134       TH2 *hlayer[2]; 
135       hdata=NULL;
136       Int_t emptymodules[2], filledmodules[2],emptyladders[2],filledladders[2];
137       for(Int_t i=0;i<2;i++){emptymodules[i]=0; filledmodules[i]=0; emptyladders[i]=0; filledladders[i]=0; }
138       for(Int_t i=0;i<2;i++)hlayer[i]=NULL;   
139       while( (hdata = dynamic_cast<TH1* >(next())) ){
140         if (hdata){TString hname=hdata->GetName();
141           if(hname.Contains("SDDchargeMap"))continue;
142           if(hname.Contains("SDDModPattern")){
143             if(hname.Contains("NORM")) continue;
144             hmodule=(TH1*)hdata->Clone();
145             entries= hdata->GetEntries();
146             if(AliITSQADataMakerRec::AreEqual(entries,0.)){AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));SDDQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];}//endif entries
147             else{int modmax=hdata->GetNbinsX();
148               Int_t empty=0;
149               Int_t filled=0;
150               Double_t content=0;
151               for(Int_t i=1;i<=modmax;i++){content=hdata->GetBinContent(i);if(AliITSQADataMakerRec::AreEqual(content,0.)) empty++; else filled++; }//end for
152               AliInfo(Form(" %s : empty modules %i \t filled modules %i",hname.Data(), empty, filled));}//end else pattern entries !=0
153           }             
154           if(hname.Contains("_RelativeOccupancy")) {
155             //fRawModulePattern = (TH1F *) hdata;
156             Float_t threshold = hdata->GetMean() + 4*hdata->GetRMS();
157             if(hname.Contains("L3")) AliInfo(Form("SDD check number 1: L3 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
158             if(hname.Contains("L4")) AliInfo(Form("SDD check number 2: L4 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
159             Int_t aboveThreshold = 0;
160             for(Int_t k=0; k<= hdata->GetNbinsX(); k++) {if(hdata->GetBinLowEdge(k) > threshold) aboveThreshold += (int)(hdata->GetBinContent(k));}
161             Float_t fractionAboveThreshold=0.;
162             if(hdata->GetEntries()>0.)fractionAboveThreshold=((Float_t) aboveThreshold)/hdata->GetEntries();
163             if(hname.Contains("L3")) AliInfo(Form("SDD check number 1, L3: Raw fractionAboveThreshold: %f",fractionAboveThreshold));
164             if(hname.Contains("L4")) AliInfo(Form("SDD check number 2, L4: Raw fractionAboveThreshold: %f",fractionAboveThreshold));
165             if(fractionAboveThreshold > fThresholdForRelativeOccupancy) {SDDQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
166               if(hname.Contains("L3")) AliInfo(Form("SDD check number 1: Set Warning (L3 Raw)"));
167               if(hname.Contains("L4")) AliInfo(Form("SDD check number 2: Set Warning (L4 Raw)")); } }
168           if(hname.Contains("SDDphizL3") || hname.Contains("SDDphizL4")){if(hname.Contains("NORM"))continue;
169             //if(hname.Contains("L3")) {fRawL3Pattern = (TH2F *) hdata;}
170             //if(hname.Contains("L4")) {fRawL4Pattern = (TH2F *) hdata;}
171             Int_t layer=0;
172             if(hname.Contains("3"))layer=0;
173             else  if(hname.Contains("4"))layer=1;
174             entries2[layer]=hdata->GetEntries();
175             if(entries2[layer]==0){AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));
176               SDDQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];}//end if getentries
177             else{
178               Int_t layer1=0;
179               if(hname.Contains("3"))layer1=0;
180               else  if(hname.Contains("4"))layer1=1;
181               TH2* htemp=dynamic_cast<TH2*>(hdata);
182               if(htemp){
183                 hlayer[layer1]=(TH2*)htemp->Clone();
184                 hlayer[layer1]->SetName(Form("%s_copy",hname.Data()));
185                 hlayer[layer1]->RebinX(2);
186                 int modmay=hlayer[layer1]->GetNbinsY();
187                 TH1D* hproj= hlayer[layer1]->ProjectionY();
188                 Double_t ladcontent=0;
189                 for(Int_t i=1;i<=modmay;i++) {//loop on the ladders
190                   ladcontent=hproj->GetBinContent(i);
191                   if(AliITSQADataMakerRec::AreEqual(ladcontent,0.)) emptyladders[layer1]++;
192                   else filledladders[layer1]++;}//end for
193                 AliInfo(Form(" %s : empty ladders %i \t filled ladders %i\n",hname.Data(), emptyladders[layer], filledladders[layer]));//end else layer 3
194                 delete hproj;
195                 hproj=NULL;
196               }//end if htemp
197             }//end else entries !=0
198           }//end check on phiz        
199         }//end if hdata 
200       }//end while
201       if(AliITSQADataMakerRec::AreEqual(entries,0.)&&AliITSQADataMakerRec::AreEqual(entries2[0],0.)&&AliITSQADataMakerRec::AreEqual(entries2[1],0.)) break;
202       //else{
203       if(hmodule || (hlayer[0] && hlayer[1])){
204         Int_t excluded=0;
205         Int_t active=0;
206         Int_t exactive=0;//excluded but taking data
207         for(Int_t imod=0;imod<fgknSDDmodules;imod++){
208           Int_t lay=0;
209           Int_t lad=0;
210           Int_t det=0;
211           Int_t module=0;
212           module=imod+fgkmodoffset;
213           AliITSCalibrationSDD * cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
214           if(cal==0) { continue;}
215           AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
216           if (cal->IsBad()){
217             excluded++;
218             Double_t content=0.;
219             Double_t contentlayer[2];
220             for(Int_t i=0;i<2;i++)contentlayer[i]=0.;
221             if(hmodule)content=hmodule->GetBinContent(imod+1);//if expert bit is active the histogram has been created 
222             if(hlayer[lay-3]) contentlayer[lay-3]=hlayer[lay-3]->GetBinContent(det,lad);
223             if(AliITSQADataMakerRec::AreEqual(content,0.)== kFALSE || AliITSQADataMakerRec::AreEqual(contentlayer[lay-3],0.)==kFALSE) {
224               filledmodules[lay-3]++;
225               AliWarning(Form("The module %d (layer %i, ladder %i det %i ) excluded from the acquisition, took data \n ",module,lay,lad,det));
226               exactive++;
227             } else if(AliITSQADataMakerRec::AreEqual(content,0.) && AliITSQADataMakerRec::AreEqual(contentlayer[lay-3],0.)) 
228               emptymodules[lay-3]++;
229           } else {
230             Double_t contentgood=0.;
231             active++;
232             if(hlayer[lay-3]) contentgood=hlayer[lay-3]->GetBinContent(det,lad);
233             if(AliITSQADataMakerRec::AreEqual(contentgood,0.)) 
234               emptymodules[lay-3]++;
235             else 
236               filledmodules[lay-3]++;
237           }
238         }//end for
239         for(Int_t i=0;i<2;i++){AliInfo(Form("Layer %i \tempty modules %i \t filled modules %i\n", i+3,emptymodules[i], filledmodules[i]));}//end else layers
240         if(exactive==0){
241           AliInfo(Form("All the active modules (%i) are in acquisition. The number of excluded modules are %i \n",active,excluded));
242           SDDQACheckerValue=fHighSDDValue[AliQAv1::kINFO];
243         }
244         if(exactive!=0){
245           AliWarning(Form("%i modules excluded from the acquisition took data. Active modules%i \n ",exactive,active));
246           SDDQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
247         }
248         if(excluded==exactive){
249           AliWarning(Form("All the modules excluded from the acquisition (%d) took data!  Active modules %i\n",excluded,active));
250           SDDQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
251         }
252         if(active==0){
253           AliWarning(Form("No modules took data: excluded %i \t exactive %i \n", excluded, exactive)); 
254           SDDQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
255         }
256         
257       }//end else 
258       delete hmodule;
259       hmodule=NULL;
260       for(Int_t i=0;i<2;i++) {
261         delete hlayer[i];
262         hlayer[i]=NULL;
263       }
264
265     }
266       
267       break;
268       
269   case AliQAv1::kNULLTASK:{
270     AliInfo(Form("No Check on %s\n",AliQAv1::GetAliTaskName(index))); 
271     SDDQACheckerValue=1.;
272   }
273     break;
274     
275   case AliQAv1::kREC:
276     {
277       Int_t uidrec=list->GetUniqueID();
278       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index))); 
279       if(uidrec==20){
280         //recpoints
281         if (list->GetEntries() == 0){ //check if the list is empty
282           //printf("SDDQACheckerValue = %f \t value %f\n",SDDQACheckerValue,fHighSDDValue[AliQAv1::kFATAL]);
283           SDDQACheckerValue=fHighSDDValue[AliQAv1::kFATAL]; 
284           break;                        
285         }//end if getentries
286       
287         while((hdata=dynamic_cast<TH1* >(next()))){
288           if (hdata){
289             TString hname=hdata->GetName();
290             if(hname.Contains("_RelativeOccupancy")) {
291               Float_t threshold = hdata->GetMean() + 4*hdata->GetRMS();
292               if(hname.Contains("L3")) AliInfo(Form("SDD check number 3: L3 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
293               if(hname.Contains("L4")) AliInfo(Form("SDD check number 4: L4 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
294               Int_t aboveThreshold = 0;
295               for(Int_t k=0; k<= ((Int_t)hdata->GetNbinsX()); k++) {
296                 if(hdata->GetBinLowEdge(k) > threshold) aboveThreshold += (Int_t)(hdata->GetBinContent(k));
297               }
298               Float_t fractionAboveThreshold=0.;
299               if(hdata->GetEntries()>0.) fractionAboveThreshold = ((Float_t) aboveThreshold)/hdata->GetEntries();
300               if(hname.Contains("L3")) AliInfo(Form("SDD check number 3, L3: RecPoints fractionAboveThreshold: %f",fractionAboveThreshold));
301               if(hname.Contains("L4")) AliInfo(Form("SDD check number 4, L4: RecPoints fractionAboveThreshold: %f",fractionAboveThreshold));
302               if(fractionAboveThreshold > fThresholdForRelativeOccupancy) { 
303                 SDDQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
304                 if(hname.Contains("L3")) AliInfo(Form("SDD check number 3: Set Warning (L3 RecPoints)"));
305                 if(hname.Contains("L4")) AliInfo(Form("SDD check number 4: Set Warning (L4 RecPoints)"));
306               }
307             }
308             if(hname.Contains("Rec2Raw") && !hname.Contains("2D")) {
309               //Float_t threshold = 0.;
310               if(hname.Contains("L3")) AliInfo(Form("SDD check number 5: L3 R2R mean: %f, rms: ,%f",((TH1F *) hdata)->GetMean(),((TH1F *) hdata)->GetRMS()));
311               if(hname.Contains("L4")) AliInfo(Form("SDD check number 6: L4 R2R mean: %f, rms: ,%f",((TH1F *) hdata)->GetMean(),((TH1F *) hdata)->GetRMS()));
312               Int_t belowThreshold = 0;
313               for(Int_t k=0; k<=((TH1F *)hdata)->GetNbinsX(); k++) {
314                 if(((TH1F *) hdata)->GetBinLowEdge(k) < fThresholdForRecToRawRatio) belowThreshold += ((Int_t)((TH1F *) hdata)->GetBinContent(k));
315               }
316               Double_t fractionBelowThreshold =0.;
317               Double_t entries3=((TH1F *)hdata)->GetEntries();
318               if(entries3>0.001)fractionBelowThreshold = ((Double_t)(belowThreshold))/entries3;
319               else{ AliWarning(Form("No entries on %s. The check will retuns zero.\n",hdata->GetName() )); }
320               if(hname.Contains("L3")) AliInfo(Form("SDD check number 5, L3: RecPoints2Raws fractionBelowThreshold: %f",fractionBelowThreshold));
321               if(hname.Contains("L4")) AliInfo(Form("SDD check number 6, L4: RecPoints2Raws fractionBelowThreshold: %f",fractionBelowThreshold));
322               if(fractionBelowThreshold > fThresholdForRelativeOccupancy) { 
323                 SDDQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
324                 if(hname.Contains("L3")) AliInfo(Form("SDD check number 5: Set Warning (L3 RecPoints2Raws)"));
325                 if(hname.Contains("L4")) AliInfo(Form("SDD check number 6: Set Warning (L4 RecPoints2Raws)"));
326               }
327             }
328             if(hname.Contains("dedx")) {
329               if(hname.Contains("L3")) AliInfo(Form("SDD check number 7: L3 average charge: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
330               if(hname.Contains("L4")) AliInfo(Form("SDD check number 8: L4 average charge: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
331             }
332           }
333         }                               
334       
335         SDDQACheckerValue=1.;
336       }
337       else if(uidrec==40)
338         {
339           //digitsr
340           if (list->GetEntries() == 0){ 
341             SDDQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
342             break;
343           } else{
344         
345             while( (hdata = dynamic_cast<TH1* >(next())) ){
346               if (hdata){
347                 if(hdata->GetEntries()==0)SDDQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
348                 else {
349                   TString hname=hdata->GetName();
350                   if(hname.Contains("SDD DIGITS Module Pattern")) {
351                     //see raws
352                 
353                     SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
354                   } else if(hname.Contains("SDD Anode Distribution")) {
355                     SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
356                   } else if(hname.Contains("SDD Tbin Distribution")) {
357                     //to do as rp
358                     SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
359                   } else if(hname.Contains("SDD ADC Counts Distribution")) {
360                     SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
361                   }//end adc counts
362               
363                 }//end entries !=0
364               }//end hdata
365             }//end while
366           }//end else
367           SDDQACheckerValue=1.;
368         }
369
370     }
371     break;
372   case AliQAv1::kANA:
373     {
374       AliInfo(Form("===================> No Check on %s\n",AliQAv1::GetAliTaskName(index)));
375       SDDQACheckerValue=1.; 
376     }
377     break;
378   case AliQAv1::kESD:
379     {
380       AliInfo(Form("==================>  No Check on %s\n",AliQAv1::GetAliTaskName(index)));
381       SDDQACheckerValue=1.;
382     } 
383     break;
384   case AliQAv1::kNTASK:{
385     AliInfo(Form("==================>  No Check on %s\n",AliQAv1::GetAliTaskName(index))); 
386     SDDQACheckerValue=1.;
387   }
388     break;
389   case AliQAv1::kSIM:{
390     AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index))); 
391     Int_t uid=list->GetUniqueID();
392     if(uid==60) {
393       //digits
394       if (list->GetEntries() == 0){ 
395         SDDQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
396         break;
397       } else{
398         
399         while( (hdata = dynamic_cast<TH1* >(next())) ){
400           if (hdata){
401             if(hdata->GetEntries()==0)SDDQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
402             else {
403               TString hname=hdata->GetName();
404               if(hname.Contains("SDDDIGITSModulePattern")) {
405                 //see raws
406                 
407                 SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
408               } else if(hname.Contains("SDDAnodeDistribution")) {
409                 SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
410               } else if(hname.Contains("SDDTbinDistribution")) {
411                 //to do as rp
412                 SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
413               } else if(hname.Contains("SDDADCCountsDistribution")) {
414                 SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
415               }//end adc counts
416               
417             }//end entries !=0
418           }//end hdata
419         }//end while
420       }//end else
421     } else if(uid==50) 
422       {
423         //hits
424         if (list->GetEntries() == 0){ 
425           SDDQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
426           break;
427         } 
428         else{
429           
430           while( (hdata = dynamic_cast<TH1* >(next())) ){
431             if (hdata){
432               if(hdata->GetEntries()==0)SDDQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
433               else {
434                 TString hname=hdata->GetName();
435                 if(hname.Contains("SDDHITSModulePattern")) {
436                   //to do as raws
437                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
438                 } else if(hname.Contains("SDDHITlenghtalonglocalYCoord")) {
439                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
440                 } else if(hname.Contains("SDDHITlenghtalonglocalYCoordZoom")) {
441                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
442                 } else if(hname.Contains("SDDDepositedEnergyDistribution")) {
443                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
444                 }//end deposited energy
445                 
446               }//end entries !=0
447             }//end hdata
448           }//end while
449         }//end else
450       } else if(uid==70) 
451       {
452         //sdigits
453         if (list->GetEntries() == 0){ 
454           SDDQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
455           break;
456         } else{
457           
458           while( (hdata = dynamic_cast<TH1* >(next())) ){
459             if (hdata){
460               if(hdata->GetEntries()==0)SDDQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
461               else {
462                 TString hname=hdata->GetName();
463                 if(hname.Contains("SDDSDIGITSModulePattern")) {
464                   //to do as raws
465                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
466                 } else if(hname.Contains("SDDAnodeDistribution")) {
467                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
468                 } else if(hname.Contains("SDDTbinDistribution")) {
469                   //to do as rp
470                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
471                 } else if(hname.Contains("SDDADCCountsDistribution")) {
472                   SDDQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
473                 }//end adc counts bindistribution
474               }//end entries !=0
475             }//end hdata
476           }//end while
477         }//end else
478       }//end sdigits
479     SDDQACheckerValue=1.;
480   }
481     break;
482     
483   }//end switch
484   
485   fCalibration=NULL;
486   if(hdata) delete hdata;
487
488
489   return SDDQACheckerValue;     
490 }
491
492 //__________________________________________________________________
493 void AliITSQASDDChecker::SetTaskOffset(Int_t taskoffset)
494 {
495   //set the number of the histograms already present in the list before the SDD histograms
496   fSubDetOffset = taskoffset;
497 }
498
499
500 //__________________________________________________________________
501 void AliITSQASDDChecker::SetStepBit(const Double_t *steprange)
502 {
503   //set the values of the step bit for each QA bit range calculated in the AliITSQAChecker class
504   fStepBitSDD = new Double_t[AliQAv1::kNBIT];
505   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
506     {
507       fStepBitSDD[bit]=steprange[bit];
508     }
509 }
510
511 //__________________________________________________________________
512 void  AliITSQASDDChecker::SetSDDLimits(const Float_t *lowvalue, const Float_t * highvalue)
513 {
514   //set the low and high values in for each QA bit range calculated in the AliITSQAChecker class
515   fLowSDDValue = new Float_t[AliQAv1::kNBIT];
516   fHighSDDValue= new Float_t[AliQAv1::kNBIT];
517
518   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
519     {
520       fLowSDDValue[bit]=lowvalue[bit];
521       fHighSDDValue[bit]= highvalue[bit];
522     }
523
524 }
525 //__________________________________________________________________
526 Bool_t  AliITSQASDDChecker::MakeSDDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode)
527 {
528   Bool_t rval=kFALSE;
529   fImage=(TCanvas**)AliQAChecker::Instance()->GetDetQAChecker(0)->GetImage();
530   //create the image for raws and recpoints. In the other case, the default methodof CheckerBase class will be used
531   switch(task)
532     {
533     case AliQAv1::kRAWS:{
534       rval=MakeSDDRawsImage(list, task,mode);
535     }
536       break;
537     case AliQAv1::kRECPOINTS:{ rval=MakeSDDRecPointsImage(list, task,mode); }
538       break;
539     case AliQAv1::kHITS:; case AliQAv1::kESDS:; case AliQAv1::kDIGITS:;case AliQAv1::kDIGITSR:;case AliQAv1::kSDIGITS:;case AliQAv1::kTRACKSEGMENTS:;case AliQAv1::kRECPARTICLES:; default:
540     {
541        rval=kFALSE;
542        //AliQAChecker::Instance()->GetDetQAChecker(0)->MakeImage(list,task,mode);
543     }
544     break;
545     case AliQAv1::kNULLTASKINDEX:; case  AliQAv1::kNTASKINDEX: 
546       {AliWarning(Form("No histograms for this task ( %s ) \n", AliQAv1::GetTaskName(task).Data())); rval=kFALSE;}
547       break;
548     }
549 return rval;  
550 }
551
552
553 //_______________________________________________________________________
554 Bool_t AliITSQASDDChecker::MakeSDDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
555 {
556
557     for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
558       //printf("-------------------------> %i \n", esIndex);
559       if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0) 
560           {//printf ("Nothing for %s \n", AliRecoParam::GetEventSpecieName(esIndex));
561          continue;
562         }
563       else{
564         const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ; 
565         if ( !fImage[esIndex] ) {
566           fImage[esIndex] = new TCanvas(title, title,1280,980) ;
567         }
568         
569         fImage[esIndex]->Clear() ; 
570         fImage[esIndex]->SetTitle(title) ; 
571         fImage[esIndex]->cd();
572  
573         TPaveText someText(0.015, 0.015, 0.98, 0.98);
574         someText.AddText(title);
575         someText.Draw(); 
576         fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
577         fImage[esIndex]->Clear() ; 
578         Int_t nx =2; //TMath::Nint(TMath::Sqrt(nImages));
579         Int_t ny =1; // nx  ; 
580         //if (nx < TMath::Sqrt(nImages))
581         //ny++ ;  
582         fImage[esIndex]->Divide(nx, ny) ; 
583         TIter nexthist(list[esIndex]) ; 
584         TH1* hist = NULL ;
585         Int_t npad = 1 ; 
586         fImage[esIndex]->cd(npad); 
587         fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
588         while ( (hist=static_cast<TH1*>(nexthist())) ) {
589           //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
590           TString cln(hist->ClassName()) ; 
591           if ( ! cln.Contains("TH") )
592             continue ;
593           
594           if(hist->TestBit(AliQAv1::GetImageBit())) {
595             hist->GetXaxis()->SetTitleSize(0.02);
596             hist->GetYaxis()->SetTitleSize(0.02);
597             hist->GetXaxis()->SetLabelSize(0.02);
598             hist->GetYaxis()->SetLabelSize(0.02);
599             if(cln.Contains("TH2"))
600               {
601                 gPad->SetRightMargin(0.15);
602                 gPad->SetLeftMargin(0.05);
603                 hist->SetStats(0);
604                 hist->SetOption("colz") ;
605                 //hist->GetListOfFunctions()->FindObject("palette")->SetLabelSize(0.025);
606                 //gPad->Update();
607               }
608             hist->DrawCopy() ; 
609             fImage[esIndex]->cd(++npad) ; 
610             fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
611           }
612         }
613         fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
614       }
615     }
616    return kTRUE;
617 }
618
619
620
621
622 //_______________________________________________________________________
623 Bool_t AliITSQASDDChecker::MakeSDDRecPointsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
624 {
625
626     for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
627       if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0) 
628         {
629         //printf ("Nothing for %s \n", AliQAv1::GetTaskName(task).Data()); 
630         continue;
631         }
632       const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ; 
633       if ( !fImage[esIndex] ) {
634         fImage[esIndex] = new TCanvas(title, title,1280,980) ;
635       }
636       fImage[esIndex]->Clear() ; 
637       fImage[esIndex]->SetTitle(title) ; 
638       fImage[esIndex]->cd();
639       fImage[esIndex]->SetBorderMode(0) ;  
640       TPaveText someText(0.015, 0.015, 0.98, 0.98);
641       someText.AddText(title);
642       someText.Draw(); 
643       fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
644       fImage[esIndex]->Clear() ; 
645       Int_t nx =2; //TMath::Nint(TMath::Sqrt(nImages));
646       Int_t ny =4; // nx  ; 
647       //if (nx < TMath::Sqrt(nImages))
648       //ny++ ;  
649       fImage[esIndex]->Divide(nx, ny) ; 
650       TIter nexthist(list[esIndex]) ; 
651       TH1* hist = NULL ;
652       Int_t npad = 1 ; 
653       fImage[esIndex]->cd(npad) ; 
654       fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
655       while ( (hist=static_cast<TH1*>(nexthist())) ) {
656         //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
657         TString cln(hist->ClassName()) ;
658         //printf("=====================> Class name %s \n",cln.Data()); 
659         if ( ! cln.Contains("TH") )
660           continue ;
661         if(hist->TestBit(AliQAv1::GetImageBit())) {
662             hist->GetXaxis()->SetTitleSize(0.02);
663             hist->GetYaxis()->SetTitleSize(0.02);
664             hist->GetXaxis()->SetLabelSize(0.02);
665             hist->GetYaxis()->SetLabelSize(0.02);
666           if(cln.Contains("TH1"))
667             {
668               hist->SetFillColor(kOrange+7);
669               //SetFrameFillColor(kAzure-9);
670               //hist->DrawCopy() ; 
671             }
672           if(cln.Contains("TH2"))
673             {
674               gPad->SetRightMargin(0.15);
675               gPad->SetLeftMargin(0.05);
676               hist->SetStats(0);
677               hist->SetOption("colz") ;
678               //              TPaletteAxis *paletta =(TPaletteAxis*)hist->GetListOfFunctions()->FindObject("palette");
679               //paletta->SetLabelSize(0.025);
680               //gPad->Update(); 
681             }
682           hist->DrawCopy();
683           fImage[esIndex]->cd(++npad) ; 
684           fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
685         }
686       }
687       fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
688     }
689     // }  
690    return kTRUE;
691 }