]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASDDChecker.cxx
0f1bdc1b944ccb68a2e36734bf5fecc46f089f74
[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
49
50 //_____________________________________________________________________
51
52 AliITSQASDDChecker::AliITSQASDDChecker():
53 fSubDetOffset(0),
54   fStepBitSDD(NULL),
55   fLowSDDValue(NULL),
56   fHighSDDValue(NULL),
57   fCalibration(NULL),
58   fThresholdForRelativeOccupancy(0.01),
59   fThresholdForRecToRawRatio(0.04),
60 fImage(NULL),
61   fESforCheck(0)
62 {
63 // Default constructor
64         fStepBitSDD=new Double_t[AliQAv1::kNBIT];
65         fLowSDDValue=new Float_t[AliQAv1::kNBIT];
66         fHighSDDValue=new Float_t[AliQAv1::kNBIT];
67
68         for(Int_t ibit=0;ibit<AliQAv1::kNBIT;ibit++)
69           {
70             fStepBitSDD[ibit]=0.;
71             fLowSDDValue[ibit]=0.;
72             fHighSDDValue[ibit]=0.;
73           }
74         for(Int_t i=0;i<AliRecoParam::kNSpecies;i++) fPaveText[i] = NULL;
75 }          // ctor
76
77
78
79 AliITSQASDDChecker::~AliITSQASDDChecker() 
80 {
81
82   //destructor
83   if(fStepBitSDD) 
84     {
85       delete[] fStepBitSDD ;
86       fStepBitSDD = NULL;
87     }
88   if(fLowSDDValue)
89     {
90       delete[]fLowSDDValue;
91       fLowSDDValue=NULL;
92     }
93   if(fHighSDDValue)
94     { 
95       delete[]fHighSDDValue;
96       fHighSDDValue=NULL;
97     }
98   if(fCalibration)
99     {
100       delete fCalibration;
101       fCalibration=NULL;
102     }
103         if(fImage)
104     {
105                 delete []fImage; 
106                 fImage=NULL;
107     }
108         for(Int_t i=0;i<AliRecoParam::kNSpecies;i++) {
109                 if(fPaveText[i])
110                 {
111                         delete fPaveText[i]; 
112                         fPaveText[i]=NULL;
113                 }
114         }
115 } // dtor
116
117 //__________________________________________________________________
118 Double_t AliITSQASDDChecker::Check(AliQAv1::ALITASK_t index, const TObjArray * list, const AliDetectorRecoParam * /*recoparam*/) 
119 {
120   //check histograms of the different lists  
121   AliInfo(Form("AliITSQASDDChecker called with offset: %d \t and specie %d\n", fSubDetOffset,fESforCheck));
122
123   AliDebug(1,Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset));
124
125   Double_t sddQACheckerValue = 0.;
126   TH1 *hdata=NULL;
127   Double_t entries=0.;
128   Double_t entries2[2];
129   for(Int_t i=0;i<2;i++)entries2[i]=0.;
130
131   if(!fCalibration){
132     AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
133     Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
134     if(!calibSDD)
135       {
136         AliError("Calibration object retrieval failed! SDD will not be processed");
137         fCalibration = NULL;
138         sddQACheckerValue= fHighSDDValue[AliQAv1::kWARNING];
139       }
140     else{
141       fCalibration = (TObjArray *)calibSDD->GetObject();
142       
143       if(!cacheStatus)calibSDD->SetObject(NULL);
144       calibSDD->SetOwner(kTRUE);
145       if(!cacheStatus)
146         {
147           delete calibSDD;
148         }
149     }//end calibsdd 
150   }//end f calibration
151
152   AliInfo("Calib SDD Created\n ");
153
154   TIter next(list);
155   TString results1;
156   TString results2;
157         Int_t color=kBlack;
158         Int_t textcolor=kBlack;
159
160   switch(index) {
161     case AliQAv1::kRAW:{
162       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index)));
163 //       if(fRawModulePattern) { delete fRawModulePattern; fRawModulePattern = 0; }
164 //       if(fRawL3Pattern) { delete fRawL3Pattern; fRawL3Pattern = 0; }
165 //       if(fRawL4Pattern) { delete fRawL4Pattern; fRawL4Pattern = 0; }
166       if (list->GetEntries() == 0){AliError("Raw List for SDD is empty \n");sddQACheckerValue += fHighSDDValue[AliQAv1::kFATAL];        break;}
167       TH1 *hmodule=NULL;
168       TH2 *hlayer[2]; 
169       hdata=NULL;
170       for(Int_t i=0;i<2;i++)hlayer[i]=NULL;
171
172       //check counters
173       Int_t emptymodules[2], filledmodules[2],emptyladders[2],filledladders[2],emptydriftregion[2], filleddriftregion[2], excludedmoduleperlayer[2], excludeddrperlayer[2], activemoduleperlayer[2],activedrperlayer[2],exactivemoduleperlayer[2],exactivedrperlayer[2];
174       Int_t excluded=0;            //excluded modules  
175       Int_t excludeddriftregion=0; //excluded single drift region
176       Int_t active=0;              //active modules  
177       Int_t activedriftregion=0;   //active single drift region
178       Int_t exactive=0;            //excluded modules but taking data
179       Int_t exactivedriftregion=0; //excluded single drift region but taking data   
180       Int_t empty=0;
181       Int_t filled=0;
182       Int_t emptydr=0;
183       Int_t filleddr=0;
184       //Int_t emptyactivemodule=0;
185       Int_t emptyactivemoduleperlayer[2];
186       //Int_t emptydractivemodule=0;
187       Int_t emptyactivedrperlayer[2];
188       Int_t emptysum=0;
189       Int_t emptydiff=0;
190       Int_t emptydrsum=0;
191       Int_t emptydrdiff=0;
192
193     for(Int_t i=0;i<2;i++)
194       {
195         emptymodules[i]=0; 
196         filledmodules[i]=0; 
197         emptyladders[i]=0; 
198         filledladders[i]=0; 
199         emptydriftregion[i]=0;
200         filleddriftregion[i]=0; 
201         excludedmoduleperlayer[i]=0;
202         excludeddrperlayer[i]=0;
203         activemoduleperlayer[i]=0;
204         activedrperlayer[i]=0;
205         exactivemoduleperlayer[i]=0;
206         exactivedrperlayer[i]=0;
207         emptyactivemoduleperlayer[i]=0;
208         emptyactivedrperlayer[i]=0;
209       }  
210
211     Int_t neventsraw=0;
212
213     //take the number of events
214
215       while( (hdata = dynamic_cast<TH1* >(next())) ){
216         if (hdata){
217           TString hname=hdata->GetName();
218
219           if(hname.Contains("SDDRawDataCheck"))
220             { 
221               neventsraw=(Int_t)hdata->GetBinContent(1); 
222               //break;
223             }
224           else continue;
225         }//end if hdata
226       }//end while
227
228       next.Begin();
229       while( (hdata = dynamic_cast<TH1* >(next())) ){
230         if (hdata){
231                 TString hname=hdata->GetName();
232           if(hname.Contains("SDDchargeMap"))continue;
233           if(hname.Contains("SDDDDLPattern"))continue;
234           if(hname.Contains("SDDEventSize"))continue;
235           if(hname.Contains("_RelativeOccupancy"))continue;
236           if(hname.Contains("SDDModPattern")){
237             if(hname.Contains("NORM")) continue;
238             hmodule=(TH1*)hdata->Clone();
239             entries= hdata->GetEntries();
240             if(AliITSQADataMakerRec::AreEqual(entries,0.)){AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];}//endif entries
241             else{
242               int modmax=hdata->GetNbinsX();
243               Double_t content=0;
244               Int_t llay=0;
245               for(Int_t i=1;i<=modmax;i++)
246                 {
247                   if(i<85)llay=0;
248                   else llay=1;
249                   content=hdata->GetBinContent(i);
250                   if(AliITSQADataMakerRec::AreEqual(content,0.))
251                     {
252                     empty++;
253                     emptymodules[llay]++;
254                     } 
255                   else 
256                     {
257                       filled++;
258                       filledmodules[llay]++;
259                     }
260                 }//end for
261               //output of the check at the level of the modules. Drift region in the following checks
262
263               AliInfo(Form(" %s : empty modules %i \t filled modules %i",hname.Data(), empty, filled));
264               AliInfo(Form(" %s : Layer 3 empty modules %i \t filled modules %i",hname.Data(), emptymodules[0], filledmodules[0]));
265               AliInfo(Form(" %s : Layer 4 empty modules %i \t filled modules %i",hname.Data(), emptymodules[1], filledmodules[1]));
266             }//end else pattern entries !=0
267           } //modpattern (1d histogram)                 
268           if(hname.Contains("_RelativeOccupancy")) {
269             //fRawModulePattern = (TH1F *) hdata;
270             Float_t threshold = hdata->GetMean() + 4*hdata->GetRMS();
271             if(hname.Contains("L3")) AliInfo(Form("SDD check number 1: L3 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
272             if(hname.Contains("L4")) AliInfo(Form("SDD check number 2: L4 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
273             Int_t aboveThreshold = 0;
274             for(Int_t k=0; k<= hdata->GetNbinsX(); k++) {if(hdata->GetBinLowEdge(k) > threshold) aboveThreshold += (int)(hdata->GetBinContent(k));}
275             Float_t fractionAboveThreshold=0.;
276             if(hdata->GetEntries()>0.)fractionAboveThreshold=((Float_t) aboveThreshold)/hdata->GetEntries();
277             if(hname.Contains("L3")) AliInfo(Form("SDD check number 1, L3: Raw fractionAboveThreshold: %f",fractionAboveThreshold));
278             if(hname.Contains("L4")) AliInfo(Form("SDD check number 2, L4: Raw fractionAboveThreshold: %f",fractionAboveThreshold));
279             if(fractionAboveThreshold > fThresholdForRelativeOccupancy) {sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
280               if(hname.Contains("L3")) AliInfo(Form("SDD check number 1: Set Warning (L3 Raw)"));
281               if(hname.Contains("L4")) AliInfo(Form("SDD check number 2: Set Warning (L4 Raw)")); } }//relativeoccupancy
282
283           if(hname.Contains("SDDphizL3") || hname.Contains("SDDphizL4")){if(hname.Contains("NORM"))continue;
284             Int_t layer=0;
285             if(hname.Contains("3"))layer=0;
286             else  if(hname.Contains("4"))layer=1;
287             entries2[layer]=hdata->GetEntries();
288             if(entries2[layer]==0){AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));
289               sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];}//end if getentries
290             else{
291               Int_t layer1=0;
292               if(hname.Contains("3"))layer1=0;
293               else  if(hname.Contains("4"))layer1=1;
294                         TH2* htemp=dynamic_cast<TH2*>(hdata);
295                         if(htemp){
296                           hlayer[layer1]=(TH2*)htemp->Clone();
297                                 hlayer[layer1]->SetName(Form("%s_copy",hname.Data()));
298                                 int modmay=hlayer[layer1]->GetNbinsY();
299                                 TH1D* hproj= hlayer[layer1]->ProjectionY();
300                                 Double_t ladcontent=0;
301                                 for(Int_t i=1;i<=modmay;i++) {//loop on the ladders
302                                         ladcontent=hproj->GetBinContent(i);
303                                         if(AliITSQADataMakerRec::AreEqual(ladcontent,0.)) emptyladders[layer1]++;
304                                         else filledladders[layer1]++;}//end for
305                                         AliInfo(Form(" %s : empty ladders %i \t filled ladders %i\n",hname.Data(), emptyladders[layer1], filledladders[layer1]));//end else layer 3
306                                         delete hproj;
307                                         hproj=NULL;
308                         }//end if htemp
309             }//end else entries !=0
310           }//end check on phiz        
311                 
312         }//end if hdata 
313       
314           }//end while
315       for(Int_t ii=0;ii<2;ii++)
316         {
317           filledmodules[ii]=0;
318           emptymodules[ii]=0;
319         }
320       filled=0;
321       empty=0;
322       if(AliITSQADataMakerRec::AreEqual(entries,0.)&& AliITSQADataMakerRec::AreEqual(entries2[0],0.)&& AliITSQADataMakerRec::AreEqual(entries2[1],0.)) break;
323       //else{
324       if(hmodule || (hlayer[0] && hlayer[1])){
325         for(Int_t imod=0;imod<fgknSDDmodules;imod++){
326           Int_t lay=0;
327           Int_t lad=0;
328           Int_t det=0;
329           Int_t module=0;
330           module=imod+fgkmodoffset;
331           AliITSCalibrationSDD * cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
332           if(cal==0) { continue;}
333           AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
334           if (cal->IsBad()){
335             excluded++;
336             excludedmoduleperlayer[lay-3]++;
337             Double_t content=0.;
338             //Double_t contentlayer[2];
339             //for(Int_t i=0;i<2;i++)contentlayer[i]=0.;
340             if(hmodule)content=hmodule->GetBinContent(imod+1);//if expert bit is active the histogram will be stored in the QA file otherwise the histogram will not be written on the logbook
341             //      if(hlayer[lay-3]) contentlayer[lay-3]=hlayer[lay-3]->GetBinContent(det,lad);
342             if(AliITSQADataMakerRec::AreEqual(content,0.)== kFALSE) {
343               filledmodules[lay-3]++;
344               filled++;
345               AliError(Form("The module %d (layer %i, ladder %i det %i ) excluded from the acquisition, took data \n ",module,lay,lad,det));
346               exactive++;
347               exactivemoduleperlayer[lay-3]++;
348             } else if(AliITSQADataMakerRec::AreEqual(content,0.)) 
349               {
350                 emptymodules[lay-3]++; //it has to be empty
351                 empty++;
352               }
353           } else {
354             Int_t totside=0;
355             Int_t totactiveside=0;
356             //Int_t totbadside=0;
357             Double_t contentgood=0.;
358
359             for(Int_t i=0;i<2;i++){
360               if(hlayer[lay-3]) contentgood=hlayer[lay-3]->GetBinContent(2*det+i-1,lad);
361               if(cal->IsWingBad(i))
362                 { 
363                   excludeddriftregion++; 
364                   excludeddrperlayer[lay-3]++; 
365                   if(AliITSQADataMakerRec::AreEqual(contentgood,0.)==kFALSE){
366                     AliError(Form("The side %d of the module %d (layer %i, ladder %i det %i ) excluded from the acquisition, took data \n ",i,module,lay,lad,det));
367                     exactivedriftregion++; 
368                     exactivedrperlayer[lay-3]++;
369                     filleddr++;
370                     filleddriftregion[lay-3]++;
371                   }
372                 }//end wingbad
373               else{
374                 if(AliITSQADataMakerRec::AreEqual(contentgood,0.)==kTRUE)
375                   {
376                     AliWarning(Form("The side %d of the module %d (layer %i, ladder %i det %i ) is in acquisition, but it didn't take data\n ",i,module, lay, lad, det));
377                   }
378                 else 
379                   {
380                     totside++;
381                   }
382                 totactiveside++;
383               }
384             }//end for
385             if(totside==0){
386             AliWarning(Form("The  module %d (layer %i, ladder %i det %i ) is in acquisition, but it didn't take data\n ",module, lay, lad, det));
387               emptymodules[lay-3]++;
388               empty++;
389
390             }
391               else 
392                 if(totside==2){
393                 filledmodules[lay-3]++;
394                 filled++;
395                 }
396                 else
397                   if(totside==1)
398                     {
399                       //                      emptydr++;
400                       //emptydriftregion[lay-3]++; //it has to be empty
401                       emptydriftregion[lay-3]++; 
402                       emptydr++;
403                       filleddr++;
404                       filleddriftregion[lay-3]++;
405                     }
406             if(totactiveside==1)
407               {
408                 activedriftregion++;
409                 activedrperlayer[lay-3]++;
410               }else if(totactiveside==2)
411               {
412                 active++;
413                 activemoduleperlayer[lay-3]++;
414               }
415
416           }
417         }//end for
418         AliInfo(Form("In total %d modules and %d single drift regions took data.\n ",filled, filleddr));
419         AliInfo(Form("In total %d modules and %d single drift regions were empty\n",empty, emptydr));
420         for(Int_t i=0;i<2;i++)
421           {
422             AliInfo(Form("Layer %i   \tempty modules %i             \t filled modules %i\n", i+3,emptymodules[i], filledmodules[i]));
423             AliInfo(Form("Layer %i   \tempty single drift regions %i \t filled single drift regions %i\n",i+3,emptydriftregion[i], filleddriftregion[i]));
424           }//end else layers
425         emptysum=emptymodules[0]+emptymodules[1];
426         emptydiff=emptysum-excluded;
427         emptyactivemoduleperlayer[0]=emptymodules[0]- excludedmoduleperlayer[0];
428         emptyactivemoduleperlayer[1]=emptymodules[1]- excludedmoduleperlayer[1];
429
430         emptydrsum=emptydriftregion[0]+emptydriftregion[1];
431         emptydrdiff=emptydrsum-excludeddriftregion;
432         emptyactivedrperlayer[0]=emptydriftregion[0]- excludeddrperlayer[0];
433         emptyactivedrperlayer[1]=emptydriftregion[1]- excludeddrperlayer[1];
434
435         Int_t numlimit=1000;
436
437         if(emptysum>excluded||emptydrsum>excludeddriftregion){
438           AliWarning(Form(" %i good module(s) and %i good single drift regions didn't take data! \n",emptydiff,emptydrdiff));
439           AliWarning(Form(" Layer 3: %i good module(s) and %i good single drift regions didn't take data! \n",emptyactivemoduleperlayer[0] ,emptyactivedrperlayer[0] ));
440           AliWarning(Form(" Layer 4: %i good module(s) and %i good single drift regions didn't take data! \n",emptyactivemoduleperlayer[1] ,emptyactivedrperlayer[1] ));
441           //printf("========================= %d",AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::kCosmic));
442           //      if((AliQAv1::Instance(AliQAv1::GetDetIndex("ITS")))->IsEventSpecieSet(AliRecoParam::kCosmic)==kFALSE){     
443           if(AliRecoParam::ConvertIndex(GetEventSpecieForCheck())!=AliRecoParam::kCosmic){     
444             
445             results1.Form("%i good module(s) and %i good drift regions didn't take data!",emptydiff,emptydrdiff);
446             if(neventsraw<numlimit) {
447                         results2.Form(" Events %d .Too few events.DO NOT CALL the Expert ",neventsraw);
448                         color=kYellow;
449                         textcolor=kBlack;
450                         sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
451                 } else {
452                         results2.Form(" Events %d. If PHYSICS, follow the TWiki instruction and call the Expert ",neventsraw);
453                         color=kRed;
454                         textcolor=kWhite;
455                         sddQACheckerValue=fHighSDDValue[AliQAv1::kERROR];
456                 }
457           }
458           else
459             //      if((AliQAv1::Instance(AliQAv1::GetDetIndex("ITS")))->IsEventSpecieSet(AliRecoParam::kCosmic)==kTRUE)
460             if(AliRecoParam::ConvertIndex(GetEventSpecieForCheck())==AliRecoParam::kCosmic)
461               {     
462                 numlimit=10000;
463                 if(neventsraw<numlimit)
464                   {
465                     AliWarning(Form("This is a cosmic run. Some module and drift region are empty but all is OK. "));
466                     results1.Form("OK. This is a cosmic run. you need a lot of events. Events %i",neventsraw);
467                     results2.Form("%i good module(s) and %i good drift are empty! DO NOT CALL THE EXPERT",emptydiff,emptydrdiff);
468                           color=kYellow;
469                           textcolor=kBlack;
470                     sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
471                   }
472                 else
473                   {
474                     results1.Form("%i good module(s) and %i good drift region(s) have no data!",emptydiff,emptydrdiff);
475                     results2.Form(" Cosmic Events %d .Follow the TWiki instruction and call the Expert ",neventsraw);
476                           color=kRed;
477                           textcolor=kWhite;
478                     sddQACheckerValue=fHighSDDValue[AliQAv1::kERROR];
479                   }
480               }
481         }
482         
483         if(exactive==0 && emptydiff==0 && exactivedriftregion==0 && emptydrdiff==0){
484           AliInfo(Form("All the active modules (%i) and single drift regions (%i) are in acquisition. The number of excluded modules are %i and the excluded single drift regions are %i\n",active,activedriftregion,excluded,excludeddriftregion));
485           results1.Form("OK.");
486           results2.Form(" All active modules and drift regions in acquisition");
487           color=kGreen;
488                 textcolor=kBlack;
489           sddQACheckerValue=fHighSDDValue[AliQAv1::kINFO];
490         }
491         if(exactive!=0||exactivedriftregion!=0){
492           AliError(Form("%i modules and %i single  drift regions excluded from the acquisition took data. Active modules%i single drift region %i \n ",exactive,exactivedriftregion,active,activedriftregion));
493           AliError(Form("Layer 3: %i modules and %i single  drift regions excluded from the acquisition took data. Active modules%i single drift region %i \n ",exactivemoduleperlayer[0],exactivedrperlayer[0],activemoduleperlayer[0],activedrperlayer[0]));
494           AliError(Form("Layer 3: %i modules and %i single  drift regions excluded from the acquisition took data. Active modules%i single drift region %i \n ",exactivemoduleperlayer[1],exactivedrperlayer[1],activemoduleperlayer[1],activedrperlayer[1]));
495           results1.Form("%i modules and %i drift region excluded from the acquisition took data",exactive,exactivedriftregion);
496           results2.Form("Follow the TWiki instructions and Call the SDD expert ");
497                 color=kRed;
498                 textcolor=kWhite;
499           sddQACheckerValue=fHighSDDValue[AliQAv1::kERROR];
500         }
501         if(excluded==exactive||excludeddriftregion==exactivedriftregion){
502           AliError(Form("All the modules (%d) or single drift regions (%d) excluded from the acquisition  took data!\n  Active modules %i \t Active drfift regions %i\n",excluded,excludeddriftregion,active,activedriftregion));
503           results1.Form("All the modules (%d) or drift regions (%d) excluded from the acquisition took data!",excluded,excludeddriftregion );
504           results2.Form("Follow the TWiki instructions and Call the SDD expert ");
505                 color=kRed;
506                 textcolor=kWhite;
507           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
508         }
509         if(active==0||activedriftregion==0){
510           AliError(Form("No modules or single drift regions took data: excluded %i \t excluded active %i \n\t\t excluded single drift regions %i \t excluded active drift regions %i \n", excluded, exactive, excludeddriftregion, exactivedriftregion)); 
511           results1.Form("No modules or drift region took data: excluded modules %i  excluded drift regions %i ", excluded, excludeddriftregion );
512           results2.Form("Follow the TWiki instructions and Call the SDD expert ");
513                 color=kRed;
514                 textcolor=kWhite;
515           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
516         }
517
518         //TPaveText *pave[2]={0,0};
519         next.Begin();
520
521         while( (hdata=dynamic_cast<TH1* >(next())) ) {
522             if (hdata){
523                         TString hname=hdata->GetName();
524                         if(hname.Contains("SDDphizL3") || hname.Contains("SDDphizL4")){
525                           if(hname.Contains("NORM"))continue;
526                           //AliInfo("========================================Found histo 11\n");
527                                 TPaveText *ptext = ((TPaveText *)hdata->GetListOfFunctions()->FindObject("TPave"));
528                                 if(ptext) {
529                                         ptext->Clear();
530                                         ptext->AddText(results1.Data());
531                                         ptext->AddText(results2.Data());
532                                         ptext->SetFillColor(color);
533                                         ptext->SetTextColor(textcolor);
534                                 }
535               } else if(hname.Contains("SDDRawDataCheck")) {
536                     
537                           //AliInfo("========================================Found histo\n");
538                           ((TH1F*)hdata)->SetBinContent(5,active);
539                           ((TH1F*)hdata)->SetBinContent(6,filled);
540                           ((TH1F*)hdata)->SetBinContent(7,activedriftregion);
541                           ((TH1F*)hdata)->SetBinContent(8,filleddr);
542                           ((TH1F*)hdata)->SetBinContent(9,excluded);
543                           ((TH1F*)hdata)->SetBinContent(10,empty);
544                           ((TH1F*)hdata)->SetBinContent(11,excludeddriftregion);
545                           ((TH1F*)hdata)->SetBinContent(12,emptydr);
546                           ((TH1F*)hdata)->SetBinContent(13,exactive);
547                           ((TH1F*)hdata)->SetBinContent(14,emptydiff);
548                           ((TH1F*)hdata)->SetBinContent(15,exactivedriftregion);
549                           ((TH1F*)hdata)->SetBinContent(16,emptydrdiff);
550                     
551                           //layer 3
552                           ((TH1F*)hdata)->SetBinContent(19,activemoduleperlayer[0]);
553                           ((TH1F*)hdata)->SetBinContent(20,filledmodules[0]);
554                           ((TH1F*)hdata)->SetBinContent(21,activedrperlayer[0]);
555                           ((TH1F*)hdata)->SetBinContent(22,filleddriftregion[0]);
556                           ((TH1F*)hdata)->SetBinContent(23,excludedmoduleperlayer[0]);
557                           ((TH1F*)hdata)->SetBinContent(24,emptymodules[0]);
558                           ((TH1F*)hdata)->SetBinContent(25,excludeddrperlayer[0]);
559                           ((TH1F*)hdata)->SetBinContent(26,emptydriftregion[0]);
560                           ((TH1F*)hdata)->SetBinContent(27,exactivemoduleperlayer[0]);
561                           ((TH1F*)hdata)->SetBinContent(28,emptyactivemoduleperlayer[0]);
562                           ((TH1F*)hdata)->SetBinContent(29,exactivedrperlayer[0]);
563                           ((TH1F*)hdata)->SetBinContent(30,emptyactivedrperlayer[0]);
564                     
565                           //layer 4
566                           ((TH1F*)hdata)->SetBinContent(33,activemoduleperlayer[1]);
567                           ((TH1F*)hdata)->SetBinContent(34,filledmodules[1]);
568                           ((TH1F*)hdata)->SetBinContent(35,activedrperlayer[1]);
569                           ((TH1F*)hdata)->SetBinContent(36,filleddriftregion[1]);
570                           ((TH1F*)hdata)->SetBinContent(37,excludedmoduleperlayer[1]);
571                           ((TH1F*)hdata)->SetBinContent(38,emptymodules[1]);
572                           ((TH1F*)hdata)->SetBinContent(39,excludeddrperlayer[1]);
573                           ((TH1F*)hdata)->SetBinContent(40,emptydriftregion[1]);
574                           ((TH1F*)hdata)->SetBinContent(41,exactivemoduleperlayer[1]);
575                           ((TH1F*)hdata)->SetBinContent(42,emptyactivemoduleperlayer[1]);
576                           ((TH1F*)hdata)->SetBinContent(43,exactivedrperlayer[1]);
577                           ((TH1F*)hdata)->SetBinContent(44,emptyactivedrperlayer[1]);
578                           //break; 
579                         }
580                 }//if hdata
581             
582         }//end while 
583         
584       }//end else 
585       delete hmodule;
586       hmodule=NULL;
587       for(Int_t i=0;i<2;i++) {
588         delete hlayer[i];
589         hlayer[i]=NULL;
590       }//end for
591
592     }//end raw
593       
594       break;
595       
596   case AliQAv1::kNULLTASK:{
597     AliInfo(Form("No Check on %s\n",AliQAv1::GetAliTaskName(index))); 
598     sddQACheckerValue=1.;
599   }
600     break;
601     
602   case AliQAv1::kREC:
603     {
604       Int_t uidrec=list->GetUniqueID();
605       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index))); 
606       if(uidrec==20){
607         //recpoints
608         if (list->GetEntries() == 0){ //check if the list is empty
609           //printf("sddQACheckerValue = %f \t value %f\n",sddQACheckerValue,fHighSDDValue[AliQAv1::kFATAL]);
610           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL]; 
611           //break;                      
612         }//end if getentries
613       
614
615       TH1 *hmodule=NULL;
616       TH2 *hlayer[2]; 
617       hdata=NULL;
618       for(Int_t i=0;i<2;i++)hlayer[i]=NULL;
619
620       //check counters
621       Int_t emptymodules[2], filledmodules[2],emptyladders[2],filledladders[2],emptydriftregion[2], filleddriftregion[2], excludedmoduleperlayer[2], excludeddrperlayer[2], activemoduleperlayer[2],activedrperlayer[2],exactivemoduleperlayer[2],exactivedrperlayer[2];
622       Int_t excluded=0;            //excluded modules  
623       Int_t excludeddriftregion=0; //excluded single drift region
624       Int_t active=0;              //active modules  
625       Int_t activedriftregion=0;   //active single drift region
626       Int_t exactive=0;            //excluded modules but taking data
627       Int_t exactivedriftregion=0; //excluded single drift region but taking data   
628       Int_t empty=0;
629       Int_t filled=0;
630       Int_t emptydr=0;
631       Int_t filleddr=0;
632       //Int_t emptyactivemodule=0;
633       Int_t emptyactivemoduleperlayer[2];
634       //Int_t emptydractivemodule=0;
635       Int_t emptyactivedrperlayer[2];
636       Int_t emptysum=0;
637       Int_t emptydiff=0;
638       Int_t emptydrsum=0;
639       Int_t emptydrdiff=0;
640
641     for(Int_t i=0;i<2;i++)
642       {
643         emptymodules[i]=0; 
644         filledmodules[i]=0; 
645         emptyladders[i]=0; 
646         filledladders[i]=0; 
647         emptydriftregion[i]=0;
648         filleddriftregion[i]=0; 
649         excludedmoduleperlayer[i]=0;
650         excludeddrperlayer[i]=0;
651         activemoduleperlayer[i]=0;
652         activedrperlayer[i]=0;
653         exactivemoduleperlayer[i]=0;
654         exactivedrperlayer[i]=0;
655         emptyactivemoduleperlayer[i]=0;
656         emptyactivedrperlayer[i]=0;
657       }  
658
659     Int_t neventsrecpoints=0;
660
661       while( (hdata = dynamic_cast<TH1* >(next())) ){
662         if (hdata){
663           TString hname=hdata->GetName();
664
665           if(hname.Contains("SDDRecPointCheck"))
666             { 
667               neventsrecpoints=(Int_t)hdata->GetBinContent(1); 
668               //break;
669             }
670           else{continue;}
671         }//end if hdata
672       }//end while
673
674       next.Begin();
675
676         while((hdata=dynamic_cast<TH1* >(next()))){
677           if (hdata){
678             TString hname=hdata->GetName();
679             if(hname.Contains("_RelativeOccupancy")) {
680               Float_t threshold = hdata->GetMean() + 4*hdata->GetRMS();
681               if(hname.Contains("L3")) AliInfo(Form("SDD check number 3: L3 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
682               if(hname.Contains("L4")) AliInfo(Form("SDD check number 4: L4 mean: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
683               Int_t aboveThreshold = 0;
684               for(Int_t k=0; k<= ((Int_t)hdata->GetNbinsX()); k++) {
685                 if(hdata->GetBinLowEdge(k) > threshold) aboveThreshold += (Int_t)(hdata->GetBinContent(k));
686               }
687               Float_t fractionAboveThreshold=0.;
688               if(hdata->GetEntries()>0.) fractionAboveThreshold = ((Float_t) aboveThreshold)/hdata->GetEntries();
689               if(hname.Contains("L3")) AliInfo(Form("SDD check number 3, L3: RecPoints fractionAboveThreshold: %f",fractionAboveThreshold));
690               if(hname.Contains("L4")) AliInfo(Form("SDD check number 4, L4: RecPoints fractionAboveThreshold: %f",fractionAboveThreshold));
691               if(fractionAboveThreshold > fThresholdForRelativeOccupancy) { 
692                 sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
693                 if(hname.Contains("L3")) AliInfo(Form("SDD check number 3: Set Warning (L3 RecPoints)"));
694                 if(hname.Contains("L4")) AliInfo(Form("SDD check number 4: Set Warning (L4 RecPoints)"));
695               }
696             }
697             if(hname.Contains("Rec2Raw") && !hname.Contains("2D")) {
698               //Float_t threshold = 0.;
699               if(hname.Contains("L3")) AliInfo(Form("SDD check number 5: L3 R2R mean: %f, rms: ,%f",((TH1F *) hdata)->GetMean(),((TH1F *) hdata)->GetRMS()));
700               if(hname.Contains("L4")) AliInfo(Form("SDD check number 6: L4 R2R mean: %f, rms: ,%f",((TH1F *) hdata)->GetMean(),((TH1F *) hdata)->GetRMS()));
701               Int_t belowThreshold = 0;
702               for(Int_t k=0; k<=((TH1F *)hdata)->GetNbinsX(); k++) {
703                 if(((TH1F *) hdata)->GetBinLowEdge(k) < fThresholdForRecToRawRatio) belowThreshold += ((Int_t)((TH1F *) hdata)->GetBinContent(k));
704               }
705               Double_t fractionBelowThreshold =0.;
706               Double_t entries3=((TH1F *)hdata)->GetEntries();
707               if(entries3>0.001)fractionBelowThreshold = ((Double_t)(belowThreshold))/entries3;
708               else{ AliWarning(Form("No entries on %s. The check will retuns zero.\n",hdata->GetName() )); }
709               if(hname.Contains("L3")) AliInfo(Form("SDD check number 5, L3: RecPoints2Raws fractionBelowThreshold: %f",fractionBelowThreshold));
710               if(hname.Contains("L4")) AliInfo(Form("SDD check number 6, L4: RecPoints2Raws fractionBelowThreshold: %f",fractionBelowThreshold));
711               if(fractionBelowThreshold > fThresholdForRelativeOccupancy) { 
712                 sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
713                 if(hname.Contains("L3")) AliInfo(Form("SDD check number 5: Set Warning (L3 RecPoints2Raws)"));
714                 if(hname.Contains("L4")) AliInfo(Form("SDD check number 6: Set Warning (L4 RecPoints2Raws)"));
715               }
716             }
717             if(hname.Contains("dedx")) {
718               if(hname.Contains("L3")) AliInfo(Form("SDD check number 7: L3 average charge: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
719               if(hname.Contains("L4")) AliInfo(Form("SDD check number 8: L4 average charge: %f, rms: ,%f",hdata->GetMean(),hdata->GetRMS()));
720             }//end if dedx
721           if(hname.Contains("SDDModPatternRP")){
722             if(hname.Contains("NORM")) continue;
723             hmodule=(TH1*)hdata->Clone();
724             entries= hdata->GetEntries();
725             if(AliITSQADataMakerRec::AreEqual(entries,0.)){AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];}//endif entries
726             else{
727               int modmax=hdata->GetNbinsX();
728               Double_t content=0;
729               Int_t llay=0;
730               for(Int_t i=1;i<=modmax;i++)
731                 {
732                   if(i<85)llay=0;
733                   else llay=1;
734                   content=hdata->GetBinContent(i);
735                   if(AliITSQADataMakerRec::AreEqual(content,0.))
736                     {
737                     empty++;
738                     emptymodules[llay]++;
739                     } 
740                   else 
741                     {
742                       filled++;
743                       filledmodules[llay]++;
744                     }
745                 }//end for
746               //output of the check at the level of the modules. Drift region in the following checks
747
748               AliInfo(Form(" %s : empty modules %i \t filled modules %i",hname.Data(), empty, filled));
749               AliInfo(Form(" %s : Layer 3 empty modules %i \t filled modules %i",hname.Data(), emptymodules[0], filledmodules[0]));
750               AliInfo(Form(" %s : Layer 4 empty modules %i \t filled modules %i",hname.Data(), emptymodules[1], filledmodules[1]));
751             }//end else pattern entries !=0
752           } //modpattern (1d histogram)                 
753
754           if(hname.Contains("SDDModPatternL3RP") || hname.Contains("SDDModPatternL4RP")){if(hname.Contains("NORM"))continue;
755             Int_t layer=0;
756             if(hname.Contains("3"))layer=0;
757             else  if(hname.Contains("4"))layer=1;
758             entries2[layer]=hdata->GetEntries();
759             if(entries2[layer]==0){AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));
760               sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];}//end if getentries
761             else{
762               Int_t layer1=0;
763               if(hname.Contains("3"))layer1=0;
764               else  if(hname.Contains("4"))layer1=1;
765               TH2* htemp=dynamic_cast<TH2*>(hdata);
766               if(htemp){
767                 hlayer[layer1]=(TH2*)htemp->Clone();
768                 hlayer[layer1]->SetName(Form("%s_copy",hname.Data()));
769                 //hlayer[layer1]->RebinX(2);
770                 int modmay=hlayer[layer1]->GetNbinsY();
771                 TH1D* hproj= hlayer[layer1]->ProjectionY();
772                 Double_t ladcontent=0;
773                 for(Int_t i=1;i<=modmay;i++) {//loop on the ladders
774                   ladcontent=hproj->GetBinContent(i);
775                   if(AliITSQADataMakerRec::AreEqual(ladcontent,0.)) emptyladders[layer1]++;
776                   else filledladders[layer1]++;}//end for
777                 AliInfo(Form(" %s : empty ladders %i \t filled ladders %i\n",hname.Data(), emptyladders[layer1], filledladders[layer1]));//end else layer 3
778                 delete hproj;
779                 hproj=NULL;
780               }//end if htemp
781             }//end else entries !=0
782           }//end check on phiz
783           }//end if hdata
784         }//end while                            
785       for(Int_t ii=0;ii<2;ii++)
786         {
787           filledmodules[ii]=0;
788           emptymodules[ii]=0;
789         }
790       filled=0;
791       empty=0;
792       if(AliITSQADataMakerRec::AreEqual(entries,0.)&& AliITSQADataMakerRec::AreEqual(entries2[0],0.)&& AliITSQADataMakerRec::AreEqual(entries2[1],0.)) break;
793       //else{
794       if(hmodule || (hlayer[0] && hlayer[1])){
795         for(Int_t imod=0;imod<fgknSDDmodules;imod++){
796           Int_t lay=0;
797           Int_t lad=0;
798           Int_t det=0;
799           Int_t module=0;
800           module=imod+fgkmodoffset;
801           AliITSCalibrationSDD * cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
802           if(cal==0) { continue;}
803           AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
804           if (cal->IsBad()){
805             excluded++;
806             excludedmoduleperlayer[lay-3]++;
807             Double_t content=0.;
808             //Double_t contentlayer[2];
809             //for(Int_t i=0;i<2;i++)contentlayer[i]=0.;
810             if(hmodule)content=hmodule->GetBinContent(imod+1);//if expert bit is active the histogram will be stored in the QA file otherwise the histogram will not be written on the logbook
811             //      if(hlayer[lay-3]) contentlayer[lay-3]=hlayer[lay-3]->GetBinContent(det,lad);
812             if(AliITSQADataMakerRec::AreEqual(content,0.)== kFALSE) {
813               filledmodules[lay-3]++;
814               filled++;
815               AliError(Form("The module %d (layer %i, ladder %i det %i ) excluded from the acquisition,has recpoints \n ",module,lay,lad,det));
816               exactive++;
817               exactivemoduleperlayer[lay-3]++;
818             } else if(AliITSQADataMakerRec::AreEqual(content,0.)) 
819               {
820                 emptymodules[lay-3]++; //it has to be empty
821                 empty++;
822               }
823           } else {
824             Int_t totside=0;
825             Int_t totactiveside=0;
826             //Int_t totbadside=0;
827             Double_t contentgood=0.;
828
829             for(Int_t i=0;i<2;i++){
830               if(hlayer[lay-3]) contentgood=hlayer[lay-3]->GetBinContent(2*det+i-1,lad);
831               if(cal->IsWingBad(i))
832                 { 
833                   excludeddriftregion++; 
834                   excludeddrperlayer[lay-3]++; 
835                   if(AliITSQADataMakerRec::AreEqual(contentgood,0.)==kFALSE){
836                     AliError(Form("The side %d of the module %d (layer %i, ladder %i det %i ) excluded from the acquisition, has recpoints \n ",i,module,lay,lad,det));
837                     exactivedriftregion++; 
838                     exactivedrperlayer[lay-3]++;
839                     filleddr++;
840                     filleddriftregion[lay-3]++;
841                   }
842                 }//end wingbad
843               else{
844                 if(AliITSQADataMakerRec::AreEqual(contentgood,0.)==kTRUE)
845                   {
846                     AliWarning(Form("The side %d of the module %d (layer %i, ladder %i det %i ) is in acquisition, but no recpoints are present\n ",i,module, lay, lad, det));
847                   }
848                 else 
849                   {
850                     totside++;
851                   }
852                 totactiveside++;
853               }
854             }//end for
855             if(totside==0){
856             AliWarning(Form("The  module %d (layer %i, ladder %i det %i ) is in acquisition, but no recpoints are present \n ",module, lay, lad, det));
857               emptymodules[lay-3]++;
858               empty++;
859
860             }
861               else 
862                 if(totside==2){
863                 filledmodules[lay-3]++;
864                 filled++;
865                 }
866                 else
867                   if(totside==1)
868                     {
869                       //                      emptydr++;
870                       //emptydriftregion[lay-3]++; //it has to be empty
871                       emptydriftregion[lay-3]++; 
872                       emptydr++;
873                       filleddr++;
874                       filleddriftregion[lay-3]++;
875                     }
876             if(totactiveside==1)
877               {
878                 activedriftregion++;
879                 activedrperlayer[lay-3]++;
880               }else if(totactiveside==2)
881               {
882                 active++;
883                 activemoduleperlayer[lay-3]++;
884               }
885
886           }
887         }//end for
888         AliInfo(Form("In total %d modules and %d single drift regions have recpoints.\n ",filled, filleddr));
889         AliInfo(Form("In total %d modules and %d single drift regions are empty\n",empty, emptydr));
890         for(Int_t i=0;i<2;i++)
891           {
892             AliInfo(Form("Layer %i   \tempty modules %i             \t filled modules %i\n", i+3,emptymodules[i], filledmodules[i]));
893             AliInfo(Form("Layer %i   \tempty single drift regions %i \t filled single drift regions %i\n",i+3,emptydriftregion[i], filleddriftregion[i]));
894           }//end else layers
895         emptysum=emptymodules[0]+emptymodules[1];
896         emptydiff=emptysum-excluded;
897         emptyactivemoduleperlayer[0]=emptymodules[0]- excludedmoduleperlayer[0];
898         emptyactivemoduleperlayer[1]=emptymodules[1]- excludedmoduleperlayer[1];
899
900         emptydrsum=emptydriftregion[0]+emptydriftregion[1];
901         emptydrdiff=emptydrsum-excludeddriftregion;
902         emptyactivedrperlayer[0]=emptydriftregion[0]- excludeddrperlayer[0];
903         emptyactivedrperlayer[1]=emptydriftregion[1]- excludeddrperlayer[1];
904
905         Int_t numlimit=1000;
906         if(emptysum>excluded||emptydrsum>excludeddriftregion){ 
907           AliWarning(Form(" %i good module(s) and %i good single drift regions have not recpoints! \n",emptydiff,emptydrdiff));
908           AliWarning(Form(" Layer 3: %i good module(s) and %i good single drift regions have not recpoints! \n",emptyactivemoduleperlayer[0] ,emptyactivedrperlayer[0] ));
909           AliWarning(Form(" Layer 4: %i good module(s) and %i good single drift regions have not recpoints! \n",emptyactivemoduleperlayer[1] ,emptyactivedrperlayer[1] ));
910           
911           //sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
912           Int_t numlimits=1000;   
913
914           results1.Form("%i good module(s) and %i good drift region(s) have not recpoints!",emptydiff,emptydrdiff);
915           //      if((AliQAv1::Instance(AliQAv1::GetDetIndex("ITS")))->IsEventSpecieSet(AliRecoParam::kCosmic)==kFALSE)
916           if(AliRecoParam::ConvertIndex(GetEventSpecieForCheck())!=AliRecoParam::kCosmic){     
917             
918               if(neventsrecpoints<numlimits)
919                 {
920                   results2.Form(" Events %d .Too few events.DO NOT CALL the Expert ",neventsrecpoints);
921                         color=kYellow;
922                         textcolor=kBlack;
923                   sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
924                 }
925               else
926                 {
927                   results2.Form(" Events %d .If PHYSICS, follow the TWiki instruction and call the Expert ",neventsrecpoints);
928                         color=kRed;
929                         textcolor=kWhite;
930                   sddQACheckerValue=fHighSDDValue[AliQAv1::kERROR];
931                 }
932             }
933           else
934             //if((AliQAv1::Instance(AliQAv1::GetDetIndex("ITS")))->IsEventSpecieSet(AliRecoParam::kCosmic)==kTRUE)
935             if(AliRecoParam::ConvertIndex(GetEventSpecieForCheck())==AliRecoParam::kCosmic){     
936                 numlimit=10000;
937                 if( neventsrecpoints<numlimit)
938                   {
939                     AliWarning(Form("This is a cosmic run. Some module and drift region are empty but all is OK. "));
940                     results1.Form("OK. Thi is a cosmic run. You need a lot of events. Events %i",neventsrecpoints);
941                     results2.Form("%i good module(s) and %i good drift are empty! DO NOT CALL THE EXPERT",emptydiff,emptydrdiff);
942                           color=kYellow;
943                           textcolor=kBlack;
944                     sddQACheckerValue=fHighSDDValue[AliQAv1::kWARNING];
945                   }
946                 else
947                   {
948                     results1.Form("%i good module(s) and %i good drift region(s) have not recpoints!",emptydiff,emptydrdiff);
949                     results2.Form("Cosmic Events %d .Follow the TWiki instruction and call the Expert ",neventsrecpoints);
950                           color=kRed;
951                           textcolor=kWhite;
952                     sddQACheckerValue=fHighSDDValue[AliQAv1::kERROR];
953                   }
954               }
955         }
956         
957       
958
959         if(exactive==0 && emptydiff==0 && exactivedriftregion==0 && emptydrdiff==0){
960           AliInfo(Form("All the active modules (%i) and single drift regions (%i) are in acquisition. The number of excluded modules are %i and the excluded single drift regions are %i\n",active,activedriftregion,excluded,excludeddriftregion));
961           results1.Form("OK.");
962           results2.Form(" All active modules have recpoints");
963                 color=kGreen;
964                 textcolor=kBlack;
965           sddQACheckerValue=fHighSDDValue[AliQAv1::kINFO];
966         }
967         if(exactive!=0||exactivedriftregion!=0){
968           AliError(Form("%i modules and %i single  drift regions excluded from the acquisition have recpoints. Active modules %i single drift region %i \n ",exactive,exactivedriftregion,active,activedriftregion));
969           AliError(Form("Layer 3: %i modules and %i single  drift regions excluded from the acquisition have recpoints. Active modules %i single drift region %i \n ",exactivemoduleperlayer[0],exactivedrperlayer[0],activemoduleperlayer[0],activedrperlayer[0]));
970           AliError(Form("Layer 3: %i modules and %i single  drift regions excluded from the acquisition have recpoints. Active modules %i single drift region %i \n ",exactivemoduleperlayer[1],exactivedrperlayer[1],activemoduleperlayer[1],activedrperlayer[1]));
971           results1.Form("%i modules and %i drift region excluded from the acquisition have recpoints",exactive,exactivedriftregion);
972           results2.Form("Follow the TWiki instructions and Call the SDD expert ");
973                 color=kRed;
974                 textcolor=kWhite;
975           sddQACheckerValue=fHighSDDValue[AliQAv1::kERROR];
976         }
977         if(excluded==exactive||excludeddriftregion==exactivedriftregion){
978           AliError(Form("All the modules (%d) or single drift regions (%d) excluded from the acquisition have recpoints!\n  Active modules %i \t Active drfift regions %i\n",excluded,excludeddriftregion,active,activedriftregion));
979           results1.Form("All the modules (%d) or drift regions (%d) excluded from the acquisition have recpoints!",excluded,excludeddriftregion );
980           results2.Form("Follow the TWiki instructions and Call the SDD expert ");
981                 color=kRed;
982                 textcolor=kWhite;
983           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
984         }
985         if(active==0||activedriftregion==0){
986           AliError(Form("No modules or single drift regions have recpoints: excluded %i \t excluded active %i \n\t\t excluded single drift regions %i \t excluded active drift regions %i \n", excluded, exactive, excludeddriftregion, exactivedriftregion)); 
987           results1.Form("No modules or drift region have recpoints: excluded modules %i  excluded drift regions %i ", excluded, excludeddriftregion );
988           results2.Form("Follow the TWiki instructions and Call the SDD expert ");
989                 color=kRed;
990                 textcolor=kWhite;
991           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
992         }
993
994         //TPaveText *pave[2]={0,0};
995         next.Begin();
996
997         while( (hdata=dynamic_cast<TH1* >(next())) )
998           {
999             if (hdata){
1000               TString hname=hdata->GetName();
1001               if(hname.Contains("SDDModPatternL3RP") || hname.Contains("SDDModPatternL4RP")){
1002                 if(hname.Contains("NORM"))continue;
1003                 //AliInfo("========================================Found histo 11\n");
1004                           TPaveText *ptext = ((TPaveText *)hdata->GetListOfFunctions()->FindObject("TPave"));
1005                           if(ptext) {
1006                                   ptext->Clear();
1007                                   ptext->AddText(results1.Data());
1008                                   ptext->AddText(results2.Data());
1009                                   ptext->SetFillColor(color);
1010                                   ptext->SetTextColor(textcolor);
1011                           }
1012                   }
1013               else
1014                 if(hname.Contains("SDDRecPointCheck"))
1015                   {
1016                     
1017                     //AliInfo("========================================Found histo\n");
1018                     ((TH1F*)hdata)->SetBinContent(5,active);
1019                     ((TH1F*)hdata)->SetBinContent(6,filled);
1020                     ((TH1F*)hdata)->SetBinContent(7,activedriftregion);
1021                     ((TH1F*)hdata)->SetBinContent(8,filleddr);
1022                     ((TH1F*)hdata)->SetBinContent(9,excluded);
1023                     ((TH1F*)hdata)->SetBinContent(10,empty);
1024                     ((TH1F*)hdata)->SetBinContent(11,excludeddriftregion);
1025                     ((TH1F*)hdata)->SetBinContent(12,emptydr);
1026                     ((TH1F*)hdata)->SetBinContent(13,exactive);
1027                     ((TH1F*)hdata)->SetBinContent(14,emptydiff);
1028                     ((TH1F*)hdata)->SetBinContent(15,exactivedriftregion);
1029                     ((TH1F*)hdata)->SetBinContent(16,emptydrdiff);
1030                     
1031                     //layer 3
1032                     ((TH1F*)hdata)->SetBinContent(19,activemoduleperlayer[0]);
1033                     ((TH1F*)hdata)->SetBinContent(20,filledmodules[0]);
1034                     ((TH1F*)hdata)->SetBinContent(21,activedrperlayer[0]);
1035                     ((TH1F*)hdata)->SetBinContent(22,filleddriftregion[0]);
1036                     ((TH1F*)hdata)->SetBinContent(23,excludedmoduleperlayer[0]);
1037                     ((TH1F*)hdata)->SetBinContent(24,emptymodules[0]);
1038                     ((TH1F*)hdata)->SetBinContent(25,excludeddrperlayer[0]);
1039                     ((TH1F*)hdata)->SetBinContent(26,emptydriftregion[0]);
1040                     ((TH1F*)hdata)->SetBinContent(27,exactivemoduleperlayer[0]);
1041                     ((TH1F*)hdata)->SetBinContent(28,emptyactivemoduleperlayer[0]);
1042                     ((TH1F*)hdata)->SetBinContent(29,exactivedrperlayer[0]);
1043                     ((TH1F*)hdata)->SetBinContent(30,emptyactivedrperlayer[0]);
1044                     
1045                     //layer 4
1046                     ((TH1F*)hdata)->SetBinContent(35,activemoduleperlayer[1]);
1047                     ((TH1F*)hdata)->SetBinContent(36,filledmodules[1]);
1048                     ((TH1F*)hdata)->SetBinContent(37,activedrperlayer[1]);
1049                     ((TH1F*)hdata)->SetBinContent(38,filleddriftregion[1]);
1050                     ((TH1F*)hdata)->SetBinContent(39,excludedmoduleperlayer[1]);
1051                     ((TH1F*)hdata)->SetBinContent(40,emptymodules[1]);
1052                     ((TH1F*)hdata)->SetBinContent(41,excludeddrperlayer[1]);
1053                     ((TH1F*)hdata)->SetBinContent(42,emptydriftregion[1]);
1054                     ((TH1F*)hdata)->SetBinContent(43,exactivemoduleperlayer[1]);
1055                     ((TH1F*)hdata)->SetBinContent(44,emptyactivemoduleperlayer[1]);
1056                     ((TH1F*)hdata)->SetBinContent(45,exactivedrperlayer[1]);
1057                     ((TH1F*)hdata)->SetBinContent(46,emptyactivedrperlayer[1]);
1058                     //hdata->GetListOfFunctions()->Add(pave[0]);
1059                     
1060                   }
1061             }//if hadata
1062             
1063           }//end while 
1064         
1065       }//end else 
1066       delete hmodule;
1067       hmodule=NULL;
1068       for(Int_t i=0;i<2;i++) {
1069         delete hlayer[i];
1070         hlayer[i]=NULL;
1071       }//end for      
1072
1073
1074       //sddQACheckerValue=1.;
1075       }//end recpoint list uid = 20
1076       if(uidrec==40)
1077         {
1078           //digitsr
1079           if (list->GetEntries() == 0){ 
1080             sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
1081             break;
1082           } else{
1083         
1084             while( (hdata = dynamic_cast<TH1* >(next())) ){
1085               if (hdata){
1086                 if(hdata->GetEntries()==0)sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
1087                 else {
1088                   TString hname=hdata->GetName();
1089                   if(hname.Contains("SDD DIGITS Module Pattern")) {
1090                     //see raws
1091                 
1092                     sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1093                   } else if(hname.Contains("SDD Anode Distribution")) {
1094                     sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1095                   } else if(hname.Contains("SDD Tbin Distribution")) {
1096                     //to do as rp
1097                     sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1098                   } else if(hname.Contains("SDD ADC Counts Distribution")) {
1099                     sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1100                   }//end adc counts
1101               
1102                 }//end entries !=0
1103               }//end hdata
1104             }//end while
1105           }//end else
1106           sddQACheckerValue=1.;
1107         }
1108
1109     }
1110     break;
1111   case AliQAv1::kANA:
1112     {
1113       AliInfo(Form("===================> No Check on %s\n",AliQAv1::GetAliTaskName(index)));
1114       sddQACheckerValue=1.; 
1115     }
1116     break;
1117   case AliQAv1::kESD:
1118     {
1119       AliInfo(Form("==================>  No Check on %s\n",AliQAv1::GetAliTaskName(index)));
1120       sddQACheckerValue=1.;
1121     } 
1122     break;
1123   case AliQAv1::kNTASK:{
1124     AliInfo(Form("==================>  No Check on %s\n",AliQAv1::GetAliTaskName(index))); 
1125     sddQACheckerValue=1.;
1126   }
1127     break;
1128   case AliQAv1::kSIM:{
1129     AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index))); 
1130     Int_t uid=list->GetUniqueID();
1131     if(uid==60) {
1132       //digits
1133       if (list->GetEntries() == 0){ 
1134         sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
1135         break;
1136       } else{
1137         
1138         while( (hdata = dynamic_cast<TH1* >(next())) ){
1139           if (hdata){
1140             if(hdata->GetEntries()==0)sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
1141             else {
1142               TString hname=hdata->GetName();
1143               if(hname.Contains("SDDDIGITSModulePattern")) {
1144                 //see raws
1145                 
1146                 sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1147               } else if(hname.Contains("SDDAnodeDistribution")) {
1148                 sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1149               } else if(hname.Contains("SDDTbinDistribution")) {
1150                 //to do as rp
1151                 sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1152               } else if(hname.Contains("SDDADCCountsDistribution")) {
1153                 sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1154               }//end adc counts
1155               
1156             }//end entries !=0
1157           }//end hdata
1158         }//end while
1159       }//end else
1160     } else if(uid==50) 
1161       {
1162         //hits
1163         if (list->GetEntries() == 0){ 
1164           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
1165           break;
1166         } 
1167         else{
1168           
1169           while( (hdata = dynamic_cast<TH1* >(next())) ){
1170             if (hdata){
1171               if(hdata->GetEntries()==0)sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
1172               else {
1173                 TString hname=hdata->GetName();
1174                 if(hname.Contains("SDDHITSModulePattern")) {
1175                   //to do as raws
1176                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1177                 } else if(hname.Contains("SDDHITlenghtalonglocalYCoord")) {
1178                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1179                 } else if(hname.Contains("SDDHITlenghtalonglocalYCoordZoom")) {
1180                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1181                 } else if(hname.Contains("SDDDepositedEnergyDistribution")) {
1182                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1183                 }//end deposited energy
1184                 
1185               }//end entries !=0
1186             }//end hdata
1187           }//end while
1188         }//end else
1189       } else if(uid==70) 
1190       {
1191         //sdigits
1192         if (list->GetEntries() == 0){ 
1193           sddQACheckerValue=fHighSDDValue[AliQAv1::kFATAL];
1194           break;
1195         } else{
1196           
1197           while( (hdata = dynamic_cast<TH1* >(next())) ){
1198             if (hdata){
1199               if(hdata->GetEntries()==0)sddQACheckerValue += fStepBitSDD[AliQAv1::kFATAL];
1200               else {
1201                 TString hname=hdata->GetName();
1202                 if(hname.Contains("SDDSDIGITSModulePattern")) {
1203                   //to do as raws
1204                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1205                 } else if(hname.Contains("SDDAnodeDistribution")) {
1206                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1207                 } else if(hname.Contains("SDDTbinDistribution")) {
1208                   //to do as rp
1209                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1210                 } else if(hname.Contains("SDDADCCountsDistribution")) {
1211                   sddQACheckerValue += fStepBitSDD[AliQAv1::kINFO];    
1212                 }//end adc counts bindistribution
1213               }//end entries !=0
1214                         
1215             }//end hdata
1216           }//end while
1217         }//end else
1218       }//end sdigits
1219     sddQACheckerValue=1.;
1220   }
1221     break;
1222     
1223   }//end switch
1224   
1225   fCalibration=NULL;
1226   return sddQACheckerValue;     
1227 }
1228
1229 //__________________________________________________________________
1230 void AliITSQASDDChecker::SetTaskOffset(Int_t taskoffset)
1231 {
1232   //set the number of the histograms already present in the list before the SDD histograms
1233   fSubDetOffset = taskoffset;
1234 }
1235
1236
1237 //__________________________________________________________________
1238 void AliITSQASDDChecker::SetStepBit(const Double_t *steprange)
1239 {
1240   //set the values of the step bit for each QA bit range calculated in the AliITSQAChecker class
1241   //if(fStepBitSDD){/*delete fStepBitSDD;*/ fStepBitSDD=NULL;}
1242   //fStepBitSDD = new Double_t[AliQAv1::kNBIT];
1243   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
1244     {
1245       fStepBitSDD[bit]=steprange[bit];
1246     }
1247 }
1248
1249 //__________________________________________________________________
1250 void  AliITSQASDDChecker::SetSDDLimits(const Float_t *lowvalue, const Float_t * highvalue)
1251 {
1252   //set the low and high values in for each QA bit range calculated in the AliITSQAChecker class
1253   //  fLowSDDValue = new Float_t[AliQAv1::kNBIT];
1254   //  fHighSDDValue= new Float_t[AliQAv1::kNBIT];
1255
1256   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
1257     {
1258       fLowSDDValue[bit]=lowvalue[bit];
1259       fHighSDDValue[bit]= highvalue[bit];
1260     }
1261
1262 }
1263 //__________________________________________________________________
1264 Bool_t  AliITSQASDDChecker::MakeSDDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode)
1265 {
1266   //create the image for raws and recpoints. In the other case, the default methodof CheckerBase class will be used
1267   //
1268         Bool_t rval=kFALSE;
1269     fImage=(TCanvas**)AliQAChecker::Instance()->GetDetQAChecker(0)->GetImage();
1270   switch(task)
1271     {
1272     case AliQAv1::kRAWS:{
1273       rval=MakeSDDRawsImage(list, task,mode);
1274     }
1275       break;
1276     case AliQAv1::kRECPOINTS:{ rval=MakeSDDRecPointsImage(list, task,mode); }
1277       break;
1278     case AliQAv1::kHITS:; case AliQAv1::kESDS:; case AliQAv1::kDIGITS:;case AliQAv1::kDIGITSR:;case AliQAv1::kSDIGITS:;case AliQAv1::kTRACKSEGMENTS:;case AliQAv1::kRECPARTICLES:; default:
1279     {
1280        rval=kFALSE;
1281        //AliQAChecker::Instance()->GetDetQAChecker(0)->MakeImage(list,task,mode);
1282     }
1283     break;
1284     case AliQAv1::kNULLTASKINDEX:; case  AliQAv1::kNTASKINDEX: 
1285       {
1286         Int_t ts=(Int_t)task;
1287         AliWarning(Form("No histograms for this task number %d  \n", ts)); 
1288         rval=kFALSE;
1289       }
1290       break;
1291     }
1292 return rval;  
1293 }
1294
1295
1296 //_______________________________________________________________________
1297 Bool_t AliITSQASDDChecker::MakeSDDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
1298 {
1299   // MakeSDDRawsImage: raw data QA plots
1300
1301         for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
1302                 //printf("-------------------------> %i \n", esIndex);
1303                 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0)  {
1304                         //printf ("Nothing for %s \n", AliRecoParam::GetEventSpecieName(esIndex));
1305                         continue;
1306                 } else {
1307                         const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ; 
1308                         if ( !fImage[esIndex] ) {
1309                                 fImage[esIndex] = new TCanvas(title, title,1280,980) ;
1310                         }
1311                         fImage[esIndex]->Clear() ; 
1312                         fImage[esIndex]->SetTitle(title) ; 
1313                         fImage[esIndex]->cd();
1314                         fPaveText[esIndex] = new TPaveText(0.015, 0.015, 0.98, 0.98);
1315                         fPaveText[esIndex]->AddText(title);
1316                         fPaveText[esIndex]->Draw(); 
1317                         fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
1318                         fImage[esIndex]->Clear() ; 
1319                         Int_t nx =2;//TMath::Nint(TMath::Sqrt(nImages));//2
1320                         Int_t ny =3;//nx  ; //2
1321                         // if (nx < TMath::Sqrt(nImages))
1322                         // ny++ ;  
1323                         fImage[esIndex]->Divide(nx, ny) ; 
1324                         TIter nexthist(list[esIndex]) ; 
1325                         Int_t npad = 1 ; 
1326                         fImage[esIndex]->cd(npad); 
1327                         fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
1328                         Int_t nhist = 0;
1329                         while ( 1 ) {
1330                                 TH1* hist = static_cast<TH1*>(nexthist());
1331                                 if(hist == NULL) break;
1332                                 nhist++;
1333                                 TString hname(hist->GetName());
1334
1335                                 //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
1336                                 TString cln(hist->ClassName()) ; 
1337                                 if ( ! cln.Contains("TH") )
1338                                         continue ;
1339           
1340                                 if(hist->TestBit(AliQAv1::GetImageBit())) {
1341                                         hist->GetXaxis()->SetTitleSize(0.04);
1342                                         hist->GetYaxis()->SetTitleSize(0.04);
1343                                         hist->GetXaxis()->SetLabelSize(0.02);
1344                                         hist->GetYaxis()->SetLabelSize(0.02);
1345                                         if(cln.Contains("TH2")) {
1346                                                 gPad->SetRightMargin(0.15);
1347                                                 gPad->SetLeftMargin(0.05);
1348                                                 hist->SetStats(0);
1349                                                 hist->SetOption("colz") ;
1350
1351                                                 ////hist->GetListOfFunctions()->FindObject("palette")->SetLabelSize(0.025);
1352                                                 //gPad->Update();
1353                                         }
1354                                         hist->DrawCopy(); 
1355                                         fImage[esIndex]->cd(++npad) ; 
1356                                         fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
1357                                 } 
1358                         }
1359                         fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
1360                 }
1361         }
1362         return kTRUE;
1363 }
1364
1365
1366
1367
1368 //_______________________________________________________________________
1369 Bool_t AliITSQASDDChecker::MakeSDDRecPointsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode )
1370 {
1371   // MakeSDDRecPointsImage: rec point QA plots
1372
1373     for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
1374       if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0) 
1375         {
1376         //printf ("Nothing for %s \n", AliQAv1::GetTaskName(task).Data()); 
1377         continue;
1378         }
1379       const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ; 
1380       if ( !fImage[esIndex] ) {
1381         fImage[esIndex] = new TCanvas(title, title,1280,980) ;
1382       }
1383       fImage[esIndex]->Clear() ; 
1384       fImage[esIndex]->SetTitle(title) ; 
1385       fImage[esIndex]->cd();
1386       fImage[esIndex]->SetBorderMode(0) ;  
1387       TPaveText someText(0.015, 0.015, 0.98, 0.98);
1388       someText.AddText(title);
1389       someText.Draw(); 
1390       fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
1391       fImage[esIndex]->Clear() ; 
1392       Int_t nx =2; //TMath::Nint(TMath::Sqrt(nImages));
1393       Int_t ny =6; // nx  ; 
1394       //if (nx < TMath::Sqrt(nImages))
1395       //ny++ ;  
1396       fImage[esIndex]->Divide(nx, ny) ; 
1397       TIter nexthist(list[esIndex]) ; 
1398       TH1* hist = NULL ;
1399       Int_t npad = 1 ; 
1400       fImage[esIndex]->cd(npad) ; 
1401       fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
1402       while ( (hist=static_cast<TH1*>(nexthist())) ) {
1403         //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
1404         TString cln(hist->ClassName()) ;
1405
1406         TString hname(hist->GetName());
1407                   
1408                   //printf("=====================> Class name %s \n",cln.Data()); 
1409         if ( ! cln.Contains("TH") )
1410           continue ;
1411         if(hist->TestBit(AliQAv1::GetImageBit())) {
1412             hist->GetXaxis()->SetTitleSize(0.04);
1413             hist->GetYaxis()->SetTitleSize(0.04);
1414             hist->GetXaxis()->SetLabelSize(0.02);
1415             hist->GetYaxis()->SetLabelSize(0.02);
1416           if(cln.Contains("TH1"))
1417             {
1418               if(!hname.Contains("Check")) hist->SetFillColor(kOrange+7);
1419               //SetFrameFillColor(kAzure-9);
1420               //hist->DrawCopy() ; 
1421             }
1422           if(cln.Contains("TH2"))
1423             {
1424               gPad->SetRightMargin(0.15);
1425               gPad->SetLeftMargin(0.05);
1426               hist->SetStats(0);
1427               hist->SetOption("colz") ;
1428               ////            TPaletteAxis *paletta =(TPaletteAxis*)hist->GetListOfFunctions()->FindObject("palette");
1429               //paletta->SetLabelSize(0.025);
1430               //gPad->Update(); 
1431             }
1432
1433                         hist->DrawCopy(); 
1434                         fImage[esIndex]->cd(++npad) ; 
1435                         fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
1436                 }
1437       }
1438       fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
1439     }
1440    return kTRUE;
1441 }
1442