]>
Commit | Line | Data |
---|---|---|
8661738e | 1 | |
421ab0fb | 2 | /************************************************************************** |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | /* $Id$ */ | |
17 | ||
18 | ////////////////////////////////////////////////////////////////////////////// | |
19 | // | |
20 | // Quality Assurance Object//_________________________________________________________________________ | |
21 | // Quality Assurance object. The QA status is held in one word per detector, | |
22 | // each bit corresponds to a different status. | |
23 | // bit 0-3 : QA raised during simulation (SIM) | |
24 | // bit 4-7 : QA raised during reconstruction (REC) | |
25 | // bit 8-11 : QA raised during ESD checking (ESD) | |
26 | // bit 12-15: QA raised during analysis (ANA) | |
27 | // Each of the 4 bits corresponds to a severity level of increasing importance | |
28 | // from lower to higher bit (INFO, WARNING, ERROR, FATAL) | |
29 | // | |
30 | //*-- Yves Schutz CERN, July 2007 | |
31 | ////////////////////////////////////////////////////////////////////////////// | |
32 | ||
33 | ||
34 | // --- ROOT system --- | |
35 | #include <TFile.h> | |
36 | #include <TSystem.h> | |
37 | ||
38 | // --- Standard library --- | |
39 | ||
40 | // --- AliRoot header files --- | |
41 | #include "AliLog.h" | |
2e42b4d4 | 42 | #include "AliQA.h" |
9a223722 | 43 | #include "AliQAChecker.h" |
421ab0fb | 44 | |
45 | ||
2e42b4d4 | 46 | ClassImp(AliQA) |
47 | AliQA * AliQA::fgQA = 0x0 ; | |
48 | TFile * AliQA::fgDataFile = 0x0 ; | |
49 | TString AliQA::fgDataName = "QA" ; | |
50 | TString AliQA::fgDetNames[] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", | |
a5fa6165 | 51 | "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"} ; |
2e42b4d4 | 52 | TString AliQA::fgTaskNames[] = {"Raws", "Hits", "SDigits", "Digits", "RecPoints", "TrackSegments", "RecParticles", "ESDs"} ; |
421ab0fb | 53 | |
54 | //____________________________________________________________________________ | |
2e42b4d4 | 55 | AliQA::AliQA() : |
421ab0fb | 56 | TNamed("", ""), |
9a223722 | 57 | fNdet(kNDET), |
58 | fQA(new ULong_t[fNdet]), | |
421ab0fb | 59 | fDet(kNULLDET), |
60 | fTask(kNULLTASK) | |
61 | { | |
62 | // default constructor | |
63 | // beware singleton: not to be used | |
9a223722 | 64 | for (Int_t index = 0 ; index < fNdet ; index++) |
65 | fQA[index] = 0 ; | |
421ab0fb | 66 | } |
67 | ||
68 | //____________________________________________________________________________ | |
2e42b4d4 | 69 | AliQA::AliQA(const AliQA& qa) : |
421ab0fb | 70 | TNamed(qa), |
9a223722 | 71 | fNdet(qa.fNdet), |
421ab0fb | 72 | fQA(qa.fQA), |
73 | fDet(qa.fDet), | |
74 | fTask(qa.fTask) | |
75 | { | |
76 | // cpy ctor | |
77 | } | |
78 | ||
79 | //_____________________________________________________________________________ | |
2e42b4d4 | 80 | AliQA& AliQA::operator = (const AliQA& qa) |
421ab0fb | 81 | { |
82 | // assignment operator | |
83 | ||
2e42b4d4 | 84 | this->~AliQA(); |
85 | new(this) AliQA(qa); | |
421ab0fb | 86 | return *this; |
87 | } | |
88 | ||
89 | //_______________________________________________________________ | |
2e42b4d4 | 90 | AliQA::AliQA(const DETECTORINDEX det) : |
9a223722 | 91 | TNamed("QA", "Quality Assurance status"), |
92 | fNdet(kNDET), | |
93 | fQA(new ULong_t[fNdet]), | |
a5fa6165 | 94 | fDet(det), |
95 | fTask(kNULLTASK) | |
96 | { | |
97 | // constructor to be used | |
98 | if (! CheckRange(det) ) { | |
99 | fDet = kNULLDET ; | |
100 | return ; | |
a4976ef3 | 101 | } |
a5fa6165 | 102 | Int_t index ; |
9a223722 | 103 | for (index = 0; index < fNdet; index++) |
a5fa6165 | 104 | fQA[index] = 0 ; |
105 | } | |
106 | ||
107 | //_______________________________________________________________ | |
2e42b4d4 | 108 | AliQA::AliQA(const ALITASK tsk) : |
421ab0fb | 109 | TNamed("QA", "Quality Assurance status"), |
9a223722 | 110 | fNdet(kNDET), |
111 | fQA(new ULong_t[fNdet]), | |
421ab0fb | 112 | fDet(kNULLDET), |
113 | fTask(tsk) | |
114 | { | |
115 | // constructor to be used in the AliRoot module (SIM, REC, ESD or ANA) | |
116 | if (! CheckRange(tsk) ) { | |
117 | fTask = kNULLTASK ; | |
118 | return ; | |
a4976ef3 | 119 | } |
a5fa6165 | 120 | Int_t index ; |
9a223722 | 121 | for (index = 0; index < fNdet; index++) |
a5fa6165 | 122 | fQA[index] = 0 ; |
421ab0fb | 123 | } |
124 | ||
125 | //____________________________________________________________________________ | |
2e42b4d4 | 126 | AliQA::~AliQA() |
421ab0fb | 127 | { |
128 | // dtor | |
129 | delete[] fQA ; | |
130 | } | |
131 | ||
132 | //_______________________________________________________________ | |
2e42b4d4 | 133 | const Bool_t AliQA::CheckRange(DETECTORINDEX det) const |
421ab0fb | 134 | { |
a4976ef3 | 135 | // check if detector is in given detector range: 0-kNDET |
421ab0fb | 136 | |
a5fa6165 | 137 | Bool_t rv = ( det < 0 || det > kNDET ) ? kFALSE : kTRUE ; |
421ab0fb | 138 | if (!rv) |
139 | AliFatal(Form("Detector index %d is out of range: 0 <= index <= %d", det, kNDET)) ; | |
140 | return rv ; | |
141 | } | |
142 | ||
143 | //_______________________________________________________________ | |
2e42b4d4 | 144 | const Bool_t AliQA::CheckRange(ALITASK task) const |
421ab0fb | 145 | { |
146 | // check if task is given taskk range: 0:kNTASK | |
6c18591a | 147 | Bool_t rv = ( task < kRAW || task > kNTASK ) ? kFALSE : kTRUE ; |
421ab0fb | 148 | if (!rv) |
149 | AliFatal(Form("Module index %d is out of range: 0 <= index <= %d", task, kNTASK)) ; | |
150 | return rv ; | |
151 | } | |
152 | ||
153 | //_______________________________________________________________ | |
2e42b4d4 | 154 | const Bool_t AliQA::CheckRange(QABIT bit) const |
421ab0fb | 155 | { |
156 | // check if bit is in given bit range: 0-kNBit | |
157 | ||
158 | Bool_t rv = ( bit < 0 || bit > kNBIT ) ? kFALSE : kTRUE ; | |
159 | if (!rv) | |
160 | AliFatal(Form("Status bit %d is out of range: 0 <= bit <= %d", bit, kNBIT)) ; | |
161 | return rv ; | |
162 | } | |
163 | ||
421ab0fb | 164 | |
165 | //_______________________________________________________________ | |
2e42b4d4 | 166 | TFile * AliQA::GetQADMOutFile(const char * name, const Int_t run, const Int_t cycle) |
421ab0fb | 167 | { |
168 | // opens the file to store the detectors Quality Assurance Data Maker results | |
5b188f2f | 169 | char temp[100] ; |
d62f9368 | 170 | sprintf(temp, "%s.%s.%d.%d.root", name, fgDataName.Data(), run, cycle) ; |
5b188f2f | 171 | TString opt ; |
a5fa6165 | 172 | if (! fgDataFile ) { |
5b188f2f | 173 | if (gSystem->AccessPathName(temp)) |
174 | opt = "NEW" ; | |
175 | else | |
176 | opt = "UPDATE" ; | |
177 | fgDataFile = TFile::Open(temp, opt.Data()) ; | |
178 | } else { | |
179 | if ( (strcmp(temp, fgDataFile->GetName()) != 0) ) { | |
180 | if (gSystem->AccessPathName(temp)) | |
a5fa6165 | 181 | opt = "NEW" ; |
182 | else | |
183 | opt = "UPDATE" ; | |
5b188f2f | 184 | fgDataFile = TFile::Open(temp, opt.Data()) ; |
185 | } | |
421ab0fb | 186 | } |
a5fa6165 | 187 | return fgDataFile ; |
421ab0fb | 188 | } |
189 | ||
190 | //_______________________________________________________________ | |
2e42b4d4 | 191 | const char * AliQA::GetDetName(Int_t det) |
a5fa6165 | 192 | { |
193 | // returns the detector name corresponding to a given index (needed in a loop) | |
194 | ||
195 | if ( det >= 0 && det < kNDET) | |
196 | return (fgDetNames[det]).Data() ; | |
197 | else | |
198 | return NULL ; | |
199 | } | |
200 | ||
201 | //_______________________________________________________________ | |
2e42b4d4 | 202 | const char * AliQA::GetAliTaskName(ALITASK tsk) |
421ab0fb | 203 | { |
204 | // returns the char name corresponding to module index | |
a5fa6165 | 205 | TString tskName ; |
421ab0fb | 206 | switch (tsk) { |
207 | case kNULLTASK: | |
208 | break ; | |
6c18591a | 209 | case kRAW: |
210 | tskName = "RAW" ; | |
211 | break ; | |
421ab0fb | 212 | case kSIM: |
213 | tskName = "SIM" ; | |
214 | break ; | |
215 | case kREC: | |
216 | tskName = "REC" ; | |
217 | break ; | |
218 | case kESD: | |
219 | tskName = "ESD" ; | |
220 | break ; | |
221 | case kANA: | |
222 | tskName = "ANA" ; | |
223 | break ; | |
224 | default: | |
a5fa6165 | 225 | tsk = kNULLTASK ; |
421ab0fb | 226 | break ; |
227 | } | |
a5fa6165 | 228 | return tskName.Data() ; |
421ab0fb | 229 | } |
230 | ||
231 | //_______________________________________________________________ | |
2e42b4d4 | 232 | const Bool_t AliQA::CheckFatal() const |
421ab0fb | 233 | { |
234 | // check if any FATAL status is set | |
235 | Bool_t rv = kFALSE ; | |
236 | Int_t index ; | |
237 | for (index = 0; index < kNDET ; index++) | |
238 | rv = rv || IsSet(DETECTORINDEX(index), fTask, kFATAL) ; | |
239 | return rv ; | |
240 | } | |
241 | ||
242 | //_______________________________________________________________ | |
2e42b4d4 | 243 | const Bool_t AliQA::IsSet(DETECTORINDEX det, ALITASK tsk, QABIT bit) const |
421ab0fb | 244 | { |
245 | // Checks is the requested bit is set | |
246 | ||
247 | CheckRange(det) ; | |
248 | CheckRange(tsk) ; | |
249 | CheckRange(bit) ; | |
250 | ||
251 | ULong_t offset = Offset(tsk) ; | |
252 | ULong_t status = GetStatus(det) ; | |
253 | offset+= bit ; | |
254 | status = (status & 1 << offset) != 0 ; | |
255 | return status ; | |
256 | } | |
257 | ||
258 | //_______________________________________________________________ | |
2e42b4d4 | 259 | AliQA * AliQA::Instance() |
421ab0fb | 260 | { |
261 | // Get an instance of the singleton. | |
262 | // Object must have been instantiated with Instance(ALITASK) first | |
263 | ||
264 | return fgQA ; | |
265 | } | |
266 | ||
267 | //_______________________________________________________________ | |
2e42b4d4 | 268 | AliQA * AliQA::Instance(const DETECTORINDEX det) |
421ab0fb | 269 | { |
270 | // Get an instance of the singleton. The only authorized way to call the ctor | |
271 | ||
9a223722 | 272 | if ( ! fgQA) { |
273 | TFile * f = AliQAChecker::GetQAResultFile() ; | |
274 | fgQA = dynamic_cast<AliQA *>(f->Get("QA")) ; | |
275 | if ( ! fgQA ) | |
276 | fgQA = new AliQA(det) ; | |
277 | } | |
421ab0fb | 278 | fgQA->Set(det) ; |
279 | return fgQA ; | |
280 | } | |
281 | ||
282 | //_______________________________________________________________ | |
2e42b4d4 | 283 | AliQA * AliQA::Instance(const ALITASK tsk) |
421ab0fb | 284 | { |
285 | // get an instance of the singleton. | |
286 | ||
287 | if ( ! fgQA) | |
288 | switch (tsk) { | |
289 | case kNULLTASK: | |
290 | break ; | |
6c18591a | 291 | case kRAW: |
2e42b4d4 | 292 | fgQA = new AliQA(tsk) ; |
6c18591a | 293 | break ; |
294 | case kSIM: | |
2e42b4d4 | 295 | fgQA = new AliQA(tsk) ; |
421ab0fb | 296 | break ; |
297 | case kREC: | |
298 | printf("fgQA = gAlice->GetQA()") ; | |
299 | break ; | |
300 | case kESD: | |
301 | printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ; | |
302 | break ; | |
303 | case kANA: | |
304 | printf("fgQA = dynamic_cast<AliQA *> (esdFile->Get(\"QA\")") ; | |
305 | break ; | |
306 | case kNTASK: | |
307 | break ; | |
308 | } | |
309 | if (fgQA) | |
310 | fgQA->Set(tsk) ; | |
311 | return fgQA ; | |
312 | } | |
313 | ||
314 | //_______________________________________________________________ | |
2e42b4d4 | 315 | const ULong_t AliQA::Offset(ALITASK tsk) const |
421ab0fb | 316 | { |
317 | // Calculates the bit offset for a given module (SIM, REC, ESD, ANA) | |
318 | ||
319 | CheckRange(tsk) ; | |
320 | ||
321 | ULong_t offset = 0 ; | |
322 | switch (tsk) { | |
323 | case kNULLTASK: | |
324 | break ; | |
6c18591a | 325 | case kRAW: |
421ab0fb | 326 | offset+= 0 ; |
327 | break ; | |
6c18591a | 328 | case kSIM: |
421ab0fb | 329 | offset+= 4 ; |
330 | break ; | |
6c18591a | 331 | case kREC: |
421ab0fb | 332 | offset+= 8 ; |
333 | break ; | |
6c18591a | 334 | case kESD: |
421ab0fb | 335 | offset+= 12 ; |
336 | break ; | |
6c18591a | 337 | case kANA: |
338 | offset+= 16 ; | |
339 | break ; | |
421ab0fb | 340 | case kNTASK: |
341 | break ; | |
342 | } | |
343 | ||
344 | return offset ; | |
345 | } | |
346 | ||
347 | //_______________________________________________________________ | |
2e42b4d4 | 348 | void AliQA::Set(QABIT bit) |
421ab0fb | 349 | { |
350 | // Set the status bit of the current detector in the current module | |
351 | ||
352 | SetStatusBit(fDet, fTask, bit) ; | |
353 | } | |
354 | ||
355 | //_______________________________________________________________ | |
2e42b4d4 | 356 | void AliQA::SetStatusBit(DETECTORINDEX det, ALITASK tsk, QABIT bit) |
421ab0fb | 357 | { |
358 | // Set the status bit for a given detector and a given task | |
359 | ||
360 | CheckRange(det) ; | |
361 | CheckRange(tsk) ; | |
362 | CheckRange(bit) ; | |
363 | ||
364 | ULong_t offset = Offset(tsk) ; | |
365 | ULong_t status = GetStatus(det) ; | |
366 | offset+= bit ; | |
367 | status = status | 1 << offset ; | |
368 | SetStatus(det, status) ; | |
369 | } | |
370 | ||
371 | //_______________________________________________________________ | |
2e42b4d4 | 372 | void AliQA::ShowAll() const |
421ab0fb | 373 | { |
374 | // dispplay the QA status word | |
375 | Int_t index ; | |
376 | for (index = 0 ; index < kNDET ; index++) | |
377 | ShowStatus(DETECTORINDEX(index)) ; | |
378 | } | |
379 | ||
380 | //_______________________________________________________________ | |
2e42b4d4 | 381 | void AliQA::ShowStatus(DETECTORINDEX det) const |
421ab0fb | 382 | { |
383 | // Prints the full QA status of a given detector | |
384 | CheckRange(det) ; | |
385 | ULong_t status = GetStatus(det) ; | |
a4976ef3 | 386 | ULong_t rawStatus = status & 0x0000f ; |
387 | ULong_t simStatus = status & 0x000f0 ; | |
388 | ULong_t recStatus = status & 0x00f00 ; | |
389 | ULong_t esdStatus = status & 0x0f000 ; | |
390 | ULong_t anaStatus = status & 0xf0000 ; | |
421ab0fb | 391 | |
a4976ef3 | 392 | AliInfo(Form("QA Status for %s raw =0x%x, sim=0x%x, rec=0x%x, esd=0x%x, ana=0x%x\n", GetDetName(det).Data(), rawStatus, simStatus, recStatus, esdStatus, anaStatus )) ; |
421ab0fb | 393 | } |
394 |