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>
28 // --- AliRoot header files ---
29 #include "AliITSQAChecker.h"
30 #include "AliITSQASPDChecker.h"
31 #include "AliITSQASDDChecker.h"
32 #include "AliITSQASSDChecker.h"
33 #include "AliITSQADataMakerRec.h"
35 ClassImp(AliITSQAChecker)
37 //____________________________________________________________________________
38 AliITSQAChecker::AliITSQAChecker(Bool_t kMode, Short_t subDet, Short_t ldc) :
39 AliQACheckerBase("ITS","SDD Quality Assurance Checker"),
49 fSPDChecker(0), // SPD Checker
50 fSDDChecker(0), // SDD Checker
51 fSSDChecker(0) // SSD Checker
54 // Standard constructor
55 fkOnline = kMode; fDet = subDet; fLDC = ldc;
56 if(fDet == 0 || fDet == 1) {
57 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SPD Checker\n");
58 fSPDChecker = new AliITSQASPDChecker();
60 if(fDet == 0 || fDet == 2) {
61 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SDD Checker\n");
62 fSDDChecker = new AliITSQASDDChecker();
64 if(fDet == 0 || fDet == 3) {
65 AliDebug(AliQAv1::GetQADebugLevel(),"AliITSQAChecker::Create SSD Checker\n");
66 fSSDChecker = new AliITSQASSDChecker();
68 InitQACheckerLimits();
71 //____________________________________________________________________________
72 AliITSQAChecker::AliITSQAChecker(const AliITSQAChecker& qac):
73 AliQACheckerBase(qac.GetName(), qac.GetTitle()),
74 fkOnline(qac.fkOnline),
77 fSPDOffset(qac.fSPDOffset),
78 fSDDOffset(qac.fSDDOffset),
79 fSSDOffset(qac.fSSDOffset),
80 fSPDHisto(qac.fSPDHisto),
81 fSDDHisto(qac.fSDDHisto),
82 fSSDHisto(qac.fSSDHisto),
83 fSPDChecker(qac.fSPDChecker),
84 fSDDChecker(qac.fSDDChecker),
85 fSSDChecker(qac.fSSDChecker)
88 AliError("Copy should not be used with this class\n");
90 //____________________________________________________________________________
91 AliITSQAChecker& AliITSQAChecker::operator=(const AliITSQAChecker& qac){
92 // assignment operator
93 this->~AliITSQAChecker();
94 new(this)AliITSQAChecker(qac);
99 //____________________________________________________________________________
100 AliITSQAChecker::~AliITSQAChecker(){
102 if(fSPDChecker)delete fSPDChecker;
103 if(fSDDChecker)delete fSDDChecker;
104 if(fSSDChecker)delete fSSDChecker;
107 //____________________________________________________________________________
108 void AliITSQAChecker::Check(Double_t * rv, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * recoParam)
112 // basic checks on the QA histograms on the input list
113 //for the ITS subdetectorQA (Raws Digits Hits RecPoints SDigits) return the worst value of the three result
114 if(index == AliQAv1::kESD){
116 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
118 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) )
120 AliDebug(AliQAv1::GetQADebugLevel(),"Checker for ESD");
123 // The following flags are set to kTRUE if the corresponding
124 // QA histograms exceed a given quality threshold
125 Bool_t cluMapSA = kFALSE;
126 Bool_t cluMapMI = kFALSE;
127 Bool_t cluMI = kFALSE;
128 Bool_t cluSA = kFALSE;
129 Bool_t verSPDZ = kFALSE;
130 if (list[specie]->GetEntries() == 0) {
131 rv[specie] = 0.; // nothing to check
134 Double_t *stepbit=new Double_t[AliQAv1::kNBIT];
135 Double_t histonumb= list[specie]->GetEntries();
136 CreateStepForBit(histonumb,stepbit);
137 TIter next1(list[specie]);
140 Bool_t skipped[6]={kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE};
141 // look for layers that we wanted to skip
142 while ( (hdata = dynamic_cast<TH1 *>(next1())) ) {
144 TString hname = hdata->GetName();
145 if(!hname.Contains("hESDSkippedLayers")) continue;
146 for(Int_t k=1; k<7; k++) {
147 if(hdata->GetBinContent(k)>0) {
153 TIter next(list[specie]);
154 while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
156 TString hname = hdata->GetName();
157 Double_t entries = hdata->GetEntries();
159 if(!(entries>0.))++empty;
160 AliDebug(AliQAv1::GetQADebugLevel(),Form("ESD hist name %s - entries %12.1g",hname.Data(),entries));
161 if(hname.Contains("hESDClusterMapSA") && entries>0.){
163 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
164 // Check if there are layers with anomalously low
165 // contributing points to SA reconstructed tracks
166 for(Int_t k=1;k<7;k++){
167 // check if the layer was skipped
168 if(skipped[k-1]) continue;
169 if(hdata->GetBinContent(k)<0.5*(entries/6.)){
171 AliDebug(AliQAv1::GetQADebugLevel(),Form("SA tracks have few points on layer %d - look at histogram hESDClustersSA",k));
176 else if(hname.Contains("hESDClusterMapMI") && entries>0.){
177 // Check if there are layers with anomalously low
178 // contributing points to MI reconstructed tracks
179 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
181 for(Int_t k=1;k<7;k++){
182 // check if the layer was skipped
183 if(skipped[k-1]) continue;
184 if(hdata->GetBinContent(k)<0.5*(entries/6.)){
186 AliDebug(AliQAv1::GetQADebugLevel(),Form("MI tracks have few points on layer %d - look at histogram hESDClustersMI",k));
191 else if(hname.Contains("hESDClustersMI") && entries>0.){
192 // Check if 6 clusters MI tracks are the majority
193 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
195 Double_t maxlaytracks = hdata->GetBinContent(7-nskipped);
196 for(Int_t k=2; k<7-nskipped; k++){
197 if(hdata->GetBinContent(k)>maxlaytracks){
199 AliDebug(AliQAv1::GetQADebugLevel(),Form("MI Tracks with %d clusters are more than tracks with %d clusters. Look at histogram hESDClustersMI",k-1,6-nskipped));
204 else if(hname.Contains("hESDClustersSA") && entries>0.){
205 // Check if 6 clusters SA tracks are the majority
206 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
208 Double_t maxlaytracks = hdata->GetBinContent(7-nskipped);
209 for(Int_t k=2; k<7-nskipped; k++){
210 if(hdata->GetBinContent(k)>maxlaytracks){
212 AliDebug(AliQAv1::GetQADebugLevel(), Form("SA Tracks with %d clusters are more than tracks with %d clusters. Look at histogram hESDClustersSA",k-1,6-nskipped));
217 else if(hname.Contains("hSPDVertexZ") && entries>0.){
218 // Check if average Z vertex coordinate is -5 < z < 5 cm
219 AliDebug(AliQAv1::GetQADebugLevel(),Form("Processing histogram %s",hname.Data()));
221 if(hdata->GetMean()<-5. && hdata->GetMean()>5.){
223 AliDebug(AliQAv1::GetQADebugLevel(),Form("Average z vertex coordinate is at z= %10.4g cm",hdata->GetMean()));
228 AliError("ESD Checker - invalid data type");
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
247 // AliDebug(AliQAv1::GetQADebugLevel(), Form("ESD - Tested %d histograms, Return value %f \n",tested,rv[specie]));
248 AliInfo(Form("ESD - Tested %d histograms, Return value %f \n",tested,rv[specie]));
253 //____________________________________________________________________________
255 Double_t spdCheck[AliRecoParam::kNSpecies] ;
256 Double_t sddCheck[AliRecoParam::kNSpecies] ;
257 Double_t ssdCheck[AliRecoParam::kNSpecies] ;
261 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
262 if ( !AliQAv1::Instance()->IsEventSpecieSet(specie)) continue;
263 if ( AliQAv1::Instance()->IsEventSpecieSet(specie) ) {
264 Double_t histotot=list[specie]->GetEntries();
272 if(fDet == 0 || fDet == 1) {
273 fSPDChecker->SetTaskOffset(fSPDOffset);
274 //printf("spdoffset = %i \n",fSPDOffset );
275 Double_t histoSPD=double(GetSPDHisto());
276 if(AliITSQADataMakerRec::AreEqual(histoSPD,0)==kFALSE){
277 Double_t *stepSPD=new Double_t[AliQAv1::kNBIT];
278 CreateStepForBit(histoSPD,stepSPD);
279 fSPDChecker->SetStepBit(stepSPD);
280 spdCheck[specie] = fSPDChecker->Check(index, list[specie], recoParam);
281 if(spdCheck[specie]>fUpTestValue[AliQAv1::kFATAL]||spdCheck[specie]<0.)
283 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)));
284 spdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];
287 }//end check SPD entries
288 else{spdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];}
289 rv[specie]=spdCheck[specie];
292 if(fDet == 0 || fDet == 2) {
293 fSDDChecker->SetTaskOffset(fSDDOffset);
294 Double_t histoSDD=double(GetSDDHisto());
295 if(AliITSQADataMakerRec::AreEqual(histoSDD,0)==kFALSE){
296 Double_t *stepSDD=new Double_t[AliQAv1::kNBIT];
297 CreateStepForBit(histoSDD,stepSDD);
298 fSDDChecker->SetStepBit(stepSDD);
299 sddCheck[specie] = fSDDChecker->Check(index, list[specie], recoParam);
300 if(sddCheck[specie]>fUpTestValue[AliQAv1::kFATAL]||sddCheck[specie]<0.)
302 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)));
303 sddCheck[specie]=fUpTestValue[AliQAv1::kFATAL];
306 }//end check SDD entries
307 else{ssdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];}
308 if(sddCheck[specie]>rv[specie])rv[specie]=sddCheck[specie];
311 if(fDet == 0 || fDet == 3) {
312 fSSDChecker->SetTaskOffset(fSSDOffset);
313 Double_t histoSSD=double(GetSSDHisto());
314 if(AliITSQADataMakerRec::AreEqual(histoSSD,0)==kFALSE){
315 Double_t *stepSSD=new Double_t[AliQAv1::kNBIT];
316 CreateStepForBit(histoSSD,stepSSD);
317 fSSDChecker->SetStepBit(stepSSD);
318 ssdCheck[specie] = fSSDChecker->Check(index, list[specie], recoParam);
319 if(ssdCheck[specie]>fUpTestValue[AliQAv1::kFATAL]||ssdCheck[specie]<0.)
321 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)));
322 ssdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];
325 }//end check SSD entries
326 else{ssdCheck[specie]=fUpTestValue[AliQAv1::kFATAL];}
327 if(ssdCheck[specie]>rv[specie])rv[specie]=ssdCheck[specie];
330 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]));
331 // here merging part for common ITS QA result
334 }//end if event specie
339 //____________________________________________________________________________
340 void AliITSQAChecker::SetTaskOffset(Int_t SPDOffset, Int_t SDDOffset, Int_t SSDOffset)
342 //Setting the 3 offsets for each task called
343 fSPDOffset = SPDOffset;
344 fSDDOffset = SDDOffset;
345 fSSDOffset = SSDOffset;
348 //____________________________________________________________________________
349 void AliITSQAChecker::SetHisto(Int_t SPDhisto, Int_t SDDhisto, Int_t SSDhisto)
351 //Setting the 3 offsets for each task called
352 fSPDHisto = SPDhisto;
353 fSDDHisto = SDDhisto;
354 fSSDHisto = SSDhisto;
357 //____________________________________________________________________________
358 void AliITSQAChecker::SetDetTaskOffset(Int_t subdet,Int_t offset)
362 SetSPDTaskOffset(offset);
365 SetSDDTaskOffset(offset);
368 SetSSDTaskOffset(offset);
371 AliWarning("No specific (SPD,SDD or SSD) subdetector correspond to to this number!!! all offsets set to zero for all the detectors\n");
372 SetTaskOffset(0, 0, 0);
377 //____________________________________________________________________________
378 void AliITSQAChecker::SetDetHisto(Int_t subdet,Int_t histo)
391 AliWarning("No specific (SPD,SDD or SSD) subdetector correspond to to this number!!! all offsets set to zero for all the detectors\n");
397 //_____________________________________________________________________________
399 void AliITSQAChecker::InitQACheckerLimits()
402 AliInfo("Setting of tolerance values\n");
404 Float_t lowtolerancevalue[AliQAv1::kNBIT];
406 Float_t hightolerancevalue[AliQAv1::kNBIT];
407 for(Int_t bit=0;bit<AliQAv1::kNBIT;bit++)
409 lowtolerancevalue[bit]=(bit*1000.);
410 hightolerancevalue[bit]=((bit+1.)*1000.);
412 SetHiLo(hightolerancevalue,lowtolerancevalue);
413 // 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] ));
415 if(fDet == 0 || fDet == 1) {
416 fSPDChecker->SetSPDLimits( lowtolerancevalue,hightolerancevalue );
418 if(fDet == 0 || fDet == 2) {
419 fSDDChecker->SetSDDLimits( lowtolerancevalue,hightolerancevalue );
421 if(fDet == 0 || fDet == 3) {
422 fSSDChecker->SetSSDLimits( lowtolerancevalue,hightolerancevalue );
430 //_____________________________________________________________________________
432 void AliITSQAChecker::CreateStepForBit(Double_t histonumb,Double_t *steprange)
434 for(Int_t bit=0;bit < AliQAv1::kNBIT; bit++)
436 //printf("%i\t %f \t %f \t %f \n",bit, fUpTestValue[bit],fLowTestValue[AliQAv1::kINFO],histonumb);
437 steprange[bit]=double((fUpTestValue[bit] - fLowTestValue[AliQAv1::kINFO])/histonumb);
438 //printf("%i\t %f \t %f \t %f \t %f\n",bit, fUpTestValue[bit],fLowTestValue[AliQAv1::kINFO],histonumb,steprange[bit] );
440 //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]));
444 //_____________________________________________________________________________
445 void AliITSQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
448 AliQAv1 * qa = AliQAv1::Instance(index) ;
451 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
453 if (! qa->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)))
455 if ( value == NULL ) { // No checker is implemented, set all QA to Fatal
456 qa->Set(AliQAv1::kFATAL, specie) ;
458 if ( value[specie] > fLowTestValue[AliQAv1::kFATAL] && value[specie] <= fUpTestValue[AliQAv1::kFATAL] )
459 qa->Set(AliQAv1::kFATAL, AliRecoParam::ConvertIndex(specie)) ;
460 else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] )
461 qa->Set(AliQAv1::kERROR, AliRecoParam::ConvertIndex(specie)) ;
462 else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] )
463 qa->Set(AliQAv1::kWARNING, AliRecoParam::ConvertIndex(specie)) ;
464 else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] )
465 qa->Set(AliQAv1::kINFO, AliRecoParam::ConvertIndex(specie)) ;
466 //else if(value[specie]==0) qa->Set(AliQAv1::kFATAL, AliRecoParam::ConvertIndex(specie)) ; //no ckeck has been done
468 qa->ShowStatus(AliQAv1::kITS,index,AliRecoParam::ConvertIndex(specie));