]>
Commit | Line | Data |
---|---|---|
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 "AliCDBEntry.h" | |
25 | #include "AliQAManager.h" | |
26 | #include "AliCDBStorage.h" | |
27 | #include "AliRunInfo.h" | |
28 | #include "AliLog.h" | |
29 | #include "AliModule.h" | |
30 | #include "AliQAv1.h" | |
31 | #include "AliQAChecker.h" | |
32 | #include "AliQACheckerBase.h" | |
33 | #include "AliCorrQAChecker.h" | |
34 | #include "AliGlobalQAChecker.h" | |
35 | #include "AliGRPObject.h" | |
36 | ||
37 | #include <TKey.h> | |
38 | #include <TObjArray.h> | |
39 | #include <TObjString.h> | |
40 | #include <TPluginManager.h> | |
41 | #include <TROOT.h> | |
42 | #include <TStopwatch.h> | |
43 | #include <TString.h> | |
44 | #include <TSystem.h> | |
45 | #include <TList.h> | |
46 | #include <TNtupleD.h> | |
47 | ||
48 | ClassImp(AliQAChecker) | |
49 | AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ; | |
50 | ||
51 | //_____________________________________________________________________________ | |
52 | AliQAChecker::AliQAChecker(const char* name, const char* title) : | |
53 | TNamed(name, title), | |
54 | fDataFile(0x0), | |
55 | fRunInfo(0x0), | |
56 | fRunInfoOwner(kFALSE), | |
57 | fRefFile(0x0), | |
58 | fFoundDetectors("."), | |
59 | fEventSpecie(AliRecoParam::kDefault), | |
60 | fRun(0) | |
61 | { | |
62 | // ctor: initialise checkers and open the data file | |
63 | for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) | |
64 | fCheckers[det] = NULL ; | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliQAChecker::AliQAChecker(const AliQAChecker& qac) : | |
69 | TNamed(qac), | |
70 | fDataFile(qac.fDataFile), | |
71 | fRunInfo(qac.fRunInfo), | |
72 | fRunInfoOwner(kFALSE), | |
73 | fRefFile(qac.fRefFile), | |
74 | fFoundDetectors(qac.fFoundDetectors), | |
75 | fEventSpecie(qac.fEventSpecie), | |
76 | fRun(qac.fRun) | |
77 | { | |
78 | // copy constructor | |
79 | ||
80 | for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) | |
81 | fCheckers[det] = NULL ; | |
82 | } | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac) | |
86 | { | |
87 | // assignment operator | |
88 | ||
89 | this->~AliQAChecker(); | |
90 | new(this) AliQAChecker(qac); | |
91 | return *this; | |
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | AliQAChecker::~AliQAChecker() | |
96 | { | |
97 | // clean up | |
98 | if (fRunInfo) | |
99 | delete fRunInfo ; | |
100 | for (Int_t det=0; det<AliQAv1::kNDET; det++) | |
101 | delete fCheckers[det] ; | |
102 | AliQAv1::Close() ; | |
103 | } | |
104 | ||
105 | //_____________________________________________________________________________ | |
106 | AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det) | |
107 | { | |
108 | // Gets the Quality Assurance checker for the detector specified by its name | |
109 | ||
110 | if (det<0 || det>=AliQAv1::kNDET) return NULL; | |
111 | ||
112 | if (fCheckers[det]) | |
113 | return fCheckers[det]; | |
114 | ||
115 | AliQACheckerBase * qac = NULL ; | |
116 | ||
117 | TString detName(AliQAv1::GetDetName(det)) ; | |
118 | ||
119 | if (det == AliQAv1::kGLOBAL) { | |
120 | qac = new AliGlobalQAChecker() ; | |
121 | } else if (det == AliQAv1::kCORR) { | |
122 | qac = new AliCorrQAChecker() ; | |
123 | } else { | |
124 | AliDebugClass(AliQAv1::GetQADebugLevel(), Form("Retrieving QA checker for %s", detName.Data())) ; | |
125 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
126 | TString qacName = "Ali" + detName + "QAChecker" ; | |
127 | ||
128 | // first check if a plugin is defined for the quality assurance checker | |
129 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data()); | |
130 | // if not, add a plugin for it | |
131 | if (!pluginHandler) { | |
132 | //AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qacName.Data())); | |
133 | TString libs = gSystem->GetLibraries(); | |
134 | ||
135 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) | |
136 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()"); | |
137 | else | |
138 | pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()"); | |
139 | ||
140 | pluginHandler = pluginManager->FindHandler("AliQAChecker", detName); | |
141 | ||
142 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) | |
143 | qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0); | |
144 | ||
145 | } | |
146 | } | |
147 | if (qac) | |
148 | fCheckers[det] = qac ; | |
149 | ||
150 | return qac ; | |
151 | } | |
152 | ||
153 | //_____________________________________________________________________________ | |
154 | AliQAChecker * AliQAChecker::Instance() | |
155 | { | |
156 | // returns unique instance of the checker | |
157 | if ( ! fgQAChecker ) | |
158 | fgQAChecker = new AliQAChecker() ; | |
159 | return fgQAChecker ; | |
160 | } | |
161 | ||
162 | //_____________________________________________________________________________ | |
163 | void AliQAChecker::LoadRunInfoFromGRP() | |
164 | { | |
165 | AliCDBManager* man = AliCDBManager::Instance() ; | |
166 | AliCDBEntry* entry = man->Get(AliQAv1::GetGRPPath().Data()); | |
167 | AliGRPObject* grpObject = 0x0; | |
168 | if (entry) { | |
169 | ||
170 | TMap* m = static_cast<TMap*>(entry->GetObject()); // old GRP entry | |
171 | ||
172 | if (m) { | |
173 | AliDebug(AliQAv1::GetQADebugLevel(), "It is a map"); | |
174 | //m->Print(); | |
175 | grpObject = new AliGRPObject(); | |
176 | grpObject->ReadValuesFromMap(m); | |
177 | } | |
178 | ||
179 | else { | |
180 | AliDebug(AliQAv1::GetQADebugLevel(), "It is a new GRP object"); | |
181 | grpObject = static_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry | |
182 | } | |
183 | ||
184 | entry->SetOwner(0); | |
185 | AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data"); | |
186 | } | |
187 | ||
188 | if (!grpObject) { | |
189 | AliFatal("No GRP entry found in OCDB!"); | |
190 | } | |
191 | ||
192 | TString lhcState = grpObject->GetLHCState(); | |
193 | if (lhcState==AliGRPObject::GetInvalidString()) { | |
194 | AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN"); | |
195 | lhcState = "UNKNOWN"; | |
196 | } | |
197 | ||
198 | TString beamType = grpObject->GetBeamType(); | |
199 | if (beamType==AliGRPObject::GetInvalidString()) { | |
200 | AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN"); | |
201 | beamType = "UNKNOWN"; | |
202 | } | |
203 | ||
204 | Float_t beamEnergy = grpObject->GetBeamEnergy(); | |
205 | if (beamEnergy==AliGRPObject::GetInvalidFloat()) { | |
206 | AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0"); | |
207 | beamEnergy = 0; | |
208 | } | |
209 | ||
210 | TString runType = grpObject->GetRunType(); | |
211 | if (runType==AliGRPObject::GetInvalidString()) { | |
212 | AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN"); | |
213 | runType = "UNKNOWN"; | |
214 | } | |
215 | ||
216 | Int_t activeDetectors = grpObject->GetDetectorMask(); | |
217 | if (activeDetectors==AliGRPObject::GetInvalidInt()) { | |
218 | AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399"); | |
219 | activeDetectors = 1074790399; | |
220 | } | |
221 | ||
222 | fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors); | |
223 | ||
224 | fRunInfoOwner = kTRUE ; | |
225 | ||
226 | // set the event specie | |
227 | fEventSpecie = AliRecoParam::kDefault ; | |
228 | if (strcmp(runType,"PHYSICS")) { | |
229 | // Not a physics run, the event specie is set to kCalib | |
230 | fEventSpecie = AliRecoParam::kCalib ; | |
231 | return; | |
232 | } | |
233 | if (strcmp(lhcState,"STABLE_BEAMS") == 0) { | |
234 | // Heavy ion run (any beam tha is not pp, the event specie is set to kHighMult | |
235 | fEventSpecie = AliRecoParam::kHighMult ; | |
236 | if ((strcmp(beamType,"p-p") == 0) || | |
237 | (strcmp(beamType,"p-") == 0) || | |
238 | (strcmp(beamType,"-p") == 0) || | |
239 | (strcmp(beamType,"P-P") == 0) || | |
240 | (strcmp(beamType,"P-") == 0) || | |
241 | (strcmp(beamType,"-P") == 0)) { | |
242 | // Proton run, the event specie is set to kLowMult | |
243 | fEventSpecie = AliRecoParam::kLowMult ; | |
244 | } | |
245 | else if (strcmp(beamType,"-") == 0) { | |
246 | // No beams, we assume cosmic data | |
247 | fEventSpecie = AliRecoParam::kCosmic ; | |
248 | } | |
249 | else if (strcmp(beamType,"UNKNOWN") == 0) { | |
250 | // No LHC beam information is available, we use the default event specie | |
251 | fEventSpecie = AliRecoParam::kDefault ; | |
252 | } | |
253 | } | |
254 | } | |
255 | ||
256 | //_____________________________________________________________________________ | |
257 | Bool_t AliQAChecker::Run(const char * fileName, AliDetectorRecoParam * recoParam) | |
258 | { | |
259 | // run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, DigitsR, RecPoints, TrackSegments, RecParticles and ESDs | |
260 | // starting from data in file | |
261 | TStopwatch stopwatch; | |
262 | stopwatch.Start(); | |
263 | ||
264 | //search for all detectors QA directories | |
265 | TList * detKeyList = AliQAv1::GetQADataFile(fileName)->GetListOfKeys() ; | |
266 | TIter nextd(detKeyList) ; | |
267 | TKey * detKey ; | |
268 | while ( (detKey = static_cast<TKey *>(nextd()) ) ) { | |
269 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Found %s", detKey->GetName())) ; | |
270 | //Check which detector | |
271 | TString detName ; | |
272 | TString detNameQA(detKey->GetName()) ; | |
273 | Int_t det ; | |
274 | for ( det = 0; det < AliQAv1::kNDET ; det++) { | |
275 | detName = AliQAv1::GetDetName(det) ; | |
276 | if (detNameQA.Contains(detName)) { | |
277 | fFoundDetectors+=detName ; | |
278 | fFoundDetectors+="." ; | |
279 | break ; | |
280 | } | |
281 | } | |
282 | TDirectory * detDir = AliQAv1::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ; | |
283 | TList * taskKeyList = detDir->GetListOfKeys() ; | |
284 | TIter nextt(taskKeyList) ; | |
285 | TKey * taskKey ; | |
286 | // now search for the tasks dir | |
287 | while ( (taskKey = static_cast<TKey *>(nextt()) ) ) { | |
288 | TString taskName( taskKey->GetName() ) ; | |
289 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Found %s", taskName.Data())) ; | |
290 | TDirectory * taskDir = detDir->GetDirectory(taskName.Data()) ; | |
291 | taskDir->cd() ; | |
292 | AliQACheckerBase * qac = GetDetQAChecker(det) ; | |
293 | if (qac) | |
294 | AliDebug(AliQAv1::GetQADebugLevel(), Form("QA checker found for %s", detName.Data())) ; | |
295 | if (!qac) | |
296 | AliFatal(Form("QA checker not found for %s", detName.Data())) ; | |
297 | AliQAv1::ALITASK_t index = AliQAv1::kNULLTASK ; | |
298 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kHITS) ) | |
299 | index = AliQAv1::kSIM ; | |
300 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kSDIGITS) ) | |
301 | index = AliQAv1::kSIM ; | |
302 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kDIGITS) ) | |
303 | index = AliQAv1::kSIM ; | |
304 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kRAWS) ) | |
305 | index = AliQAv1::kRAW ; | |
306 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kDIGITSR) ) | |
307 | index = AliQAv1::kREC ; | |
308 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kRECPOINTS) ) | |
309 | index = AliQAv1::kREC ; | |
310 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kTRACKSEGMENTS) ) | |
311 | index = AliQAv1::kREC ; | |
312 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kRECPARTICLES) ) | |
313 | index = AliQAv1::kREC ; | |
314 | if ( taskName == AliQAv1::GetTaskName(AliQAv1::kESDS) ) | |
315 | index = AliQAv1::kESD ; | |
316 | qac->Init(AliQAv1::DETECTORINDEX_t(det)) ; | |
317 | qac->Run(index, recoParam) ; | |
318 | } | |
319 | } | |
320 | TString detList ; | |
321 | for ( Int_t det = 0; det < AliQAv1::kNDET; det++) { | |
322 | if (fFoundDetectors.Contains(AliQAv1::GetDetName(det))) { | |
323 | detList += AliQAv1::GetDetName(det) ; | |
324 | detList += " " ; | |
325 | fFoundDetectors.ReplaceAll(AliQAv1::GetDetName(det), "") ; | |
326 | AliQAv1::Instance()->Show(AliQAv1::GetDetIndex(AliQAv1::GetDetName(det))) ; | |
327 | } | |
328 | } | |
329 | AliInfo(Form("QA performed for following detectors: %s", detList.Data())) ; | |
330 | return kTRUE ; | |
331 | } | |
332 | ||
333 | //_____________________________________________________________________________ | |
334 | Bool_t AliQAChecker::Run(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, TObjArray ** list, AliDetectorRecoParam * recoParam) | |
335 | { | |
336 | // run the Quality Assurance Checker for detector det, for task task starting from data in list | |
337 | ||
338 | if (det >= AliQAv1::kNDET) { | |
339 | AliError(Form("det = %i is larger than AliQAv1::kNDET ... should never happen", det)); | |
340 | return kFALSE ; | |
341 | } | |
342 | AliQACheckerBase * qac = GetDetQAChecker(det) ; | |
343 | if (qac) | |
344 | AliDebug(AliQAv1::GetQADebugLevel(), Form("QA checker found for %s", AliQAv1::GetDetName(det).Data())) ; | |
345 | if (!qac) { | |
346 | AliError(Form("QA checker not found for %s", AliQAv1::GetDetName(det).Data())) ; | |
347 | return kFALSE; | |
348 | } | |
349 | ||
350 | AliQAv1::ALITASK_t index = AliQAv1::kNULLTASK ; | |
351 | if ( task == AliQAv1::kRAWS ) | |
352 | index = AliQAv1::kRAW ; | |
353 | else if ( task == AliQAv1::kHITS ) | |
354 | index = AliQAv1::kSIM ; | |
355 | else if ( task == AliQAv1::kSDIGITS ) | |
356 | index = AliQAv1::kSIM ; | |
357 | else if ( task == AliQAv1::kDIGITS ) | |
358 | index = AliQAv1::kSIM ; | |
359 | else if ( task == AliQAv1::kDIGITSR ) | |
360 | index = AliQAv1::kREC ; | |
361 | else if ( task == AliQAv1::kRECPOINTS ) | |
362 | index = AliQAv1::kREC ; | |
363 | else if ( task == AliQAv1::kTRACKSEGMENTS ) | |
364 | index = AliQAv1::kREC ; | |
365 | else if ( task == AliQAv1::kRECPARTICLES ) | |
366 | index = AliQAv1::kREC ; | |
367 | else if ( task == AliQAv1::kESDS ) | |
368 | index = AliQAv1::kESD ; | |
369 | ||
370 | qac->Init(det) ; | |
371 | qac->Run(index, list, recoParam) ; | |
372 | ||
373 | // make the image | |
374 | qac->MakeImage(list, task, AliQAv1::Mode(task)) ; | |
375 | ||
376 | return kTRUE ; | |
377 | } | |
378 | ||
379 | //_____________________________________________________________________________ | |
380 | Bool_t AliQAChecker::Run(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, TNtupleD ** list, AliDetectorRecoParam * recoParam) | |
381 | { | |
382 | // run the Quality Assurance Checker for detector det, for task task starting from data in list | |
383 | ||
384 | AliQACheckerBase * qac = GetDetQAChecker(det) ; | |
385 | if (qac) | |
386 | AliDebug(AliQAv1::GetQADebugLevel(), Form("QA checker found for %s", AliQAv1::GetDetName(det).Data())) ; | |
387 | if (!qac) { | |
388 | AliError(Form("QA checker not found for %s", AliQAv1::GetDetName(det).Data())) ; | |
389 | return kFALSE; | |
390 | } | |
391 | ||
392 | AliQAv1::ALITASK_t index = AliQAv1::kNULLTASK ; | |
393 | if ( task == AliQAv1::kRAWS ) | |
394 | index = AliQAv1::kRAW ; | |
395 | else if ( task == AliQAv1::kHITS ) | |
396 | index = AliQAv1::kSIM ; | |
397 | else if ( task == AliQAv1::kSDIGITS ) | |
398 | index = AliQAv1::kSIM ; | |
399 | else if ( task == AliQAv1::kDIGITS ) | |
400 | index = AliQAv1::kSIM ; | |
401 | else if ( task == AliQAv1::kDIGITSR ) | |
402 | index = AliQAv1::kREC ; | |
403 | else if ( task == AliQAv1::kRECPOINTS ) | |
404 | index = AliQAv1::kREC ; | |
405 | else if ( task == AliQAv1::kTRACKSEGMENTS ) | |
406 | index = AliQAv1::kREC ; | |
407 | else if ( task == AliQAv1::kRECPARTICLES ) | |
408 | index = AliQAv1::kREC ; | |
409 | else if ( task == AliQAv1::kESDS ) | |
410 | index = AliQAv1::kESD ; | |
411 | ||
412 | qac->Init(det) ; | |
413 | qac->Run(index, list, recoParam) ; | |
414 | ||
415 | return kTRUE ; | |
416 | } |