]>
Commit | Line | Data |
---|---|---|
2e331c8b | 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: AliQAManager.cxx 30894 2009-02-05 13:46:48Z schutz $ */ | |
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // class for running the QA makers // | |
20 | // // | |
bf76b847 | 21 | // AliQAManager qas; // |
22 | // qas.Run(AliQAv1::kRAWS, rawROOTFileName); // | |
23 | // qas.Run(AliQAv1::kHITS); // | |
24 | // qas.Run(AliQAv1::kSDIGITS); // | |
25 | // qas.Run(AliQAv1::kDIGITS); // | |
26 | // qas.Run(AliQAv1::kRECPOINTS); // | |
27 | // qas.Run(AliQAv1::kESDS); // | |
2e331c8b | 28 | // // |
29 | /////////////////////////////////////////////////////////////////////////////// | |
30 | ||
fec0891b | 31 | #include <TCanvas.h> |
2e331c8b | 32 | #include <TKey.h> |
33 | #include <TFile.h> | |
34 | #include <TFileMerger.h> | |
149a2367 | 35 | #include <TGrid.h> |
36 | #include <TGridCollection.h> | |
37 | #include <TGridResult.h> | |
2e331c8b | 38 | #include <TPluginManager.h> |
39 | #include <TROOT.h> | |
40 | #include <TString.h> | |
41 | #include <TSystem.h> | |
7c9ff472 | 42 | #include <TStopwatch.h> |
2e331c8b | 43 | |
44 | #include "AliCDBManager.h" | |
45 | #include "AliCDBEntry.h" | |
46 | #include "AliCDBId.h" | |
47 | #include "AliCDBMetaData.h" | |
48 | #include "AliCodeTimer.h" | |
49 | #include "AliCorrQADataMakerRec.h" | |
50 | #include "AliDetectorRecoParam.h" | |
51 | #include "AliESDEvent.h" | |
52 | #include "AliGeomManager.h" | |
53 | #include "AliGlobalQADataMaker.h" | |
54 | #include "AliHeader.h" | |
55 | #include "AliLog.h" | |
56 | #include "AliModule.h" | |
4e25ac79 | 57 | #include "AliQAv1.h" |
634696f5 | 58 | #include "AliQAChecker.h" |
59 | #include "AliQACheckerBase.h" | |
2e331c8b | 60 | #include "AliQADataMakerRec.h" |
61 | #include "AliQADataMakerSim.h" | |
62 | #include "AliQAManager.h" | |
63 | #include "AliRawReaderDate.h" | |
64 | #include "AliRawReaderFile.h" | |
65 | #include "AliRawReaderRoot.h" | |
66 | #include "AliRun.h" | |
67 | #include "AliRunLoader.h" | |
68 | #include "AliRunTag.h" | |
69 | ||
70 | ClassImp(AliQAManager) | |
71 | AliQAManager* AliQAManager::fgQAInstance = 0x0; | |
72 | ||
73 | //_____________________________________________________________________________ | |
74 | AliQAManager::AliQAManager() : | |
75 | AliCDBManager(), | |
76 | fCurrentEvent(0), | |
77 | fCycleSame(kFALSE), | |
78 | fDetectors("ALL"), | |
79 | fDetectorsW("ALL"), | |
80 | fESD(NULL), | |
81 | fESDTree(NULL), | |
82 | fGAliceFileName(""), | |
83 | fFirstEvent(0), | |
84 | fMaxEvents(0), | |
85 | fMode(""), | |
86 | fNumberOfEvents(999999), | |
87 | fRecoParam(), | |
88 | fRunNumber(0), | |
89 | fRawReader(NULL), | |
90 | fRawReaderDelete(kTRUE), | |
91 | fRunLoader(NULL), | |
bc8761a0 | 92 | fTasks(""), |
fec0891b | 93 | fEventSpecie(AliRecoParam::kDefault), |
50dee02c | 94 | fPrintImage(kTRUE), |
95 | fSaveData(kTRUE) | |
2e331c8b | 96 | { |
97 | // default ctor | |
98 | fMaxEvents = fNumberOfEvents ; | |
99 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 100 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 101 | fLoader[iDet] = NULL ; |
102 | fQADataMaker[iDet] = NULL ; | |
103 | fQACycles[iDet] = 999999 ; | |
2e331c8b | 104 | } |
105 | } | |
75373542 | 106 | SetWriteExpert() ; |
2e331c8b | 107 | } |
108 | ||
109 | //_____________________________________________________________________________ | |
634696f5 | 110 | AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) : |
2e331c8b | 111 | AliCDBManager(), |
112 | fCurrentEvent(0), | |
113 | fCycleSame(kFALSE), | |
114 | fDetectors("ALL"), | |
115 | fDetectorsW("ALL"), | |
116 | fESD(NULL), | |
117 | fESDTree(NULL), | |
118 | fGAliceFileName(gAliceFilename), | |
119 | fFirstEvent(0), | |
120 | fMaxEvents(0), | |
634696f5 | 121 | fMode(AliQAv1::GetModeName(mode)), |
2e331c8b | 122 | fNumberOfEvents(999999), |
123 | fRecoParam(), | |
124 | fRunNumber(0), | |
125 | fRawReader(NULL), | |
126 | fRawReaderDelete(kTRUE), | |
127 | fRunLoader(NULL), | |
bc8761a0 | 128 | fTasks(""), |
fec0891b | 129 | fEventSpecie(AliRecoParam::kDefault), |
50dee02c | 130 | fPrintImage(kTRUE), |
131 | fSaveData(kTRUE) | |
2e331c8b | 132 | { |
133 | // default ctor | |
134 | fMaxEvents = fNumberOfEvents ; | |
135 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 136 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 137 | fLoader[iDet] = NULL ; |
138 | fQADataMaker[iDet] = NULL ; | |
139 | fQACycles[iDet] = 999999 ; | |
65660bf3 | 140 | } |
141 | } | |
75373542 | 142 | SetWriteExpert() ; |
2e331c8b | 143 | } |
144 | ||
145 | //_____________________________________________________________________________ | |
146 | AliQAManager::AliQAManager(const AliQAManager & qas) : | |
147 | AliCDBManager(), | |
148 | fCurrentEvent(qas.fCurrentEvent), | |
149 | fCycleSame(kFALSE), | |
150 | fDetectors(qas.fDetectors), | |
151 | fDetectorsW(qas.fDetectorsW), | |
152 | fESD(NULL), | |
153 | fESDTree(NULL), | |
154 | fGAliceFileName(qas.fGAliceFileName), | |
155 | fFirstEvent(qas.fFirstEvent), | |
156 | fMaxEvents(qas.fMaxEvents), | |
157 | fMode(qas.fMode), | |
158 | fNumberOfEvents(qas.fNumberOfEvents), | |
159 | fRecoParam(), | |
160 | fRunNumber(qas.fRunNumber), | |
161 | fRawReader(NULL), | |
162 | fRawReaderDelete(kTRUE), | |
163 | fRunLoader(NULL), | |
bc8761a0 | 164 | fTasks(qas.fTasks), |
fec0891b | 165 | fEventSpecie(qas.fEventSpecie), |
50dee02c | 166 | fPrintImage(qas.fPrintImage), |
167 | fSaveData(qas.fSaveData) | |
fec0891b | 168 | |
2e331c8b | 169 | { |
170 | // cpy ctor | |
171 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
172 | fLoader[iDet] = qas.fLoader[iDet] ; | |
173 | fQADataMaker[iDet] = qas.fQADataMaker[iDet] ; | |
174 | fQACycles[iDet] = qas.fQACycles[iDet] ; | |
175 | fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ; | |
176 | } | |
177 | } | |
178 | ||
179 | //_____________________________________________________________________________ | |
180 | AliQAManager & AliQAManager::operator = (const AliQAManager & qas) | |
181 | { | |
182 | // assignment operator | |
183 | this->~AliQAManager() ; | |
184 | new(this) AliQAManager(qas) ; | |
185 | return *this ; | |
186 | } | |
187 | ||
188 | //_____________________________________________________________________________ | |
189 | AliQAManager::~AliQAManager() | |
190 | { | |
191 | // dtor | |
192 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 193 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 194 | fLoader[iDet] = NULL; |
195 | if (fQADataMaker[iDet]) { | |
196 | (fQADataMaker[iDet])->Finish() ; | |
197 | delete fQADataMaker[iDet] ; | |
198 | } | |
199 | } | |
200 | } | |
201 | if (fRawReaderDelete) { | |
202 | fRunLoader = NULL ; | |
203 | delete fRawReader ; | |
204 | fRawReader = NULL ; | |
205 | } | |
fec0891b | 206 | TCanvas fakeCanvas ; |
207 | if (fPrintImage) | |
7c9ff472 | 208 | fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps"); |
2e331c8b | 209 | } |
210 | ||
211 | //_____________________________________________________________________________ | |
4e25ac79 | 212 | Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex) |
2e331c8b | 213 | { |
214 | // Runs all the QA data Maker for every detector | |
215 | ||
216 | Bool_t rv = kFALSE ; | |
217 | // Fill QA data in event loop | |
218 | for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) { | |
219 | fCurrentEvent++ ; | |
220 | // Get the event | |
221 | if ( iEvent%10 == 0 ) | |
5379c4a3 | 222 | AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent)); |
4e25ac79 | 223 | if ( taskIndex == AliQAv1::kRAWS ) { |
2e331c8b | 224 | if ( !fRawReader->NextEvent() ) |
225 | break ; | |
4e25ac79 | 226 | } else if ( taskIndex == AliQAv1::kESDS ) { |
2e331c8b | 227 | if ( fESDTree->GetEntry(iEvent) == 0 ) |
228 | break ; | |
229 | } else { | |
230 | if ( fRunLoader->GetEvent(iEvent) != 0 ) | |
231 | break ; | |
232 | } | |
233 | // loop over active loaders | |
234 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
4e25ac79 | 235 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 236 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
237 | if (!qadm) continue; // This detector doesn't have any QA (for example, HLT) | |
238 | if ( qadm->IsCycleDone() ) { | |
239 | qadm->EndOfCycle(taskIndex) ; | |
240 | } | |
241 | TTree * data = NULL ; | |
242 | AliLoader* loader = GetLoader(qadm->GetUniqueID()); | |
243 | switch (taskIndex) { | |
4e25ac79 | 244 | case AliQAv1::kNULLTASKINDEX : |
2e331c8b | 245 | break ; |
4e25ac79 | 246 | case AliQAv1::kRAWS : |
2e331c8b | 247 | qadm->Exec(taskIndex, fRawReader) ; |
248 | break ; | |
4e25ac79 | 249 | case AliQAv1::kHITS : |
2e331c8b | 250 | if( loader ) { |
251 | loader->LoadHits() ; | |
252 | data = loader->TreeH() ; | |
253 | if ( ! data ) { | |
4e25ac79 | 254 | AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 255 | break ; |
256 | } | |
eca4fa66 | 257 | qadm->Exec(taskIndex, data) ; |
2e331c8b | 258 | } |
2e331c8b | 259 | break ; |
4e25ac79 | 260 | case AliQAv1::kSDIGITS : |
95144eea | 261 | { |
262 | ||
263 | TString fileName(Form("%s.SDigits.root", AliQAv1::GetDetName(iDet))) ; | |
264 | if (gSystem->FindFile("./", fileName)) { | |
265 | if( loader ) { | |
266 | loader->LoadSDigits() ; | |
267 | data = loader->TreeS() ; | |
268 | if ( ! data ) { | |
269 | AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; | |
270 | break ; | |
271 | } | |
272 | qadm->Exec(taskIndex, data) ; | |
273 | } | |
2e331c8b | 274 | } |
95144eea | 275 | } |
2e331c8b | 276 | break; |
4e25ac79 | 277 | case AliQAv1::kDIGITS : |
fec0891b | 278 | if( loader ) { |
279 | loader->LoadDigits() ; | |
280 | data = loader->TreeD() ; | |
281 | if ( ! data ) { | |
282 | AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; | |
283 | break ; | |
284 | } | |
eca4fa66 | 285 | qadm->Exec(taskIndex, data) ; |
fec0891b | 286 | } |
eca4fa66 | 287 | break; |
fec0891b | 288 | case AliQAv1::kDIGITSR : |
289 | if( loader ) { | |
290 | loader->LoadDigits() ; | |
291 | data = loader->TreeD() ; | |
292 | if ( ! data ) { | |
293 | AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ; | |
294 | break ; | |
295 | } | |
eca4fa66 | 296 | qadm->Exec(taskIndex, data) ; |
fec0891b | 297 | } |
2e331c8b | 298 | break; |
4e25ac79 | 299 | case AliQAv1::kRECPOINTS : |
2e331c8b | 300 | if( loader ) { |
301 | loader->LoadRecPoints() ; | |
302 | data = loader->TreeR() ; | |
303 | if (!data) { | |
4e25ac79 | 304 | AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 305 | break ; |
306 | } | |
eca4fa66 | 307 | qadm->Exec(taskIndex, data) ; |
2e331c8b | 308 | } |
2e331c8b | 309 | break; |
4e25ac79 | 310 | case AliQAv1::kTRACKSEGMENTS : |
2e331c8b | 311 | break; |
4e25ac79 | 312 | case AliQAv1::kRECPARTICLES : |
2e331c8b | 313 | break; |
4e25ac79 | 314 | case AliQAv1::kESDS : |
2e331c8b | 315 | qadm->Exec(taskIndex, fESD) ; |
316 | break; | |
4e25ac79 | 317 | case AliQAv1::kNTASKINDEX : |
2e331c8b | 318 | break; |
319 | } //task switch | |
320 | } | |
321 | } // detector loop | |
5e303886 | 322 | Increment(taskIndex) ; |
2e331c8b | 323 | } // event loop |
324 | // Save QA data for all detectors | |
5e303886 | 325 | |
2e331c8b | 326 | rv = Finish(taskIndex) ; |
327 | ||
4e25ac79 | 328 | if ( taskIndex == AliQAv1::kRAWS ) |
2e331c8b | 329 | fRawReader->RewindEvents() ; |
330 | ||
331 | return rv ; | |
332 | } | |
333 | ||
334 | //_____________________________________________________________________________ | |
4e25ac79 | 335 | Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex) |
2e331c8b | 336 | { |
337 | // write output to file for all detectors | |
8fa875cb | 338 | |
339 | AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; | |
340 | ||
2e331c8b | 341 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 342 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 343 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
344 | if (qadm) | |
345 | qadm->EndOfCycle(taskIndex) ; | |
346 | } | |
347 | } | |
348 | return kTRUE ; | |
349 | } | |
350 | ||
351 | //_____________________________________________________________________________ | |
fec0891b | 352 | TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const |
2e331c8b | 353 | { |
354 | // Retrieve the list of QA data for a given detector and a given task | |
355 | TObjArray * rv = NULL ; | |
4e25ac79 | 356 | if ( !strlen(AliQAv1::GetQARefStorage()) ) { |
357 | AliError("No storage defined, use AliQAv1::SetQARefStorage") ; | |
2e331c8b | 358 | return NULL ; |
359 | } | |
360 | if ( ! IsDefaultStorageSet() ) { | |
4e25ac79 | 361 | TString tmp(AliQAv1::GetQARefDefaultStorage()) ; |
2e331c8b | 362 | tmp.Append(year) ; |
363 | tmp.Append("/") ; | |
364 | Instance()->SetDefaultStorage(tmp.Data()) ; | |
4e25ac79 | 365 | Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ; |
2e331c8b | 366 | } |
4e25ac79 | 367 | TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ; |
5379c4a3 | 368 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ; |
2e331c8b | 369 | AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number |
eca4fa66 | 370 | TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ; |
2e331c8b | 371 | if ( listDetQAD ) |
eca4fa66 | 372 | rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ; |
2e331c8b | 373 | return rv ; |
374 | } | |
375 | ||
fec0891b | 376 | //_____________________________________________________________________________ |
377 | TCanvas ** AliQAManager::GetImage(Char_t * detName) | |
378 | { | |
379 | // retrieves QA Image for the given detector | |
380 | TCanvas ** rv = NULL ; | |
381 | Int_t detIndex = AliQAv1::GetDetIndex(detName) ; | |
634696f5 | 382 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; |
383 | rv = qac->GetImage() ; | |
fec0891b | 384 | return rv ; |
385 | } | |
386 | ||
2e331c8b | 387 | //_____________________________________________________________________________ |
388 | AliLoader * AliQAManager::GetLoader(Int_t iDet) | |
389 | { | |
390 | // get the loader for a detector | |
391 | ||
bf76b847 | 392 | if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL ) |
2e331c8b | 393 | return NULL ; |
394 | ||
4e25ac79 | 395 | TString detName = AliQAv1::GetDetName(iDet) ; |
2e331c8b | 396 | fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader"); |
397 | if (fLoader[iDet]) | |
398 | return fLoader[iDet] ; | |
399 | ||
400 | // load the QA data maker object | |
401 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
402 | TString loaderName = "Ali" + detName + "Loader" ; | |
403 | ||
404 | AliLoader * loader = NULL ; | |
405 | // first check if a plugin is defined for the quality assurance data maker | |
406 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
407 | // if not, add a plugin for it | |
408 | if (!pluginHandler) { | |
5379c4a3 | 409 | AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ; |
2e331c8b | 410 | TString libs = gSystem->GetLibraries() ; |
411 | if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) { | |
412 | pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ; | |
413 | } else { | |
414 | pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ; | |
415 | } | |
416 | pluginHandler = pluginManager->FindHandler("AliLoader", detName) ; | |
417 | } | |
418 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
419 | loader = (AliLoader *) pluginHandler->ExecPlugin(0) ; | |
420 | } | |
421 | if (loader) | |
422 | fLoader[iDet] = loader ; | |
423 | return loader ; | |
424 | } | |
425 | ||
426 | //_____________________________________________________________________________ | |
4e25ac79 | 427 | AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt) |
2e331c8b | 428 | { |
429 | // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root" | |
fec0891b | 430 | Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ; |
2e331c8b | 431 | TFile * tagFile = TFile::Open(fileName) ; |
432 | if ( !tagFile ) { | |
433 | AliError(Form("File %s not found", fileName)) ; | |
434 | return NULL ; | |
435 | } | |
eca4fa66 | 436 | TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ; |
2e331c8b | 437 | if ( !tagTree ) { |
438 | AliError(Form("Tree T not found in %s", fileName)) ; | |
439 | tagFile->Close() ; | |
440 | return NULL ; | |
441 | } | |
442 | AliRunTag * tag = new AliRunTag ; | |
443 | tagTree->SetBranchAddress("AliTAG", &tag) ; | |
444 | tagTree->GetEntry(evt) ; | |
4e25ac79 | 445 | AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ; |
2e331c8b | 446 | tagFile->Close() ; |
447 | return qa ; | |
448 | } | |
449 | ||
450 | //_____________________________________________________________________________ | |
451 | AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet) | |
452 | { | |
453 | // get the quality assurance data maker for a detector | |
454 | ||
eca4fa66 | 455 | AliQADataMaker * qadm = fQADataMaker[iDet] ; |
456 | ||
457 | if (qadm) { | |
458 | ||
5e232cd6 | 459 | qadm->SetEventSpecie(fEventSpecie) ; |
bc8761a0 | 460 | if ( qadm->GetRecoParam() ) |
eca4fa66 | 461 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
5e232cd6 | 462 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; |
2e331c8b | 463 | |
eca4fa66 | 464 | } else if (iDet == AliQAv1::kGLOBAL) { //Global QA |
465 | ||
466 | qadm = new AliGlobalQADataMaker(); | |
4e25ac79 | 467 | qadm->SetName(AliQAv1::GetDetName(iDet)); |
2e331c8b | 468 | qadm->SetUniqueID(iDet); |
469 | fQADataMaker[iDet] = qadm; | |
5e232cd6 | 470 | qadm->SetEventSpecie(fEventSpecie) ; |
bc8761a0 | 471 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 472 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
473 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
2e331c8b | 474 | |
eca4fa66 | 475 | } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors |
476 | qadm = new AliCorrQADataMakerRec(fQADataMaker) ; | |
4e25ac79 | 477 | qadm->SetName(AliQAv1::GetDetName(iDet)); |
2e331c8b | 478 | qadm->SetUniqueID(iDet); |
eca4fa66 | 479 | fQADataMaker[iDet] = qadm; |
5e232cd6 | 480 | qadm->SetEventSpecie(fEventSpecie) ; |
bc8761a0 | 481 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 482 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
483 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
2e331c8b | 484 | |
6090cc85 | 485 | } else if ( iDet < AliQAv1::kGLOBAL ) { |
eca4fa66 | 486 | |
487 | // load the QA data maker object | |
488 | TPluginManager* pluginManager = gROOT->GetPluginManager() ; | |
489 | TString detName = AliQAv1::GetDetName(iDet) ; | |
490 | TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ; | |
491 | ||
492 | // first check if a plugin is defined for the quality assurance data maker | |
493 | TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; | |
494 | // if not, add a plugin for it | |
495 | if (!pluginHandler) { | |
496 | AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ; | |
497 | TString libs = gSystem->GetLibraries() ; | |
bf76b847 | 498 | TString temp(GetMode()) ; |
499 | temp.ToLower() ; | |
500 | if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) { | |
eca4fa66 | 501 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ; |
502 | } else { | |
503 | pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ; | |
504 | } | |
505 | pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ; | |
506 | } | |
507 | if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) { | |
508 | qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ; | |
509 | } | |
510 | if (qadm) { | |
511 | qadm->SetName(AliQAv1::GetDetName(iDet)); | |
512 | qadm->SetUniqueID(iDet); | |
513 | fQADataMaker[iDet] = qadm ; | |
514 | qadm->SetEventSpecie(fEventSpecie) ; | |
515 | if ( qadm->GetRecoParam() ) | |
516 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) | |
517 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
518 | } | |
519 | } | |
2e331c8b | 520 | return qadm ; |
521 | } | |
522 | ||
523 | //_____________________________________________________________________________ | |
524 | void AliQAManager::EndOfCycle(TObjArray * detArray) | |
525 | { | |
526 | // End of cycle QADataMakers | |
527 | ||
8fa875cb | 528 | AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; |
529 | if (fPrintImage) { | |
fec0891b | 530 | TCanvas fakeCanvas ; |
1d46dcf4 | 531 | fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; |
fec0891b | 532 | } |
2e331c8b | 533 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 534 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 535 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
634696f5 | 536 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ; |
2e331c8b | 537 | if (!qadm) |
538 | continue ; | |
539 | // skip non active detectors | |
540 | if (detArray) { | |
4e25ac79 | 541 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 542 | if (!det || !det->IsActive()) |
543 | continue ; | |
544 | } | |
6090cc85 | 545 | if (qac) |
546 | qac->SetPrintImage(fPrintImage) ; | |
eca4fa66 | 547 | |
50dee02c | 548 | if (IsSaveData()) { |
549 | for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { | |
550 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
551 | qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ; | |
552 | } | |
553 | } | |
2e331c8b | 554 | qadm->Finish(); |
555 | } | |
556 | } | |
557 | } | |
558 | ||
559 | //_____________________________________________________________________________ | |
560 | void AliQAManager::EndOfCycle(TString detectors) | |
561 | { | |
562 | // End of cycle QADataMakers | |
563 | ||
634696f5 | 564 | AliQAChecker::Instance()->SetRunNumber(fRunNumber) ; |
fec0891b | 565 | if (fPrintImage) { |
566 | TCanvas fakeCanvas ; | |
1d46dcf4 | 567 | fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; |
fec0891b | 568 | } |
569 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
4e25ac79 | 570 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 571 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
634696f5 | 572 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ; |
2e331c8b | 573 | if (!qadm) |
574 | continue ; | |
575 | // skip non active detectors | |
4e25ac79 | 576 | if (!detectors.Contains(AliQAv1::GetDetName(iDet))) |
2e331c8b | 577 | continue ; |
6090cc85 | 578 | if (qac) |
579 | qac->SetPrintImage(fPrintImage) ; | |
50dee02c | 580 | if (IsSaveData()) { |
581 | for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { | |
582 | if ( fTasks.Contains(Form("%d", taskIndex)) ) | |
583 | qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ; | |
584 | } | |
585 | } | |
2e331c8b | 586 | qadm->Finish(); |
587 | } | |
588 | } | |
589 | } | |
590 | ||
591 | //_____________________________________________________________________________ | |
5e303886 | 592 | void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex) |
2e331c8b | 593 | { |
594 | // Increments the cycle counter for all QA Data Makers | |
5e303886 | 595 | static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ; |
596 | if (currentTask == taskIndex) | |
597 | return ; | |
598 | else | |
599 | currentTask = taskIndex ; | |
2e331c8b | 600 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 601 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 602 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
603 | if (qadm) | |
604 | qadm->Increment() ; | |
605 | } | |
606 | } | |
607 | } | |
608 | ||
609 | //_____________________________________________________________________________ | |
fec0891b | 610 | Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input ) |
2e331c8b | 611 | { |
612 | // Initialize the event source and QA data makers | |
613 | ||
614 | fTasks += Form("%d", taskIndex) ; | |
615 | ||
4e25ac79 | 616 | if (taskIndex == AliQAv1::kRAWS) { |
2e331c8b | 617 | if (!fRawReader) { |
618 | fRawReader = AliRawReader::Create(input); | |
619 | } | |
620 | if ( ! fRawReader ) | |
621 | return kFALSE ; | |
622 | fRawReaderDelete = kTRUE ; | |
623 | fRawReader->NextEvent() ; | |
624 | fRunNumber = fRawReader->GetRunNumber() ; | |
625 | SetRun(fRunNumber) ; | |
626 | fRawReader->RewindEvents(); | |
627 | fNumberOfEvents = 999999 ; | |
628 | if ( fMaxEvents < 0 ) | |
629 | fMaxEvents = fNumberOfEvents ; | |
4e25ac79 | 630 | } else if (taskIndex == AliQAv1::kESDS) { |
631 | fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ; | |
2e331c8b | 632 | if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists |
633 | TFile * esdFile = TFile::Open("AliESDs.root") ; | |
eca4fa66 | 634 | fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ; |
2e331c8b | 635 | if ( !fESDTree ) { |
636 | AliError("esdTree not found") ; | |
637 | return kFALSE ; | |
638 | } else { | |
639 | fESD = new AliESDEvent() ; | |
640 | fESD->ReadFromTree(fESDTree) ; | |
641 | fESDTree->GetEntry(0) ; | |
642 | fRunNumber = fESD->GetRunNumber() ; | |
643 | fNumberOfEvents = fESDTree->GetEntries() ; | |
644 | if ( fMaxEvents < 0 ) | |
645 | fMaxEvents = fNumberOfEvents ; | |
646 | } | |
647 | } else { | |
648 | AliError("AliESDs.root not found") ; | |
649 | return kFALSE ; | |
650 | } | |
651 | } else { | |
652 | if ( !InitRunLoader() ) { | |
653 | AliWarning("No Run Loader not found") ; | |
654 | } else { | |
655 | fNumberOfEvents = fRunLoader->GetNumberOfEvents() ; | |
656 | if ( fMaxEvents < 0 ) | |
657 | fMaxEvents = fNumberOfEvents ; | |
658 | } | |
659 | } | |
660 | ||
661 | // Get Detectors | |
662 | TObjArray* detArray = NULL ; | |
663 | if (fRunLoader) // check if RunLoader exists | |
664 | if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root | |
665 | detArray = fRunLoader->GetAliRun()->Detectors() ; | |
666 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; | |
667 | } | |
668 | ||
669 | // Initialize all QA data makers for all detectors | |
670 | fRunNumber = AliCDBManager::Instance()->GetRun() ; | |
671 | if ( ! AliGeomManager::GetGeometry() ) | |
672 | AliGeomManager::LoadGeometry() ; | |
673 | ||
674 | InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ; | |
fec0891b | 675 | if (fPrintImage) { |
676 | TCanvas fakeCanvas ; | |
7c9ff472 | 677 | TStopwatch timer ; |
678 | timer.Start() ; | |
679 | while (timer.CpuTime()<5) { | |
680 | timer.Continue(); | |
681 | gSystem->ProcessEvents(); | |
682 | } | |
1d46dcf4 | 683 | fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ; |
fec0891b | 684 | } |
2e331c8b | 685 | return kTRUE ; |
686 | } | |
687 | ||
688 | //_____________________________________________________________________________ | |
689 | void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray) | |
690 | { | |
691 | // Initializes The QADataMaker for all active detectors and for all active tasks | |
fec0891b | 692 | fRunNumber = run ; |
2e331c8b | 693 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
4e25ac79 | 694 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 695 | AliQADataMaker * qadm = GetQADataMaker(iDet) ; |
696 | if (!qadm) { | |
4e25ac79 | 697 | AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ; |
698 | fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ; | |
2e331c8b | 699 | } else { |
700 | if (fQAWriteExpert[iDet]) | |
701 | qadm->SetWriteExpert() ; | |
5379c4a3 | 702 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ; |
2e331c8b | 703 | // skip non active detectors |
704 | if (detArray) { | |
4e25ac79 | 705 | AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ; |
2e331c8b | 706 | if (!det || !det->IsActive()) |
707 | continue ; | |
708 | } | |
2e331c8b | 709 | // Set default reco params |
710 | Bool_t sameCycle = kFALSE ; | |
4e25ac79 | 711 | for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { |
2e331c8b | 712 | if ( fTasks.Contains(Form("%d", taskIndex)) ) { |
4e25ac79 | 713 | qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ; |
714 | qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ; | |
2e331c8b | 715 | sameCycle = kTRUE ; |
716 | } | |
717 | } | |
718 | } | |
719 | } | |
720 | } | |
721 | } | |
722 | ||
723 | ||
724 | //_____________________________________________________________________________ | |
725 | Bool_t AliQAManager::InitRunLoader() | |
726 | { | |
727 | // get or create the run loader | |
728 | if (fRunLoader) { | |
729 | fCycleSame = kTRUE ; | |
730 | } else { | |
731 | if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists | |
732 | // load all base libraries to get the loader classes | |
733 | TString libs = gSystem->GetLibraries() ; | |
734 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 735 | if (!IsSelected(AliQAv1::GetDetName(iDet))) |
2e331c8b | 736 | continue ; |
4e25ac79 | 737 | TString detName = AliQAv1::GetDetName(iDet) ; |
2e331c8b | 738 | if (detName == "HLT") |
739 | continue; | |
740 | if (libs.Contains("lib" + detName + "base.so")) | |
741 | continue; | |
742 | gSystem->Load("lib" + detName + "base.so"); | |
743 | } | |
744 | fRunLoader = AliRunLoader::Open(fGAliceFileName.Data()); | |
745 | if (!fRunLoader) { | |
746 | AliError(Form("no run loader found in file %s", fGAliceFileName.Data())); | |
747 | return kFALSE; | |
748 | } | |
749 | fRunLoader->CdGAFile(); | |
750 | if (fRunLoader->LoadgAlice() == 0) { | |
751 | gAlice = fRunLoader->GetAliRun(); | |
752 | } | |
753 | ||
754 | if (!gAlice) { | |
755 | AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data())); | |
756 | return kFALSE; | |
757 | } | |
758 | ||
759 | } else { // galice.root does not exist | |
760 | AliError(Form("the file %s does not exist", fGAliceFileName.Data())); | |
761 | return kFALSE; | |
762 | } | |
763 | } | |
764 | ||
765 | if (!fRunNumber) { | |
766 | fRunLoader->LoadHeader(); | |
767 | fRunNumber = fRunLoader->GetHeader()->GetRun() ; | |
768 | } | |
769 | return kTRUE; | |
770 | } | |
771 | ||
772 | //_____________________________________________________________________________ | |
fec0891b | 773 | Bool_t AliQAManager::IsSelected(const Char_t * det) |
2e331c8b | 774 | { |
775 | // check whether detName is contained in detectors | |
776 | // if yes, it is removed from detectors | |
777 | ||
778 | Bool_t rv = kFALSE; | |
779 | const TString detName(det) ; | |
780 | // always activates Correlation | |
d282dbf5 | 781 | if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR)) || detName.Contains(AliQAv1::GetDetName(AliQAv1::kGLOBAL))) { |
2e331c8b | 782 | rv = kTRUE ; |
783 | } else { | |
784 | // check if all detectors are selected | |
785 | if (fDetectors.Contains("ALL")) { | |
786 | fDetectors = "ALL"; | |
787 | rv = kTRUE; | |
788 | } else if ((fDetectors.CompareTo(detName) == 0) || | |
789 | fDetectors.BeginsWith(detName+" ") || | |
790 | fDetectors.EndsWith(" "+detName) || | |
791 | fDetectors.Contains(" "+detName+" ")) { | |
792 | rv = kTRUE; | |
793 | } | |
794 | } | |
795 | return rv ; | |
796 | } | |
797 | ||
798 | //_____________________________________________________________________________ | |
87da0921 | 799 | Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const |
2e331c8b | 800 | { |
bededc30 | 801 | // Merge data from all detectors from a given run in one single file |
87da0921 | 802 | // Merge the QA results from all the data chunks in one run |
803 | // The 'fileName' is name of the output file with merged QA data | |
bededc30 | 804 | if ( runNumber == -1) |
805 | runNumber = fRunNumber ; | |
87da0921 | 806 | Bool_t rv = MergeData(runNumber,fileName) ; |
bededc30 | 807 | //rv *= MergeResults(runNumber) ; // not needed for the time being |
2e331c8b | 808 | return rv ; |
809 | } | |
810 | ||
149a2367 | 811 | //______________________________________________________________________ |
fec0891b | 812 | Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile) |
149a2367 | 813 | { |
814 | // merges files listed in a xml collection | |
815 | // usage Merge(collection, outputFile)) | |
816 | // collection: is a xml collection | |
817 | ||
818 | Bool_t rv = kFALSE ; | |
819 | ||
820 | if ( strstr(collectionFile, ".xml") == 0 ) { | |
821 | AliError("Input collection file must be an \".xml\" file\n") ; | |
822 | return kFALSE ; | |
823 | } | |
824 | ||
825 | if ( !gGrid ) | |
826 | TGrid::Connect("alien://"); | |
827 | if ( !gGrid ) | |
828 | return kFALSE ; | |
829 | ||
830 | // Open the file collection | |
5e232cd6 | 831 | AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile)); |
149a2367 | 832 | |
bededc30 | 833 | TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile)); |
149a2367 | 834 | TGridResult* result = collection->GetGridResult("", 0, 0); |
835 | ||
836 | Int_t index = 0 ; | |
fec0891b | 837 | const Char_t * turl ; |
adae62c9 | 838 | TFileMerger merger(kFALSE) ; |
149a2367 | 839 | if (!outFile) { |
840 | TString tempo(collectionFile) ; | |
841 | if ( subFile) | |
842 | tempo.ReplaceAll(".xml", subFile) ; | |
843 | else | |
844 | tempo.ReplaceAll(".xml", "_Merged.root") ; | |
845 | outFile = tempo.Data() ; | |
846 | } | |
847 | merger.OutputFile(outFile) ; | |
848 | ||
849 | while ( (turl = result->GetKey(index, "turl")) ) { | |
fec0891b | 850 | Char_t * file ; |
149a2367 | 851 | if ( subFile ) |
852 | file = Form("%s#%s", turl, subFile) ; | |
853 | else | |
854 | file = Form("%s", turl) ; | |
855 | ||
5379c4a3 | 856 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ; |
149a2367 | 857 | merger.AddFile(file) ; |
858 | index++ ; | |
859 | } | |
860 | ||
861 | if (index) | |
862 | merger.Merge() ; | |
863 | ||
5379c4a3 | 864 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ; |
149a2367 | 865 | |
866 | rv = kFALSE; | |
867 | return rv ; | |
868 | } | |
869 | ||
69a898e3 | 870 | //_____________________________________________________________________________ |
871 | void AliQAManager::MergeCustom() const | |
872 | { | |
873 | // Custom Merge of QA data from all detectors for all runs in one single file | |
874 | // search all the run numbers | |
875 | // search all the run numbers | |
876 | gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ; | |
877 | TString QAfile ; | |
878 | FILE * QAfiles = fopen("QAtempo.txt", "r") ; | |
879 | Int_t index = 0 ; | |
880 | TList srunList ; | |
881 | TIter nextRun(&srunList) ; | |
882 | TObjString * srun = NULL ; | |
883 | Int_t loRun = 999999999 ; | |
884 | Int_t hiRun = 0 ; | |
885 | while ( QAfile.Gets(QAfiles) ) { | |
886 | Bool_t runExist = kFALSE ; | |
887 | TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ; | |
888 | Int_t cuRun = srunNew.Atoi() ; | |
889 | if (cuRun < loRun) | |
890 | loRun = cuRun ; | |
891 | if (cuRun > hiRun) | |
892 | hiRun = cuRun ; | |
eca4fa66 | 893 | while ( (srun = static_cast<TObjString *> (nextRun())) ) { |
69a898e3 | 894 | if ( cuRun == (srun->String()).Atoi() ) { |
895 | runExist = kTRUE ; | |
896 | break ; | |
897 | } | |
898 | } | |
899 | nextRun.Reset() ; | |
900 | if ( ! runExist ) | |
901 | srunList.Add(new TObjString(srunNew.Data())); | |
902 | } | |
903 | nextRun.Reset() ; | |
904 | Int_t runNumber = 0 ; | |
4e25ac79 | 905 | TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ; |
69a898e3 | 906 | TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ; |
907 | // create the structure into the merged file | |
4e25ac79 | 908 | for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) { |
909 | TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ; | |
910 | for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) { | |
69a898e3 | 911 | detDir->cd() ; |
4e25ac79 | 912 | TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ; |
69a898e3 | 913 | for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) { |
914 | taskDir->cd() ; | |
915 | TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ; | |
916 | esDir->cd() ; | |
4e25ac79 | 917 | gDirectory->mkdir(AliQAv1::GetExpert()) ; |
69a898e3 | 918 | } |
919 | } | |
920 | } | |
eca4fa66 | 921 | while ( (srun = static_cast<TObjString *> (nextRun())) ) { |
69a898e3 | 922 | runNumber = (srun->String()).Atoi() ; |
923 | hisRun->Fill(runNumber) ; | |
5379c4a3 | 924 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ; |
69a898e3 | 925 | // search all QA files for runNumber in the current directory |
fec0891b | 926 | Char_t * fileList[AliQAv1::kNDET] ; |
69a898e3 | 927 | index = 0 ; |
4e25ac79 | 928 | for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) { |
fec0891b | 929 | Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); |
69a898e3 | 930 | if (file) |
931 | fileList[index++] = file ; | |
932 | } | |
933 | if ( index == 0 ) { | |
934 | AliError("No QA data file found\n") ; | |
935 | return ; | |
936 | } | |
937 | for ( Int_t i = 0 ; i < index ; i++) { | |
938 | TFile * inFile = TFile::Open(fileList[i]) ; | |
939 | TList * listOfKeys =inFile->GetListOfKeys() ; | |
940 | TIter nextkey(listOfKeys) ; | |
941 | TObject * obj1 ; | |
942 | TString dirName("") ; | |
943 | while ( (obj1 = nextkey()) ) { | |
944 | TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ; | |
945 | if ( directoryDet ) { | |
5379c4a3 | 946 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ; |
69a898e3 | 947 | dirName += Form("%s/", directoryDet->GetName() ) ; |
948 | directoryDet->cd() ; | |
949 | TList * listOfTasks = directoryDet->GetListOfKeys() ; | |
950 | TIter nextTask(listOfTasks) ; | |
951 | TObject * obj2 ; | |
952 | while ( (obj2 = nextTask()) ) { | |
953 | TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ; | |
954 | if ( directoryTask ) { | |
955 | dirName += Form("%s", obj2->GetName()) ; | |
5379c4a3 | 956 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ; |
69a898e3 | 957 | directoryTask->cd() ; |
958 | TList * listOfEventSpecie = directoryTask->GetListOfKeys() ; | |
959 | TIter nextEventSpecie(listOfEventSpecie) ; | |
960 | TObject * obj3 ; | |
961 | while ( (obj3 = nextEventSpecie()) ) { | |
962 | TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ; | |
963 | if ( directoryEventSpecie ) { | |
964 | dirName += Form("/%s/", obj3->GetName()) ; | |
5379c4a3 | 965 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ; |
69a898e3 | 966 | directoryEventSpecie->cd() ; |
967 | // histograms are here | |
968 | TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ; | |
969 | TList * listOfData = directoryEventSpecie->GetListOfKeys() ; | |
970 | TIter nextData(listOfData) ; | |
971 | TKey * key ; | |
eca4fa66 | 972 | while ( (key = static_cast<TKey *>(nextData())) ) { |
69a898e3 | 973 | TString className(key->GetClassName()) ; |
974 | if ( className.Contains("TH") || className.Contains("TProfile") ) { | |
eca4fa66 | 975 | TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ; |
976 | TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ; | |
5379c4a3 | 977 | AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ; |
69a898e3 | 978 | mergedDirectory->cd() ; |
979 | if ( ! histOu ) { | |
980 | histIn->Write() ; | |
981 | } else { | |
982 | histOu->Add(histIn) ; | |
983 | histOu->Write(histOu->GetName(), kOverwrite) ; | |
984 | } | |
985 | } | |
986 | else if ( className.Contains("TDirectoryFile") ) { | |
987 | TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ; | |
988 | dirExpert->cd() ; | |
989 | TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ; | |
990 | TList * listOfExpertData = dirExpert->GetListOfKeys() ; | |
991 | TIter nextExpertData(listOfExpertData) ; | |
992 | TKey * keykey ; | |
eca4fa66 | 993 | while ( (keykey = static_cast<TKey *>(nextExpertData())) ) { |
69a898e3 | 994 | TString classNameExpert(keykey->GetClassName()) ; |
995 | if (classNameExpert.Contains("TH")) { | |
eca4fa66 | 996 | TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ; |
997 | TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ; | |
69a898e3 | 998 | mergedDirectoryExpert->cd() ; |
999 | if ( ! histOuExpert ) { | |
1000 | histInExpert->Write() ; | |
1001 | } else { | |
1002 | histOuExpert->Add(histInExpert) ; | |
1003 | histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ; | |
1004 | } | |
1005 | } | |
1006 | } | |
1007 | } else { | |
1008 | AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ; | |
1009 | } | |
1010 | } | |
1011 | dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ; | |
1012 | } | |
1013 | } | |
1014 | dirName.ReplaceAll(obj2->GetName(), "") ; | |
1015 | } | |
1016 | } | |
1017 | } | |
1018 | } | |
1019 | inFile->Close() ; | |
1020 | } | |
1021 | } | |
1022 | mergedFile.cd() ; | |
1023 | hisRun->Write() ; | |
1024 | mergedFile.Close() ; | |
1025 | srunList.Delete() ; | |
1026 | } | |
1027 | ||
2e331c8b | 1028 | //_____________________________________________________________________________ |
87da0921 | 1029 | Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const |
2e331c8b | 1030 | { |
bededc30 | 1031 | // Merge QA data from all detectors for a given run in one single file |
1032 | ||
87da0921 | 1033 | TFileMerger merger(kFALSE) ; |
1034 | TString outFileName = fileName; | |
1035 | if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName()); | |
2e331c8b | 1036 | merger.OutputFile(outFileName.Data()) ; |
bededc30 | 1037 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { |
fec0891b | 1038 | Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber)); |
bededc30 | 1039 | if (file) |
1040 | merger.AddFile(file) ; | |
1041 | } | |
2e331c8b | 1042 | merger.Merge() ; |
1043 | return kTRUE ; | |
1044 | } | |
1045 | ||
1046 | //_____________________________________________________________________________ | |
1047 | Bool_t AliQAManager::MergeResults(const Int_t runNumber) const | |
1048 | { | |
1049 | // Merge the QA result from all the data chunks in a run | |
bededc30 | 1050 | // to be revised whwn it will be used (see MergeData) |
2e331c8b | 1051 | TString cmd ; |
4e25ac79 | 1052 | cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ; |
2e331c8b | 1053 | gROOT->ProcessLine(cmd.Data()) ; |
1054 | ifstream in("tempo.txt") ; | |
1055 | const Int_t chunkMax = 100 ; | |
1056 | TString fileList[chunkMax] ; | |
1057 | ||
1058 | Int_t index = 0 ; | |
1059 | while ( 1 ) { | |
1060 | TString file ; | |
1061 | in >> fileList[index] ; | |
1062 | if ( !in.good() ) | |
1063 | break ; | |
5379c4a3 | 1064 | AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ; |
2e331c8b | 1065 | index++ ; |
1066 | } | |
1067 | ||
1068 | if ( index == 0 ) { | |
1069 | AliError("No QA Result File found") ; | |
1070 | return kFALSE ; | |
1071 | } | |
1072 | ||
1073 | TFileMerger merger ; | |
fc07289e | 1074 | TString outFileName ; |
1075 | if (runNumber != -1) | |
4e25ac79 | 1076 | outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber); |
fc07289e | 1077 | else |
4e25ac79 | 1078 | outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName()); |
2e331c8b | 1079 | merger.OutputFile(outFileName.Data()) ; |
1080 | for (Int_t ifile = 0 ; ifile < index ; ifile++) { | |
1081 | TString file = fileList[ifile] ; | |
1082 | merger.AddFile(file) ; | |
1083 | } | |
1084 | merger.Merge() ; | |
1085 | ||
1086 | return kTRUE ; | |
1087 | } | |
1088 | ||
1089 | //_____________________________________________________________________________ | |
1090 | void AliQAManager::Reset(const Bool_t sameCycle) | |
1091 | { | |
1092 | // Reset the default data members | |
1093 | ||
1094 | for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) { | |
4e25ac79 | 1095 | if (IsSelected(AliQAv1::GetDetName(iDet))) { |
2e331c8b | 1096 | AliQADataMaker * qadm = GetQADataMaker(iDet); |
1097 | qadm->Reset(); | |
1098 | } | |
1099 | } | |
1100 | if (fRawReaderDelete) { | |
1101 | delete fRawReader ; | |
1102 | fRawReader = NULL ; | |
1103 | } | |
1104 | ||
1105 | fCycleSame = sameCycle ; | |
1106 | fESD = NULL ; | |
1107 | fESDTree = NULL ; | |
1108 | //fFirst = kTRUE ; | |
1109 | fNumberOfEvents = 999999 ; | |
1110 | } | |
1111 | ||
1112 | //_____________________________________________________________________________ | |
634696f5 | 1113 | AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run) |
2e331c8b | 1114 | { |
1115 | // returns AliQAManager instance (singleton) | |
1116 | ||
1117 | if (!fgQAInstance) { | |
634696f5 | 1118 | if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) { |
1119 | AliErrorClass("You must specify kSIMMODE or kRECMODE") ; | |
bf76b847 | 1120 | return NULL ; |
1121 | } | |
2e331c8b | 1122 | fgQAInstance = new AliQAManager(mode) ; |
1123 | if (!entryCache) | |
1124 | fgQAInstance->Init(); | |
1125 | else | |
1126 | fgQAInstance->InitFromCache(entryCache,run); | |
1127 | } | |
1128 | return fgQAInstance; | |
1129 | } | |
1130 | ||
5e303886 | 1131 | //_____________________________________________________________________________ |
1132 | AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task) | |
1133 | { | |
1134 | // returns AliQAManager instance (singleton) | |
634696f5 | 1135 | return QAManager(AliQAv1::Mode(task)) ; |
5e303886 | 1136 | } |
1137 | ||
2e331c8b | 1138 | //_____________________________________________________________________________ |
fec0891b | 1139 | TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle) |
2e331c8b | 1140 | { |
1141 | //Runs all the QA data Maker for Raws only | |
1142 | ||
1143 | fCycleSame = sameCycle ; | |
1144 | fRawReader = rawReader ; | |
1145 | fDetectors = detectors ; | |
1146 | fDetectorsW = detectors ; | |
1147 | ||
1148 | AliCDBManager* man = AliCDBManager::Instance() ; | |
1149 | ||
1150 | if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data | |
1151 | rawReader->NextEvent() ; | |
1152 | man->SetRun(fRawReader->GetRunNumber()) ; | |
1153 | rawReader->RewindEvents() ; | |
1154 | } | |
1155 | ||
1156 | if (!fCycleSame) | |
4e25ac79 | 1157 | if ( !InitQA(AliQAv1::kRAWS) ) |
9b4aee57 | 1158 | return "" ; |
2e331c8b | 1159 | fRawReaderDelete = kFALSE ; |
1160 | ||
4e25ac79 | 1161 | DoIt(AliQAv1::kRAWS) ; |
2e331c8b | 1162 | return fDetectorsW ; |
1163 | } | |
1164 | ||
1165 | //_____________________________________________________________________________ | |
fec0891b | 1166 | TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle) |
2e331c8b | 1167 | { |
1168 | //Runs all the QA data Maker for Raws only | |
1169 | ||
1170 | fCycleSame = sameCycle ; | |
1171 | fDetectors = detectors ; | |
1172 | fDetectorsW = detectors ; | |
1173 | ||
1174 | AliCDBManager* man = AliCDBManager::Instance() ; | |
1175 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun | |
1176 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
1177 | if ( ! rl ) { | |
1178 | AliFatal("galice.root file not found in current directory") ; | |
1179 | } else { | |
1180 | rl->CdGAFile() ; | |
1181 | rl->LoadgAlice() ; | |
1182 | if ( ! rl->GetAliRun() ) { | |
1183 | AliFatal("AliRun not found in galice.root") ; | |
1184 | } else { | |
1185 | rl->LoadHeader() ; | |
1186 | man->SetRun(rl->GetHeader()->GetRun()); | |
1187 | } | |
1188 | } | |
1189 | } | |
1190 | ||
1191 | if (!fCycleSame) | |
4e25ac79 | 1192 | if ( !InitQA(AliQAv1::kRAWS, fileName) ) |
9b4aee57 | 1193 | return "" ; |
2e331c8b | 1194 | |
4e25ac79 | 1195 | DoIt(AliQAv1::kRAWS) ; |
2e331c8b | 1196 | return fDetectorsW ; |
1197 | } | |
1198 | ||
1199 | //_____________________________________________________________________________ | |
fec0891b | 1200 | TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName ) |
2e331c8b | 1201 | { |
1202 | // Runs all the QA data Maker for every detector | |
1203 | ||
1204 | fCycleSame = sameCycle ; | |
1205 | fDetectors = detectors ; | |
1206 | fDetectorsW = detectors ; | |
1207 | ||
1208 | AliCDBManager* man = AliCDBManager::Instance() ; | |
1209 | if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun | |
1210 | AliRunLoader * rl = AliRunLoader::Open("galice.root") ; | |
1211 | if ( ! rl ) { | |
1212 | AliFatal("galice.root file not found in current directory") ; | |
1213 | } else { | |
1214 | rl->CdGAFile() ; | |
1215 | rl->LoadgAlice() ; | |
1216 | if ( ! rl->GetAliRun() ) { | |
5379c4a3 | 1217 | AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ; |
2e331c8b | 1218 | } else { |
1219 | rl->LoadHeader() ; | |
1220 | man->SetRun(rl->GetHeader()->GetRun()) ; | |
1221 | } | |
1222 | } | |
1223 | } | |
fec0891b | 1224 | if ( taskIndex == AliQAv1::kNULLTASKINDEX) { |
4e25ac79 | 1225 | for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) { |
2e331c8b | 1226 | if ( fTasks.Contains(Form("%d", task)) ) { |
1227 | if (!fCycleSame) | |
4e25ac79 | 1228 | if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) ) |
9b4aee57 | 1229 | return "" ; |
4e25ac79 | 1230 | DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ; |
2e331c8b | 1231 | } |
1232 | } | |
1233 | } else { | |
1234 | if (! fCycleSame ) | |
1235 | if ( !InitQA(taskIndex, fileName) ) | |
9b4aee57 | 1236 | return "" ; |
2e331c8b | 1237 | DoIt(taskIndex) ; |
1238 | } | |
2e331c8b | 1239 | return fDetectorsW ; |
2e331c8b | 1240 | } |
1241 | ||
1242 | //_____________________________________________________________________________ | |
1243 | void AliQAManager::RunOneEvent(AliRawReader * rawReader) | |
1244 | { | |
1245 | //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method) | |
1246 | if ( ! rawReader ) | |
1247 | return ; | |
0d105c36 | 1248 | if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){ |
2e331c8b | 1249 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
4e25ac79 | 1250 | if (!IsSelected(AliQAv1::GetDetName(iDet))) |
2e331c8b | 1251 | continue; |
1252 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
1253 | if (!qadm) | |
1254 | continue; | |
1255 | if ( qadm->IsCycleDone() ) { | |
1256 | qadm->EndOfCycle() ; | |
1257 | } | |
5e232cd6 | 1258 | qadm->SetEventSpecie(fEventSpecie) ; |
13a2370e | 1259 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 1260 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
1261 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
4e25ac79 | 1262 | qadm->Exec(AliQAv1::kRAWS, rawReader) ; |
2e331c8b | 1263 | } |
1264 | } | |
1265 | } | |
1266 | ||
1267 | //_____________________________________________________________________________ | |
1268 | void AliQAManager::RunOneEvent(AliESDEvent *& esd) | |
1269 | { | |
1270 | //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
1271 | ||
0d105c36 | 1272 | if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) { |
2e331c8b | 1273 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { |
4e25ac79 | 1274 | if (!IsSelected(AliQAv1::GetDetName(iDet))) |
2e331c8b | 1275 | continue; |
1276 | AliQADataMaker *qadm = GetQADataMaker(iDet); | |
1277 | if (!qadm) | |
1278 | continue; | |
5e232cd6 | 1279 | qadm->SetEventSpecie(fEventSpecie) ; |
82a30871 | 1280 | if ( qadm->GetRecoParam() ) |
5e232cd6 | 1281 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
1282 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; | |
2e331c8b | 1283 | if ( qadm->IsCycleDone() ) { |
1284 | qadm->EndOfCycle() ; | |
1285 | } | |
4e25ac79 | 1286 | qadm->Exec(AliQAv1::kESDS, esd) ; |
2e331c8b | 1287 | } |
1288 | } | |
1289 | } | |
1290 | ||
1291 | //_____________________________________________________________________________ | |
1292 | void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree) | |
1293 | { | |
1294 | // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method) | |
44ed7a66 | 1295 | |
1296 | TString test(tree->GetName()) ; | |
0d105c36 | 1297 | if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) { |
4e25ac79 | 1298 | if (IsSelected(AliQAv1::GetDetName(det))) { |
2e331c8b | 1299 | AliQADataMaker *qadm = GetQADataMaker(det); |
1300 | if (qadm) { | |
5e232cd6 | 1301 | qadm->SetEventSpecie(fEventSpecie) ; |
31c31326 | 1302 | if ( qadm->GetRecoParam() ) { |
5e232cd6 | 1303 | if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault) |
31c31326 | 1304 | qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ; |
1305 | else | |
5c5ea798 | 1306 | AliError(Form("%d defined by %s is not an event specie", qadm->GetRecoParam()->GetEventSpecie(), qadm->GetName())) ; |
31c31326 | 1307 | } |
2e331c8b | 1308 | if ( qadm->IsCycleDone() ) { |
1309 | qadm->EndOfCycle() ; | |
1310 | } | |
44ed7a66 | 1311 | if (test.Contains("TreeD")) { |
1312 | qadm->Exec(AliQAv1::kDIGITSR, tree) ; | |
44ed7a66 | 1313 | } else if (test.Contains("TreeR")) { |
1314 | qadm->Exec(AliQAv1::kRECPOINTS, tree) ; | |
44ed7a66 | 1315 | } |
2e331c8b | 1316 | } |
1317 | } | |
1318 | } | |
1319 | } | |
1320 | ||
1321 | //_____________________________________________________________________________ | |
fec0891b | 1322 | Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const |
2e331c8b | 1323 | { |
1324 | // take the locasl QA data merge into a single file and save in OCDB | |
1325 | Bool_t rv = kTRUE ; | |
4e25ac79 | 1326 | TString tmp(AliQAv1::GetQARefStorage()) ; |
2e331c8b | 1327 | if ( tmp.IsNull() ) { |
4e25ac79 | 1328 | AliError("No storage defined, use AliQAv1::SetQARefStorage") ; |
2e331c8b | 1329 | return kFALSE ; |
1330 | } | |
4e25ac79 | 1331 | if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) { |
1332 | AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ; | |
2e331c8b | 1333 | return kFALSE ; |
1334 | } | |
1335 | TString sdet(detectors) ; | |
1336 | sdet.ToUpper() ; | |
1337 | TFile * inputFile ; | |
1338 | if ( sdet.Contains("ALL") ) { | |
1339 | rv = Merge(runNumber) ; | |
1340 | if ( ! rv ) | |
1341 | return kFALSE ; | |
4e25ac79 | 1342 | TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ; |
2e331c8b | 1343 | inputFile = TFile::Open(inputFileName.Data()) ; |
1344 | rv = SaveIt2OCDB(runNumber, inputFile, year, es) ; | |
1345 | } else { | |
4e25ac79 | 1346 | for (Int_t index = 0; index < AliQAv1::kNDET; index++) { |
1347 | if (sdet.Contains(AliQAv1::GetDetName(index))) { | |
1348 | TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ; | |
2e331c8b | 1349 | inputFile = TFile::Open(inputFileName.Data()) ; |
1350 | rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ; | |
1351 | } | |
1352 | } | |
1353 | } | |
1354 | return rv ; | |
1355 | } | |
1356 | ||
1357 | //_____________________________________________________________________________ | |
fec0891b | 1358 | Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const |
2e331c8b | 1359 | { |
1360 | // reads the TH1 from file and adds it to appropriate list before saving to OCDB | |
1361 | Bool_t rv = kTRUE ; | |
5379c4a3 | 1362 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ; |
2e331c8b | 1363 | if ( ! IsDefaultStorageSet() ) { |
4e25ac79 | 1364 | TString tmp( AliQAv1::GetQARefStorage() ) ; |
1365 | if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) ) | |
1366 | Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ; | |
2e331c8b | 1367 | else { |
4e25ac79 | 1368 | TString tmp1(AliQAv1::GetQARefDefaultStorage()) ; |
2e331c8b | 1369 | tmp1.Append(year) ; |
1370 | tmp1.Append("?user=alidaq") ; | |
1371 | Instance()->SetDefaultStorage(tmp1.Data()) ; | |
1372 | } | |
1373 | } | |
4e25ac79 | 1374 | Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ; |
2e331c8b | 1375 | if(GetRun() < 0) |
1376 | Instance()->SetRun(runNumber); | |
1377 | ||
1378 | AliCDBMetaData mdr ; | |
1379 | mdr.SetResponsible("yves schutz"); | |
1380 | ||
4e25ac79 | 1381 | for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) { |
1382 | TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ; | |
2e331c8b | 1383 | if ( detDir ) { |
5379c4a3 | 1384 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ; |
4e25ac79 | 1385 | AliQAv1::SetQARefDataDirName(es) ; |
1386 | TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ; | |
2e331c8b | 1387 | AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ; |
1388 | TList * listDetQAD = new TList() ; | |
4e25ac79 | 1389 | TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ; |
1390 | mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex))); | |
2e331c8b | 1391 | listDetQAD->SetName(listName) ; |
1392 | TList * taskList = detDir->GetListOfKeys() ; | |
1393 | TIter nextTask(taskList) ; | |
1394 | TKey * taskKey ; | |
eca4fa66 | 1395 | while ( (taskKey = static_cast<TKey*>(nextTask())) ) { |
2e331c8b | 1396 | TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ; |
1397 | TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ; | |
5379c4a3 | 1398 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ; |
2e331c8b | 1399 | TObjArray * listTaskQAD = new TObjArray(100) ; |
1400 | listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ; | |
1401 | listDetQAD->Add(listTaskQAD) ; | |
1402 | TList * histList = esDir->GetListOfKeys() ; | |
1403 | TIter nextHist(histList) ; | |
1404 | TKey * histKey ; | |
eca4fa66 | 1405 | while ( (histKey = static_cast<TKey*>(nextHist())) ) { |
2e331c8b | 1406 | TObject * odata = esDir->Get(histKey->GetName()) ; |
1407 | if ( !odata ) { | |
1408 | AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
1409 | } else { | |
4e25ac79 | 1410 | if ( AliQAv1::GetExpert() == histKey->GetName() ) { |
2e331c8b | 1411 | TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ; |
1412 | TList * expertHistList = expertDir->GetListOfKeys() ; | |
1413 | TIter nextExpertHist(expertHistList) ; | |
1414 | TKey * expertHistKey ; | |
eca4fa66 | 1415 | while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) { |
2e331c8b | 1416 | TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ; |
1417 | if ( !expertOdata ) { | |
1418 | AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ; | |
1419 | } else { | |
5379c4a3 | 1420 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ; |
2e331c8b | 1421 | if ( expertOdata->IsA()->InheritsFrom("TH1") ) { |
5379c4a3 | 1422 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ; |
2e331c8b | 1423 | TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ; |
1424 | listTaskQAD->Add(hExpertdata) ; | |
1425 | } | |
1426 | } | |
1427 | } | |
1428 | } | |
5379c4a3 | 1429 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ; |
2e331c8b | 1430 | if ( odata->IsA()->InheritsFrom("TH1") ) { |
5379c4a3 | 1431 | AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ; |
2e331c8b | 1432 | TH1 * hdata = static_cast<TH1*>(odata) ; |
1433 | listTaskQAD->Add(hdata) ; | |
1434 | } | |
1435 | } | |
1436 | } | |
1437 | } | |
1438 | Instance()->Put(listDetQAD, idr, &mdr) ; | |
1439 | } | |
1440 | } | |
1441 | return rv ; | |
1442 | } | |
1443 | ||
7c9ff472 | 1444 | //_____________________________________________________________________________ |
1445 | ||
1446 | void AliQAManager::SetCheckerExternParam(AliQAv1::DETECTORINDEX_t detIndex, TList * parameterList) | |
1447 | { | |
1448 | // set the external parameters list for the detector checkers | |
1449 | AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ; | |
1450 | qac->SetExternParamlist(parameterList) ; | |
1451 | qac->PrintExternParam() ; | |
1452 | } | |
1453 | ||
2e331c8b | 1454 | //_____________________________________________________________________________ |
1455 | void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es) | |
1456 | { | |
4e25ac79 | 1457 | // set the current event specie and inform AliQAv1 that this event specie has been encountered |
bc8761a0 | 1458 | fEventSpecie = es ; |
4e25ac79 | 1459 | AliQAv1::Instance()->SetEventSpecie(es) ; |
2e331c8b | 1460 | } |
1461 | ||
1462 | //_____________________________________________________________________________ | |
1463 | void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par) | |
1464 | { | |
1465 | // Set custom reconstruction parameters for a given detector | |
1466 | // Single set of parameters for all the events | |
1467 | GetQADataMaker(det)->SetRecoParam(par) ; | |
1468 | } | |
1469 | ||
75373542 | 1470 | //_____________________________________________________________________________ |
1471 | void AliQAManager::SetWriteExpert() | |
1472 | { | |
1473 | // enable the writing of QA expert data | |
1474 | for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) { | |
4e25ac79 | 1475 | if (IsSelected(AliQAv1::GetDetName(iDet))) |
75373542 | 1476 | fQAWriteExpert[iDet] = kTRUE ; |
1477 | } | |
1478 | } | |
7cade814 | 1479 | |
1480 | //_____________________________________________________________________________ | |
1481 | void AliQAManager::Destroy() { | |
bf76b847 | 1482 | // delete AliQAManager instance and |
1483 | // all associated objects | |
7cade814 | 1484 | |
1485 | if (fgQAInstance) { | |
eca4fa66 | 1486 | delete fgQAInstance ; |
1487 | fgQAInstance = NULL ; | |
7cade814 | 1488 | } |
1489 | } | |
1490 | ||
bf76b847 | 1491 | //_____________________________________________________________________________ |
1492 | void AliQAManager::ShowQA() { | |
1493 | // Show the result of the QA checking | |
1494 | // for all detectors | |
1495 | for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) | |
1496 | AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ; | |
1497 | } |