]>
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" | |
96d67a8d | 26 | #include "AliCDBStorage.h" |
7e88424f | 27 | #include "AliRunInfo.h" |
421ab0fb | 28 | #include "AliLog.h" |
29 | #include "AliModule.h" | |
2e42b4d4 | 30 | #include "AliQA.h" |
31 | #include "AliQAChecker.h" | |
32 | #include "AliQACheckerBase.h" | |
421ab0fb | 33 | |
a5fa6165 | 34 | #include <TKey.h> |
421ab0fb | 35 | #include <TObjArray.h> |
cbae8032 | 36 | #include <TObjString.h> |
a5fa6165 | 37 | #include <TPluginManager.h> |
38 | #include <TROOT.h> | |
421ab0fb | 39 | #include <TStopwatch.h> |
40 | #include <TString.h> | |
a5fa6165 | 41 | #include <TSystem.h> |
a4976ef3 | 42 | #include <TList.h> |
421ab0fb | 43 | |
2e42b4d4 | 44 | ClassImp(AliQAChecker) |
45 | AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ; | |
421ab0fb | 46 | |
47 | //_____________________________________________________________________________ | |
2e42b4d4 | 48 | AliQAChecker::AliQAChecker(const char* name, const char* title) : |
421ab0fb | 49 | TNamed(name, title), |
a5fa6165 | 50 | fDataFile(0x0), |
7e88424f | 51 | fRunInfo(0x0), |
52 | fRunInfoOwner(kFALSE), | |
4edbc5bc | 53 | fRefFile(0x0), |
a5fa6165 | 54 | fFoundDetectors(".") |
421ab0fb | 55 | { |
a5fa6165 | 56 | // ctor: initialise checkers and open the data file |
2e42b4d4 | 57 | for (Int_t det = 0 ; det < AliQA::kNDET ; det++) |
a5fa6165 | 58 | fCheckers[det] = NULL ; |
421ab0fb | 59 | } |
60 | ||
61 | //_____________________________________________________________________________ | |
2e42b4d4 | 62 | AliQAChecker::AliQAChecker(const AliQAChecker& qac) : |
421ab0fb | 63 | TNamed(qac), |
a5fa6165 | 64 | fDataFile(qac.fDataFile), |
7e88424f | 65 | fRunInfo(qac.fRunInfo), |
66 | fRunInfoOwner(kFALSE), | |
4edbc5bc | 67 | fRefFile(qac.fRefFile), |
a5fa6165 | 68 | fFoundDetectors(qac.fFoundDetectors) |
421ab0fb | 69 | { |
a5fa6165 | 70 | // copy constructor |
71 | ||
2e42b4d4 | 72 | for (Int_t det = 0 ; det < AliQA::kNDET ; det++) |
a5fa6165 | 73 | fCheckers[det] = NULL ; |
421ab0fb | 74 | } |
75 | ||
76 | //_____________________________________________________________________________ | |
2e42b4d4 | 77 | AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac) |
421ab0fb | 78 | { |
79 | // assignment operator | |
80 | ||
2e42b4d4 | 81 | this->~AliQAChecker(); |
82 | new(this) AliQAChecker(qac); | |
421ab0fb | 83 | return *this; |
84 | } | |
85 | ||
86 | //_____________________________________________________________________________ | |
2e42b4d4 | 87 | AliQAChecker::~AliQAChecker() |
421ab0fb | 88 | { |
89 | // clean up | |
7e88424f | 90 | if (fRunInfo) |
91 | delete fRunInfo ; | |
a4976ef3 | 92 | delete [] fCheckers ; |
8bea2de0 | 93 | AliQA::Close() ; |
421ab0fb | 94 | } |
95 | ||
96 | //_____________________________________________________________________________ | |
2e42b4d4 | 97 | AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det) |
421ab0fb | 98 | { |
7ce961eb | 99 | // Gets the Quality Assurance checker for the detector specified by its name |
100 | ||
101 | if (fCheckers[det]) | |
a5fa6165 | 102 | return fCheckers[det]; |
103 | ||
7ce961eb | 104 | TString detName(AliQA::GetDetName(det)) ; |
a5fa6165 | 105 | |
54a7f3ac | 106 | AliDebug(1, Form("Retrieving QA checker for %s", detName.Data())) ; |
a5fa6165 | 107 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; |
2e42b4d4 | 108 | TString qacName = "Ali" + detName + "QAChecker" ; |
a5fa6165 | 109 | |
2e42b4d4 | 110 | AliQACheckerBase * qac = NULL ; |
a5fa6165 | 111 | // first check if a plugin is defined for the quality assurance checker |
2e42b4d4 | 112 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data()); |
a5fa6165 | 113 | // if not, add a plugin for it |
114 | if (!pluginHandler) { | |
115 | //AliInfo(Form("defining plugin for %s", qacName.Data())); | |
116 | TString libs = gSystem->GetLibraries(); | |
7ce961eb | 117 | |
118 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) | |
2e42b4d4 | 119 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()"); |
7ce961eb | 120 | else |
2e42b4d4 | 121 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()"); |
a5fa6165 | 122 | |
7ce961eb | 123 | pluginHandler = pluginManager->FindHandler("AliQAChecker", detName); |
a5fa6165 | 124 | |
7ce961eb | 125 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) |
126 | qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0); | |
a5fa6165 | 127 | |
7ce961eb | 128 | if (qac) |
129 | fCheckers[det] = qac ; | |
130 | } | |
a5fa6165 | 131 | |
132 | return qac ; | |
133 | } | |
cbae8032 | 134 | |
a5fa6165 | 135 | //_____________________________________________________________________________ |
f73f556a | 136 | void AliQAChecker::GetRefSubDir(const char * det, const char * task, TDirectory *& dirFile, TObjArray *& dirOCDB) |
a5fa6165 | 137 | { |
138 | // Opens and returns the file with the reference data | |
4edbc5bc | 139 | |
cbae8032 | 140 | dirFile = NULL ; |
141 | dirOCDB = NULL ; | |
142 | TString refStorage(AliQA::GetQARefStorage()) ; | |
143 | //refStorage += AliQA::GetQARefFileName() ; | |
144 | if (refStorage.Contains(AliQA::GetLabLocalFile())) { | |
145 | refStorage.ReplaceAll(AliQA::GetLabLocalFile(), "") ; | |
146 | if ( fRefFile ) | |
147 | if ( fRefFile->IsOpen() ) | |
7ce961eb | 148 | fRefFile->Close() ; |
cbae8032 | 149 | fRefFile = TFile::Open(refStorage.Data()) ; |
150 | if (!fRefFile) { | |
151 | AliError(Form("Cannot find reference file %s", refStorage.Data())) ; | |
152 | dirFile = NULL ; | |
153 | } | |
154 | dirFile = fRefFile->GetDirectory(det) ; | |
155 | if (!dirFile) { | |
156 | AliWarning(Form("Directory %s not found in %d", det, refStorage.Data())) ; | |
157 | } else { | |
7ce961eb | 158 | dirFile = dirFile->GetDirectory(task) ; |
cbae8032 | 159 | if (!dirFile) |
7ce961eb | 160 | AliWarning(Form("Directory %s/%s not found in %s", det, task, refStorage.Data())) ; |
cbae8032 | 161 | } |
162 | } else if (refStorage.Contains(AliQA::GetLabLocalOCDB()) || refStorage.Contains(AliQA::GetLabAliEnOCDB())) { | |
163 | AliCDBManager* man = AliCDBManager::Instance() ; | |
164 | if ( strcmp(AliQA::GetRefDataDirName(), "") == 0 ) { // the name of the last level of the directory is not set (RUNTYPE) | |
7e88424f | 165 | // Get it from RunInfo |
166 | if (!fRunInfo) // not yet set, get the info from GRP | |
167 | LoadRunInfoFromGRP() ; | |
168 | AliQA::SetQARefDataDirName(fRunInfo->GetRunType()) ; | |
cbae8032 | 169 | } |
170 | if ( ! man->GetLock() ) { | |
171 | man->SetDefaultStorage(AliQA::GetQARefStorage()) ; | |
172 | man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ; | |
173 | } | |
174 | char * detOCDBDir = Form("%s/%s/%s", det, AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName()) ; | |
175 | AliInfo(Form("Reference QA data are taken from %s", detOCDBDir)) ; | |
176 | AliCDBEntry * entry = man->Get(detOCDBDir, man->GetRun()) ; | |
177 | if (entry) { | |
178 | TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ; | |
179 | if ( listDetQAD ) | |
7ce961eb | 180 | dirOCDB = dynamic_cast<TObjArray *>(listDetQAD->FindObject(task)) ; |
cbae8032 | 181 | } |
182 | } | |
421ab0fb | 183 | } |
184 | ||
a4976ef3 | 185 | //_____________________________________________________________________________ |
2e42b4d4 | 186 | AliQAChecker * AliQAChecker::Instance() |
a4976ef3 | 187 | { |
188 | // returns unique instance of the checker | |
189 | if ( ! fgQAChecker ) | |
2e42b4d4 | 190 | fgQAChecker = new AliQAChecker() ; |
a4976ef3 | 191 | return fgQAChecker ; |
192 | } | |
193 | ||
cbae8032 | 194 | //_____________________________________________________________________________ |
7e88424f | 195 | void AliQAChecker::LoadRunInfoFromGRP() |
cbae8032 | 196 | { |
197 | AliCDBManager* man = AliCDBManager::Instance() ; | |
198 | AliCDBEntry* entry = man->Get(AliQA::GetGRPPath().Data()); | |
199 | TMap * data = 0x0 ; | |
200 | if (entry) | |
201 | data = dynamic_cast<TMap*>(entry->GetObject()); | |
202 | if (!data) { | |
203 | AliFatal("No GRP entry found in OCDB!"); | |
204 | } | |
205 | TObjString *lhcState= | |
206 | dynamic_cast<TObjString*>(data->GetValue("fLHCState")); | |
207 | if (!lhcState) { | |
208 | AliWarning(Form("%s entry: missing value for the LHC state ! Using UNKNOWN", AliQA::GetGRPPath().Data())); | |
209 | } | |
210 | TObjString *beamType= | |
211 | dynamic_cast<TObjString*>(data->GetValue("fAliceBeamType")); | |
212 | if (!beamType) { | |
213 | AliWarning(Form("%s entry: missing value for the LHC state ! Using UNKNOWN", AliQA::GetGRPPath().Data())); | |
214 | } | |
7e88424f | 215 | TObjString *beamEnergyStr= |
216 | dynamic_cast<TObjString*>(data->GetValue("fAliceBeamEnergy")); | |
217 | if (!beamEnergyStr) { | |
218 | AliWarning(Form("%s entry: missing value for the beam energy ! Using 0", AliQA::GetGRPPath().Data())); | |
219 | } | |
cbae8032 | 220 | TObjString *runType= |
221 | dynamic_cast<TObjString*>(data->GetValue("fRunType")); | |
222 | if (!runType) { | |
223 | AliWarning(Form("%s entry: missing value for the run type ! Using UNKNOWN", AliQA::GetGRPPath().Data())); } | |
224 | TObjString *activeDetectors= | |
225 | dynamic_cast<TObjString*>(data->GetValue("fDetectorMask")); | |
226 | if (!activeDetectors) { | |
7e88424f | 227 | AliWarning(Form("%s entry: missing value for the detector mask ! Using 1074790399", AliQA::GetGRPPath().Data())); |
cbae8032 | 228 | } |
7e88424f | 229 | fRunInfo = new AliRunInfo(lhcState ? lhcState->GetString().Data() : "UNKNOWN", |
230 | beamType ? beamType->GetString().Data() : "UNKNOWN", | |
231 | beamEnergyStr ? beamEnergyStr->GetString().Atof() : 0, | |
232 | runType ? runType->GetString().Data() : "UNKNOWN", | |
233 | activeDetectors ? activeDetectors->GetString().Atoi() : 1074790399); | |
234 | fRunInfoOwner = kTRUE ; | |
cbae8032 | 235 | } |
236 | ||
421ab0fb | 237 | //_____________________________________________________________________________ |
808b7099 | 238 | Bool_t AliQAChecker::Run(const char * fileName) |
421ab0fb | 239 | { |
a5fa6165 | 240 | // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs |
a4976ef3 | 241 | // starting from data in file |
421ab0fb | 242 | |
243 | Bool_t rv = kFALSE ; | |
a5fa6165 | 244 | |
421ab0fb | 245 | TStopwatch stopwatch; |
246 | stopwatch.Start(); | |
247 | ||
a5fa6165 | 248 | //search for all detectors QA directories |
8bea2de0 | 249 | TList * detKeyList = AliQA::GetQADataFile(fileName)->GetListOfKeys() ; |
a5fa6165 | 250 | TIter nextd(detKeyList) ; |
251 | TKey * detKey ; | |
252 | while ( (detKey = dynamic_cast<TKey *>(nextd()) ) ) { | |
54a7f3ac | 253 | AliDebug(1, Form("Found %s", detKey->GetName())) ; |
a5fa6165 | 254 | //Check which detector |
255 | TString detName ; | |
256 | TString detNameQA(detKey->GetName()) ; | |
257 | Int_t det ; | |
2e42b4d4 | 258 | for ( det = 0; det < AliQA::kNDET ; det++) { |
259 | detName = AliQA::GetDetName(det) ; | |
a5fa6165 | 260 | if (detNameQA.Contains(detName)) { |
261 | fFoundDetectors+=detName ; | |
262 | fFoundDetectors+="." ; | |
263 | break ; | |
264 | } | |
265 | } | |
8bea2de0 | 266 | TDirectory * detDir = AliQA::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ; |
a5fa6165 | 267 | TList * taskKeyList = detDir->GetListOfKeys() ; |
268 | TIter nextt(taskKeyList) ; | |
269 | TKey * taskKey ; | |
270 | // now search for the tasks dir | |
271 | while ( (taskKey = static_cast<TKey *>(nextt()) ) ) { | |
272 | TString taskName( taskKey->GetName() ) ; | |
273 | AliInfo(Form("Found %s", taskName.Data())) ; | |
274 | TDirectory * taskDir = detDir->GetDirectory(taskName.Data()) ; | |
275 | taskDir->cd() ; | |
2e42b4d4 | 276 | AliQACheckerBase * qac = GetDetQAChecker(det) ; |
a5fa6165 | 277 | if (qac) |
a4976ef3 | 278 | AliInfo(Form("QA checker found for %s", detName.Data())) ; |
a5fa6165 | 279 | if (!qac) |
a4976ef3 | 280 | AliFatal(Form("QA checker not found for %s", detName.Data())) ; |
96d67a8d | 281 | AliQA::ALITASK_t index = AliQA::kNULLTASK ; |
2e42b4d4 | 282 | if ( taskName == AliQA::GetTaskName(AliQA::kHITS) ) |
283 | index = AliQA::kSIM ; | |
284 | if ( taskName == AliQA::GetTaskName(AliQA::kSDIGITS) ) | |
285 | index = AliQA::kSIM ; | |
286 | if ( taskName == AliQA::GetTaskName(AliQA::kDIGITS) ) | |
287 | index = AliQA::kSIM ; | |
288 | if ( taskName == AliQA::GetTaskName(AliQA::kRECPOINTS) ) | |
289 | index = AliQA::kREC ; | |
290 | if ( taskName == AliQA::GetTaskName(AliQA::kTRACKSEGMENTS) ) | |
291 | index = AliQA::kREC ; | |
292 | if ( taskName == AliQA::GetTaskName(AliQA::kRECPARTICLES) ) | |
293 | index = AliQA::kREC ; | |
294 | if ( taskName == AliQA::GetTaskName(AliQA::kESDS) ) | |
295 | index = AliQA::kESD ; | |
96d67a8d | 296 | qac->Init(AliQA::DETECTORINDEX_t(det)) ; |
10a28129 | 297 | |
f73f556a | 298 | TDirectory * refDir = NULL ; |
299 | TObjArray * refOCDBDir = NULL ; | |
4edbc5bc | 300 | GetRefSubDir(detNameQA.Data(), taskName.Data(), refDir, refOCDBDir) ; |
301 | if ( refDir || refOCDBDir) { | |
302 | qac->SetRefandData(refDir, refOCDBDir, taskDir) ; | |
303 | qac->Run(index) ; | |
ac2bb64a | 304 | } |
4edbc5bc | 305 | } |
306 | } | |
a5fa6165 | 307 | AliInfo("QA performed for following detectors:") ; |
2e42b4d4 | 308 | for ( Int_t det = 0; det < AliQA::kNDET; det++) { |
309 | if (fFoundDetectors.Contains(AliQA::GetDetName(det))) { | |
310 | printf("%s, ",AliQA::GetDetName(det)) ; | |
311 | fFoundDetectors.ReplaceAll(AliQA::GetDetName(det), "") ; | |
a5fa6165 | 312 | } |
421ab0fb | 313 | } |
a5fa6165 | 314 | printf("\n") ; |
315 | rv = kTRUE ; | |
421ab0fb | 316 | |
a5fa6165 | 317 | return rv ; |
318 | ||
421ab0fb | 319 | } |
320 | ||
a4976ef3 | 321 | //_____________________________________________________________________________ |
96d67a8d | 322 | Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, TObjArray * list) |
a4976ef3 | 323 | { |
d6372ce8 | 324 | // run the Quality Assurance Checker for detector det, for task task starting from data in list |
a4976ef3 | 325 | |
d6372ce8 | 326 | AliQACheckerBase * qac = GetDetQAChecker(det) ; |
327 | if (qac) | |
328 | AliDebug(1, Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ; | |
329 | if (!qac) | |
330 | AliError(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ; | |
a4976ef3 | 331 | |
d6372ce8 | 332 | AliQA::ALITASK_t index = AliQA::kNULLTASK ; |
333 | if ( task == AliQA::kRAWS ) | |
2e42b4d4 | 334 | index = AliQA::kRAW ; |
d6372ce8 | 335 | else if ( task == AliQA::kHITS ) |
2e42b4d4 | 336 | index = AliQA::kSIM ; |
d6372ce8 | 337 | else if ( task == AliQA::kSDIGITS ) |
2e42b4d4 | 338 | index = AliQA::kSIM ; |
d6372ce8 | 339 | else if ( task == AliQA::kDIGITS ) |
2e42b4d4 | 340 | index = AliQA::kSIM ; |
d6372ce8 | 341 | else if ( task == AliQA::kRECPOINTS ) |
2e42b4d4 | 342 | index = AliQA::kREC ; |
d6372ce8 | 343 | else if ( task == AliQA::kTRACKSEGMENTS ) |
2e42b4d4 | 344 | index = AliQA::kREC ; |
d6372ce8 | 345 | else if ( task == AliQA::kRECPARTICLES ) |
2e42b4d4 | 346 | index = AliQA::kREC ; |
d6372ce8 | 347 | else if ( task == AliQA::kESDS ) |
2e42b4d4 | 348 | index = AliQA::kESD ; |
4edbc5bc | 349 | |
d6372ce8 | 350 | TDirectory * refDir = NULL ; |
351 | TObjArray * refOCDBDir = NULL ; | |
352 | qac->Init(det) ; | |
4edbc5bc | 353 | GetRefSubDir(AliQA::GetDetName(det), AliQA::GetTaskName(task), refDir, refOCDBDir) ; |
d6372ce8 | 354 | if ( refDir || refOCDBDir) // references found |
4edbc5bc | 355 | qac->SetRefandData(refDir, refOCDBDir) ; |
d6372ce8 | 356 | qac->Run(index, list) ; |
357 | return kTRUE ; | |
a4976ef3 | 358 | } |
359 | ||
421ab0fb | 360 | |
361 |