1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 /* $Id: AliQAManager.cxx 30894 2009-02-05 13:46:48Z schutz $ */
17 ///////////////////////////////////////////////////////////////////////////////
19 // class for running the QA makers //
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); //
29 ///////////////////////////////////////////////////////////////////////////////
34 #include <TFileMerger.h>
36 #include <TGridCollection.h>
37 #include <TGridResult.h>
38 #include <TPluginManager.h>
43 #include "AliCDBManager.h"
44 #include "AliCDBEntry.h"
46 #include "AliCDBMetaData.h"
47 #include "AliCodeTimer.h"
48 #include "AliCorrQADataMakerRec.h"
49 #include "AliDetectorRecoParam.h"
50 #include "AliESDEvent.h"
51 #include "AliGeomManager.h"
52 #include "AliGlobalQADataMaker.h"
53 #include "AliHeader.h"
55 #include "AliModule.h"
57 #include "AliQADataMakerRec.h"
58 #include "AliQADataMakerSim.h"
59 #include "AliQAManager.h"
60 #include "AliRawReaderDate.h"
61 #include "AliRawReaderFile.h"
62 #include "AliRawReaderRoot.h"
64 #include "AliRunLoader.h"
65 #include "AliRunTag.h"
67 ClassImp(AliQAManager)
68 AliQAManager* AliQAManager::fgQAInstance = 0x0;
70 //_____________________________________________________________________________
71 AliQAManager::AliQAManager() :
83 fNumberOfEvents(999999),
87 fRawReaderDelete(kTRUE),
90 fEventSpecie(AliRecoParam::kDefault),
94 fMaxEvents = fNumberOfEvents ;
95 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
96 if (IsSelected(AliQAv1::GetDetName(iDet))) {
97 fLoader[iDet] = NULL ;
98 fQADataMaker[iDet] = NULL ;
99 fQACycles[iDet] = 999999 ;
105 //_____________________________________________________________________________
106 AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
114 fGAliceFileName(gAliceFilename),
118 fNumberOfEvents(999999),
122 fRawReaderDelete(kTRUE),
125 fEventSpecie(AliRecoParam::kDefault),
129 fMaxEvents = fNumberOfEvents ;
130 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
131 if (IsSelected(AliQAv1::GetDetName(iDet))) {
132 fLoader[iDet] = NULL ;
133 fQADataMaker[iDet] = NULL ;
134 fQACycles[iDet] = 999999 ;
139 if (fMode.Contains("sim"))
140 fMode.ReplaceAll("s", "S") ;
141 else if (fMode.Contains("rec"))
142 fMode.ReplaceAll("r", "R") ;
145 //_____________________________________________________________________________
146 AliQAManager::AliQAManager(const AliQAManager & qas) :
148 fCurrentEvent(qas.fCurrentEvent),
150 fDetectors(qas.fDetectors),
151 fDetectorsW(qas.fDetectorsW),
154 fGAliceFileName(qas.fGAliceFileName),
155 fFirstEvent(qas.fFirstEvent),
156 fMaxEvents(qas.fMaxEvents),
158 fNumberOfEvents(qas.fNumberOfEvents),
160 fRunNumber(qas.fRunNumber),
162 fRawReaderDelete(kTRUE),
165 fEventSpecie(qas.fEventSpecie),
166 fPrintImage(qas.fPrintImage)
170 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
171 fLoader[iDet] = qas.fLoader[iDet] ;
172 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
173 fQACycles[iDet] = qas.fQACycles[iDet] ;
174 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
178 //_____________________________________________________________________________
179 AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
181 // assignment operator
182 this->~AliQAManager() ;
183 new(this) AliQAManager(qas) ;
187 //_____________________________________________________________________________
188 AliQAManager::~AliQAManager()
191 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
192 if (IsSelected(AliQAv1::GetDetName(iDet))) {
193 fLoader[iDet] = NULL;
194 if (fQADataMaker[iDet]) {
195 (fQADataMaker[iDet])->Finish() ;
196 delete fQADataMaker[iDet] ;
200 if (fRawReaderDelete) {
207 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()));
210 //_____________________________________________________________________________
211 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
213 // Runs all the QA data Maker for every detector
216 // Fill QA data in event loop
217 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
220 if ( iEvent%10 == 0 )
221 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
222 if ( taskIndex == AliQAv1::kRAWS ) {
223 if ( !fRawReader->NextEvent() )
225 } else if ( taskIndex == AliQAv1::kESDS ) {
226 if ( fESDTree->GetEntry(iEvent) == 0 )
229 if ( fRunLoader->GetEvent(iEvent) != 0 )
232 // loop over active loaders
233 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
234 if (IsSelected(AliQAv1::GetDetName(iDet))) {
235 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
236 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
237 if ( qadm->IsCycleDone() ) {
238 qadm->EndOfCycle(taskIndex) ;
240 TTree * data = NULL ;
241 AliLoader* loader = GetLoader(qadm->GetUniqueID());
243 case AliQAv1::kNULLTASKINDEX :
245 case AliQAv1::kRAWS :
246 qadm->Exec(taskIndex, fRawReader) ;
248 case AliQAv1::kHITS :
251 data = loader->TreeH() ;
253 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
256 qadm->Exec(taskIndex, data) ;
259 case AliQAv1::kSDIGITS :
261 loader->LoadSDigits() ;
262 data = loader->TreeS() ;
264 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
267 qadm->Exec(taskIndex, data) ;
270 case AliQAv1::kDIGITS :
272 loader->LoadDigits() ;
273 data = loader->TreeD() ;
275 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
278 qadm->Exec(taskIndex, data) ;
281 case AliQAv1::kDIGITSR :
283 loader->LoadDigits() ;
284 data = loader->TreeD() ;
286 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
289 qadm->Exec(taskIndex, data) ;
292 case AliQAv1::kRECPOINTS :
294 loader->LoadRecPoints() ;
295 data = loader->TreeR() ;
297 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ;
300 qadm->Exec(taskIndex, data) ;
303 case AliQAv1::kTRACKSEGMENTS :
305 case AliQAv1::kRECPARTICLES :
307 case AliQAv1::kESDS :
308 qadm->Exec(taskIndex, fESD) ;
310 case AliQAv1::kNTASKINDEX :
317 // Save QA data for all detectors
318 rv = Finish(taskIndex) ;
320 if ( taskIndex == AliQAv1::kRAWS )
321 fRawReader->RewindEvents() ;
326 //_____________________________________________________________________________
327 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
329 // write output to file for all detectors
330 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
331 if (IsSelected(AliQAv1::GetDetName(iDet))) {
332 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
334 qadm->EndOfCycle(taskIndex) ;
340 //_____________________________________________________________________________
341 TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const
343 // Retrieve the list of QA data for a given detector and a given task
344 TObjArray * rv = NULL ;
345 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
346 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
349 if ( ! IsDefaultStorageSet() ) {
350 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
353 Instance()->SetDefaultStorage(tmp.Data()) ;
354 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
356 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
357 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
358 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
359 TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ;
361 rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
365 //_____________________________________________________________________________
366 TCanvas ** AliQAManager::GetImage(Char_t * detName)
368 // retrieves QA Image for the given detector
369 TCanvas ** rv = NULL ;
370 Int_t detIndex = AliQAv1::GetDetIndex(detName) ;
371 AliQADataMaker * qadm = GetQADataMaker(detIndex) ;
372 rv = qadm->GetImage() ;
376 //_____________________________________________________________________________
377 AliLoader * AliQAManager::GetLoader(Int_t iDet)
379 // get the loader for a detector
381 if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL )
384 TString detName = AliQAv1::GetDetName(iDet) ;
385 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
387 return fLoader[iDet] ;
389 // load the QA data maker object
390 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
391 TString loaderName = "Ali" + detName + "Loader" ;
393 AliLoader * loader = NULL ;
394 // first check if a plugin is defined for the quality assurance data maker
395 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
396 // if not, add a plugin for it
397 if (!pluginHandler) {
398 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
399 TString libs = gSystem->GetLibraries() ;
400 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
401 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
403 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
405 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
407 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
408 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
411 fLoader[iDet] = loader ;
415 //_____________________________________________________________________________
416 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
418 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
419 Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
420 TFile * tagFile = TFile::Open(fileName) ;
422 AliError(Form("File %s not found", fileName)) ;
425 TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ;
427 AliError(Form("Tree T not found in %s", fileName)) ;
431 AliRunTag * tag = new AliRunTag ;
432 tagTree->SetBranchAddress("AliTAG", &tag) ;
433 tagTree->GetEntry(evt) ;
434 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
439 //_____________________________________________________________________________
440 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
442 // get the quality assurance data maker for a detector
444 AliQADataMaker * qadm = fQADataMaker[iDet] ;
448 qadm->SetEventSpecie(fEventSpecie) ;
449 if ( qadm->GetRecoParam() )
450 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
451 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
453 } else if (iDet == AliQAv1::kGLOBAL) { //Global QA
455 qadm = new AliGlobalQADataMaker();
456 qadm->SetName(AliQAv1::GetDetName(iDet));
457 qadm->SetUniqueID(iDet);
458 fQADataMaker[iDet] = qadm;
459 qadm->SetEventSpecie(fEventSpecie) ;
460 if ( qadm->GetRecoParam() )
461 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
462 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
464 } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
465 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
466 qadm->SetName(AliQAv1::GetDetName(iDet));
467 qadm->SetUniqueID(iDet);
468 fQADataMaker[iDet] = qadm;
469 qadm->SetEventSpecie(fEventSpecie) ;
470 if ( qadm->GetRecoParam() )
471 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
472 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
474 } else if ( iDet != AliQAv1::kCORR ) {
476 // load the QA data maker object
477 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
478 TString detName = AliQAv1::GetDetName(iDet) ;
479 TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
481 // first check if a plugin is defined for the quality assurance data maker
482 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
483 // if not, add a plugin for it
484 if (!pluginHandler) {
485 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
486 TString libs = gSystem->GetLibraries() ;
487 TString temp(GetMode()) ;
489 if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
490 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
492 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
494 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
496 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
497 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
500 qadm->SetName(AliQAv1::GetDetName(iDet));
501 qadm->SetUniqueID(iDet);
502 fQADataMaker[iDet] = qadm ;
503 qadm->SetEventSpecie(fEventSpecie) ;
504 if ( qadm->GetRecoParam() )
505 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
506 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
512 //_____________________________________________________________________________
513 void AliQAManager::EndOfCycle(TObjArray * detArray)
515 // End of cycle QADataMakers
519 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
521 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
522 if (IsSelected(AliQAv1::GetDetName(iDet))) {
523 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
526 // skip non active detectors
528 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
529 if (!det || !det->IsActive())
532 qadm->SetPrintImage(fPrintImage) ;
534 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
535 if ( fTasks.Contains(Form("%d", taskIndex)) )
536 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
543 //_____________________________________________________________________________
544 void AliQAManager::EndOfCycle(TString detectors)
546 // End of cycle QADataMakers
550 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
552 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
553 if (IsSelected(AliQAv1::GetDetName(iDet))) {
554 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
557 // skip non active detectors
558 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
560 qadm->SetPrintImage(fPrintImage) ;
561 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
562 if ( fTasks.Contains(Form("%d", taskIndex)) )
563 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
570 //_____________________________________________________________________________
571 void AliQAManager::Increment()
573 // Increments the cycle counter for all QA Data Makers
574 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
575 if (IsSelected(AliQAv1::GetDetName(iDet))) {
576 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
583 //_____________________________________________________________________________
584 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
586 // Initialize the event source and QA data makers
588 fTasks += Form("%d", taskIndex) ;
590 if (taskIndex == AliQAv1::kRAWS) {
592 fRawReader = AliRawReader::Create(input);
596 fRawReaderDelete = kTRUE ;
597 fRawReader->NextEvent() ;
598 fRunNumber = fRawReader->GetRunNumber() ;
600 fRawReader->RewindEvents();
601 fNumberOfEvents = 999999 ;
602 if ( fMaxEvents < 0 )
603 fMaxEvents = fNumberOfEvents ;
604 } else if (taskIndex == AliQAv1::kESDS) {
605 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
606 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
607 TFile * esdFile = TFile::Open("AliESDs.root") ;
608 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
610 AliError("esdTree not found") ;
613 fESD = new AliESDEvent() ;
614 fESD->ReadFromTree(fESDTree) ;
615 fESDTree->GetEntry(0) ;
616 fRunNumber = fESD->GetRunNumber() ;
617 fNumberOfEvents = fESDTree->GetEntries() ;
618 if ( fMaxEvents < 0 )
619 fMaxEvents = fNumberOfEvents ;
622 AliError("AliESDs.root not found") ;
626 if ( !InitRunLoader() ) {
627 AliWarning("No Run Loader not found") ;
629 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
630 if ( fMaxEvents < 0 )
631 fMaxEvents = fNumberOfEvents ;
636 TObjArray* detArray = NULL ;
637 if (fRunLoader) // check if RunLoader exists
638 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
639 detArray = fRunLoader->GetAliRun()->Detectors() ;
640 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
643 // Initialize all QA data makers for all detectors
644 fRunNumber = AliCDBManager::Instance()->GetRun() ;
645 if ( ! AliGeomManager::GetGeometry() )
646 AliGeomManager::LoadGeometry() ;
648 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
651 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
656 //_____________________________________________________________________________
657 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
659 // Initializes The QADataMaker for all active detectors and for all active tasks
661 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
662 if (IsSelected(AliQAv1::GetDetName(iDet))) {
663 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
665 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
666 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
668 if (fQAWriteExpert[iDet])
669 qadm->SetWriteExpert() ;
670 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
671 // skip non active detectors
673 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
674 if (!det || !det->IsActive())
677 // Set default reco params
678 Bool_t sameCycle = kFALSE ;
679 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
680 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
681 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
682 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
692 //_____________________________________________________________________________
693 Bool_t AliQAManager::InitRunLoader()
695 // get or create the run loader
699 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
700 // load all base libraries to get the loader classes
701 TString libs = gSystem->GetLibraries() ;
702 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
703 if (!IsSelected(AliQAv1::GetDetName(iDet)))
705 TString detName = AliQAv1::GetDetName(iDet) ;
706 if (detName == "HLT")
708 if (libs.Contains("lib" + detName + "base.so"))
710 gSystem->Load("lib" + detName + "base.so");
712 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
714 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
717 fRunLoader->CdGAFile();
718 if (fRunLoader->LoadgAlice() == 0) {
719 gAlice = fRunLoader->GetAliRun();
723 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
727 } else { // galice.root does not exist
728 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
734 fRunLoader->LoadHeader();
735 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
740 //_____________________________________________________________________________
741 Bool_t AliQAManager::IsSelected(const Char_t * det)
743 // check whether detName is contained in detectors
744 // if yes, it is removed from detectors
747 const TString detName(det) ;
748 // always activates Correlation
749 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
752 // check if all detectors are selected
753 if (fDetectors.Contains("ALL")) {
756 } else if ((fDetectors.CompareTo(detName) == 0) ||
757 fDetectors.BeginsWith(detName+" ") ||
758 fDetectors.EndsWith(" "+detName) ||
759 fDetectors.Contains(" "+detName+" ")) {
766 //_____________________________________________________________________________
767 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
769 // Merge data from all detectors from a given run in one single file
770 // Merge the QA results from all the data chunks in one run
771 // The 'fileName' is name of the output file with merged QA data
772 if ( runNumber == -1)
773 runNumber = fRunNumber ;
774 Bool_t rv = MergeData(runNumber,fileName) ;
775 //rv *= MergeResults(runNumber) ; // not needed for the time being
779 //______________________________________________________________________
780 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
782 // merges files listed in a xml collection
783 // usage Merge(collection, outputFile))
784 // collection: is a xml collection
788 if ( strstr(collectionFile, ".xml") == 0 ) {
789 AliError("Input collection file must be an \".xml\" file\n") ;
794 TGrid::Connect("alien://");
798 // Open the file collection
799 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
801 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
802 TGridResult* result = collection->GetGridResult("", 0, 0);
805 const Char_t * turl ;
806 TFileMerger merger(kFALSE) ;
808 TString tempo(collectionFile) ;
810 tempo.ReplaceAll(".xml", subFile) ;
812 tempo.ReplaceAll(".xml", "_Merged.root") ;
813 outFile = tempo.Data() ;
815 merger.OutputFile(outFile) ;
817 while ( (turl = result->GetKey(index, "turl")) ) {
820 file = Form("%s#%s", turl, subFile) ;
822 file = Form("%s", turl) ;
824 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
825 merger.AddFile(file) ;
832 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
838 //_____________________________________________________________________________
839 void AliQAManager::MergeCustom() const
841 // Custom Merge of QA data from all detectors for all runs in one single file
842 // search all the run numbers
843 // search all the run numbers
844 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
846 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
849 TIter nextRun(&srunList) ;
850 TObjString * srun = NULL ;
851 Int_t loRun = 999999999 ;
853 while ( QAfile.Gets(QAfiles) ) {
854 Bool_t runExist = kFALSE ;
855 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
856 Int_t cuRun = srunNew.Atoi() ;
861 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
862 if ( cuRun == (srun->String()).Atoi() ) {
869 srunList.Add(new TObjString(srunNew.Data()));
872 Int_t runNumber = 0 ;
873 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
874 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
875 // create the structure into the merged file
876 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
877 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
878 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
880 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
881 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
883 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
885 gDirectory->mkdir(AliQAv1::GetExpert()) ;
889 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
890 runNumber = (srun->String()).Atoi() ;
891 hisRun->Fill(runNumber) ;
892 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
893 // search all QA files for runNumber in the current directory
894 Char_t * fileList[AliQAv1::kNDET] ;
896 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
897 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
899 fileList[index++] = file ;
902 AliError("No QA data file found\n") ;
905 for ( Int_t i = 0 ; i < index ; i++) {
906 TFile * inFile = TFile::Open(fileList[i]) ;
907 TList * listOfKeys =inFile->GetListOfKeys() ;
908 TIter nextkey(listOfKeys) ;
910 TString dirName("") ;
911 while ( (obj1 = nextkey()) ) {
912 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
913 if ( directoryDet ) {
914 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
915 dirName += Form("%s/", directoryDet->GetName() ) ;
917 TList * listOfTasks = directoryDet->GetListOfKeys() ;
918 TIter nextTask(listOfTasks) ;
920 while ( (obj2 = nextTask()) ) {
921 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
922 if ( directoryTask ) {
923 dirName += Form("%s", obj2->GetName()) ;
924 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
925 directoryTask->cd() ;
926 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
927 TIter nextEventSpecie(listOfEventSpecie) ;
929 while ( (obj3 = nextEventSpecie()) ) {
930 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
931 if ( directoryEventSpecie ) {
932 dirName += Form("/%s/", obj3->GetName()) ;
933 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
934 directoryEventSpecie->cd() ;
935 // histograms are here
936 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
937 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
938 TIter nextData(listOfData) ;
940 while ( (key = static_cast<TKey *>(nextData())) ) {
941 TString className(key->GetClassName()) ;
942 if ( className.Contains("TH") || className.Contains("TProfile") ) {
943 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
944 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
945 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
946 mergedDirectory->cd() ;
950 histOu->Add(histIn) ;
951 histOu->Write(histOu->GetName(), kOverwrite) ;
954 else if ( className.Contains("TDirectoryFile") ) {
955 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
957 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
958 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
959 TIter nextExpertData(listOfExpertData) ;
961 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
962 TString classNameExpert(keykey->GetClassName()) ;
963 if (classNameExpert.Contains("TH")) {
964 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
965 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
966 mergedDirectoryExpert->cd() ;
967 if ( ! histOuExpert ) {
968 histInExpert->Write() ;
970 histOuExpert->Add(histInExpert) ;
971 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
976 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
979 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
982 dirName.ReplaceAll(obj2->GetName(), "") ;
996 //_____________________________________________________________________________
997 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
999 // Merge QA data from all detectors for a given run in one single file
1001 TFileMerger merger(kFALSE) ;
1002 TString outFileName = fileName;
1003 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1004 merger.OutputFile(outFileName.Data()) ;
1005 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1006 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1008 merger.AddFile(file) ;
1014 //_____________________________________________________________________________
1015 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1017 // Merge the QA result from all the data chunks in a run
1018 // to be revised whwn it will be used (see MergeData)
1020 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1021 gROOT->ProcessLine(cmd.Data()) ;
1022 ifstream in("tempo.txt") ;
1023 const Int_t chunkMax = 100 ;
1024 TString fileList[chunkMax] ;
1029 in >> fileList[index] ;
1032 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1037 AliError("No QA Result File found") ;
1041 TFileMerger merger ;
1042 TString outFileName ;
1043 if (runNumber != -1)
1044 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1046 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1047 merger.OutputFile(outFileName.Data()) ;
1048 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1049 TString file = fileList[ifile] ;
1050 merger.AddFile(file) ;
1057 //_____________________________________________________________________________
1058 void AliQAManager::Reset(const Bool_t sameCycle)
1060 // Reset the default data members
1062 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1063 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1064 AliQADataMaker * qadm = GetQADataMaker(iDet);
1068 if (fRawReaderDelete) {
1073 fCycleSame = sameCycle ;
1077 fNumberOfEvents = 999999 ;
1080 //_____________________________________________________________________________
1081 AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, Int_t run)
1083 // returns AliQAManager instance (singleton)
1085 if (!fgQAInstance) {
1086 if ( (strcmp(mode, "sim") != 0) && (strcmp(mode, "rec") != 0) ) {
1087 AliErrorClass("You must specify sim or rec") ;
1090 fgQAInstance = new AliQAManager(mode) ;
1092 fgQAInstance->Init();
1094 fgQAInstance->InitFromCache(entryCache,run);
1096 return fgQAInstance;
1099 //_____________________________________________________________________________
1100 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1102 //Runs all the QA data Maker for Raws only
1104 fCycleSame = sameCycle ;
1105 fRawReader = rawReader ;
1106 fDetectors = detectors ;
1107 fDetectorsW = detectors ;
1109 AliCDBManager* man = AliCDBManager::Instance() ;
1111 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1112 rawReader->NextEvent() ;
1113 man->SetRun(fRawReader->GetRunNumber()) ;
1114 rawReader->RewindEvents() ;
1118 if ( !InitQA(AliQAv1::kRAWS) )
1120 fRawReaderDelete = kFALSE ;
1122 DoIt(AliQAv1::kRAWS) ;
1123 return fDetectorsW ;
1126 //_____________________________________________________________________________
1127 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1129 //Runs all the QA data Maker for Raws only
1131 fCycleSame = sameCycle ;
1132 fDetectors = detectors ;
1133 fDetectorsW = detectors ;
1135 AliCDBManager* man = AliCDBManager::Instance() ;
1136 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1137 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1139 AliFatal("galice.root file not found in current directory") ;
1143 if ( ! rl->GetAliRun() ) {
1144 AliFatal("AliRun not found in galice.root") ;
1147 man->SetRun(rl->GetHeader()->GetRun());
1153 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1156 DoIt(AliQAv1::kRAWS) ;
1157 return fDetectorsW ;
1160 //_____________________________________________________________________________
1161 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1163 // Runs all the QA data Maker for every detector
1165 fCycleSame = sameCycle ;
1166 fDetectors = detectors ;
1167 fDetectorsW = detectors ;
1169 AliCDBManager* man = AliCDBManager::Instance() ;
1170 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1171 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1173 AliFatal("galice.root file not found in current directory") ;
1177 if ( ! rl->GetAliRun() ) {
1178 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1181 man->SetRun(rl->GetHeader()->GetRun()) ;
1185 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1186 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1187 if ( fTasks.Contains(Form("%d", task)) ) {
1189 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1191 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1196 if ( !InitQA(taskIndex, fileName) )
1200 return fDetectorsW ;
1203 //_____________________________________________________________________________
1204 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1206 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1209 AliCodeTimerAuto("") ;
1210 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1211 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1212 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1214 AliQADataMaker *qadm = GetQADataMaker(iDet);
1217 if ( qadm->IsCycleDone() ) {
1218 qadm->EndOfCycle() ;
1220 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1221 qadm->SetEventSpecie(fEventSpecie) ;
1222 if ( qadm->GetRecoParam() )
1223 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1224 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1225 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1226 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1231 //_____________________________________________________________________________
1232 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1234 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1236 AliCodeTimerAuto("") ;
1237 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1238 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1239 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1241 AliQADataMaker *qadm = GetQADataMaker(iDet);
1244 qadm->SetEventSpecie(fEventSpecie) ;
1245 if ( qadm->GetRecoParam() )
1246 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1247 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1248 if ( qadm->IsCycleDone() ) {
1249 qadm->EndOfCycle() ;
1251 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1252 qadm->Exec(AliQAv1::kESDS, esd) ;
1253 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1258 //_____________________________________________________________________________
1259 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1261 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1263 TString test(tree->GetName()) ;
1264 AliCodeTimerAuto("") ;
1265 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1266 if (IsSelected(AliQAv1::GetDetName(det))) {
1267 AliQADataMaker *qadm = GetQADataMaker(det);
1269 qadm->SetEventSpecie(fEventSpecie) ;
1270 if ( qadm->GetRecoParam() )
1271 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1272 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1273 if ( qadm->IsCycleDone() ) {
1274 qadm->EndOfCycle() ;
1276 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1277 if (test.Contains("TreeD")) {
1278 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1279 } else if (test.Contains("TreeR")) {
1280 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1281 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1288 //_____________________________________________________________________________
1289 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1291 // take the locasl QA data merge into a single file and save in OCDB
1293 TString tmp(AliQAv1::GetQARefStorage()) ;
1294 if ( tmp.IsNull() ) {
1295 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1298 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1299 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1302 TString sdet(detectors) ;
1305 if ( sdet.Contains("ALL") ) {
1306 rv = Merge(runNumber) ;
1309 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1310 inputFile = TFile::Open(inputFileName.Data()) ;
1311 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1313 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1314 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1315 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1316 inputFile = TFile::Open(inputFileName.Data()) ;
1317 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1324 //_____________________________________________________________________________
1325 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1327 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1329 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1330 if ( ! IsDefaultStorageSet() ) {
1331 TString tmp( AliQAv1::GetQARefStorage() ) ;
1332 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1333 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1335 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1337 tmp1.Append("?user=alidaq") ;
1338 Instance()->SetDefaultStorage(tmp1.Data()) ;
1341 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1343 Instance()->SetRun(runNumber);
1345 AliCDBMetaData mdr ;
1346 mdr.SetResponsible("yves schutz");
1348 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1349 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1351 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1352 AliQAv1::SetQARefDataDirName(es) ;
1353 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1354 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1355 TList * listDetQAD = new TList() ;
1356 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1357 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1358 listDetQAD->SetName(listName) ;
1359 TList * taskList = detDir->GetListOfKeys() ;
1360 TIter nextTask(taskList) ;
1362 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1363 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1364 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1365 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1366 TObjArray * listTaskQAD = new TObjArray(100) ;
1367 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1368 listDetQAD->Add(listTaskQAD) ;
1369 TList * histList = esDir->GetListOfKeys() ;
1370 TIter nextHist(histList) ;
1372 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1373 TObject * odata = esDir->Get(histKey->GetName()) ;
1375 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1377 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1378 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1379 TList * expertHistList = expertDir->GetListOfKeys() ;
1380 TIter nextExpertHist(expertHistList) ;
1381 TKey * expertHistKey ;
1382 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1383 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1384 if ( !expertOdata ) {
1385 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1387 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1388 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1389 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1390 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1391 listTaskQAD->Add(hExpertdata) ;
1396 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1397 if ( odata->IsA()->InheritsFrom("TH1") ) {
1398 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1399 TH1 * hdata = static_cast<TH1*>(odata) ;
1400 listTaskQAD->Add(hdata) ;
1405 Instance()->Put(listDetQAD, idr, &mdr) ;
1411 //_____________________________________________________________________________
1412 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1414 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1416 AliQAv1::Instance()->SetEventSpecie(es) ;
1419 //_____________________________________________________________________________
1420 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1422 // Set custom reconstruction parameters for a given detector
1423 // Single set of parameters for all the events
1424 GetQADataMaker(det)->SetRecoParam(par) ;
1427 //_____________________________________________________________________________
1428 void AliQAManager::SetWriteExpert()
1430 // enable the writing of QA expert data
1431 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1432 if (IsSelected(AliQAv1::GetDetName(iDet)))
1433 fQAWriteExpert[iDet] = kTRUE ;
1437 //_____________________________________________________________________________
1438 void AliQAManager::Destroy() {
1439 // delete AliQAManager instance and
1440 // all associated objects
1443 delete fgQAInstance ;
1444 fgQAInstance = NULL ;
1448 //_____________________________________________________________________________
1449 void AliQAManager::ShowQA() {
1450 // Show the result of the QA checking
1451 // for all detectors
1452 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1453 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;