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(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 ;
138 if (fMode.Contains("sim"))
139 fMode.ReplaceAll("s", "S") ;
140 else if (fMode.Contains("rec"))
141 fMode.ReplaceAll("r", "R") ;
144 //_____________________________________________________________________________
145 AliQAManager::AliQAManager(const AliQAManager & qas) :
147 fCurrentEvent(qas.fCurrentEvent),
149 fDetectors(qas.fDetectors),
150 fDetectorsW(qas.fDetectorsW),
153 fGAliceFileName(qas.fGAliceFileName),
154 fFirstEvent(qas.fFirstEvent),
155 fMaxEvents(qas.fMaxEvents),
157 fNumberOfEvents(qas.fNumberOfEvents),
159 fRunNumber(qas.fRunNumber),
161 fRawReaderDelete(kTRUE),
164 fEventSpecie(qas.fEventSpecie),
165 fPrintImage(qas.fPrintImage)
169 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
170 fLoader[iDet] = qas.fLoader[iDet] ;
171 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
172 fQACycles[iDet] = qas.fQACycles[iDet] ;
173 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
177 //_____________________________________________________________________________
178 AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
180 // assignment operator
181 this->~AliQAManager() ;
182 new(this) AliQAManager(qas) ;
186 //_____________________________________________________________________________
187 AliQAManager::~AliQAManager()
190 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
191 if (IsSelected(AliQAv1::GetDetName(iDet))) {
192 fLoader[iDet] = NULL;
193 if (fQADataMaker[iDet]) {
194 (fQADataMaker[iDet])->Finish() ;
195 delete fQADataMaker[iDet] ;
199 if (fRawReaderDelete) {
206 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()));
209 //_____________________________________________________________________________
210 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
212 // Runs all the QA data Maker for every detector
215 // Fill QA data in event loop
216 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
219 if ( iEvent%10 == 0 )
220 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
221 if ( taskIndex == AliQAv1::kRAWS ) {
222 if ( !fRawReader->NextEvent() )
224 } else if ( taskIndex == AliQAv1::kESDS ) {
225 if ( fESDTree->GetEntry(iEvent) == 0 )
228 if ( fRunLoader->GetEvent(iEvent) != 0 )
231 // loop over active loaders
232 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
233 if (IsSelected(AliQAv1::GetDetName(iDet))) {
234 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
235 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
236 if ( qadm->IsCycleDone() ) {
237 qadm->EndOfCycle(taskIndex) ;
239 TTree * data = NULL ;
240 AliLoader* loader = GetLoader(qadm->GetUniqueID());
242 case AliQAv1::kNULLTASKINDEX :
244 case AliQAv1::kRAWS :
245 qadm->Exec(taskIndex, fRawReader) ;
247 case AliQAv1::kHITS :
250 data = loader->TreeH() ;
252 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
256 qadm->Exec(taskIndex, data) ;
258 case AliQAv1::kSDIGITS :
260 loader->LoadSDigits() ;
261 data = loader->TreeS() ;
263 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
267 qadm->Exec(taskIndex, data) ;
269 case AliQAv1::kDIGITS :
271 loader->LoadDigits() ;
272 data = loader->TreeD() ;
274 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
278 case AliQAv1::kDIGITSR :
280 loader->LoadDigits() ;
281 data = loader->TreeD() ;
283 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
287 qadm->Exec(taskIndex, data) ;
289 case AliQAv1::kRECPOINTS :
291 loader->LoadRecPoints() ;
292 data = loader->TreeR() ;
294 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ;
298 qadm->Exec(taskIndex, data) ;
300 case AliQAv1::kTRACKSEGMENTS :
302 case AliQAv1::kRECPARTICLES :
304 case AliQAv1::kESDS :
305 qadm->Exec(taskIndex, fESD) ;
307 case AliQAv1::kNTASKINDEX :
314 // Save QA data for all detectors
315 rv = Finish(taskIndex) ;
317 if ( taskIndex == AliQAv1::kRAWS )
318 fRawReader->RewindEvents() ;
323 //_____________________________________________________________________________
324 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
326 // write output to file for all detectors
327 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
328 if (IsSelected(AliQAv1::GetDetName(iDet))) {
329 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
331 qadm->EndOfCycle(taskIndex) ;
337 //_____________________________________________________________________________
338 TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const
340 // Retrieve the list of QA data for a given detector and a given task
341 TObjArray * rv = NULL ;
342 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
343 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
346 if ( ! IsDefaultStorageSet() ) {
347 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
350 Instance()->SetDefaultStorage(tmp.Data()) ;
351 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
353 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
354 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
355 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
356 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
358 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
362 //_____________________________________________________________________________
363 TCanvas ** AliQAManager::GetImage(Char_t * detName)
365 // retrieves QA Image for the given detector
366 TCanvas ** rv = NULL ;
367 Int_t detIndex = AliQAv1::GetDetIndex(detName) ;
368 AliQADataMaker * qadm = GetQADataMaker(detIndex) ;
369 rv = qadm->GetImage() ;
373 //_____________________________________________________________________________
374 AliLoader * AliQAManager::GetLoader(Int_t iDet)
376 // get the loader for a detector
378 if ( !fRunLoader || iDet == AliQAv1::kCORR)
381 TString detName = AliQAv1::GetDetName(iDet) ;
382 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
384 return fLoader[iDet] ;
386 // load the QA data maker object
387 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
388 TString loaderName = "Ali" + detName + "Loader" ;
390 AliLoader * loader = NULL ;
391 // first check if a plugin is defined for the quality assurance data maker
392 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
393 // if not, add a plugin for it
394 if (!pluginHandler) {
395 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
396 TString libs = gSystem->GetLibraries() ;
397 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
398 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
400 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
402 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
404 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
405 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
408 fLoader[iDet] = loader ;
412 //_____________________________________________________________________________
413 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
415 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
416 Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
417 TFile * tagFile = TFile::Open(fileName) ;
419 AliError(Form("File %s not found", fileName)) ;
422 TTree * tagTree = dynamic_cast<TTree *>(tagFile->Get("T")) ;
424 AliError(Form("Tree T not found in %s", fileName)) ;
428 AliRunTag * tag = new AliRunTag ;
429 tagTree->SetBranchAddress("AliTAG", &tag) ;
430 tagTree->GetEntry(evt) ;
431 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
436 //_____________________________________________________________________________
437 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
439 // get the quality assurance data maker for a detector
441 if (fQADataMaker[iDet]) {
442 fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ;
443 if ( fQADataMaker[iDet]->GetRecoParam() )
444 if ( AliRecoParam::Convert(fQADataMaker[iDet]->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
445 fQADataMaker[iDet]->SetEventSpecie(fQADataMaker[iDet]->GetRecoParam()->GetEventSpecie()) ;
446 return fQADataMaker[iDet] ;
449 AliQADataMaker * qadm = NULL ;
451 if (iDet == AliQAv1::kGLOBAL) { //Global QA
452 qadm = new AliGlobalQADataMaker();
453 qadm->SetName(AliQAv1::GetDetName(iDet));
454 qadm->SetUniqueID(iDet);
455 fQADataMaker[iDet] = qadm;
456 qadm->SetEventSpecie(fEventSpecie) ;
457 if ( qadm->GetRecoParam() )
458 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
459 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
463 if (iDet == AliQAv1::kCORR) { //the data maker for correlations among detectors
464 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
465 qadm->SetName(AliQAv1::GetDetName(iDet));
466 qadm->SetUniqueID(iDet);
467 fQADataMaker[iDet] = qadm;
468 qadm->SetEventSpecie(fEventSpecie) ;
469 if ( qadm->GetRecoParam() )
470 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
471 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
475 // load the QA data maker object
476 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
477 TString detName = AliQAv1::GetDetName(iDet) ;
478 TString qadmName = "Ali" + detName + "QADataMaker" + fMode ;
480 // first check if a plugin is defined for the quality assurance data maker
481 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
482 // if not, add a plugin for it
483 if (!pluginHandler) {
484 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
485 TString libs = gSystem->GetLibraries() ;
486 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
487 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
489 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
491 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
493 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
494 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
497 qadm->SetName(AliQAv1::GetDetName(iDet));
498 qadm->SetUniqueID(iDet);
499 fQADataMaker[iDet] = qadm ;
500 qadm->SetEventSpecie(fEventSpecie) ;
501 if ( qadm->GetRecoParam() )
502 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
503 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
509 //_____________________________________________________________________________
510 void AliQAManager::EndOfCycle(TObjArray * detArray)
512 // End of cycle QADataMakers
516 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
518 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
519 if (IsSelected(AliQAv1::GetDetName(iDet))) {
520 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
523 // skip non active detectors
525 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
526 if (!det || !det->IsActive())
529 qadm->SetPrintImage(fPrintImage) ;
530 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
531 if ( fTasks.Contains(Form("%d", taskIndex)) )
532 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
539 //_____________________________________________________________________________
540 void AliQAManager::EndOfCycle(TString detectors)
542 // End of cycle QADataMakers
546 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
548 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
549 if (IsSelected(AliQAv1::GetDetName(iDet))) {
550 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
553 // skip non active detectors
554 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
556 qadm->SetPrintImage(fPrintImage) ;
557 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
558 if ( fTasks.Contains(Form("%d", taskIndex)) )
559 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
566 //_____________________________________________________________________________
567 void AliQAManager::Increment()
569 // Increments the cycle counter for all QA Data Makers
570 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
571 if (IsSelected(AliQAv1::GetDetName(iDet))) {
572 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
579 //_____________________________________________________________________________
580 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
582 // Initialize the event source and QA data makers
584 fTasks += Form("%d", taskIndex) ;
586 if (taskIndex == AliQAv1::kRAWS) {
588 fRawReader = AliRawReader::Create(input);
592 fRawReaderDelete = kTRUE ;
593 fRawReader->NextEvent() ;
594 fRunNumber = fRawReader->GetRunNumber() ;
596 fRawReader->RewindEvents();
597 fNumberOfEvents = 999999 ;
598 if ( fMaxEvents < 0 )
599 fMaxEvents = fNumberOfEvents ;
600 } else if (taskIndex == AliQAv1::kESDS) {
601 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
602 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
603 TFile * esdFile = TFile::Open("AliESDs.root") ;
604 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
606 AliError("esdTree not found") ;
609 fESD = new AliESDEvent() ;
610 fESD->ReadFromTree(fESDTree) ;
611 fESDTree->GetEntry(0) ;
612 fRunNumber = fESD->GetRunNumber() ;
613 fNumberOfEvents = fESDTree->GetEntries() ;
614 if ( fMaxEvents < 0 )
615 fMaxEvents = fNumberOfEvents ;
618 AliError("AliESDs.root not found") ;
622 if ( !InitRunLoader() ) {
623 AliWarning("No Run Loader not found") ;
625 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
626 if ( fMaxEvents < 0 )
627 fMaxEvents = fNumberOfEvents ;
632 TObjArray* detArray = NULL ;
633 if (fRunLoader) // check if RunLoader exists
634 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
635 detArray = fRunLoader->GetAliRun()->Detectors() ;
636 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
639 // Initialize all QA data makers for all detectors
640 fRunNumber = AliCDBManager::Instance()->GetRun() ;
641 if ( ! AliGeomManager::GetGeometry() )
642 AliGeomManager::LoadGeometry() ;
644 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
647 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
652 //_____________________________________________________________________________
653 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
655 // Initializes The QADataMaker for all active detectors and for all active tasks
657 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
658 if (IsSelected(AliQAv1::GetDetName(iDet))) {
659 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
661 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
662 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
664 if (fQAWriteExpert[iDet])
665 qadm->SetWriteExpert() ;
666 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
667 // skip non active detectors
669 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
670 if (!det || !det->IsActive())
673 // Set default reco params
674 Bool_t sameCycle = kFALSE ;
675 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
676 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
677 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
678 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
688 //_____________________________________________________________________________
689 Bool_t AliQAManager::InitRunLoader()
691 // get or create the run loader
695 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
696 // load all base libraries to get the loader classes
697 TString libs = gSystem->GetLibraries() ;
698 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
699 if (!IsSelected(AliQAv1::GetDetName(iDet)))
701 TString detName = AliQAv1::GetDetName(iDet) ;
702 if (detName == "HLT")
704 if (libs.Contains("lib" + detName + "base.so"))
706 gSystem->Load("lib" + detName + "base.so");
708 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
710 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
713 fRunLoader->CdGAFile();
714 if (fRunLoader->LoadgAlice() == 0) {
715 gAlice = fRunLoader->GetAliRun();
719 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
723 } else { // galice.root does not exist
724 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
730 fRunLoader->LoadHeader();
731 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
736 //_____________________________________________________________________________
737 Bool_t AliQAManager::IsSelected(const Char_t * det)
739 // check whether detName is contained in detectors
740 // if yes, it is removed from detectors
743 const TString detName(det) ;
744 // always activates Correlation
745 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
748 // check if all detectors are selected
749 if (fDetectors.Contains("ALL")) {
752 } else if ((fDetectors.CompareTo(detName) == 0) ||
753 fDetectors.BeginsWith(detName+" ") ||
754 fDetectors.EndsWith(" "+detName) ||
755 fDetectors.Contains(" "+detName+" ")) {
762 //_____________________________________________________________________________
763 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
765 // Merge data from all detectors from a given run in one single file
766 // Merge the QA results from all the data chunks in one run
767 // The 'fileName' is name of the output file with merged QA data
768 if ( runNumber == -1)
769 runNumber = fRunNumber ;
770 Bool_t rv = MergeData(runNumber,fileName) ;
771 //rv *= MergeResults(runNumber) ; // not needed for the time being
775 //______________________________________________________________________
776 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
778 // merges files listed in a xml collection
779 // usage Merge(collection, outputFile))
780 // collection: is a xml collection
784 if ( strstr(collectionFile, ".xml") == 0 ) {
785 AliError("Input collection file must be an \".xml\" file\n") ;
790 TGrid::Connect("alien://");
794 // Open the file collection
795 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
797 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
798 TGridResult* result = collection->GetGridResult("", 0, 0);
801 const Char_t * turl ;
802 TFileMerger merger(kFALSE) ;
804 TString tempo(collectionFile) ;
806 tempo.ReplaceAll(".xml", subFile) ;
808 tempo.ReplaceAll(".xml", "_Merged.root") ;
809 outFile = tempo.Data() ;
811 merger.OutputFile(outFile) ;
813 while ( (turl = result->GetKey(index, "turl")) ) {
816 file = Form("%s#%s", turl, subFile) ;
818 file = Form("%s", turl) ;
820 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
821 merger.AddFile(file) ;
828 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
834 //_____________________________________________________________________________
835 void AliQAManager::MergeCustom() const
837 // Custom Merge of QA data from all detectors for all runs in one single file
838 // search all the run numbers
839 // search all the run numbers
840 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
842 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
845 TIter nextRun(&srunList) ;
846 TObjString * srun = NULL ;
847 Int_t loRun = 999999999 ;
849 while ( QAfile.Gets(QAfiles) ) {
850 Bool_t runExist = kFALSE ;
851 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
852 Int_t cuRun = srunNew.Atoi() ;
857 while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
858 if ( cuRun == (srun->String()).Atoi() ) {
865 srunList.Add(new TObjString(srunNew.Data()));
868 Int_t runNumber = 0 ;
869 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
870 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
871 // create the structure into the merged file
872 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
873 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
874 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
876 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
877 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
879 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
881 gDirectory->mkdir(AliQAv1::GetExpert()) ;
885 while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
886 runNumber = (srun->String()).Atoi() ;
887 hisRun->Fill(runNumber) ;
888 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
889 // search all QA files for runNumber in the current directory
890 Char_t * fileList[AliQAv1::kNDET] ;
892 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
893 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
895 fileList[index++] = file ;
898 AliError("No QA data file found\n") ;
901 for ( Int_t i = 0 ; i < index ; i++) {
902 TFile * inFile = TFile::Open(fileList[i]) ;
903 TList * listOfKeys =inFile->GetListOfKeys() ;
904 TIter nextkey(listOfKeys) ;
906 TString dirName("") ;
907 while ( (obj1 = nextkey()) ) {
908 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
909 if ( directoryDet ) {
910 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
911 dirName += Form("%s/", directoryDet->GetName() ) ;
913 TList * listOfTasks = directoryDet->GetListOfKeys() ;
914 TIter nextTask(listOfTasks) ;
916 while ( (obj2 = nextTask()) ) {
917 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
918 if ( directoryTask ) {
919 dirName += Form("%s", obj2->GetName()) ;
920 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
921 directoryTask->cd() ;
922 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
923 TIter nextEventSpecie(listOfEventSpecie) ;
925 while ( (obj3 = nextEventSpecie()) ) {
926 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
927 if ( directoryEventSpecie ) {
928 dirName += Form("/%s/", obj3->GetName()) ;
929 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
930 directoryEventSpecie->cd() ;
931 // histograms are here
932 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
933 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
934 TIter nextData(listOfData) ;
936 while ( (key = dynamic_cast<TKey *>(nextData())) ) {
937 TString className(key->GetClassName()) ;
938 if ( className.Contains("TH") || className.Contains("TProfile") ) {
939 TH1 * histIn = dynamic_cast<TH1*> (key->ReadObj()) ;
940 TH1 * histOu = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
941 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
942 mergedDirectory->cd() ;
946 histOu->Add(histIn) ;
947 histOu->Write(histOu->GetName(), kOverwrite) ;
950 else if ( className.Contains("TDirectoryFile") ) {
951 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
953 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
954 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
955 TIter nextExpertData(listOfExpertData) ;
957 while ( (keykey = dynamic_cast<TKey *>(nextExpertData())) ) {
958 TString classNameExpert(keykey->GetClassName()) ;
959 if (classNameExpert.Contains("TH")) {
960 TH1 * histInExpert = dynamic_cast<TH1*> (keykey->ReadObj()) ;
961 TH1 * histOuExpert = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
962 mergedDirectoryExpert->cd() ;
963 if ( ! histOuExpert ) {
964 histInExpert->Write() ;
966 histOuExpert->Add(histInExpert) ;
967 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
972 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
975 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
978 dirName.ReplaceAll(obj2->GetName(), "") ;
992 //_____________________________________________________________________________
993 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
995 // Merge QA data from all detectors for a given run in one single file
997 TFileMerger merger(kFALSE) ;
998 TString outFileName = fileName;
999 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1000 merger.OutputFile(outFileName.Data()) ;
1001 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1002 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1004 merger.AddFile(file) ;
1010 //_____________________________________________________________________________
1011 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1013 // Merge the QA result from all the data chunks in a run
1014 // to be revised whwn it will be used (see MergeData)
1016 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1017 gROOT->ProcessLine(cmd.Data()) ;
1018 ifstream in("tempo.txt") ;
1019 const Int_t chunkMax = 100 ;
1020 TString fileList[chunkMax] ;
1025 in >> fileList[index] ;
1028 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1033 AliError("No QA Result File found") ;
1037 TFileMerger merger ;
1038 TString outFileName ;
1039 if (runNumber != -1)
1040 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1042 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1043 merger.OutputFile(outFileName.Data()) ;
1044 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1045 TString file = fileList[ifile] ;
1046 merger.AddFile(file) ;
1053 //_____________________________________________________________________________
1054 void AliQAManager::Reset(const Bool_t sameCycle)
1056 // Reset the default data members
1058 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1059 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1060 AliQADataMaker * qadm = GetQADataMaker(iDet);
1064 if (fRawReaderDelete) {
1069 fCycleSame = sameCycle ;
1073 fNumberOfEvents = 999999 ;
1076 //_____________________________________________________________________________
1077 AliQAManager * AliQAManager::QAManager(Char_t * mode, TMap *entryCache, Int_t run)
1079 // returns AliQAManager instance (singleton)
1081 if (!fgQAInstance) {
1082 if ( (strcmp(mode, "sim") != 0) && (strcmp(mode, "rec") != 0) )
1083 AliFatalClass("You must specify sim or rec") ;
1084 fgQAInstance = new AliQAManager(mode) ;
1086 fgQAInstance->Init();
1088 fgQAInstance->InitFromCache(entryCache,run);
1090 return fgQAInstance;
1093 //_____________________________________________________________________________
1094 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1096 //Runs all the QA data Maker for Raws only
1098 fCycleSame = sameCycle ;
1099 fRawReader = rawReader ;
1100 fDetectors = detectors ;
1101 fDetectorsW = detectors ;
1103 AliCDBManager* man = AliCDBManager::Instance() ;
1105 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1106 rawReader->NextEvent() ;
1107 man->SetRun(fRawReader->GetRunNumber()) ;
1108 rawReader->RewindEvents() ;
1112 if ( !InitQA(AliQAv1::kRAWS) )
1114 fRawReaderDelete = kFALSE ;
1116 DoIt(AliQAv1::kRAWS) ;
1117 return fDetectorsW ;
1120 //_____________________________________________________________________________
1121 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1123 //Runs all the QA data Maker for Raws only
1125 fCycleSame = sameCycle ;
1126 fDetectors = detectors ;
1127 fDetectorsW = detectors ;
1129 AliCDBManager* man = AliCDBManager::Instance() ;
1130 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1131 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1133 AliFatal("galice.root file not found in current directory") ;
1137 if ( ! rl->GetAliRun() ) {
1138 AliFatal("AliRun not found in galice.root") ;
1141 man->SetRun(rl->GetHeader()->GetRun());
1147 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1150 DoIt(AliQAv1::kRAWS) ;
1151 return fDetectorsW ;
1154 //_____________________________________________________________________________
1155 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1157 // Runs all the QA data Maker for every detector
1159 fCycleSame = sameCycle ;
1160 fDetectors = detectors ;
1161 fDetectorsW = detectors ;
1163 AliCDBManager* man = AliCDBManager::Instance() ;
1164 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1165 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1167 AliFatal("galice.root file not found in current directory") ;
1171 if ( ! rl->GetAliRun() ) {
1172 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1175 man->SetRun(rl->GetHeader()->GetRun()) ;
1179 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1180 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1181 if ( fTasks.Contains(Form("%d", task)) ) {
1183 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1185 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1190 if ( !InitQA(taskIndex, fileName) )
1194 return fDetectorsW ;
1197 //_____________________________________________________________________________
1198 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1200 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1203 AliCodeTimerAuto("") ;
1204 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1205 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1206 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1208 AliQADataMaker *qadm = GetQADataMaker(iDet);
1211 if ( qadm->IsCycleDone() ) {
1212 qadm->EndOfCycle() ;
1214 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1215 qadm->SetEventSpecie(fEventSpecie) ;
1216 if ( qadm->GetRecoParam() )
1217 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1218 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1219 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1220 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1225 //_____________________________________________________________________________
1226 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1228 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1230 AliCodeTimerAuto("") ;
1231 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1232 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1233 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1235 AliQADataMaker *qadm = GetQADataMaker(iDet);
1238 qadm->SetEventSpecie(fEventSpecie) ;
1239 if ( qadm->GetRecoParam() )
1240 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1241 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1242 if ( qadm->IsCycleDone() ) {
1243 qadm->EndOfCycle() ;
1245 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1246 qadm->Exec(AliQAv1::kESDS, esd) ;
1247 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1252 //_____________________________________________________________________________
1253 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1255 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1257 TString test(tree->GetName()) ;
1258 AliCodeTimerAuto("") ;
1259 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1260 if (IsSelected(AliQAv1::GetDetName(det))) {
1261 AliQADataMaker *qadm = GetQADataMaker(det);
1263 qadm->SetEventSpecie(fEventSpecie) ;
1264 if ( qadm->GetRecoParam() )
1265 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1266 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1267 if ( qadm->IsCycleDone() ) {
1268 qadm->EndOfCycle() ;
1270 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1271 if (test.Contains("TreeD")) {
1272 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1273 AliCodeTimerStop(Form("running Digits quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1274 } else if (test.Contains("TreeR")) {
1275 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1276 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1283 //_____________________________________________________________________________
1284 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1286 // take the locasl QA data merge into a single file and save in OCDB
1288 TString tmp(AliQAv1::GetQARefStorage()) ;
1289 if ( tmp.IsNull() ) {
1290 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1293 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1294 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1297 TString sdet(detectors) ;
1300 if ( sdet.Contains("ALL") ) {
1301 rv = Merge(runNumber) ;
1304 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1305 inputFile = TFile::Open(inputFileName.Data()) ;
1306 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1308 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1309 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1310 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1311 inputFile = TFile::Open(inputFileName.Data()) ;
1312 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1319 //_____________________________________________________________________________
1320 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1322 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1324 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1325 if ( ! IsDefaultStorageSet() ) {
1326 TString tmp( AliQAv1::GetQARefStorage() ) ;
1327 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1328 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1330 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1332 tmp1.Append("?user=alidaq") ;
1333 Instance()->SetDefaultStorage(tmp1.Data()) ;
1336 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1338 Instance()->SetRun(runNumber);
1340 AliCDBMetaData mdr ;
1341 mdr.SetResponsible("yves schutz");
1343 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1344 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1346 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1347 AliQAv1::SetQARefDataDirName(es) ;
1348 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1349 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1350 TList * listDetQAD = new TList() ;
1351 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1352 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1353 listDetQAD->SetName(listName) ;
1354 TList * taskList = detDir->GetListOfKeys() ;
1355 TIter nextTask(taskList) ;
1357 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
1358 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1359 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1360 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1361 TObjArray * listTaskQAD = new TObjArray(100) ;
1362 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1363 listDetQAD->Add(listTaskQAD) ;
1364 TList * histList = esDir->GetListOfKeys() ;
1365 TIter nextHist(histList) ;
1367 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1368 TObject * odata = esDir->Get(histKey->GetName()) ;
1370 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1372 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1373 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1374 TList * expertHistList = expertDir->GetListOfKeys() ;
1375 TIter nextExpertHist(expertHistList) ;
1376 TKey * expertHistKey ;
1377 while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) {
1378 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1379 if ( !expertOdata ) {
1380 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1382 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1383 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1384 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1385 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1386 listTaskQAD->Add(hExpertdata) ;
1391 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1392 if ( odata->IsA()->InheritsFrom("TH1") ) {
1393 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1394 TH1 * hdata = static_cast<TH1*>(odata) ;
1395 listTaskQAD->Add(hdata) ;
1400 Instance()->Put(listDetQAD, idr, &mdr) ;
1406 //_____________________________________________________________________________
1407 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1409 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1411 AliQAv1::Instance()->SetEventSpecie(es) ;
1414 //_____________________________________________________________________________
1415 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1417 // Set custom reconstruction parameters for a given detector
1418 // Single set of parameters for all the events
1419 GetQADataMaker(det)->SetRecoParam(par) ;
1422 //_____________________________________________________________________________
1423 void AliQAManager::SetWriteExpert()
1425 // enable the writing of QA expert data
1426 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1427 if (IsSelected(AliQAv1::GetDetName(iDet)))
1428 fQAWriteExpert[iDet] = kTRUE ;