]>
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 ; | |
421ab0fb | 41 | |
42 | //_____________________________________________________________________________ | |
2e42b4d4 | 43 | AliQAChecker::AliQAChecker(const char* name, const char* title) : |
421ab0fb | 44 | TNamed(name, title), |
a5fa6165 | 45 | fDataFile(0x0), |
a5fa6165 | 46 | fFoundDetectors(".") |
421ab0fb | 47 | { |
a5fa6165 | 48 | // ctor: initialise checkers and open the data file |
2e42b4d4 | 49 | for (Int_t det = 0 ; det < AliQA::kNDET ; det++) |
a5fa6165 | 50 | fCheckers[det] = NULL ; |
421ab0fb | 51 | } |
52 | ||
53 | //_____________________________________________________________________________ | |
2e42b4d4 | 54 | AliQAChecker::AliQAChecker(const AliQAChecker& qac) : |
421ab0fb | 55 | TNamed(qac), |
a5fa6165 | 56 | fDataFile(qac.fDataFile), |
a5fa6165 | 57 | fFoundDetectors(qac.fFoundDetectors) |
421ab0fb | 58 | { |
a5fa6165 | 59 | // copy constructor |
60 | ||
2e42b4d4 | 61 | for (Int_t det = 0 ; det < AliQA::kNDET ; det++) |
a5fa6165 | 62 | fCheckers[det] = NULL ; |
421ab0fb | 63 | } |
64 | ||
65 | //_____________________________________________________________________________ | |
2e42b4d4 | 66 | AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac) |
421ab0fb | 67 | { |
68 | // assignment operator | |
69 | ||
2e42b4d4 | 70 | this->~AliQAChecker(); |
71 | new(this) AliQAChecker(qac); | |
421ab0fb | 72 | return *this; |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
2e42b4d4 | 76 | AliQAChecker::~AliQAChecker() |
421ab0fb | 77 | { |
78 | // clean up | |
a4976ef3 | 79 | delete [] fCheckers ; |
8bea2de0 | 80 | AliQA::Close() ; |
421ab0fb | 81 | } |
82 | ||
83 | //_____________________________________________________________________________ | |
2e42b4d4 | 84 | AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det) |
421ab0fb | 85 | { |
a5fa6165 | 86 | // Gets the Quality Assurance checker for the detector specified by its name |
87 | ||
88 | if (fCheckers[det]) | |
89 | return fCheckers[det]; | |
90 | ||
2e42b4d4 | 91 | TString detName(AliQA::GetDetName(det)) ; |
a5fa6165 | 92 | |
93 | AliInfo(Form("Retrieving QA checker for %s", detName.Data())) ; | |
94 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
2e42b4d4 | 95 | TString qacName = "Ali" + detName + "QAChecker" ; |
a5fa6165 | 96 | |
2e42b4d4 | 97 | AliQACheckerBase * qac = NULL ; |
a5fa6165 | 98 | // first check if a plugin is defined for the quality assurance checker |
2e42b4d4 | 99 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data()); |
a5fa6165 | 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(); | |
104 | ||
105 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) | |
2e42b4d4 | 106 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()"); |
a5fa6165 | 107 | else |
2e42b4d4 | 108 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()"); |
a5fa6165 | 109 | |
2e42b4d4 | 110 | pluginHandler = pluginManager->FindHandler("AliQAChecker", detName); |
a5fa6165 | 111 | |
112 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) | |
2e42b4d4 | 113 | qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0); |
a5fa6165 | 114 | |
115 | if (qac) | |
116 | fCheckers[det] = qac ; | |
421ab0fb | 117 | } |
a5fa6165 | 118 | |
119 | return qac ; | |
120 | } | |
121 | ||
122 | ||
123 | //_____________________________________________________________________________ | |
2e42b4d4 | 124 | TDirectory * AliQAChecker::GetRefSubDir(const char * det, const char * task) |
a5fa6165 | 125 | { |
126 | // Opens and returns the file with the reference data | |
4ecde5fc | 127 | TFile * f = AliQA::GetQARefFile() ; //TFile::Open(fRefDirName, "READ") ; |
a5fa6165 | 128 | TDirectory * rv = NULL ; |
10a28129 | 129 | if (!f) { |
4ecde5fc | 130 | AliError(Form("Cannot find reference file %s", (AliQA::GetQARefFileName()))) ; |
10a28129 | 131 | return rv ; |
132 | } | |
a5fa6165 | 133 | rv = f->GetDirectory(det) ; |
134 | if (!rv) { | |
4ecde5fc | 135 | AliWarning(Form("Directory %s not found in %d", det, (AliQA::GetQARefFileName()))) ; |
a5fa6165 | 136 | } else { |
137 | rv = rv->GetDirectory(task) ; | |
138 | if (!rv) | |
4ecde5fc | 139 | AliWarning(Form("Directory %s/%s not found in %s", det, task, (AliQA::GetQARefFileName()))) ; |
a5fa6165 | 140 | } |
141 | return rv ; | |
421ab0fb | 142 | } |
143 | ||
a4976ef3 | 144 | //_____________________________________________________________________________ |
2e42b4d4 | 145 | AliQAChecker * AliQAChecker::Instance() |
a4976ef3 | 146 | { |
147 | // returns unique instance of the checker | |
148 | if ( ! fgQAChecker ) | |
2e42b4d4 | 149 | fgQAChecker = new AliQAChecker() ; |
a4976ef3 | 150 | return fgQAChecker ; |
151 | } | |
152 | ||
421ab0fb | 153 | //_____________________________________________________________________________ |
808b7099 | 154 | Bool_t AliQAChecker::Run(const char * fileName) |
421ab0fb | 155 | { |
a5fa6165 | 156 | // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs |
a4976ef3 | 157 | // starting from data in file |
421ab0fb | 158 | |
159 | Bool_t rv = kFALSE ; | |
a5fa6165 | 160 | |
421ab0fb | 161 | TStopwatch stopwatch; |
162 | stopwatch.Start(); | |
163 | ||
a5fa6165 | 164 | //search for all detectors QA directories |
8bea2de0 | 165 | TList * detKeyList = AliQA::GetQADataFile(fileName)->GetListOfKeys() ; |
a5fa6165 | 166 | TIter nextd(detKeyList) ; |
167 | TKey * detKey ; | |
168 | while ( (detKey = dynamic_cast<TKey *>(nextd()) ) ) { | |
169 | AliInfo(Form("Found %s", detKey->GetName())) ; | |
170 | //Check which detector | |
171 | TString detName ; | |
172 | TString detNameQA(detKey->GetName()) ; | |
173 | Int_t det ; | |
2e42b4d4 | 174 | for ( det = 0; det < AliQA::kNDET ; det++) { |
175 | detName = AliQA::GetDetName(det) ; | |
a5fa6165 | 176 | if (detNameQA.Contains(detName)) { |
177 | fFoundDetectors+=detName ; | |
178 | fFoundDetectors+="." ; | |
179 | break ; | |
180 | } | |
181 | } | |
8bea2de0 | 182 | TDirectory * detDir = AliQA::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ; |
a5fa6165 | 183 | TList * taskKeyList = detDir->GetListOfKeys() ; |
184 | TIter nextt(taskKeyList) ; | |
185 | TKey * taskKey ; | |
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()) ; | |
191 | taskDir->cd() ; | |
2e42b4d4 | 192 | AliQACheckerBase * qac = GetDetQAChecker(det) ; |
a5fa6165 | 193 | if (qac) |
a4976ef3 | 194 | AliInfo(Form("QA checker found for %s", detName.Data())) ; |
a5fa6165 | 195 | if (!qac) |
a4976ef3 | 196 | AliFatal(Form("QA checker not found for %s", detName.Data())) ; |
2e42b4d4 | 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)) ; | |
10a28129 | 213 | |
ac2bb64a | 214 | TDirectory * refDir = GetRefSubDir(detNameQA.Data(), taskName.Data()) ; |
215 | if ( refDir ) { | |
216 | qac->SetRefandData(refDir, taskDir) ; | |
217 | qac->Run(index) ; | |
218 | } | |
421ab0fb | 219 | } |
a5fa6165 | 220 | } |
221 | AliInfo("QA performed for following detectors:") ; | |
2e42b4d4 | 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), "") ; | |
a5fa6165 | 226 | } |
421ab0fb | 227 | } |
a5fa6165 | 228 | printf("\n") ; |
229 | rv = kTRUE ; | |
421ab0fb | 230 | |
a5fa6165 | 231 | return rv ; |
232 | ||
421ab0fb | 233 | } |
234 | ||
a4976ef3 | 235 | //_____________________________________________________________________________ |
2e42b4d4 | 236 | Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task, TList * list) |
a4976ef3 | 237 | { |
238 | // run the Quality Assurance Checker for detector det, for task task starting from data in list | |
239 | ||
2e42b4d4 | 240 | AliQACheckerBase * qac = GetDetQAChecker(det) ; |
a4976ef3 | 241 | if (qac) |
2e42b4d4 | 242 | AliInfo(Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ; |
a4976ef3 | 243 | if (!qac) |
2e42b4d4 | 244 | AliFatal(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ; |
a4976ef3 | 245 | |
2e42b4d4 | 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 ; | |
10a28129 | 263 | TDirectory * refDir = GetRefSubDir(AliQA::GetDetName(det).Data(), AliQA::GetTaskName(task).Data()) ; |
264 | if ( refDir ) { | |
265 | qac->Init(det) ; | |
266 | qac->SetRefandData(refDir) ; | |
267 | qac->Run(index, list) ; | |
268 | } | |
a4976ef3 | 269 | return kTRUE ; |
270 | ||
271 | } | |
272 | ||
421ab0fb | 273 | |
274 |