1 /**************************************************************************
2 * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // *****************************************
19 // Checks the quality assurance
20 // by comparing with reference data
21 // W.Ferrarese P.Cerello Mag 2008
24 // --- ROOT system ---
26 #include <Riostream.h>
29 // --- AliRoot header files ---
30 #include "AliITSQAChecker.h"
31 #include "AliITSQASPDChecker.h"
32 #include "AliITSQASDDChecker.h"
33 #include "AliITSQASSDChecker.h"
34 #include "AliITSQADataMakerRec.h"
36 ClassImp(AliITSQAChecker)
38 //____________________________________________________________________________
39 AliITSQAChecker::AliITSQAChecker(Bool_t kMode, Short_t subDet, Short_t ldc) :
40 AliQACheckerBase("ITS","SDD Quality Assurance Checker"),
50 fSPDChecker(0), // SPD Checker
51 fSDDChecker(0), // SDD Checker
52 fSSDChecker(0) // SSD Checker
55 // Standard constructor
56 fkOnline = kMode; fDet = subDet; fLDC = ldc;
57 if(fDet == 0 || fDet == 1) {
58 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SPD Checker\n");
59 fSPDChecker = new AliITSQASPDChecker();
61 if(fDet == 0 || fDet == 2) {
62 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SDD Checker\n");
63 fSDDChecker = new AliITSQASDDChecker();
65 if(fDet == 0 || fDet == 3) {
66 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SSD Checker\n");
67 fSSDChecker = new AliITSQASSDChecker();
69 InitQACheckerLimits();
72 //____________________________________________________________________________
73 AliITSQAChecker::AliITSQAChecker(const AliITSQAChecker& qac):
74 AliQACheckerBase(qac.GetName(), qac.GetTitle()),
75 fkOnline(qac.fkOnline),
78 fSPDOffset(qac.fSPDOffset),
79 fSDDOffset(qac.fSDDOffset),
80 fSSDOffset(qac.fSSDOffset),
81 fSPDHisto(qac.fSPDHisto),
82 fSDDHisto(qac.fSDDHisto),
83 fSSDHisto(qac.fSSDHisto),
84 fSPDChecker(qac.fSPDChecker),
85 fSDDChecker(qac.fSDDChecker),
86 fSSDChecker(qac.fSSDChecker)
89 AliError("Copy should not be used with this class\n");
91 //____________________________________________________________________________
92 AliITSQAChecker& AliITSQAChecker::operator=(const AliITSQAChecker& qac){
93 // assignment operator
94 this->~AliITSQAChecker();
95 new(this)AliITSQAChecker(qac);
100 //____________________________________________________________________________
101 AliITSQAChecker::~AliITSQAChecker(){
103 if(fSPDChecker)delete fSPDChecker;
104 if(fSDDChecker)delete fSDDChecker;
105 if(fSSDChecker)delete fSSDChecker;
108 //____________________________________________________________________________
109 void AliITSQAChecker::Check(Double_t * rv, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * recoParam)
113 // basic checks on the QA histograms on the input list
114 //for the ITS subdetectorQA (Raws Digits Hits RecPoints SDigits) return the worst value of the three result
115 if(index == AliQAv1::kESD){
117 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
119 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
121 AliDebug(AliQAv1::GetQADebugLevel(),"Checker for ESD");
124 // The following flags are set to kTRUE if the corresponding
125 // QA histograms exceed a given quality threshold
126 Bool_t cluMapSA = kFALSE;
127 Bool_t cluMapMI = kFALSE;
128 Bool_t cluMI = kFALSE;
129 Bool_t cluSA = kFALSE;
130 Bool_t verSPDZ = kFALSE;
131 if (list[specie]->GetEntries() == 0) {
132 rv[specie] = 0.; // nothing to check
135 Double_t stepbit[AliQAv1::kNBIT];
136 Double_t histonumb= list[specie]->GetEntries();
137 CreateStepForBit(histonumb,stepbit);
138 TIter next1(list[specie]);
141 Bool_t skipped[6]={kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE};
142 // look for layers that we wanted to skip
143 while ( (hdata = dynamic_cast<TH1 *>(next1())) ) {
145 TString hname = hdata->GetName();
146 if(!hname.Contains("hESDSkippedLayers")) continue;
147 for(Int_t k=1; k<7; k++) {
148 if(hdata->GetBinContent(k)>0) {
155 TIter next(list[specie]);
156 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
158 TString hname = hdata->GetName();
159 Double_t entries = hdata->GetEntries();
161 if(!(entries>0.))++empty;
162 AliDebug(AliQAv1::GetQADebugLevel(),Form("ESD hist name %s - entries %12.1g",hname.Data(),entries));
163 if(hname.Contains("hESDClusterMapSA") && entries>0.){
165 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
166 // Check if there are layers with anomalously low
167 // contributing points to SA reconstructed tracks
168 for(Int_t k=1;k<7;k++){
169 // check if the layer was skipped
170 if(skipped[k-1]) continue;
171 if(hdata->GetBinContent(k)<0.5*(entries/6.)){
173 AliDebug(AliQAv1::GetQADebugLevel(),Form("SA tracks have few points on layer %d - look at histogram hESDClustersSA",k));
178 else if(hname.Contains("hESDClusterMapMI") && entries>0.){
179 // Check if there are layers with anomalously low
180 // contributing points to MI reconstructed tracks
181 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
183 for(Int_t k=1;k<7;k++){
184 // check if the layer was skipped
185 if(skipped[k-1]) continue;
186 if(hdata->GetBinContent(k)<0.5*(entries/6.)){
188 AliDebug(AliQAv1::GetQADebugLevel(),Form("MI tracks have few points on layer %d - look at histogram hESDClustersMI",k));
193 else if(hname.Contains("hESDClustersMI") && entries>0.){
194 // Check if 6 clusters MI tracks are the majority
195 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
197 Double_t maxlaytracks = hdata->GetBinContent(7-nskipped);
198 for(Int_t k=2; k<7-nskipped; k++){
199 if(hdata->GetBinContent(k)>maxlaytracks){
201 AliDebug(AliQAv1::GetQADebugLevel(),Form("MI Tracks with %d clusters are more than tracks with %d clusters. Look at histogram hESDClustersMI",k-1,6-nskipped));
206 else if(hname.Contains("hESDClustersSA") && entries>0.){
207 // Check if 6 clusters SA tracks are the majority
208 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
210 Double_t maxlaytracks = hdata->GetBinContent(7-nskipped);
211 for(Int_t k=2; k<7-nskipped; k++){
212 if(hdata->GetBinContent(k)>maxlaytracks){
214 AliDebug(AliQAv1::GetQADebugLevel(), Form("SA Tracks with %d clusters are more than tracks with %d clusters. Look at histogram hESDClustersSA",k-1,6-nskipped));
219 else if(hname.Contains("hSPDVertexZ") && entries>0.){
220 // Check if average Z vertex coordinate is -5 < z < 5 cm
221 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
223 if(hdata->GetMean()<-5. && hdata->GetMean()>5.){
225 AliDebug(AliQAv1::GetQADebugLevel(),Form("Average z vertex coordinate is at z= %10.4g cm",hdata->GetMean()));
229 else{ AliError("ESD Checker - invalid data type");}//end else
234 rv[specie] = 2500.; // set to error
235 AliWarning(Form("All ESD histograms are empty - specie=%d",specie));
238 rv[specie] = 2500.-1500.*(static_cast<Double_t>(tested-empty)/static_cast<Double_t>(tested)); // INFO if all histos are filled
239 if(cluMapSA)rv[specie]-=200.;
240 if(cluMapMI)rv[specie]-=200.;
241 if(cluMI)rv[specie]-=200.;
242 if(cluSA)rv[specie]-=200.;
243 if(verSPDZ)rv[specie]-=199.; // down to 1 if everything is OK
248 // AliDebug(AliQAv1::GetQADebugLevel(), Form("ESD - Tested %d histograms, Return value %f \n",tested,rv[specie]));
249 AliInfo(Form("ESD - Tested %d histograms, Return value %f \n",tested,rv[specie]));
255 //____________________________________________________________________________
257 Double_t spdCheck[AliRecoParam::kNSpecies] ;
258 Double_t sddCheck[AliRecoParam::kNSpecies] ;
259 Double_t ssdCheck[AliRecoParam::kNSpecies] ;
263 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
264 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
265 if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
266 Double_t histotot=list[specie]->GetEntries();
274 if(fDet == 0 || fDet == 1) {
275 fSPDChecker->SetTaskOffset(fSPDOffset);
276 //printf("spdoffset = %i \n",fSPDOffset );
277 Double_t histoSPD=double(GetSPDHisto());
278 if(AliITSQADataMakerRec::AreEqual(histoSPD,0)==kFALSE){
279 Double_t *stepSPD=new Double_t[AliQAv1::kNBIT];
280 CreateStepForBit(histoSPD,stepSPD);
281 fSPDChecker->SetStepBit(stepSPD);
282 spdCheck[specie] = fSPDChecker->Check(index, list[specie], recoParam);
283 if(spdCheck[specie]>fUpTestValue[AliQAv1::kFATAL]||spdCheck[specie]<0.)
285 AliInfo(Form("SPD check result for %s is out of range (%f)!!! Retval of specie %s is sit to -1\n ",AliQAv1::GetAliTaskName(index),spdCheck[specie],AliRecoParam::GetEventSpecieName(specie)));
286 spdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];
289 }//end check SPD entries
290 else{spdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];}
291 rv[specie]=spdCheck[specie];
294 if(fDet == 0 || fDet == 2) {
295 fSDDChecker->SetTaskOffset(fSDDOffset);
296 Double_t histoSDD=double(GetSDDHisto());
297 if(AliITSQADataMakerRec::AreEqual(histoSDD,0)==kFALSE){
298 Double_t *stepSDD=new Double_t[AliQAv1::kNBIT];
299 CreateStepForBit(histoSDD,stepSDD);
300 fSDDChecker->SetStepBit(stepSDD);
301 sddCheck[specie] = fSDDChecker->Check(index, list[specie], recoParam);
302 if(sddCheck[specie]>fUpTestValue[AliQAv1::kFATAL]||sddCheck[specie]<0.)
304 AliInfo(Form("SDD check result for %s is out of range (%f)!!! Retval of specie %s is sit to -1\n ",AliQAv1::GetAliTaskName(index),sddCheck[specie],AliRecoParam::GetEventSpecieName(specie)));
305 sddCheck[specie]=fUpTestValue[AliQAv1::kFATAL];
308 }//end check SDD entries
309 else{ssdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];}
310 if(sddCheck[specie]>rv[specie])rv[specie]=sddCheck[specie];
313 if(fDet == 0 || fDet == 3) {
314 fSSDChecker->SetTaskOffset(fSSDOffset);
315 Double_t histoSSD=double(GetSSDHisto());
316 if(AliITSQADataMakerRec::AreEqual(histoSSD,0)==kFALSE){
317 Double_t *stepSSD=new Double_t[AliQAv1::kNBIT];
318 CreateStepForBit(histoSSD,stepSSD);
319 fSSDChecker->SetStepBit(stepSSD);
320 ssdCheck[specie] = fSSDChecker->Check(index, list[specie], recoParam);
321 if(ssdCheck[specie]>fUpTestValue[AliQAv1::kFATAL]||ssdCheck[specie]<0.)
323 AliInfo(Form("SSD check result for %s is out of range (%f)!!! Retval of specie %s is sit to -1\n ",AliQAv1::GetAliTaskName(index),ssdCheck[specie],AliRecoParam::GetEventSpecieName(specie)));
324 ssdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];
327 }//end check SSD entries
328 else{ssdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];}
329 if(ssdCheck[specie]>rv[specie])rv[specie]=ssdCheck[specie];
332 AliInfo(Form("Check result for %s: \n\t SPD %f \n\t SDD %f \n\t SSD %f \n Check result %f \n ",AliQAv1::GetAliTaskName(index),spdCheck[specie],sddCheck[specie],ssdCheck[specie],rv[specie]));
333 // here merging part for common ITS QA result
336 }//end if event specie
341 //____________________________________________________________________________
342 void AliITSQAChecker::SetTaskOffset(Int_t SPDOffset, Int_t SDDOffset, Int_t SSDOffset)
344 //Setting the 3 offsets for each task called
345 fSPDOffset = SPDOffset;
346 fSDDOffset = SDDOffset;
347 fSSDOffset = SSDOffset;
350 //____________________________________________________________________________
351 void AliITSQAChecker::SetHisto(Int_t SPDhisto, Int_t SDDhisto, Int_t SSDhisto)
353 //Setting the 3 offsets for each task called
354 fSPDHisto = SPDhisto;
355 fSDDHisto = SDDhisto;
356 fSSDHisto = SSDhisto;
359 //____________________________________________________________________________
360 void AliITSQAChecker::SetDetTaskOffset(Int_t subdet,Int_t offset)
364 SetSPDTaskOffset(offset);
367 SetSDDTaskOffset(offset);
370 SetSSDTaskOffset(offset);
373 AliWarning("No specific (SPD,SDD or SSD) subdetector correspond to to this number!!! all offsets set to zero for all the detectors\n");
374 SetTaskOffset(0, 0, 0);
379 //____________________________________________________________________________
380 void AliITSQAChecker::SetDetHisto(Int_t subdet,Int_t histo)
393 AliWarning("No specific (SPD,SDD or SSD) subdetector correspond to to this number!!! all offsets set to zero for all the detectors\n");
399 //_____________________________________________________________________________
401 void AliITSQAChecker::InitQACheckerLimits()
404 AliInfo("Setting of tolerance values\n");
406 Float_t lowtolerancevalue[AliQAv1::kNBIT];
408 Float_t hightolerancevalue[AliQAv1::kNBIT];
409 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
411 lowtolerancevalue[bit]=(bit*1000.);
412 hightolerancevalue[bit]=((bit+1.)*1000.);
414 SetHiLo(hightolerancevalue,lowtolerancevalue);
415 // AliInfo(Form("Range Value \n INFO -> %f < value < %f \n WARNING -> %f < value <= %f \n ERROR -> %f < value <= %f \n FATAL -> %f <= value < %f \n", fLowTestValue[AliQAv1::kINFO], fUpTestValue[AliQAv1::kINFO], fLowTestValue[AliQAv1::kWARNING], fUpTestValue[AliQAv1::kWARNING], fLowTestValue[AliQAv1::kERROR], fUpTestValue[AliQAv1::kERROR], fLowTestValue[AliQAv1::kFATAL], fUpTestValue[AliQAv1::kFATAL] ));
417 if(fDet == 0 || fDet == 1) {
418 fSPDChecker->SetSPDLimits( lowtolerancevalue,hightolerancevalue );
420 if(fDet == 0 || fDet == 2) {
421 fSDDChecker->SetSDDLimits( lowtolerancevalue,hightolerancevalue );
423 if(fDet == 0 || fDet == 3) {
424 fSSDChecker->SetSSDLimits( lowtolerancevalue,hightolerancevalue );
432 //_____________________________________________________________________________
434 void AliITSQAChecker::CreateStepForBit(Double_t histonumb,Double_t *steprange)
436 for(Int_t bit=0;bit < AliQAv1::kNBIT; bit++)
438 //printf("%i\t %f \t %f \t %f \n",bit, fUpTestValue[bit],fLowTestValue[AliQAv1::kINFO],histonumb);
439 steprange[bit]=double((fUpTestValue[bit] - fLowTestValue[AliQAv1::kINFO])/histonumb);
440 //printf("%i\t %f \t %f \t %f \t %f\n",bit, fUpTestValue[bit],fLowTestValue[AliQAv1::kINFO],histonumb,steprange[bit] );
442 //AliInfo(Form("StepBitValue:numner of histo %f\n\t INFO %f \t WARNING %f \t ERROR %f \t FATAL %f \n",histonumb, steprange[AliQAv1::kINFO],steprange[AliQAv1::kWARNING],steprange[AliQAv1::kERROR],steprange[AliQAv1::kFATAL]));
446 //_____________________________________________________________________________
447 void AliITSQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
450 AliQAv1 * qa = AliQAv1::Instance(index) ;
453 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
455 if (! qa->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)))
457 if ( value == NULL ) { // No checker is implemented, set all QA to Fatal
458 qa->Set(AliQAv1::kFATAL, specie) ;
460 if ( value[specie] > fLowTestValue[AliQAv1::kFATAL] && value[specie] <= fUpTestValue[AliQAv1::kFATAL] )
461 qa->Set(AliQAv1::kFATAL, AliRecoParam::ConvertIndex(specie)) ;
462 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
463 qa->Set(AliQAv1::kERROR, AliRecoParam::ConvertIndex(specie)) ;
464 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
465 qa->Set(AliQAv1::kWARNING, AliRecoParam::ConvertIndex(specie)) ;
466 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
467 qa->Set(AliQAv1::kINFO, AliRecoParam::ConvertIndex(specie)) ;
468 //else if(value[specie]==0) qa->Set(AliQAv1::kFATAL, AliRecoParam::ConvertIndex(specie)) ; //no ckeck has been done
470 qa->ShowStatus(AliQAv1::kITS,index,AliRecoParam::ConvertIndex(specie));
476 //__________________________________________________________________
477 void AliITSQAChecker::MakeImage( TObjArray ** list, AliQAv1::TASKINDEX_t task, AliQAv1::MODE_t mode)
480 //gStyle->SetPalette(1);
482 //Int_t nImages = 0 ;
483 //Int_t imageindex=0;
484 for (Int_t esIndex = 0 ; esIndex < AliRecoParam::kNSpecies ; esIndex++) {
485 if (! AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(esIndex)) )
487 //else imageindex=esIndex;
489 TIter next(list[esIndex]) ;
491 while ( (hdata=static_cast<TH1 *>(next())) ) {
492 TString cln(hdata->ClassName()) ;
493 if ( ! cln.Contains("TH") )
495 if(cln.Contains("TH2")) hdata->SetOption("colz");
500 Bool_t retvalue=kFALSE;
502 if(GetSubDet()==0) MakeITSImage(list,task, mode);
503 else if(GetSubDet()==1)
505 retvalue=fSPDChecker->MakeSPDImage(list,task, mode) ;
506 if(retvalue==kFALSE)AliQACheckerBase::MakeImage(list,task, mode);
508 else if(GetSubDet()==2){ retvalue=fSDDChecker->MakeSDDImage(list,task, mode) ;if(retvalue==kFALSE)AliQACheckerBase::MakeImage(list,task,mode); }
509 else if(GetSubDet()==3)
511 retvalue=fSSDChecker->MakeSSDImage(list,task, mode) ;
512 if(retvalue==kFALSE)AliQACheckerBase::MakeImage(list,task, mode);