1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 ///////////////////////////////////////////////////////////////////////////////
20 // class for running the Quality Assurance Checker
22 ///////////////////////////////////////////////////////////////////////////////
25 #include "AliModule.h"
27 #include "AliQAChecker.h"
28 #include "AliQACheckerBase.h"
31 #include <TObjArray.h>
32 #include <TPluginManager.h>
34 #include <TStopwatch.h>
39 ClassImp(AliQAChecker)
40 AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ;
42 //_____________________________________________________________________________
43 AliQAChecker::AliQAChecker(const char* name, const char* title) :
48 // ctor: initialise checkers and open the data file
49 for (Int_t det = 0 ; det < AliQA::kNDET ; det++)
50 fCheckers[det] = NULL ;
53 //_____________________________________________________________________________
54 AliQAChecker::AliQAChecker(const AliQAChecker& qac) :
56 fDataFile(qac.fDataFile),
57 fFoundDetectors(qac.fFoundDetectors)
61 for (Int_t det = 0 ; det < AliQA::kNDET ; det++)
62 fCheckers[det] = NULL ;
65 //_____________________________________________________________________________
66 AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac)
68 // assignment operator
70 this->~AliQAChecker();
71 new(this) AliQAChecker(qac);
75 //_____________________________________________________________________________
76 AliQAChecker::~AliQAChecker()
83 //_____________________________________________________________________________
84 AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det)
86 // Gets the Quality Assurance checker for the detector specified by its name
89 return fCheckers[det];
91 TString detName(AliQA::GetDetName(det)) ;
93 AliInfo(Form("Retrieving QA checker for %s", detName.Data())) ;
94 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
95 TString qacName = "Ali" + detName + "QAChecker" ;
97 AliQACheckerBase * qac = NULL ;
98 // first check if a plugin is defined for the quality assurance checker
99 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data());
100 // if not, add a plugin for it
101 if (!pluginHandler) {
102 //AliInfo(Form("defining plugin for %s", qacName.Data()));
103 TString libs = gSystem->GetLibraries();
105 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0))
106 pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()");
108 pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()");
110 pluginHandler = pluginManager->FindHandler("AliQAChecker", detName);
112 if (pluginHandler && (pluginHandler->LoadPlugin() == 0))
113 qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0);
116 fCheckers[det] = qac ;
123 //_____________________________________________________________________________
124 TDirectory * AliQAChecker::GetRefSubDir(const char * det, const char * task)
126 // Opens and returns the file with the reference data
127 TFile * f = AliQA::GetQARefFile() ; //TFile::Open(fRefDirName, "READ") ;
128 TDirectory * rv = NULL ;
130 AliError(Form("Cannot find reference file %s", (AliQA::GetQARefFileName()))) ;
133 rv = f->GetDirectory(det) ;
135 AliWarning(Form("Directory %s not found in %d", det, (AliQA::GetQARefFileName()))) ;
137 rv = rv->GetDirectory(task) ;
139 AliWarning(Form("Directory %s/%s not found in %s", det, task, (AliQA::GetQARefFileName()))) ;
144 //_____________________________________________________________________________
145 AliQAChecker * AliQAChecker::Instance()
147 // returns unique instance of the checker
149 fgQAChecker = new AliQAChecker() ;
153 //_____________________________________________________________________________
154 Bool_t AliQAChecker::Run(const char * fileName)
156 // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs
157 // starting from data in file
161 TStopwatch stopwatch;
164 //search for all detectors QA directories
165 TList * detKeyList = AliQA::GetQADataFile(fileName)->GetListOfKeys() ;
166 TIter nextd(detKeyList) ;
168 while ( (detKey = dynamic_cast<TKey *>(nextd()) ) ) {
169 AliInfo(Form("Found %s", detKey->GetName())) ;
170 //Check which detector
172 TString detNameQA(detKey->GetName()) ;
174 for ( det = 0; det < AliQA::kNDET ; det++) {
175 detName = AliQA::GetDetName(det) ;
176 if (detNameQA.Contains(detName)) {
177 fFoundDetectors+=detName ;
178 fFoundDetectors+="." ;
182 TDirectory * detDir = AliQA::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ;
183 TList * taskKeyList = detDir->GetListOfKeys() ;
184 TIter nextt(taskKeyList) ;
186 // now search for the tasks dir
187 while ( (taskKey = static_cast<TKey *>(nextt()) ) ) {
188 TString taskName( taskKey->GetName() ) ;
189 AliInfo(Form("Found %s", taskName.Data())) ;
190 TDirectory * taskDir = detDir->GetDirectory(taskName.Data()) ;
192 AliQACheckerBase * qac = GetDetQAChecker(det) ;
194 AliInfo(Form("QA checker found for %s", detName.Data())) ;
196 AliFatal(Form("QA checker not found for %s", detName.Data())) ;
197 AliQA::ALITASK index = AliQA::kNULLTASK ;
198 if ( taskName == AliQA::GetTaskName(AliQA::kHITS) )
199 index = AliQA::kSIM ;
200 if ( taskName == AliQA::GetTaskName(AliQA::kSDIGITS) )
201 index = AliQA::kSIM ;
202 if ( taskName == AliQA::GetTaskName(AliQA::kDIGITS) )
203 index = AliQA::kSIM ;
204 if ( taskName == AliQA::GetTaskName(AliQA::kRECPOINTS) )
205 index = AliQA::kREC ;
206 if ( taskName == AliQA::GetTaskName(AliQA::kTRACKSEGMENTS) )
207 index = AliQA::kREC ;
208 if ( taskName == AliQA::GetTaskName(AliQA::kRECPARTICLES) )
209 index = AliQA::kREC ;
210 if ( taskName == AliQA::GetTaskName(AliQA::kESDS) )
211 index = AliQA::kESD ;
212 qac->Init(AliQA::DETECTORINDEX(det)) ;
214 TDirectory * refDir = GetRefSubDir(detNameQA.Data(), taskName.Data()) ;
216 qac->SetRefandData(refDir, taskDir) ;
221 AliInfo("QA performed for following detectors:") ;
222 for ( Int_t det = 0; det < AliQA::kNDET; det++) {
223 if (fFoundDetectors.Contains(AliQA::GetDetName(det))) {
224 printf("%s, ",AliQA::GetDetName(det)) ;
225 fFoundDetectors.ReplaceAll(AliQA::GetDetName(det), "") ;
235 //_____________________________________________________________________________
236 Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task, TList * list)
238 // run the Quality Assurance Checker for detector det, for task task starting from data in list
240 AliQACheckerBase * qac = GetDetQAChecker(det) ;
242 AliInfo(Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ;
244 AliFatal(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ;
246 AliQA::ALITASK index = AliQA::kNULLTASK ;
247 if ( task == AliQA::kRAWS )
248 index = AliQA::kRAW ;
249 else if ( task == AliQA::kHITS )
250 index = AliQA::kSIM ;
251 else if ( task == AliQA::kSDIGITS )
252 index = AliQA::kSIM ;
253 else if ( task == AliQA::kDIGITS )
254 index = AliQA::kSIM ;
255 else if ( task == AliQA::kRECPOINTS )
256 index = AliQA::kREC ;
257 else if ( task == AliQA::kTRACKSEGMENTS )
258 index = AliQA::kREC ;
259 else if ( task == AliQA::kRECPARTICLES )
260 index = AliQA::kREC ;
261 else if ( task == AliQA::kESDS )
262 index = AliQA::kESD ;
263 TDirectory * refDir = GetRefSubDir(AliQA::GetDetName(det).Data(), AliQA::GetTaskName(task).Data()) ;
266 qac->SetRefandData(refDir) ;
267 qac->Run(index, list) ;