]>
Commit | Line | Data |
---|---|---|
421ab0fb | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | // // | |
20 | // class for running the Quality Assurance Checker | |
21 | // // | |
22 | /////////////////////////////////////////////////////////////////////////////// | |
23 | ||
4edbc5bc | 24 | #include "AliCDBEntry.h" |
25 | #include "AliCDBManager.h" | |
421ab0fb | 26 | #include "AliLog.h" |
27 | #include "AliModule.h" | |
2e42b4d4 | 28 | #include "AliQA.h" |
29 | #include "AliQAChecker.h" | |
30 | #include "AliQACheckerBase.h" | |
421ab0fb | 31 | |
a5fa6165 | 32 | #include <TKey.h> |
421ab0fb | 33 | #include <TObjArray.h> |
a5fa6165 | 34 | #include <TPluginManager.h> |
35 | #include <TROOT.h> | |
421ab0fb | 36 | #include <TStopwatch.h> |
37 | #include <TString.h> | |
a5fa6165 | 38 | #include <TSystem.h> |
a4976ef3 | 39 | #include <TList.h> |
421ab0fb | 40 | |
2e42b4d4 | 41 | ClassImp(AliQAChecker) |
42 | AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ; | |
421ab0fb | 43 | |
44 | //_____________________________________________________________________________ | |
2e42b4d4 | 45 | AliQAChecker::AliQAChecker(const char* name, const char* title) : |
421ab0fb | 46 | TNamed(name, title), |
a5fa6165 | 47 | fDataFile(0x0), |
4edbc5bc | 48 | fRefFile(0x0), |
a5fa6165 | 49 | fFoundDetectors(".") |
421ab0fb | 50 | { |
a5fa6165 | 51 | // ctor: initialise checkers and open the data file |
2e42b4d4 | 52 | for (Int_t det = 0 ; det < AliQA::kNDET ; det++) |
a5fa6165 | 53 | fCheckers[det] = NULL ; |
421ab0fb | 54 | } |
55 | ||
56 | //_____________________________________________________________________________ | |
2e42b4d4 | 57 | AliQAChecker::AliQAChecker(const AliQAChecker& qac) : |
421ab0fb | 58 | TNamed(qac), |
a5fa6165 | 59 | fDataFile(qac.fDataFile), |
4edbc5bc | 60 | fRefFile(qac.fRefFile), |
a5fa6165 | 61 | fFoundDetectors(qac.fFoundDetectors) |
421ab0fb | 62 | { |
a5fa6165 | 63 | // copy constructor |
64 | ||
2e42b4d4 | 65 | for (Int_t det = 0 ; det < AliQA::kNDET ; det++) |
a5fa6165 | 66 | fCheckers[det] = NULL ; |
421ab0fb | 67 | } |
68 | ||
69 | //_____________________________________________________________________________ | |
2e42b4d4 | 70 | AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac) |
421ab0fb | 71 | { |
72 | // assignment operator | |
73 | ||
2e42b4d4 | 74 | this->~AliQAChecker(); |
75 | new(this) AliQAChecker(qac); | |
421ab0fb | 76 | return *this; |
77 | } | |
78 | ||
79 | //_____________________________________________________________________________ | |
2e42b4d4 | 80 | AliQAChecker::~AliQAChecker() |
421ab0fb | 81 | { |
82 | // clean up | |
a4976ef3 | 83 | delete [] fCheckers ; |
8bea2de0 | 84 | AliQA::Close() ; |
421ab0fb | 85 | } |
86 | ||
87 | //_____________________________________________________________________________ | |
2e42b4d4 | 88 | AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det) |
421ab0fb | 89 | { |
a5fa6165 | 90 | // Gets the Quality Assurance checker for the detector specified by its name |
91 | ||
92 | if (fCheckers[det]) | |
93 | return fCheckers[det]; | |
94 | ||
2e42b4d4 | 95 | TString detName(AliQA::GetDetName(det)) ; |
a5fa6165 | 96 | |
97 | AliInfo(Form("Retrieving QA checker for %s", detName.Data())) ; | |
98 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
2e42b4d4 | 99 | TString qacName = "Ali" + detName + "QAChecker" ; |
a5fa6165 | 100 | |
2e42b4d4 | 101 | AliQACheckerBase * qac = NULL ; |
a5fa6165 | 102 | // first check if a plugin is defined for the quality assurance checker |
2e42b4d4 | 103 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data()); |
a5fa6165 | 104 | // if not, add a plugin for it |
105 | if (!pluginHandler) { | |
106 | //AliInfo(Form("defining plugin for %s", qacName.Data())); | |
107 | TString libs = gSystem->GetLibraries(); | |
108 | ||
109 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) | |
2e42b4d4 | 110 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()"); |
a5fa6165 | 111 | else |
2e42b4d4 | 112 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()"); |
a5fa6165 | 113 | |
2e42b4d4 | 114 | pluginHandler = pluginManager->FindHandler("AliQAChecker", detName); |
a5fa6165 | 115 | |
116 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) | |
2e42b4d4 | 117 | qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0); |
a5fa6165 | 118 | |
119 | if (qac) | |
120 | fCheckers[det] = qac ; | |
421ab0fb | 121 | } |
a5fa6165 | 122 | |
123 | return qac ; | |
124 | } | |
125 | ||
126 | ||
127 | //_____________________________________________________________________________ | |
f73f556a | 128 | void AliQAChecker::GetRefSubDir(const char * det, const char * task, TDirectory *& dirFile, TObjArray *& dirOCDB) |
a5fa6165 | 129 | { |
130 | // Opens and returns the file with the reference data | |
4edbc5bc | 131 | |
132 | dirFile = NULL ; | |
133 | dirOCDB = NULL ; | |
134 | TString refStorage(AliQA::GetQARefStorage()) ; | |
135 | refStorage += AliQA::GetQARefFileName() ; | |
136 | if (refStorage.Contains(AliQA::GetLabLocalFile())) { | |
137 | refStorage.ReplaceAll(AliQA::GetLabLocalFile(), "") ; | |
138 | if ( fRefFile ) | |
139 | if ( fRefFile->IsOpen() ) | |
140 | fRefFile->Close() ; | |
141 | fRefFile = TFile::Open(refStorage.Data()) ; | |
142 | if (!fRefFile) { | |
143 | AliError(Form("Cannot find reference file %s", refStorage.Data())) ; | |
144 | dirFile = NULL ; | |
145 | } | |
146 | dirFile = fRefFile->GetDirectory(det) ; | |
147 | if (!dirFile) { | |
148 | AliWarning(Form("Directory %s not found in %d", det, refStorage.Data())) ; | |
149 | } else { | |
150 | dirFile = dirFile->GetDirectory(task) ; | |
151 | if (!dirFile) | |
152 | AliWarning(Form("Directory %s/%s not found in %s", det, task, refStorage.Data())) ; | |
153 | } | |
154 | } else if (refStorage.Contains(AliQA::GetLabLocalOCDB()) || refStorage.Contains(AliQA::GetLabAliEnOCDB())) { | |
155 | AliCDBManager* man = AliCDBManager::Instance() ; | |
f73f556a | 156 | if ( ! man->IsDefaultStorageSet() ) { |
157 | man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ; | |
158 | man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ; | |
159 | } | |
4edbc5bc | 160 | char detOCDBDir[20] ; |
f73f556a | 161 | sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), det, AliQA::GetRefOCDBDirName()) ; |
162 | AliCDBEntry * entry = man->Get(detOCDBDir, 0) ; //FIXME 0 --> RUN NUMBER | |
163 | if (entry) { | |
164 | TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ; | |
165 | if ( listDetQAD ) | |
166 | dirOCDB = dynamic_cast<TObjArray *>(listDetQAD->FindObject(task)) ; | |
167 | } | |
4edbc5bc | 168 | } |
421ab0fb | 169 | } |
170 | ||
a4976ef3 | 171 | //_____________________________________________________________________________ |
2e42b4d4 | 172 | AliQAChecker * AliQAChecker::Instance() |
a4976ef3 | 173 | { |
174 | // returns unique instance of the checker | |
175 | if ( ! fgQAChecker ) | |
2e42b4d4 | 176 | fgQAChecker = new AliQAChecker() ; |
a4976ef3 | 177 | return fgQAChecker ; |
178 | } | |
179 | ||
421ab0fb | 180 | //_____________________________________________________________________________ |
808b7099 | 181 | Bool_t AliQAChecker::Run(const char * fileName) |
421ab0fb | 182 | { |
a5fa6165 | 183 | // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs |
a4976ef3 | 184 | // starting from data in file |
421ab0fb | 185 | |
186 | Bool_t rv = kFALSE ; | |
a5fa6165 | 187 | |
421ab0fb | 188 | TStopwatch stopwatch; |
189 | stopwatch.Start(); | |
190 | ||
a5fa6165 | 191 | //search for all detectors QA directories |
8bea2de0 | 192 | TList * detKeyList = AliQA::GetQADataFile(fileName)->GetListOfKeys() ; |
a5fa6165 | 193 | TIter nextd(detKeyList) ; |
194 | TKey * detKey ; | |
195 | while ( (detKey = dynamic_cast<TKey *>(nextd()) ) ) { | |
196 | AliInfo(Form("Found %s", detKey->GetName())) ; | |
197 | //Check which detector | |
198 | TString detName ; | |
199 | TString detNameQA(detKey->GetName()) ; | |
200 | Int_t det ; | |
2e42b4d4 | 201 | for ( det = 0; det < AliQA::kNDET ; det++) { |
202 | detName = AliQA::GetDetName(det) ; | |
a5fa6165 | 203 | if (detNameQA.Contains(detName)) { |
204 | fFoundDetectors+=detName ; | |
205 | fFoundDetectors+="." ; | |
206 | break ; | |
207 | } | |
208 | } | |
8bea2de0 | 209 | TDirectory * detDir = AliQA::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ; |
a5fa6165 | 210 | TList * taskKeyList = detDir->GetListOfKeys() ; |
211 | TIter nextt(taskKeyList) ; | |
212 | TKey * taskKey ; | |
213 | // now search for the tasks dir | |
214 | while ( (taskKey = static_cast<TKey *>(nextt()) ) ) { | |
215 | TString taskName( taskKey->GetName() ) ; | |
216 | AliInfo(Form("Found %s", taskName.Data())) ; | |
217 | TDirectory * taskDir = detDir->GetDirectory(taskName.Data()) ; | |
218 | taskDir->cd() ; | |
2e42b4d4 | 219 | AliQACheckerBase * qac = GetDetQAChecker(det) ; |
a5fa6165 | 220 | if (qac) |
a4976ef3 | 221 | AliInfo(Form("QA checker found for %s", detName.Data())) ; |
a5fa6165 | 222 | if (!qac) |
a4976ef3 | 223 | AliFatal(Form("QA checker not found for %s", detName.Data())) ; |
2e42b4d4 | 224 | AliQA::ALITASK index = AliQA::kNULLTASK ; |
225 | if ( taskName == AliQA::GetTaskName(AliQA::kHITS) ) | |
226 | index = AliQA::kSIM ; | |
227 | if ( taskName == AliQA::GetTaskName(AliQA::kSDIGITS) ) | |
228 | index = AliQA::kSIM ; | |
229 | if ( taskName == AliQA::GetTaskName(AliQA::kDIGITS) ) | |
230 | index = AliQA::kSIM ; | |
231 | if ( taskName == AliQA::GetTaskName(AliQA::kRECPOINTS) ) | |
232 | index = AliQA::kREC ; | |
233 | if ( taskName == AliQA::GetTaskName(AliQA::kTRACKSEGMENTS) ) | |
234 | index = AliQA::kREC ; | |
235 | if ( taskName == AliQA::GetTaskName(AliQA::kRECPARTICLES) ) | |
236 | index = AliQA::kREC ; | |
237 | if ( taskName == AliQA::GetTaskName(AliQA::kESDS) ) | |
238 | index = AliQA::kESD ; | |
239 | qac->Init(AliQA::DETECTORINDEX(det)) ; | |
10a28129 | 240 | |
f73f556a | 241 | TDirectory * refDir = NULL ; |
242 | TObjArray * refOCDBDir = NULL ; | |
4edbc5bc | 243 | GetRefSubDir(detNameQA.Data(), taskName.Data(), refDir, refOCDBDir) ; |
244 | if ( refDir || refOCDBDir) { | |
245 | qac->SetRefandData(refDir, refOCDBDir, taskDir) ; | |
246 | qac->Run(index) ; | |
ac2bb64a | 247 | } |
4edbc5bc | 248 | } |
249 | } | |
a5fa6165 | 250 | AliInfo("QA performed for following detectors:") ; |
2e42b4d4 | 251 | for ( Int_t det = 0; det < AliQA::kNDET; det++) { |
252 | if (fFoundDetectors.Contains(AliQA::GetDetName(det))) { | |
253 | printf("%s, ",AliQA::GetDetName(det)) ; | |
254 | fFoundDetectors.ReplaceAll(AliQA::GetDetName(det), "") ; | |
a5fa6165 | 255 | } |
421ab0fb | 256 | } |
a5fa6165 | 257 | printf("\n") ; |
258 | rv = kTRUE ; | |
421ab0fb | 259 | |
a5fa6165 | 260 | return rv ; |
261 | ||
421ab0fb | 262 | } |
263 | ||
a4976ef3 | 264 | //_____________________________________________________________________________ |
4edbc5bc | 265 | Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task, TObjArray * list) |
a4976ef3 | 266 | { |
267 | // run the Quality Assurance Checker for detector det, for task task starting from data in list | |
268 | ||
2e42b4d4 | 269 | AliQACheckerBase * qac = GetDetQAChecker(det) ; |
a4976ef3 | 270 | if (qac) |
2e42b4d4 | 271 | AliInfo(Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ; |
a4976ef3 | 272 | if (!qac) |
2e42b4d4 | 273 | AliFatal(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ; |
a4976ef3 | 274 | |
2e42b4d4 | 275 | AliQA::ALITASK index = AliQA::kNULLTASK ; |
276 | if ( task == AliQA::kRAWS ) | |
277 | index = AliQA::kRAW ; | |
278 | else if ( task == AliQA::kHITS ) | |
279 | index = AliQA::kSIM ; | |
280 | else if ( task == AliQA::kSDIGITS ) | |
281 | index = AliQA::kSIM ; | |
282 | else if ( task == AliQA::kDIGITS ) | |
283 | index = AliQA::kSIM ; | |
284 | else if ( task == AliQA::kRECPOINTS ) | |
285 | index = AliQA::kREC ; | |
286 | else if ( task == AliQA::kTRACKSEGMENTS ) | |
287 | index = AliQA::kREC ; | |
288 | else if ( task == AliQA::kRECPARTICLES ) | |
289 | index = AliQA::kREC ; | |
290 | else if ( task == AliQA::kESDS ) | |
291 | index = AliQA::kESD ; | |
4edbc5bc | 292 | |
f73f556a | 293 | TDirectory * refDir = NULL ; |
294 | TObjArray * refOCDBDir = NULL ; | |
4edbc5bc | 295 | GetRefSubDir(AliQA::GetDetName(det), AliQA::GetTaskName(task), refDir, refOCDBDir) ; |
296 | if ( refDir || refOCDBDir) { | |
297 | qac->Init(det) ; | |
298 | qac->SetRefandData(refDir, refOCDBDir) ; | |
299 | qac->Run(index, list) ; | |
10a28129 | 300 | } |
a4976ef3 | 301 | return kTRUE ; |
302 | ||
303 | } | |
304 | ||
421ab0fb | 305 | |
306 |