]>
Commit | Line | Data |
---|---|---|
312e6f8d | 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$ */ | |
202374b1 | 17 | /////////////////////////////////////////////////////////////////////////////// |
18 | // // | |
19 | // class for running the QA makers // | |
20 | // // | |
21 | // AliQADataMakerSteer qas; // | |
22 | // qas.Run(AliQA::kRAWS, rawROOTFileName); // | |
23 | // qas.Run(AliQA::kHITS); // | |
24 | // qas.Run(AliQA::kSDIGITS); // | |
25 | // qas.Run(AliQA::kDIGITS); // | |
26 | // qas.Run(AliQA::kRECPOINTS); // | |
27 | // qas.Run(AliQA::kESDS); // | |
28 | // // | |
29 | /////////////////////////////////////////////////////////////////////////////// | |
312e6f8d | 30 | |
4edbc5bc | 31 | #include <TKey.h> |
312e6f8d | 32 | #include <TFile.h> |
567d83d9 | 33 | #include <TFileMerger.h> |
312e6f8d | 34 | #include <TPluginManager.h> |
35 | #include <TROOT.h> | |
36 | #include <TString.h> | |
37 | #include <TSystem.h> | |
38 | ||
4edbc5bc | 39 | #include "AliCDBManager.h" |
40 | #include "AliCDBEntry.h" | |
41 | #include "AliCDBId.h" | |
42 | #include "AliCDBMetaData.h" | |
940d8e5f | 43 | #include "AliCodeTimer.h" |
a2b64fbd | 44 | #include "AliCorrQADataMakerRec.h" |
0233bebf | 45 | #include "AliDetectorRecoParam.h" |
312e6f8d | 46 | #include "AliESDEvent.h" |
f451171e | 47 | #include "AliGeomManager.h" |
30bbd491 | 48 | #include "AliGlobalQADataMaker.h" |
6441b07a | 49 | #include "AliHeader.h" |
312e6f8d | 50 | #include "AliLog.h" |
007fcebb | 51 | #include "AliModule.h" |
312e6f8d | 52 | #include "AliQA.h" |
04236e67 | 53 | #include "AliQADataMakerRec.h" |
54 | #include "AliQADataMakerSim.h" | |
312e6f8d | 55 | #include "AliQADataMakerSteer.h" |
4ecde5fc | 56 | #include "AliRawReaderDate.h" |
57 | #include "AliRawReaderFile.h" | |
312e6f8d | 58 | #include "AliRawReaderRoot.h" |
59 | #include "AliRun.h" | |
60 | #include "AliRunLoader.h" | |
61 | ||
62 | ClassImp(AliQADataMakerSteer) | |
63 | ||
64 | //_____________________________________________________________________________ | |
a6e0ebfe | 65 | AliQADataMakerSteer::AliQADataMakerSteer(const Char_t * mode, const Char_t* gAliceFilename, const Char_t * name, const Char_t * title) : |
312e6f8d | 66 | TNamed(name, title), |
018c2b09 | 67 | fCurrentEvent(0), |
c65c502a | 68 | fCycleSame(kFALSE), |
fff5167b | 69 | fDetectors("ALL"), |
70 | fDetectorsW("ALL"), | |
312e6f8d | 71 | fESD(NULL), |
72 | fESDTree(NULL), | |
312e6f8d | 73 | fGAliceFileName(gAliceFilename), |
e30aef00 | 74 | fFirstEvent(0), |
30bbd491 | 75 | fMaxEvents(0), |
76 | fMode(mode), | |
774ac967 | 77 | fNumberOfEvents(999999), |
940d8e5f | 78 | fRecoParam(), |
30bbd491 | 79 | fRunNumber(0), |
312e6f8d | 80 | fRawReader(NULL), |
6441b07a | 81 | fRawReaderDelete(kTRUE), |
940d8e5f | 82 | fRunLoader(NULL), |
57acd2d2 | 83 | fTasks(""), |
84 | fEventSpecie(AliRecoParam::kDefault) | |
312e6f8d | 85 | { |
86 | // default ctor | |
f0c6fb4b | 87 | fMaxEvents = fNumberOfEvents ; |
312e6f8d | 88 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
4d52736b | 89 | if (IsSelected(AliQA::GetDetName(iDet))) { |
90 | fLoader[iDet] = NULL ; | |
91 | fQADataMaker[iDet] = NULL ; | |
92 | fQACycles[iDet] = 999999 ; | |
57acd2d2 | 93 | fQAWriteExpert[iDet] = kTRUE ; |
4d52736b | 94 | } |
312e6f8d | 95 | } |
96 | } | |
97 | ||
98 | //_____________________________________________________________________________ | |
99 | AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) : | |
100 | TNamed(qas), | |
018c2b09 | 101 | fCurrentEvent(qas.fCurrentEvent), |
c65c502a | 102 | fCycleSame(kFALSE), |
fff5167b | 103 | fDetectors(qas.fDetectors), |
104 | fDetectorsW(qas.fDetectorsW), | |
312e6f8d | 105 | fESD(NULL), |
106 | fESDTree(NULL), | |
312e6f8d | 107 | fGAliceFileName(qas.fGAliceFileName), |
e30aef00 | 108 | fFirstEvent(qas.fFirstEvent), |
30bbd491 | 109 | fMaxEvents(qas.fMaxEvents), |
110 | fMode(qas.fMode), | |
312e6f8d | 111 | fNumberOfEvents(qas.fNumberOfEvents), |
940d8e5f | 112 | fRecoParam(), |
113 | fRunNumber(qas.fRunNumber), | |
312e6f8d | 114 | fRawReader(NULL), |
6441b07a | 115 | fRawReaderDelete(kTRUE), |
940d8e5f | 116 | fRunLoader(NULL), |
57acd2d2 | 117 | fTasks(qas.fTasks), |
118 | fEventSpecie(qas.fEventSpecie) | |
312e6f8d | 119 | { |
120 | // cpy ctor | |
121 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
252f8aa8 | 122 | fLoader[iDet] = qas.fLoader[iDet] ; |
123 | fQADataMaker[iDet] = qas.fQADataMaker[iDet] ; | |
124 | fQACycles[iDet] = qas.fQACycles[iDet] ; | |
125 | fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ; | |
312e6f8d | 126 | } |
127 | } | |
128 | ||
129 | //_____________________________________________________________________________ | |
130 | AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas) | |
131 | { | |
132 | // assignment operator | |
133 | this->~AliQADataMakerSteer() ; | |
134 | new(this) AliQADataMakerSteer(qas) ; | |
135 | return *this ; | |
136 | } | |
137 | ||
138 | //_____________________________________________________________________________ | |
139 | AliQADataMakerSteer::~AliQADataMakerSteer() | |
140 | { | |
141 | // dtor | |
57e8b77b | 142 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
143 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
4d52736b | 144 | fLoader[iDet] = NULL; |
145 | if (fQADataMaker[iDet]) { | |
146 | (fQADataMaker[iDet])->Finish() ; | |
fa18368b | 147 | delete fQADataMaker[iDet] ; |
4d52736b | 148 | } |
57e8b77b | 149 | } |
150 | } | |
57e8b77b | 151 | if (fRawReaderDelete) { |
152 | fRunLoader = NULL ; | |
153 | delete fRawReader ; | |
154 | fRawReader = NULL ; | |
155 | } | |
312e6f8d | 156 | } |
157 | ||
4d52736b | 158 | //_____________________________________________________________________________ |
30bbd491 | 159 | Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex) |
4d52736b | 160 | { |
161 | // Runs all the QA data Maker for every detector | |
95932286 | 162 | |
4d52736b | 163 | Bool_t rv = kFALSE ; |
4d52736b | 164 | // Fill QA data in event loop |
95932286 | 165 | for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) { |
018c2b09 | 166 | fCurrentEvent++ ; |
4d52736b | 167 | // Get the event |
a6f6970e | 168 | if ( iEvent%10 == 0 ) |
169 | AliInfo(Form("processing event %d", iEvent)); | |
4d52736b | 170 | if ( taskIndex == AliQA::kRAWS ) { |
171 | if ( !fRawReader->NextEvent() ) | |
172 | break ; | |
173 | } else if ( taskIndex == AliQA::kESDS ) { | |
774ac967 | 174 | if ( fESDTree->GetEntry(iEvent) == 0 ) |
175 | break ; | |
4d52736b | 176 | } else { |
774ac967 | 177 | if ( fRunLoader->GetEvent(iEvent) != 0 ) |
178 | break ; | |
4d52736b | 179 | } |
56f4f5f4 | 180 | // loop over active loaders |
30bbd491 | 181 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
182 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
183 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
d15bbee6 | 184 | if (!qadm) continue; // This detector doesn't have any QA (for example, HLT) |
30bbd491 | 185 | if ( qadm->IsCycleDone() ) { |
57acd2d2 | 186 | qadm->EndOfCycle(taskIndex) ; |
30bbd491 | 187 | } |
c5595529 | 188 | TTree * data = NULL ; |
30bbd491 | 189 | AliLoader* loader = GetLoader(qadm->GetUniqueID()); |
190 | switch (taskIndex) { | |
940d8e5f | 191 | case AliQA::kNULLTASKINDEX : |
192 | break ; | |
30bbd491 | 193 | case AliQA::kRAWS : |
194 | qadm->Exec(taskIndex, fRawReader) ; | |
195 | break ; | |
196 | case AliQA::kHITS : | |
c5595529 | 197 | if( loader ) { |
198 | loader->LoadHits() ; | |
199 | data = loader->TreeH() ; | |
200 | if ( ! data ) { | |
201 | AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ; | |
202 | break ; | |
203 | } | |
204 | } | |
205 | qadm->Exec(taskIndex, data) ; | |
30bbd491 | 206 | break ; |
207 | case AliQA::kSDIGITS : | |
c5595529 | 208 | if( loader ) { |
209 | loader->LoadSDigits() ; | |
210 | data = loader->TreeS() ; | |
211 | if ( ! data ) { | |
212 | AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ; | |
213 | break ; | |
214 | } | |
215 | } | |
216 | qadm->Exec(taskIndex, data) ; | |
30bbd491 | 217 | break; |
218 | case AliQA::kDIGITS : | |
c5595529 | 219 | if( loader ) { |
220 | loader->LoadDigits() ; | |
221 | data = loader->TreeD() ; | |
222 | if ( ! data ) { | |
223 | AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ; | |
224 | break ; | |
225 | } | |
226 | } | |
227 | qadm->Exec(taskIndex, data) ; | |
30bbd491 | 228 | break; |
229 | case AliQA::kRECPOINTS : | |
c5595529 | 230 | if( loader ) { |
231 | loader->LoadRecPoints() ; | |
232 | data = loader->TreeR() ; | |
233 | if (!data) { | |
234 | AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ; | |
235 | break ; | |
236 | } | |
237 | } | |
238 | qadm->Exec(taskIndex, data) ; | |
239 | break; | |
30bbd491 | 240 | case AliQA::kTRACKSEGMENTS : |
241 | break; | |
242 | case AliQA::kRECPARTICLES : | |
243 | break; | |
244 | case AliQA::kESDS : | |
245 | qadm->Exec(taskIndex, fESD) ; | |
246 | break; | |
247 | case AliQA::kNTASKINDEX : | |
248 | break; | |
249 | } //task switch | |
250 | } | |
4d52736b | 251 | } // detector loop |
930e6e3e | 252 | Increment() ; |
4d52736b | 253 | } // event loop |
30bbd491 | 254 | // Save QA data for all detectors |
255 | rv = Finish(taskIndex) ; | |
54b7165d | 256 | |
257 | if ( taskIndex == AliQA::kRAWS ) | |
258 | fRawReader->RewindEvents() ; | |
fff5167b | 259 | |
4d52736b | 260 | return rv ; |
261 | } | |
262 | ||
4edbc5bc | 263 | //_____________________________________________________________________________ |
30bbd491 | 264 | Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex) |
4edbc5bc | 265 | { |
266 | // write output to file for all detectors | |
30bbd491 | 267 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
268 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
269 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
57acd2d2 | 270 | if (qadm) |
271 | qadm->EndOfCycle(taskIndex) ; | |
30bbd491 | 272 | } |
273 | } | |
4edbc5bc | 274 | return kTRUE ; |
275 | } | |
276 | ||
277 | //_____________________________________________________________________________ | |
96d67a8d | 278 | TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const |
4edbc5bc | 279 | { |
280 | // Retrieve the list of QA data for a given detector and a given task | |
f73f556a | 281 | TObjArray * rv = NULL ; |
605cb8bb | 282 | if ( !strlen(AliQA::GetQARefStorage()) ) { |
f73f556a | 283 | AliError("No storage defined, use AliQA::SetQARefStorage") ; |
284 | return NULL ; | |
285 | } | |
4edbc5bc | 286 | AliCDBManager* man = AliCDBManager::Instance() ; |
f73f556a | 287 | if ( ! man->IsDefaultStorageSet() ) { |
11032e1d | 288 | TString tmp(AliQA::GetQARefDefaultStorage()) ; |
289 | tmp.Append(year) ; | |
290 | tmp.Append("/") ; | |
291 | man->SetDefaultStorage(tmp.Data()) ; | |
96d67a8d | 292 | man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ; |
f73f556a | 293 | } |
614a7f99 | 294 | TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ; |
295 | AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ; | |
296 | AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number | |
4edbc5bc | 297 | TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ; |
298 | if ( listDetQAD ) | |
f73f556a | 299 | rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ; |
4edbc5bc | 300 | return rv ; |
301 | } | |
302 | ||
312e6f8d | 303 | //_____________________________________________________________________________ |
304 | AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet) | |
305 | { | |
306 | // get the loader for a detector | |
56f4f5f4 | 307 | |
c5595529 | 308 | if ( !fRunLoader || iDet == AliQA::kCORR) |
56f4f5f4 | 309 | return NULL ; |
312e6f8d | 310 | |
311 | TString detName = AliQA::GetDetName(iDet) ; | |
312 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); | |
313 | if (fLoader[iDet]) | |
314 | return fLoader[iDet] ; | |
315 | ||
316 | // load the QA data maker object | |
317 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
318 | TString loaderName = "Ali" + detName + "Loader" ; | |
319 | ||
320 | AliLoader * loader = NULL ; | |
321 | // first check if a plugin is defined for the quality assurance data maker | |
322 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
323 | // if not, add a plugin for it | |
324 | if (!pluginHandler) { | |
325 | AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ; | |
326 | TString libs = gSystem->GetLibraries() ; | |
327 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
328 | pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ; | |
329 | } else { | |
330 | pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ; | |
331 | } | |
332 | pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
333 | } | |
334 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
335 | loader = (AliLoader *) pluginHandler->ExecPlugin(0) ; | |
336 | } | |
337 | if (loader) | |
338 | fLoader[iDet] = loader ; | |
339 | return loader ; | |
340 | } | |
341 | ||
342 | //_____________________________________________________________________________ | |
57acd2d2 | 343 | AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet) |
312e6f8d | 344 | { |
345 | // get the quality assurance data maker for a detector | |
346 | ||
57acd2d2 | 347 | if (fQADataMaker[iDet]) { |
348 | fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ; | |
312e6f8d | 349 | return fQADataMaker[iDet] ; |
57acd2d2 | 350 | } |
312e6f8d | 351 | |
352 | AliQADataMaker * qadm = NULL ; | |
353 | ||
30bbd491 | 354 | if (iDet == AliQA::kGLOBAL) { //Global QA |
355 | qadm = new AliGlobalQADataMaker(); | |
7c37c363 | 356 | qadm->SetName(AliQA::GetDetName(iDet)); |
357 | qadm->SetUniqueID(iDet); | |
30bbd491 | 358 | fQADataMaker[iDet] = qadm; |
57acd2d2 | 359 | qadm->SetEventSpecie(fEventSpecie) ; |
30bbd491 | 360 | return qadm; |
361 | } | |
362 | ||
a2b64fbd | 363 | if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors |
364 | qadm = new AliCorrQADataMakerRec(fQADataMaker) ; | |
365 | qadm->SetName(AliQA::GetDetName(iDet)); | |
366 | qadm->SetUniqueID(iDet); | |
367 | fQADataMaker[iDet] = qadm; | |
57acd2d2 | 368 | qadm->SetEventSpecie(fEventSpecie) ; |
a2b64fbd | 369 | return qadm; |
370 | } | |
371 | ||
30bbd491 | 372 | // load the QA data maker object |
373 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
374 | TString detName = AliQA::GetDetName(iDet) ; | |
375 | TString tmp(fMode) ; | |
376 | if (tmp.Contains("sim")) | |
377 | tmp.ReplaceAll("s", "S") ; | |
378 | else if (tmp.Contains("rec")) | |
379 | tmp.ReplaceAll("r", "R") ; | |
380 | ||
381 | TString qadmName = "Ali" + detName + "QADataMaker" + tmp ; | |
382 | ||
383 | // first check if a plugin is defined for the quality assurance data maker | |
384 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; | |
385 | // if not, add a plugin for it | |
386 | if (!pluginHandler) { | |
387 | AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ; | |
388 | TString libs = gSystem->GetLibraries() ; | |
389 | if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) { | |
390 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ; | |
391 | } else { | |
392 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ; | |
312e6f8d | 393 | } |
30bbd491 | 394 | pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; |
395 | } | |
396 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
397 | qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ; | |
312e6f8d | 398 | } |
940d8e5f | 399 | if (qadm) { |
940d8e5f | 400 | qadm->SetName(AliQA::GetDetName(iDet)); |
401 | qadm->SetUniqueID(iDet); | |
7c37c363 | 402 | fQADataMaker[iDet] = qadm ; |
57acd2d2 | 403 | qadm->SetEventSpecie(fEventSpecie) ; |
940d8e5f | 404 | } |
57acd2d2 | 405 | |
406 | return qadm ; | |
312e6f8d | 407 | } |
408 | ||
940d8e5f | 409 | //_____________________________________________________________________________ |
410 | void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray) | |
411 | { | |
412 | // End of cycle QADataMakers | |
413 | ||
414 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
415 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
416 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
417 | if (!qadm) | |
418 | continue ; | |
419 | // skip non active detectors | |
420 | if (detArray) { | |
421 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ; | |
422 | if (!det || !det->IsActive()) | |
423 | continue ; | |
424 | } | |
425 | for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) { | |
426 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
427 | qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ; | |
428 | } | |
429 | qadm->Finish(); | |
430 | } | |
431 | } | |
432 | } | |
433 | ||
6294b9a7 | 434 | //_____________________________________________________________________________ |
435 | void AliQADataMakerSteer::EndOfCycle(TString detectors) | |
436 | { | |
437 | // End of cycle QADataMakers | |
438 | ||
439 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
440 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
441 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
442 | if (!qadm) | |
443 | continue ; | |
444 | // skip non active detectors | |
445 | if (!detectors.Contains(AliQA::GetDetName(iDet))) | |
446 | continue ; | |
447 | for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) { | |
448 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
449 | qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ; | |
450 | } | |
451 | qadm->Finish(); | |
452 | } | |
453 | } | |
454 | } | |
455 | ||
930e6e3e | 456 | //_____________________________________________________________________________ |
457 | void AliQADataMakerSteer::Increment() | |
458 | { | |
459 | // Increments the cycle counter for all QA Data Makers | |
460 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
461 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
462 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; | |
463 | if (qadm) | |
464 | qadm->Increment() ; | |
465 | } | |
466 | } | |
467 | } | |
468 | ||
312e6f8d | 469 | //_____________________________________________________________________________ |
30bbd491 | 470 | Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input ) |
312e6f8d | 471 | { |
472 | // Initialize the event source and QA data makers | |
473 | ||
194bc923 | 474 | //fTasks = AliQA::GetTaskName(taskIndex) ; |
940d8e5f | 475 | |
6441b07a | 476 | if (taskIndex == AliQA::kRAWS) { |
477 | if (!fRawReader) { | |
e64fcb90 | 478 | fRawReader = AliRawReader::Create(input); |
4ecde5fc | 479 | } |
940d8e5f | 480 | if ( ! fRawReader ) |
312e6f8d | 481 | return kFALSE ; |
fff5167b | 482 | fRawReaderDelete = kTRUE ; |
312e6f8d | 483 | fRawReader->NextEvent() ; |
484 | fRunNumber = fRawReader->GetRunNumber() ; | |
04236e67 | 485 | AliCDBManager::Instance()->SetRun(fRunNumber) ; |
312e6f8d | 486 | fRawReader->RewindEvents(); |
487 | fNumberOfEvents = 999999 ; | |
f0c6fb4b | 488 | if ( fMaxEvents < 0 ) |
489 | fMaxEvents = fNumberOfEvents ; | |
490 | } else if (taskIndex == AliQA::kESDS) { | |
940d8e5f | 491 | fTasks = AliQA::GetTaskName(AliQA::kESDS) ; |
b1344d8d | 492 | if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists |
493 | TFile * esdFile = TFile::Open("AliESDs.root") ; | |
494 | fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ; | |
495 | if ( !fESDTree ) { | |
496 | AliError("esdTree not found") ; | |
497 | return kFALSE ; | |
498 | } else { | |
499 | fESD = new AliESDEvent() ; | |
500 | fESD->ReadFromTree(fESDTree) ; | |
501 | fESDTree->GetEntry(0) ; | |
502 | fRunNumber = fESD->GetRunNumber() ; | |
503 | fNumberOfEvents = fESDTree->GetEntries() ; | |
504 | if ( fMaxEvents < 0 ) | |
505 | fMaxEvents = fNumberOfEvents ; | |
506 | } | |
507 | } else { | |
508 | AliError("AliESDs.root not found") ; | |
509 | return kFALSE ; | |
510 | } | |
511 | } else { | |
512 | if ( !InitRunLoader() ) { | |
513 | AliWarning("No Run Loader not found") ; | |
514 | } else { | |
515 | fNumberOfEvents = fRunLoader->GetNumberOfEvents() ; | |
516 | if ( fMaxEvents < 0 ) | |
517 | fMaxEvents = fNumberOfEvents ; | |
518 | } | |
519 | } | |
fff5167b | 520 | |
b1344d8d | 521 | // Get Detectors |
522 | TObjArray* detArray = NULL ; | |
56f4f5f4 | 523 | if (fRunLoader) // check if RunLoader exists |
b37ee1e8 | 524 | if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root |
56f4f5f4 | 525 | detArray = fRunLoader->GetAliRun()->Detectors() ; |
b37ee1e8 | 526 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; |
527 | } | |
30bbd491 | 528 | |
529 | // Initialize all QA data makers for all detectors | |
530 | fRunNumber = AliCDBManager::Instance()->GetRun() ; | |
531 | if ( ! AliGeomManager::GetGeometry() ) | |
532 | AliGeomManager::LoadGeometry() ; | |
533 | ||
57acd2d2 | 534 | InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; |
940d8e5f | 535 | return kTRUE ; |
536 | } | |
537 | ||
538 | //_____________________________________________________________________________ | |
57acd2d2 | 539 | void AliQADataMakerSteer::InitQADataMaker(UInt_t run, TObjArray * detArray) |
940d8e5f | 540 | { |
541 | // Initializes The QADataMaker for all active detectors and for all active tasks | |
56f4f5f4 | 542 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4d52736b | 543 | if (IsSelected(AliQA::GetDetName(iDet))) { |
30bbd491 | 544 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
4d52736b | 545 | if (!qadm) { |
fff5167b | 546 | AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ; |
547 | fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ; | |
4d52736b | 548 | } else { |
57acd2d2 | 549 | if (fQAWriteExpert[iDet]) |
550 | qadm->SetWriteExpert() ; | |
fff5167b | 551 | AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ; |
56f4f5f4 | 552 | // skip non active detectors |
553 | if (detArray) { | |
554 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ; | |
555 | if (!det || !det->IsActive()) | |
556 | continue ; | |
557 | } | |
e1a19d1a | 558 | if (fQAWriteExpert[iDet]) qadm->SetWriteExpert() ; |
940d8e5f | 559 | // Set default reco params |
930e6e3e | 560 | Bool_t sameCycle = kFALSE ; |
940d8e5f | 561 | for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) { |
562 | if ( fTasks.Contains(Form("%d", taskIndex)) ) { | |
930e6e3e | 563 | qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ; |
57acd2d2 | 564 | qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, sameCycle) ; |
930e6e3e | 565 | sameCycle = kTRUE ; |
940d8e5f | 566 | } |
567 | } | |
4d52736b | 568 | } |
312e6f8d | 569 | } |
940d8e5f | 570 | } |
312e6f8d | 571 | } |
572 | ||
a2b64fbd | 573 | |
312e6f8d | 574 | //_____________________________________________________________________________ |
575 | Bool_t AliQADataMakerSteer::InitRunLoader() | |
576 | { | |
577 | // get or create the run loader | |
578 | if (fRunLoader) { | |
c65c502a | 579 | fCycleSame = kTRUE ; |
e4a998ed | 580 | } else { |
581 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists | |
582 | // load all base libraries to get the loader classes | |
583 | TString libs = gSystem->GetLibraries() ; | |
584 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
585 | if (!IsSelected(AliQA::GetDetName(iDet))) | |
586 | continue ; | |
587 | TString detName = AliQA::GetDetName(iDet) ; | |
588 | if (detName == "HLT") | |
589 | continue; | |
590 | if (libs.Contains("lib" + detName + "base.so")) | |
591 | continue; | |
592 | gSystem->Load("lib" + detName + "base.so"); | |
593 | } | |
594 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); | |
595 | if (!fRunLoader) { | |
596 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
597 | return kFALSE; | |
598 | } | |
599 | fRunLoader->CdGAFile(); | |
600 | if (fRunLoader->LoadgAlice() == 0) { | |
601 | gAlice = fRunLoader->GetAliRun(); | |
602 | } | |
603 | ||
604 | if (!gAlice) { | |
605 | AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data())); | |
606 | return kFALSE; | |
607 | } | |
4d52736b | 608 | |
e4a998ed | 609 | } else { // galice.root does not exist |
610 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
312e6f8d | 611 | return kFALSE; |
612 | } | |
e4a998ed | 613 | } |
312e6f8d | 614 | |
e4a998ed | 615 | if (!fRunNumber) { |
616 | fRunLoader->LoadHeader(); | |
617 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; | |
618 | } | |
619 | return kTRUE; | |
312e6f8d | 620 | } |
621 | ||
04236e67 | 622 | //_____________________________________________________________________________ |
623 | Bool_t AliQADataMakerSteer::IsSelected(const char * det) | |
624 | { | |
625 | // check whether detName is contained in detectors | |
626 | // if yes, it is removed from detectors | |
627 | ||
56f4f5f4 | 628 | Bool_t rv = kFALSE; |
04236e67 | 629 | const TString detName(det) ; |
a2b64fbd | 630 | // always activates Correlation |
631 | if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) { | |
632 | rv = kTRUE ; | |
633 | } else { | |
634 | // check if all detectors are selected | |
635 | if (fDetectors.Contains("ALL")) { | |
636 | fDetectors = "ALL"; | |
637 | rv = kTRUE; | |
638 | } else if ((fDetectors.CompareTo(detName) == 0) || | |
639 | fDetectors.BeginsWith(detName+" ") || | |
640 | fDetectors.EndsWith(" "+detName) || | |
641 | fDetectors.Contains(" "+detName+" ")) { | |
642 | rv = kTRUE; | |
643 | } | |
644 | } | |
04236e67 | 645 | return rv ; |
646 | } | |
647 | ||
312e6f8d | 648 | //_____________________________________________________________________________ |
4edbc5bc | 649 | Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const |
f5464b75 | 650 | { |
651 | // Merge data from all the cycles from all detectors in one single file per run | |
652 | // Merge the QA results from all the data chunks in one run | |
653 | Bool_t rv = MergeData(runNumber) ; | |
654 | rv *= MergeResults(runNumber) ; | |
655 | return rv ; | |
656 | } | |
657 | ||
658 | ||
659 | //_____________________________________________________________________________ | |
660 | Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const | |
315bba70 | 661 | { |
567d83d9 | 662 | // Merge all the cycles from all detectors in one single file per run |
614a7f99 | 663 | TString cmd ; |
f5464b75 | 664 | if (runNumber == -1) |
147c1c84 | 665 | cmd = Form(".! ls *%s*.%d.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ; |
f5464b75 | 666 | else |
147c1c84 | 667 | cmd = Form(".! ls *%s*.*.root > tempo.txt", AliQA::GetQADataFileName()) ; |
614a7f99 | 668 | gROOT->ProcessLine(cmd.Data()) ; |
567d83d9 | 669 | ifstream in("tempo.txt") ; |
670 | const Int_t runMax = 10 ; | |
671 | TString file[AliQA::kNDET*runMax] ; | |
567d83d9 | 672 | |
673 | Int_t index = 0 ; | |
674 | while ( 1 ) { | |
4edbc5bc | 675 | in >> file[index] ; |
567d83d9 | 676 | if ( !in.good() ) |
677 | break ; | |
e5dedfe2 | 678 | AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ; |
679 | index++ ; | |
4edbc5bc | 680 | } |
681 | ||
682 | if ( index == 0 ) { | |
683 | AliError(Form("run number %d not found", runNumber)) ; | |
684 | return kFALSE ; | |
567d83d9 | 685 | } |
147c1c84 | 686 | |
687 | TFileMerger merger ; | |
688 | TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),runNumber)); | |
689 | merger.OutputFile(outFileName.Data()) ; | |
690 | for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) { | |
691 | TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), runNumber)); | |
692 | TString tmp(file[ifile]) ; | |
693 | if (tmp.Contains(pattern)) { | |
694 | merger.AddFile(tmp) ; | |
695 | } | |
567d83d9 | 696 | } |
147c1c84 | 697 | merger.Merge() ; |
567d83d9 | 698 | return kTRUE ; |
315bba70 | 699 | } |
700 | ||
f5464b75 | 701 | //_____________________________________________________________________________ |
702 | Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const | |
703 | { | |
704 | // Merge the QA result from all the data chunks in a run | |
705 | TString cmd ; | |
706 | cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ; | |
707 | gROOT->ProcessLine(cmd.Data()) ; | |
708 | ifstream in("tempo.txt") ; | |
709 | const Int_t chunkMax = 100 ; | |
710 | TString fileList[chunkMax] ; | |
711 | ||
712 | Int_t index = 0 ; | |
713 | while ( 1 ) { | |
714 | TString file ; | |
715 | in >> fileList[index] ; | |
716 | if ( !in.good() ) | |
717 | break ; | |
718 | AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ; | |
719 | index++ ; | |
720 | } | |
721 | ||
722 | if ( index == 0 ) { | |
723 | AliError("No QA Result File found") ; | |
724 | return kFALSE ; | |
725 | } | |
726 | ||
727 | TFileMerger merger ; | |
728 | TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber)); | |
729 | merger.OutputFile(outFileName.Data()) ; | |
730 | for (Int_t ifile = 0 ; ifile < index ; ifile++) { | |
731 | TString file = fileList[ifile] ; | |
732 | merger.AddFile(file) ; | |
733 | } | |
734 | merger.Merge() ; | |
735 | ||
736 | return kTRUE ; | |
737 | } | |
738 | ||
c65c502a | 739 | //_____________________________________________________________________________ |
fff5167b | 740 | void AliQADataMakerSteer::Reset(const Bool_t sameCycle) |
c65c502a | 741 | { |
742 | // Reset the default data members | |
c65c502a | 743 | |
30bbd491 | 744 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
745 | if (IsSelected(AliQA::GetDetName(iDet))) { | |
746 | AliQADataMaker * qadm = GetQADataMaker(iDet); | |
930e6e3e | 747 | qadm->Reset(); |
30bbd491 | 748 | } |
56f4f5f4 | 749 | } |
6441b07a | 750 | if (fRawReaderDelete) { |
751 | delete fRawReader ; | |
752 | fRawReader = NULL ; | |
753 | } | |
c65c502a | 754 | |
fff5167b | 755 | fCycleSame = sameCycle ; |
c65c502a | 756 | fESD = NULL ; |
757 | fESDTree = NULL ; | |
30bbd491 | 758 | //fFirst = kTRUE ; |
774ac967 | 759 | fNumberOfEvents = 999999 ; |
c65c502a | 760 | } |
761 | ||
6441b07a | 762 | //_____________________________________________________________________________ |
7c002d48 | 763 | TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle) |
6441b07a | 764 | { |
765 | //Runs all the QA data Maker for Raws only | |
7c002d48 | 766 | |
767 | fCycleSame = sameCycle ; | |
768 | fRawReader = rawReader ; | |
4d52736b | 769 | fDetectors = detectors ; |
7c002d48 | 770 | fDetectorsW = detectors ; |
771 | ||
95932286 | 772 | AliCDBManager* man = AliCDBManager::Instance() ; |
7930d770 | 773 | |
95932286 | 774 | if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data |
95932286 | 775 | rawReader->NextEvent() ; |
776 | man->SetRun(fRawReader->GetRunNumber()) ; | |
777 | rawReader->RewindEvents() ; | |
778 | } | |
779 | ||
6294b9a7 | 780 | if (!fCycleSame) |
781 | if ( !Init(AliQA::kRAWS) ) | |
782 | return kFALSE ; | |
783 | fRawReaderDelete = kFALSE ; | |
ea9ce23f | 784 | |
30bbd491 | 785 | DoIt(AliQA::kRAWS) ; |
e5dedfe2 | 786 | return fDetectorsW ; |
04236e67 | 787 | } |
788 | ||
789 | //_____________________________________________________________________________ | |
7c002d48 | 790 | TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle) |
04236e67 | 791 | { |
792 | //Runs all the QA data Maker for Raws only | |
7c002d48 | 793 | |
794 | fCycleSame = sameCycle ; | |
04236e67 | 795 | fDetectors = detectors ; |
e5dedfe2 | 796 | fDetectorsW = detectors ; |
04236e67 | 797 | |
95932286 | 798 | AliCDBManager* man = AliCDBManager::Instance() ; |
95932286 | 799 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun |
800 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
801 | if ( ! rl ) { | |
802 | AliFatal("galice.root file not found in current directory") ; | |
803 | } else { | |
804 | rl->CdGAFile() ; | |
805 | rl->LoadgAlice() ; | |
806 | if ( ! rl->GetAliRun() ) { | |
807 | AliFatal("AliRun not found in galice.root") ; | |
808 | } else { | |
809 | rl->LoadHeader() ; | |
810 | man->SetRun(rl->GetHeader()->GetRun()); | |
811 | } | |
812 | } | |
813 | } | |
814 | ||
6294b9a7 | 815 | if (!fCycleSame) |
816 | if ( !Init(AliQA::kRAWS, fileName) ) | |
817 | return kFALSE ; | |
ea9ce23f | 818 | |
30bbd491 | 819 | DoIt(AliQA::kRAWS) ; |
fff5167b | 820 | return fDetectorsW ; |
6441b07a | 821 | } |
822 | ||
312e6f8d | 823 | //_____________________________________________________________________________ |
7c002d48 | 824 | TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName ) |
312e6f8d | 825 | { |
826 | // Runs all the QA data Maker for every detector | |
7c002d48 | 827 | |
828 | fCycleSame = sameCycle ; | |
829 | fDetectors = detectors ; | |
830 | fDetectorsW = detectors ; | |
831 | ||
65c771ca | 832 | AliCDBManager* man = AliCDBManager::Instance() ; |
95932286 | 833 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun |
834 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
835 | if ( ! rl ) { | |
836 | AliFatal("galice.root file not found in current directory") ; | |
837 | } else { | |
838 | rl->CdGAFile() ; | |
839 | rl->LoadgAlice() ; | |
840 | if ( ! rl->GetAliRun() ) { | |
efb37e8e | 841 | AliInfo("AliRun not found in galice.root") ; |
95932286 | 842 | } else { |
843 | rl->LoadHeader() ; | |
844 | man->SetRun(rl->GetHeader()->GetRun()) ; | |
845 | } | |
846 | } | |
847 | } | |
848 | ||
ea9ce23f | 849 | |
940d8e5f | 850 | if ( taskIndex == AliQA::kNULLTASKINDEX) { |
194bc923 | 851 | for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) { |
b1344d8d | 852 | if ( fTasks.Contains(Form("%d", task)) ) { |
853 | if (!fCycleSame) | |
854 | if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) ) | |
855 | return kFALSE ; | |
856 | DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ; | |
194bc923 | 857 | } |
858 | } | |
859 | } else { | |
6294b9a7 | 860 | if (! fCycleSame ) |
861 | if ( !Init(taskIndex, fileName) ) | |
862 | return kFALSE ; | |
863 | DoIt(taskIndex) ; | |
864 | } | |
4d52736b | 865 | |
e5dedfe2 | 866 | return fDetectorsW ; |
6441b07a | 867 | |
14e1eccc | 868 | } |
4edbc5bc | 869 | |
940d8e5f | 870 | //_____________________________________________________________________________ |
871 | void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader) | |
872 | { | |
873 | //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method) | |
930e6e3e | 874 | if ( ! rawReader ) |
875 | return ; | |
940d8e5f | 876 | AliCodeTimerAuto("") ; |
a2b64fbd | 877 | if (fTasks.Contains(Form("%d", AliQA::kRAWS))){ |
878 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
879 | if (!IsSelected(AliQA::GetDetName(iDet))) | |
880 | continue; | |
881 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
882 | if (!qadm) | |
883 | continue; | |
930e6e3e | 884 | if ( qadm->IsCycleDone() ) { |
885 | qadm->EndOfCycle() ; | |
886 | } | |
a2b64fbd | 887 | AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
57acd2d2 | 888 | qadm->SetEventSpecie(fEventSpecie) ; |
940d8e5f | 889 | qadm->Exec(AliQA::kRAWS, rawReader) ; |
a2b64fbd | 890 | AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 891 | } |
a2b64fbd | 892 | } |
940d8e5f | 893 | } |
894 | ||
895 | //_____________________________________________________________________________ | |
896 | void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd) | |
897 | { | |
898 | //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
899 | ||
900 | AliCodeTimerAuto("") ; | |
a2b64fbd | 901 | if (fTasks.Contains(Form("%d", AliQA::kESDS))) { |
902 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
903 | if (!IsSelected(AliQA::GetDetName(iDet))) | |
904 | continue; | |
905 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
906 | if (!qadm) | |
907 | continue; | |
930e6e3e | 908 | if ( qadm->IsCycleDone() ) { |
909 | qadm->EndOfCycle() ; | |
910 | } | |
a2b64fbd | 911 | AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 912 | qadm->Exec(AliQA::kESDS, esd) ; |
a2b64fbd | 913 | AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet))); |
940d8e5f | 914 | } |
915 | } | |
916 | } | |
917 | ||
918 | //_____________________________________________________________________________ | |
919 | void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree) | |
920 | { | |
921 | // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
922 | AliCodeTimerAuto("") ; | |
a2b64fbd | 923 | if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) { |
930e6e3e | 924 | if (IsSelected(AliQA::GetDetName(det))) { |
a2b64fbd | 925 | AliQADataMaker *qadm = GetQADataMaker(det); |
926 | if (qadm) { | |
930e6e3e | 927 | if ( qadm->IsCycleDone() ) { |
928 | qadm->EndOfCycle() ; | |
929 | } | |
a2b64fbd | 930 | AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det))); |
931 | qadm->Exec(AliQA::kRECPOINTS, tree) ; | |
930e6e3e | 932 | AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det))); |
933 | } | |
934 | } | |
935 | } | |
940d8e5f | 936 | } |
937 | ||
4edbc5bc | 938 | //_____________________________________________________________________________ |
57acd2d2 | 939 | Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const char * year, const char * detectors) const |
4edbc5bc | 940 | { |
941 | // take the locasl QA data merge into a single file and save in OCDB | |
942 | Bool_t rv = kTRUE ; | |
943 | TString tmp(AliQA::GetQARefStorage()) ; | |
944 | if ( tmp.IsNull() ) { | |
945 | AliError("No storage defined, use AliQA::SetQARefStorage") ; | |
946 | return kFALSE ; | |
947 | } | |
948 | if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) { | |
949 | AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ; | |
950 | return kFALSE ; | |
951 | } | |
952 | TString sdet(detectors) ; | |
953 | sdet.ToUpper() ; | |
954 | TFile * inputFile ; | |
955 | if ( sdet.Contains("ALL") ) { | |
956 | rv = Merge(runNumber) ; | |
957 | if ( ! rv ) | |
958 | return kFALSE ; | |
147c1c84 | 959 | TString inputFileName(Form("Merged.%s.Data.%d.root", AliQA::GetQADataFileName(), runNumber)) ; |
614a7f99 | 960 | inputFile = TFile::Open(inputFileName.Data()) ; |
57acd2d2 | 961 | rv = SaveIt2OCDB(runNumber, inputFile, year, es) ; |
4edbc5bc | 962 | } else { |
963 | for (Int_t index = 0; index < AliQA::kNDET; index++) { | |
964 | if (sdet.Contains(AliQA::GetDetName(index))) { | |
147c1c84 | 965 | TString inputFileName(Form("%s.%s.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber)) ; |
614a7f99 | 966 | inputFile = TFile::Open(inputFileName.Data()) ; |
57acd2d2 | 967 | rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ; |
4edbc5bc | 968 | } |
969 | } | |
970 | } | |
971 | return rv ; | |
972 | } | |
973 | ||
974 | //_____________________________________________________________________________ | |
57acd2d2 | 975 | Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year, AliRecoParam::EventSpecie_t es) const |
4edbc5bc | 976 | { |
977 | // reads the TH1 from file and adds it to appropriate list before saving to OCDB | |
978 | Bool_t rv = kTRUE ; | |
979 | AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ; | |
980 | AliCDBManager* man = AliCDBManager::Instance() ; | |
f73f556a | 981 | if ( ! man->IsDefaultStorageSet() ) { |
a681ca96 | 982 | TString tmp( AliQA::GetQARefStorage() ) ; |
983 | if ( tmp.Contains(AliQA::GetLabLocalOCDB()) ) | |
984 | man->SetDefaultStorage(AliQA::GetQARefStorage()) ; | |
985 | else { | |
605cb8bb | 986 | TString tmp1(AliQA::GetQARefDefaultStorage()) ; |
987 | tmp1.Append(year) ; | |
988 | tmp1.Append("?user=alidaq") ; | |
989 | man->SetDefaultStorage(tmp1.Data()) ; | |
a681ca96 | 990 | } |
f73f556a | 991 | } |
a681ca96 | 992 | man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ; |
04236e67 | 993 | if(man->GetRun() < 0) |
994 | man->SetRun(runNumber); | |
995 | ||
11032e1d | 996 | AliCDBMetaData mdr ; |
997 | mdr.SetResponsible("yves schutz"); | |
998 | ||
4edbc5bc | 999 | for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) { |
1000 | TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ; | |
1001 | if ( detDir ) { | |
1002 | AliInfo(Form("Entering %s", detDir->GetName())) ; | |
57acd2d2 | 1003 | AliQA::SetQARefDataDirName(es) ; |
614a7f99 | 1004 | TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ; |
1005 | AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ; | |
4edbc5bc | 1006 | TList * listDetQAD = new TList() ; |
614a7f99 | 1007 | TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ; |
57acd2d2 | 1008 | mdr.SetComment(Form("%s QA stuff", AliQA::GetDetName(detIndex))); |
4edbc5bc | 1009 | listDetQAD->SetName(listName) ; |
1010 | TList * taskList = detDir->GetListOfKeys() ; | |
1011 | TIter nextTask(taskList) ; | |
1012 | TKey * taskKey ; | |
1013 | while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) { | |
1014 | TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; | |
57acd2d2 | 1015 | TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ; |
1016 | AliInfo(Form("Saving %s", esDir->GetName())) ; | |
f73f556a | 1017 | TObjArray * listTaskQAD = new TObjArray(100) ; |
57acd2d2 | 1018 | listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ; |
4edbc5bc | 1019 | listDetQAD->Add(listTaskQAD) ; |
57acd2d2 | 1020 | TList * histList = esDir->GetListOfKeys() ; |
4edbc5bc | 1021 | TIter nextHist(histList) ; |
1022 | TKey * histKey ; | |
1023 | while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) { | |
57acd2d2 | 1024 | TObject * odata = esDir->Get(histKey->GetName()) ; |
a681ca96 | 1025 | if ( !odata ) { |
1026 | AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
1027 | } else { | |
57acd2d2 | 1028 | if ( AliQA::GetExpert() == histKey->GetName() ) { |
1029 | TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ; | |
1030 | TList * expertHistList = expertDir->GetListOfKeys() ; | |
1031 | TIter nextExpertHist(expertHistList) ; | |
1032 | TKey * expertHistKey ; | |
1033 | while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) { | |
1034 | TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ; | |
1035 | if ( !expertOdata ) { | |
1036 | AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
1037 | } else { | |
1038 | AliInfo(Form("Adding %s", expertHistKey->GetName())) ; | |
1039 | if ( expertOdata->IsA()->InheritsFrom("TH1") ) { | |
1040 | AliInfo(Form("Adding %s", expertHistKey->GetName())) ; | |
1041 | TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ; | |
1042 | listTaskQAD->Add(hExpertdata) ; | |
1043 | } | |
1044 | } | |
1045 | } | |
1046 | } | |
4edbc5bc | 1047 | AliInfo(Form("Adding %s", histKey->GetName())) ; |
a681ca96 | 1048 | if ( odata->IsA()->InheritsFrom("TH1") ) { |
1049 | AliInfo(Form("Adding %s", histKey->GetName())) ; | |
1050 | TH1 * hdata = static_cast<TH1*>(odata) ; | |
1051 | listTaskQAD->Add(hdata) ; | |
1052 | } | |
4edbc5bc | 1053 | } |
1054 | } | |
1055 | } | |
4edbc5bc | 1056 | man->Put(listDetQAD, idr, &mdr) ; |
1057 | } | |
1058 | } | |
1059 | return rv ; | |
1060 | } | |
a6f6970e | 1061 | |
940d8e5f | 1062 | //_____________________________________________________________________________ |
57acd2d2 | 1063 | void AliQADataMakerSteer::SetEventSpecie(AliRecoParam::EventSpecie_t es) |
1064 | { | |
1065 | // set the current event specie and inform AliQA that this event specie has been encountered | |
1066 | fEventSpecie = es ; | |
1067 | AliQA::Instance()->SetEventSpecie(es) ; | |
1068 | } | |
1069 | ||
1070 | //_____________________________________________________________________________ | |
1071 | void AliQADataMakerSteer::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par) | |
940d8e5f | 1072 | { |
1073 | // Set custom reconstruction parameters for a given detector | |
1074 | // Single set of parameters for all the events | |
57acd2d2 | 1075 | GetQADataMaker(det)->SetRecoParam(par) ; |
940d8e5f | 1076 | } |
1077 | ||
1078 |