]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSQASSDChecker.cxx
Include dummy extreme layers in propagations for single track solution
[u/mrichter/AliRoot.git] / ITS / AliITSQASSDChecker.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 "TString.h"
27 #include "TCanvas.h"
28 #include "TStyle.h"
29 #include "TPad.h"
30 //#include "Riostream.h"
31
32 // --- AliRoot header files ---
33 #include "AliITSQASSDChecker.h"
34 #include "AliITSQADataMakerRec.h"
35 #include "AliLog.h"
36
37 ClassImp(AliITSQASSDChecker)
38 //__________________________________________________________________
39 AliITSQASSDChecker& AliITSQASSDChecker::operator = (const AliITSQASSDChecker& qac ) 
40 {
41   // Equal operator.
42   this->~AliITSQASSDChecker();
43   new(this) AliITSQASSDChecker(qac);
44   return *this;
45 }
46
47 void AliITSQASSDChecker::CheckRaws(TH1* histo) {  
48   // checker for RAWS
49   Double_t minSSDDataSize = 0;
50   Double_t maxSSDDataSize = 200;
51   Double_t minDDLDataSize = 0;
52   Double_t maxDDLDataSize = 50;
53   Double_t minLDCDataSize = 0;
54   Double_t maxLDCDataSize = 100;
55   Double_t minMeanDDLDataSize = 0;
56   Double_t maxMeanDDLDataSize = 50;
57   Double_t minMeanLDCDataSize = 0;
58   Double_t maxMeanLDCDataSize = 100;
59   //  Double_t maxOccupancy = 5;
60
61   TString histname = histo->GetName();
62
63   if (histname.EndsWith("SSDEventType")) {
64     if (histo->GetEntries()==0) {
65       AliWarning("Event type histogram is empty");
66     }
67     else if (histo->GetBinContent(histo->FindBin(7))==0) AliWarning("No type 7 (physics) events in EventType");
68   }
69
70   if (histname.EndsWith("SSDDataSize")) {
71     if (histo->GetEntries()==0) AliWarning("SSD data size histogram is empty");
72     if (histo->GetMean()>maxSSDDataSize||histo->GetMean()<minSSDDataSize) AliWarning(Form("SSD mean data size is %-.2g kB", histo->GetMean()));
73   }
74
75   if (histname.EndsWith("SSDDataSizePerDDL")) {
76     if (histo->GetEntries()==0) {
77       AliWarning("Data size per DDL histogram is empty");
78     }
79     else {
80       for(Int_t i = 512; i < 528; i++) {
81         if(histo->GetBinContent(histo->FindBin(i))==0) {
82            AliWarning(Form("Data size / DDL histogram: bin for DDL %i is empty",i));
83         }
84         else if(histo->GetBinContent(histo->FindBin(i))<minDDLDataSize||histo->GetBinContent(histo->FindBin(i))>maxDDLDataSize) AliWarning(Form("Data size DDL %i is %-.2g kB",i,histo->GetBinContent(histo->FindBin(i))));
85      }
86     }
87   }
88
89   if (histname.EndsWith("SSDDataSizePerLDC")) {
90     if (histo->GetEntries()==0) {
91       AliWarning("Data size per LDC histogram is empty");
92     }    
93     else {
94       AliInfo(Form("Data size per LDC histogram has %f entries",histo->GetEntries()));
95       for(Int_t i = 170; i < 178; i++) {
96         if(histo->GetBinContent(histo->FindBin(i))==0) {
97           AliWarning(Form("Data size / LDC histogram: bin for LDC %i is empty",i));
98         }
99         else if(AliITSQADataMakerRec::AreEqual(histo->GetBinContent(histo->FindBin(i)),minLDCDataSize) ||histo->GetBinContent(histo->FindBin(i))>maxLDCDataSize) AliWarning(Form("Data size LDC %i is %-.2g kB",i,histo->GetBinContent(i)));
100       }
101     }
102   }
103
104   if (histname.EndsWith("SSDLDCId")) {
105     if (histo->GetEntries()==0) {
106       AliWarning("LDC ID histogram is empty");
107     }    
108     else {
109       for(Int_t i = 170; i < 177; i++) {
110         if(histo->GetBinContent(histo->FindBin(i))==0) {
111           AliWarning(Form("LDC ID histogram: No entries for LDC %i",i));
112         }
113         else if(histo->GetBinContent(histo->FindBin(i))!=histo->GetBinContent(histo->FindBin(i+1))) {
114           AliWarning("LDC Id distribution is not uniform");
115           i=176;
116         }
117       }
118     }
119   }
120
121   if (histname.EndsWith("SSDDDLId")) {
122     if (histo->GetEntries()==0) {
123       AliWarning("DDL ID histogram is empty");
124     }
125     else {
126       for(Int_t i = 512; i < 527; i++) {
127         if(histo->GetBinContent(histo->FindBin(i))==0) {
128           AliWarning(Form("DDL ID histogram: No entries for DDL %i",i));
129         }
130         else if(histo->GetBinContent(histo->FindBin(i))!=histo->GetBinContent(histo->FindBin(i+1))) {
131           AliWarning("DDL Id distribution is not uniform");
132           i=526;
133         }
134       }
135     }
136   }
137
138   if (histname.Contains("SSDDataSizeLDC")) {
139     if (histo->GetEntries()==0) {
140       AliWarning(Form("LDC %s data size distribution is empty", histname(histname.Length()-3,3).Data()));
141     }
142     else if (histo->GetMean()<minMeanLDCDataSize||histo->GetMean()>maxMeanLDCDataSize) AliWarning(Form("Mean data size of LDC %s is %-.2g kB",histname(histname.Length()-3,3).Data(), histo->GetMean()));
143   }
144
145   if (histname.Contains("SSDDataSizeDDL")) {
146     if (histo->GetEntries()==0) {
147       AliWarning(Form("DDL %s data size distribution is empty", histname(histname.Length()-3,3).Data()));
148     } 
149     else if (histo->GetMean()<minMeanDDLDataSize||histo->GetMean()>maxMeanDDLDataSize) AliWarning(Form("Mean data size of DDL %s is %-.2g kB",histname(histname.Length()-3,3).Data(), histo->GetMean()));
150   }
151
152   if (histname.Contains("SSDAverageOccupancy")) {
153  
154     const char* side = "";
155     int ladder = 0;
156     int layernr = 0;
157
158     if (histname.EndsWith("5")) layernr = 499;
159     if (histname.EndsWith("6")) layernr = 599;
160
161     for (Int_t i = 1; i < histo->GetNbinsY() + 1; i++) { //ladder/side loop
162       if(i==3.*int(i/3.)){
163         ladder=int(i/3.)+layernr;
164         side="P side";
165       }
166       else if(i==3.*int(i+1/3.)){
167         ladder=int((i+1)/3.)+layernr;
168         side="N side";
169       }
170
171       for (Int_t j = 1; j < histo->GetNbinsX() + 1; j++) { //module loop
172         //if(histo->GetBinContent(j,i)>maxOccupancy)
173           // AliWarning(Form("Occupancy ladder %i, module %i, %s is %-.2f %%",ladder,j,side, histo->GetBinContent(j,i)));
174       }//module loop
175     }//ladder loop
176   }
177
178 }
179
180
181 //__________________________________________________________________
182 Bool_t  AliITSQASSDChecker::MakeSSDImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode) {
183   //create the image for raws and recpoints. In the other case, the default methodof CheckerBase class will be used  //
184   gStyle->SetPalette(1,0);
185   Bool_t rval=kFALSE;
186   fImage=(TCanvas**)AliQAChecker::Instance()->GetDetQAChecker(0)->GetImage();
187
188   if(task == AliQAv1::kRAWS) 
189     rval = MakeSSDRawsImage(list, task,mode);
190   else rval=kFALSE;
191   
192   return rval;
193 }
194
195 //_______________________________________________________________________
196 Bool_t AliITSQASSDChecker::MakeSSDRawsImage(TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode ) {
197   // MakeSSDRawsImage: raw data QA plots
198   for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
199     //printf("-------------------------> %i \n", esIndex);
200     if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) || list[esIndex]->GetEntries() == 0) continue;
201     else {
202       const Char_t * title = Form("QA_%s_%s_%s", GetName(), AliQAv1::GetTaskName(task).Data(), AliRecoParam::GetEventSpecieName(esIndex)) ; 
203       if ( !fImage[esIndex] ) fImage[esIndex] = new TCanvas(title, title,1280,980) ;
204         
205       fImage[esIndex]->Clear() ; 
206       fImage[esIndex]->SetTitle(title) ; 
207       fImage[esIndex]->cd();
208  
209       //TPaveText someText(0.015, 0.015, 0.98, 0.98);
210       //someText.AddText(title);
211       //someText.Draw(); 
212       fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
213       fImage[esIndex]->Clear() ; 
214       Int_t nx =2; //TMath::Nint(TMath::Sqrt(nImages));
215       Int_t ny =2; // nx  ; 
216         
217       fImage[esIndex]->Divide(nx, ny) ; 
218       TIter nexthist(list[esIndex]) ; 
219       TH1* hist = NULL ;
220       Int_t npad = 1 ; 
221       fImage[esIndex]->cd(npad); 
222       fImage[esIndex]->cd(npad)->SetBorderMode(0) ;
223       while ( (hist=static_cast<TH1*>(nexthist())) ) {
224         //gPad=fImage[esIndex]->cd(npad)->GetPad(npad);
225         TString cln(hist->ClassName()) ; 
226         if ( ! cln.Contains("TH") ) continue ;
227         
228         if(hist->TestBit(AliQAv1::GetImageBit())) {
229           //Printf("Histo name: %s - Class: %s",hist->GetName(),hist->ClassName());
230           hist->GetXaxis()->SetTitleSize(0.02);
231           hist->GetYaxis()->SetTitleSize(0.02);
232           hist->GetXaxis()->SetLabelSize(0.02);
233           hist->GetYaxis()->SetLabelSize(0.02);
234           if(cln.Contains("TH2")) {
235             gPad->SetRightMargin(0.15);
236             gPad->SetLeftMargin(0.05);
237             hist->SetStats(0);
238             hist->SetOption("colz") ;
239             //hist->GetListOfFunctions()->FindObject("palette")->SetLabelSize(0.025);
240             //gPad->Update();
241           }
242           hist->DrawCopy() ; 
243           fImage[esIndex]->cd(++npad) ; 
244           fImage[esIndex]->cd(npad)->SetBorderMode(0) ; 
245         }
246       }
247       fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
248     }
249   }
250   
251   return kTRUE;
252 }
253
254 //__________________________________________________________________
255 Double_t AliITSQASSDChecker::Check(AliQAv1::ALITASK_t /*index*/, const TObjArray * list, const AliDetectorRecoParam * /*recoParam*/) { 
256   // main checker method 
257   AliDebug(AliQAv1::GetQADebugLevel(),Form("AliITSQASSDChecker called with offset: %d\n", fSubDetOffset));
258
259   AliInfo(Form("AliITSQASSDChecker called with offset: %d\n", fSubDetOffset) );
260   //cout<<"(AliITSQASSDChecker::Check): List name "<<list->GetName()<<endl;
261   Double_t test = 0.0  ;
262   Int_t count = 0 ;
263   TString listname = list->GetName();
264
265   if (list->GetEntries() == 0){
266     test = 1. ; // nothing to check
267   }
268   else {
269
270     TIter next(list) ;
271     TH1 * hdata ;
272     count = 0 ;
273     while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
274       if (hdata) {
275         TString histname = hdata->GetName();
276         if(!histname.Contains("fHistSSD")) continue;
277         Double_t rv = 0.;
278         if(hdata->GetEntries()>0) {
279            rv = 1;
280
281            //if(histname.Contains("PerDDL")) cout << "(AliITSQASSDChecker::Check) " << histname << " has " << hdata->GetEntries() << " entries. Mean: " << hdata->GetMean() << endl;
282        
283        //    if(hdata->GetMean()>0&&!histname.Contains("_Ladder")) cout << "(AliITSQASSDChecker::Check) " << histname << " not empty! " << hdata->GetEntries() << " entries. Mean: " << hdata->GetMean() << endl;
284         }
285
286     //    if (listname.Contains("Raws")) CheckRaws(hdata);
287    //     if (listname.Contains("RecPoints")) CheckRecPoints(hdata);
288
289         //AliDebug(AliQAv1::GetQADebugLevel(), Form("%s -> %f", hdata->GetName(), rv)) ;
290         //cout<<hdata->GetName()<<" - "<<rv<<endl;
291         count++ ;
292         test += rv ;
293       }
294       else{
295         AliError("Data type cannot be processed") ;
296       }
297     }
298     if (count != 0) {
299       if (AliITSQADataMakerRec::AreEqual(test,0.)) {
300         AliWarning("Histograms are there, but they are all empty: setting flag to kWARNING");
301         test = 0.5;  //upper limit value to set kWARNING flag for a task
302       }
303       else {
304         test /= count ;
305       }
306     }
307   }
308   
309   //AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test)) ;
310   //cout<<"Test result: "<<test<<endl;
311
312   return test ;
313
314   //return 0.;
315
316
317 }
318
319 //__________________________________________________________________
320 void AliITSQASSDChecker::SetTaskOffset(Int_t TaskOffset){
321   // defines offset for SSD
322   fSubDetOffset = TaskOffset;
323 }
324
325 //__________________________________________________________________
326 void AliITSQASSDChecker::SetStepBit(const Double_t *steprange) {
327   // defines step range
328   fStepBitSSD = new Double_t[AliQAv1::kNBIT];
329   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
330     {
331       fStepBitSSD[bit]=steprange[bit];
332     }
333 }
334
335 //__________________________________________________________________
336 void  AliITSQASSDChecker::SetSSDLimits(const Float_t *lowvalue, const Float_t * highvalue){
337   // defines 
338   fLowSSDValue = new Float_t[AliQAv1::kNBIT];
339   fHighSSDValue= new Float_t[AliQAv1::kNBIT];
340
341   for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
342     {
343       fLowSSDValue[bit]=lowvalue[bit];
344       fHighSSDValue[bit]= highvalue[bit];
345     }
346
347 }