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