]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASDDChecker.cxx
Add new variables to injector ntuple - Set 2010 as default
[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 // --- AliRoot header files ---
29 #include "AliITSQADataMakerRec.h"
30 #include "AliITSQASDDChecker.h"
31 #include "AliLog.h"
32 #include "AliCDBEntry.h"
33 #include "AliCDBManager.h"
34 //#include "AliQAManager.h"
35 //#include "AliQACheckerBase.h"
36 //#include "TSystem.h"
37 #include "AliITSCalibrationSDD.h"
38 #include "AliITSgeomTGeo.h"
39 //#include "AliITSQAChecker.h"
40
41
42 ClassImp(AliITSQASDDChecker)
43 //__________________________________________________________________
44 AliITSQASDDChecker& AliITSQASDDChecker::operator = (const AliITSQASDDChecker& qac ) 
45 {
46   // Equal operator.
47   this->~AliITSQASDDChecker();
48   new(this) AliITSQASDDChecker(qac);
49   return *this;
50 }
51
52 AliITSQASDDChecker::~AliITSQASDDChecker() 
53 {
54
55   //destructor
56   if(fStepBitSDD) 
57     {
58       delete[] fStepBitSDD ;
59       fStepBitSDD = NULL;
60     }
61   if(fLowSDDValue)
62     {
63       delete[]fLowSDDValue;
64       fLowSDDValue=NULL;
65     }
66   if(fHighSDDValue)
67     { 
68       delete[]fHighSDDValue;
69       fHighSDDValue=NULL;
70     }
71   if(fCalibration)
72     {
73       delete fCalibration;
74       fCalibration=NULL;
75     }
76 } // dtor
77
78 //__________________________________________________________________
79 Double_t AliITSQASDDChecker::Check(AliQAv1::ALITASK_t index, const TObjArray * list, const AliDetectorRecoParam * /*recoparam*/) 
80 {
81   //check histograms of the different lists  
82   AliInfo(Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset) );
83
84   AliDebug(1,Form("AliITSQASDDChecker called with offset: %d\n", fSubDetOffset));
85
86   Double_t test = 0.;
87   TH1 *hdata=NULL;
88   Double_t entries=0.;
89   Double_t entries2[2];
90   for(Int_t i=0;i<2;i++)entries2[i]=0.;
91
92   if(!fCalibration){
93     AliCDBEntry *calibSDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
94     Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
95     if(!calibSDD)
96       {
97         AliError("Calibration object retrieval failed! SDD will not be processed");
98         fCalibration = NULL;
99         test= fHighSDDValue[AliQAv1::kWARNING];
100       }
101     fCalibration = (TObjArray *)calibSDD->GetObject();
102     
103     if(!cacheStatus)calibSDD->SetObject(NULL);
104     calibSDD->SetOwner(kTRUE);
105     if(!cacheStatus)
106       {
107         delete calibSDD;
108       }
109   }
110
111       AliInfo("Calib SDD Created\n ");
112
113   switch(index)
114     {
115
116     case AliQAv1::kRAW:
117       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index)));
118       
119       if (list->GetEntries() == 0){ //check if the list is empty
120         //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
121         test=test+fHighSDDValue[AliQAv1::kFATAL];
122         break;
123       }//end if getentries
124       else{
125         TIter next(list);
126         Int_t offset = 0;
127         for(offset =0;offset < fSubDetOffset; offset++){hdata = dynamic_cast<TH1*>(next());}//end for
128         Int_t emptymodules[2];
129         Int_t filledmodules[2];
130         Int_t emptyladders[2];
131         Int_t filledladders[2];
132         for(Int_t i=0;i<2;i++){
133           emptymodules[i]=0;
134           filledmodules[i]=0;
135           emptyladders[i]=0;
136           filledladders[i]=0;
137         }
138         TH1 *hmodule=NULL;
139         TH2 *hlayer[2];
140         for(Int_t i=0;i<2;i++)hlayer[i]=NULL;    
141         while( (hdata = dynamic_cast<TH1* >(next())) ){
142           if (hdata){
143             TString hname=hdata->GetName();
144             if(hname.Contains("SDDchargeMap"))continue;
145             if(hname.Contains("SDDModPattern")){
146               if(hname.Contains("NORM")) continue;
147               else{
148                 hmodule=hdata;
149                 entries= hdata->GetEntries();
150                 if(AliITSQADataMakerRec::AreEqual(entries,0.)){
151                   AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));
152                   //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
153                   test=test+fStepBitSDD[AliQAv1::kFATAL];
154                 }//endif entries
155                 else{
156                   int modmax=hdata->GetNbinsX();
157                   Int_t empty=0;
158                   Int_t filled=0;
159                   Double_t content=0;
160                   for(Int_t i=1;i<=modmax;i++){
161                     content=hdata->GetBinContent(i);
162                     if(AliITSQADataMakerRec::AreEqual(content,0.)){empty++;}
163                     else if((AliITSQADataMakerRec::AreEqual(content,0.)==kFALSE)){filled++;}
164                   }//end for
165                   AliInfo(Form(" %s : empty modules %i \t filled modules %i",hname.Data(), empty, filled));
166                 }//end else pattern entries !=0
167               }//end if norm          
168             }//end if modpattern
169             else if(hname.Contains("SDDphizL3")||hname.Contains("SDDphizL4")){
170               if(hname.Contains("NORM")) continue;
171               else{
172                 Int_t layer=0;
173                 if(hname.Contains("3"))layer=0;
174                 else  if(hname.Contains("4"))layer=1;
175                 entries2[layer]=hdata->GetEntries();
176                 if(entries2[layer]==0){
177                   AliWarning(Form("===================>>>>>> No entries in  %s \n",hname.Data()));
178                   //printf("test = %f \t value %f\n",test,fStepBitSDD[AliQAv1::kFATAL]);
179                   test=test+fStepBitSDD[AliQAv1::kFATAL];
180                   if(AliITSQADataMakerRec::AreEqual(entries,0.)){ 
181                     //return test; 
182                     //break;
183                   }
184                 }//end if getentries
185                 else{
186                   Int_t layer1=0;
187                   if(hname.Contains("3"))layer1=0;
188                   else  if(hname.Contains("4"))layer1=1;
189                   TH2* htemp=dynamic_cast<TH2*>(hdata);
190                   hlayer[layer1]=(TH2*)htemp->Clone();
191                   char newname[50];
192                   sprintf(newname,"%s_copy",hname.Data());
193                   hlayer[layer1]->SetName(newname);
194                   hlayer[layer1]->RebinX(2);
195                   int modmay=hlayer[layer1]->GetNbinsY();
196                   TH1D* hproj= hlayer[layer1]->ProjectionY();
197                   Double_t ladcontent=0;
198                   for(Int_t i=1;i<=modmay;i++) {//loop on the ladders
199                     ladcontent=hproj->GetBinContent(i);
200                     if(AliITSQADataMakerRec::AreEqual(ladcontent,0.)){emptyladders[layer1]++;}
201                     else {filledladders[layer1]++;} 
202                   }//end for
203                   AliInfo(Form(" %s : empty ladders %i \t filled ladders %i\n",hname.Data(), emptyladders[layer], filledladders[layer]));//end else layer 3
204                   delete hproj;
205                   hproj=NULL;   
206                   //delete htemp;
207                   //htemp=NULL;
208                 }//end else entries !=0
209               }//end check on norm            
210             }//end if layer 3
211           }//end if hdata       
212         }//end while
213         if(AliITSQADataMakerRec::AreEqual(entries,0.)&&AliITSQADataMakerRec::AreEqual(entries2[0],0.)&&AliITSQADataMakerRec::AreEqual(entries2[1],0.)) break;
214         else{
215           if(hmodule||(hlayer[0]&&hlayer[1])){
216             Int_t excluded=0;
217             Int_t active=0;
218             Int_t exactive=0;//excluded but taking data
219             //AliITSCalibrationSDD *cal;
220             for(Int_t imod=0;imod<fgknSDDmodules;imod++){
221               Int_t lay=0;
222               Int_t lad=0;
223               Int_t det=0;
224               Int_t module=0;
225               module=imod+fgkmodoffset;
226               AliITSCalibrationSDD * cal=(AliITSCalibrationSDD*)fCalibration->At(imod);
227               if(cal==0) { delete cal; continue;}
228               AliITSgeomTGeo::GetModuleId(module,lay,lad,det);
229               if (cal->IsBad()){
230                 excluded++;
231                 Double_t content=0.;
232                 Double_t contentlayer[2];
233                 for(Int_t i=0;i<2;i++)contentlayer[i]=0.;
234                 if(hmodule)content=hmodule->GetBinContent(imod+1);//if expert bit is active the histogram has been created 
235                 contentlayer[lay-3]=hlayer[lay-3]->GetBinContent(det,lad);
236                 if(AliITSQADataMakerRec::AreEqual(content,0.)==kFALSE||AliITSQADataMakerRec::AreEqual(contentlayer[lay-3],0.)==kFALSE)
237                   {
238                     filledmodules[lay-3]++;
239                     AliWarning(Form("The module %d (layer %i, ladder %i det %i ) excluded from the acquisition, took data \n ",module,lay,lad,det));
240                     exactive++;
241                   }
242                 else if(AliITSQADataMakerRec::AreEqual(content,0.)&&AliITSQADataMakerRec::AreEqual(contentlayer[lay-3],0.))emptymodules[lay-3]++;
243                 //AliInfo(Form("The module %d (layer %i, ladder %i det %i ) is bad, content %f content layer %f  filled modules position %d ",module,lay,lad,det,contentlayer[lay-3],content,lay-3) );
244               }//end if bad
245               else
246                 {
247                   Double_t contentgood=0.;
248                   active++;
249                   //printf("lay: %i\t det %i \t lad %i \n",lay,det,lad );
250                   contentgood=hlayer[lay-3]->GetBinContent(det,lad);
251                   if(AliITSQADataMakerRec::AreEqual(contentgood,0.)){emptymodules[lay-3]++;}
252                   else {filledmodules[lay-3]++;}
253                 }
254               
255               //delete cal;
256               //cal=NULL;
257             }//end for
258             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
259             if(exactive==0){
260               AliInfo(Form("All the active modules (%i) are in acquisition. The number of excluded modules are %i \n",active,excluded));
261               test=fHighSDDValue[AliQAv1::kINFO];}
262             if(exactive!=0){
263               AliWarning(Form("%i modules excluded from the acquisition took data. Active modules%i \n ",exactive,active));
264               test=fHighSDDValue[AliQAv1::kWARNING];
265             }
266             if(excluded==exactive){
267               AliWarning(Form("All the modules exluded from the acquisition (%d) took data!  Active modules %i\n",excluded,active));
268               test=fHighSDDValue[AliQAv1::kWARNING];
269             }
270             if(active==0){
271               AliWarning(Form("No modules took data: excluded %i \t exactive %i \n", excluded, exactive)); 
272               test=fHighSDDValue[AliQAv1::kFATAL];
273             }
274             for(Int_t i=0;i<2;i++)
275               {
276                 delete hlayer[i];
277                 hlayer[i]=NULL;
278               }
279           }//end else 
280         }
281       }//end getentries !=0
282       //delete calSDD;
283       
284       //delete calibSDD;
285       //delete calSDD;
286    
287       break;
288     case AliQAv1::kNULLTASK:
289       AliInfo(Form("No Check on %s\n",AliQAv1::GetAliTaskName(index))); 
290       test=1.;
291       break;
292     case AliQAv1::kREC:
293       /*
294       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index))); 
295       //TH1*hdata=NULL;
296       if(list->GetUniqueID()==40){
297         if (list->GetEntries() == 0){ //check if the list is empty
298           //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
299           test=fHighSDDValue[AliQAv1::kFATAL];
300           
301         }//end if getentries
302         else{
303           
304           TIter next(list);
305         
306           while( hdata = dynamic_cast<TH1* >(next()) ){
307             if (hdata){
308               if(AliITSQADataMakerRec::AreEqual(hdata->GetEntries(),0.))test=test+fStepBitSDD[AliQAv1::kFATAL];
309               else
310                 {
311                   TString hname=hdata->GetName();
312                   if(hname.Contains("FSE"))continue;
313                   else if(hname.Contains("SDDLay3TotCh")||hname.Contains("SDDLay4TotCh")){
314                     Double_t meancharge=hdata->GetMean();
315                     Double_t rmscharge=hdata->GetRMS();
316                     AliInfo(Form("%s : Mean value:%f RMS value%f \n ",hname.Data(),meancharge,rmscharge));
317                     test=test+fStepBitSDD[AliQAv1::kINFO];    
318                   }//end if name charge
319                   else if(hname.Contains("SDDGlobalCoordDistribYX" ))
320                     {
321                       test=test+fStepBitSDD[AliQAv1::kINFO];    
322                     }//end xy
323                   else if(hname.Contains("SDDGlobalCoordDistribRZ"))
324                     {
325                       
326                       test=test+fStepBitSDD[AliQAv1::kINFO];    
327                     } //end rz
328                   else if(hname.Contains("SDDGlobalCoordDistribL3PHIZ" )||hname.Contains("SDDGlobalCoordDistribL3PHIZ"))
329                     {    
330
331                     }//end phiz
332                   else if(hname.Contains("SDDModPatternRP"))
333                     {
334                       
335                       //to do :se raws
336
337                     }//modpattern
338                   else if(hname.Contains("SDDModPatternL3RP")||hname.Contains("SDDModPatternL4RP") )
339                     {
340                       //to do: see raws
341                     }//end ladpattern
342                   else if(hname.Contains("SDDLocalCoordDistrib"))
343                     {
344                       test=test+fStepBitSDD[AliQAv1::kINFO];    
345                     }//end local coord
346                   else if(hname.Contains("SDDrdistrib_Layer3")||hname.Contains("SDDrdistrib_Layer4"))
347                     {
348                       
349                     }//end r distribution
350                   else if(hname.Contains("SDDphidistrib_Layer3")||hname.Contains("SDDphidistrib_Layer4"))
351                     {
352                       
353                     }//end phi distribution
354                   else if(hname.Contains("SDDdrifttime_Layer3")||hname.Contains("SDDdrifttime_Layer4"))
355                     {
356                       
357                     }//end drift time
358                 }
359             }//end if hdata
360             
361           }//end while
362         }//end else geentries
363       }//end uniqueid
364       */
365       test=1.;
366       break;
367     case AliQAv1::kANA:
368       AliInfo(Form("===================> No Check on %s\n",AliQAv1::GetAliTaskName(index)));
369       test=1.; 
370       break;
371     case AliQAv1::kESD:
372       AliInfo(Form("==================>  No Check on %s\n",AliQAv1::GetAliTaskName(index)));
373       test=1.; 
374       break;
375     case AliQAv1::kNTASK:
376       AliInfo(Form("==================>  No Check on %s\n",AliQAv1::GetAliTaskName(index))); 
377       test=1.;
378       break;
379     case AliQAv1::kSIM:
380       AliInfo(Form("Check on %s\n",AliQAv1::GetAliTaskName(index))); 
381       Int_t uid=list->GetUniqueID();
382       if(uid==60)
383         {
384           //digits
385           if (list->GetEntries() == 0){ //check if the list is empty
386             //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
387             test=fHighSDDValue[AliQAv1::kFATAL];
388             
389           }//end if getentries
390           else{
391             
392             TIter next(list);
393             
394             while( (hdata = dynamic_cast<TH1* >(next())) ){
395               if (hdata){
396                 if(hdata->GetEntries()==0)test=test+fStepBitSDD[AliQAv1::kFATAL];
397                 else
398                   {
399                     TString hname=hdata->GetName();
400                     if(hname.Contains("SDDDIGITSModulePattern"))
401                       {
402                         //see raws
403
404                         test=test+fStepBitSDD[AliQAv1::kINFO];    
405                       }//end modpattern
406                     else if(hname.Contains("SDDAnodeDistribution"))
407                       {
408                        
409                         test=test+fStepBitSDD[AliQAv1::kINFO];    
410                       }//end anode distribution
411                     else if(hname.Contains("SDDTbinDistribution"))
412                       {
413
414                         //to do as rp
415                         test=test+fStepBitSDD[AliQAv1::kINFO];    
416                       }//end timebindistribution
417                     else if(hname.Contains("SDDADCCountsDistribution"))
418                       {
419                         test=test+fStepBitSDD[AliQAv1::kINFO];    
420                       }//end adc counts
421
422                   }//end entries !=0
423               }//end hdata
424             }//end while
425           }//end else
426         }//end digits
427       else if(uid==50)
428         {
429           //hits
430           if (list->GetEntries() == 0){ //check if the list is empty
431             //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
432             test=fHighSDDValue[AliQAv1::kFATAL];
433             
434           }//end if getentries
435           else{
436             
437             TIter next(list);
438             
439             while( (hdata = dynamic_cast<TH1* >(next())) ){
440               if (hdata){
441                 if(hdata->GetEntries()==0)test=test+fStepBitSDD[AliQAv1::kFATAL];
442                 else
443                   {
444                     TString hname=hdata->GetName();
445                     if(hname.Contains("SDDHITSModulePattern"))
446                       {
447                         //to do as raws
448                         test=test+fStepBitSDD[AliQAv1::kINFO];    
449                       }//end modpattern
450                     else if(hname.Contains("SDDHITlenghtalonglocalYCoord"))
451                       {
452                         test=test+fStepBitSDD[AliQAv1::kINFO];    
453                       }//end hit lenght
454                     else if(hname.Contains("SDDHITlenghtalonglocalYCoordZoom"))
455                       {
456                         test=test+fStepBitSDD[AliQAv1::kINFO];    
457                       }//end hit lenght
458                     else if(hname.Contains("SDDDepositedEnergyDistribution"))
459                       {
460                         test=test+fStepBitSDD[AliQAv1::kINFO];    
461                       }//end deposited energy
462
463                   }//end entries !=0
464               }//end hdata
465             }//end while
466           }//end else
467         }//end hits
468       else if(uid==70)
469         {
470           //sdigits
471           if (list->GetEntries() == 0){ //check if the list is empty
472             //printf("test = %f \t value %f\n",test,fHighSDDValue[AliQAv1::kFATAL]);
473             test=fHighSDDValue[AliQAv1::kFATAL];
474             
475           }//end if getentries
476           else{
477             
478             TIter next(list);
479             
480             while( (hdata = dynamic_cast<TH1* >(next())) ){
481               if (hdata){
482                 if(hdata->GetEntries()==0)test=test+fStepBitSDD[AliQAv1::kFATAL];
483                 else
484                   {
485                     TString hname=hdata->GetName();
486                     if(hname.Contains("SDDSDIGITSModulePattern"))
487                       {
488                         //to do as raws
489                         test=test+fStepBitSDD[AliQAv1::kINFO];    
490                       }//end modpattern
491                     else if(hname.Contains("SDDAnodeDistribution"))
492                       {
493                         test=test+fStepBitSDD[AliQAv1::kINFO];    
494                       }//end anode bindistribution
495                     else if(hname.Contains("SDDTbinDistribution"))
496                       {
497                         //to do as rp
498                         test=test+fStepBitSDD[AliQAv1::kINFO];    
499                       }//end timebindistribution
500                     else if(hname.Contains("SDDADCCountsDistribution"))
501                       {
502                         test=test+fStepBitSDD[AliQAv1::kINFO];    
503                       }//end adc counts bindistribution
504
505                   }//end entries !=0
506               }//end hdata
507             }//end while
508           }//end else
509         }//end sdigits
510       test=1.;
511       break;
512       
513     }//end switch
514
515   fCalibration=NULL;
516   delete hdata;
517   return test;  
518 }
519  
520 //__________________________________________________________________
521 void AliITSQASDDChecker::SetTaskOffset(Int_t taskoffset)
522 {
523   //set the number of the histograms already present in the list before the SDD histograms
524   fSubDetOffset = taskoffset;
525 }
526
527
528 //__________________________________________________________________
529 void AliITSQASDDChecker::SetStepBit(const Double_t *steprange)
530 {
531   //set the values of the step bit for each QA bit range calculated in the AliITSQAChecker class
532   fStepBitSDD = new Double_t[AliQAv1::kNBIT];
533   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
534     {
535       fStepBitSDD[bit]=steprange[bit];
536     }
537 }
538
539 //__________________________________________________________________
540 void  AliITSQASDDChecker::SetSDDLimits(const Float_t *lowvalue, const Float_t * highvalue)
541 {
542   //set the low and high values in for each QA bit range calculated in the AliITSQAChecker class
543   fLowSDDValue = new Float_t[AliQAv1::kNBIT];
544   fHighSDDValue= new Float_t[AliQAv1::kNBIT];
545
546   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
547     {
548       fLowSDDValue[bit]=lowvalue[bit];
549       fHighSDDValue[bit]= highvalue[bit];
550     }
551
552 }
553
554