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
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 if ( runNumber == -1)
768 runNumber = fRunNumber ;
769 Bool_t rv = MergeData(runNumber) ;
770 //rv *= MergeResults(runNumber) ; // not needed for the time being
774 //______________________________________________________________________
775 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
777 // merges files listed in a xml collection
778 // usage Merge(collection, outputFile))
779 // collection: is a xml collection
783 if ( strstr(collectionFile, ".xml") == 0 ) {
784 AliError("Input collection file must be an \".xml\" file\n") ;
789 TGrid::Connect("alien://");
793 // Open the file collection
794 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
796 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
797 TGridResult* result = collection->GetGridResult("", 0, 0);
800 const Char_t * turl ;
801 TFileMerger merger(kFALSE) ;
803 TString tempo(collectionFile) ;
805 tempo.ReplaceAll(".xml", subFile) ;
807 tempo.ReplaceAll(".xml", "_Merged.root") ;
808 outFile = tempo.Data() ;
810 merger.OutputFile(outFile) ;
812 while ( (turl = result->GetKey(index, "turl")) ) {
815 file = Form("%s#%s", turl, subFile) ;
817 file = Form("%s", turl) ;
819 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
820 merger.AddFile(file) ;
827 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
833 //_____________________________________________________________________________
834 void AliQAManager::MergeCustom() const
836 // Custom Merge of QA data from all detectors for all runs in one single file
837 // search all the run numbers
838 // search all the run numbers
839 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
841 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
844 TIter nextRun(&srunList) ;
845 TObjString * srun = NULL ;
846 Int_t loRun = 999999999 ;
848 while ( QAfile.Gets(QAfiles) ) {
849 Bool_t runExist = kFALSE ;
850 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
851 Int_t cuRun = srunNew.Atoi() ;
856 while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
857 if ( cuRun == (srun->String()).Atoi() ) {
864 srunList.Add(new TObjString(srunNew.Data()));
867 Int_t runNumber = 0 ;
868 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
869 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
870 // create the structure into the merged file
871 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
872 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
873 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
875 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
876 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
878 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
880 gDirectory->mkdir(AliQAv1::GetExpert()) ;
884 while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
885 runNumber = (srun->String()).Atoi() ;
886 hisRun->Fill(runNumber) ;
887 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
888 // search all QA files for runNumber in the current directory
889 Char_t * fileList[AliQAv1::kNDET] ;
891 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
892 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
894 fileList[index++] = file ;
897 AliError("No QA data file found\n") ;
900 for ( Int_t i = 0 ; i < index ; i++) {
901 TFile * inFile = TFile::Open(fileList[i]) ;
902 TList * listOfKeys =inFile->GetListOfKeys() ;
903 TIter nextkey(listOfKeys) ;
905 TString dirName("") ;
906 while ( (obj1 = nextkey()) ) {
907 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
908 if ( directoryDet ) {
909 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
910 dirName += Form("%s/", directoryDet->GetName() ) ;
912 TList * listOfTasks = directoryDet->GetListOfKeys() ;
913 TIter nextTask(listOfTasks) ;
915 while ( (obj2 = nextTask()) ) {
916 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
917 if ( directoryTask ) {
918 dirName += Form("%s", obj2->GetName()) ;
919 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
920 directoryTask->cd() ;
921 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
922 TIter nextEventSpecie(listOfEventSpecie) ;
924 while ( (obj3 = nextEventSpecie()) ) {
925 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
926 if ( directoryEventSpecie ) {
927 dirName += Form("/%s/", obj3->GetName()) ;
928 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
929 directoryEventSpecie->cd() ;
930 // histograms are here
931 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
932 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
933 TIter nextData(listOfData) ;
935 while ( (key = dynamic_cast<TKey *>(nextData())) ) {
936 TString className(key->GetClassName()) ;
937 if ( className.Contains("TH") || className.Contains("TProfile") ) {
938 TH1 * histIn = dynamic_cast<TH1*> (key->ReadObj()) ;
939 TH1 * histOu = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
940 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
941 mergedDirectory->cd() ;
945 histOu->Add(histIn) ;
946 histOu->Write(histOu->GetName(), kOverwrite) ;
949 else if ( className.Contains("TDirectoryFile") ) {
950 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
952 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
953 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
954 TIter nextExpertData(listOfExpertData) ;
956 while ( (keykey = dynamic_cast<TKey *>(nextExpertData())) ) {
957 TString classNameExpert(keykey->GetClassName()) ;
958 if (classNameExpert.Contains("TH")) {
959 TH1 * histInExpert = dynamic_cast<TH1*> (keykey->ReadObj()) ;
960 TH1 * histOuExpert = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
961 mergedDirectoryExpert->cd() ;
962 if ( ! histOuExpert ) {
963 histInExpert->Write() ;
965 histOuExpert->Add(histInExpert) ;
966 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
971 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
974 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
977 dirName.ReplaceAll(obj2->GetName(), "") ;
991 //_____________________________________________________________________________
992 Bool_t AliQAManager::MergeData(const Int_t runNumber) const
994 // Merge QA data from all detectors for a given run in one single file
997 TString outFileName = Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName()) ;
998 merger.OutputFile(outFileName.Data()) ;
999 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1000 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1002 merger.AddFile(file) ;
1008 //_____________________________________________________________________________
1009 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1011 // Merge the QA result from all the data chunks in a run
1012 // to be revised whwn it will be used (see MergeData)
1014 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1015 gROOT->ProcessLine(cmd.Data()) ;
1016 ifstream in("tempo.txt") ;
1017 const Int_t chunkMax = 100 ;
1018 TString fileList[chunkMax] ;
1023 in >> fileList[index] ;
1026 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1031 AliError("No QA Result File found") ;
1035 TFileMerger merger ;
1036 TString outFileName ;
1037 if (runNumber != -1)
1038 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1040 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1041 merger.OutputFile(outFileName.Data()) ;
1042 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1043 TString file = fileList[ifile] ;
1044 merger.AddFile(file) ;
1051 //_____________________________________________________________________________
1052 void AliQAManager::Reset(const Bool_t sameCycle)
1054 // Reset the default data members
1056 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1057 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1058 AliQADataMaker * qadm = GetQADataMaker(iDet);
1062 if (fRawReaderDelete) {
1067 fCycleSame = sameCycle ;
1071 fNumberOfEvents = 999999 ;
1074 //_____________________________________________________________________________
1075 AliQAManager * AliQAManager::QAManager(Char_t * mode, TMap *entryCache, Int_t run)
1077 // returns AliQAManager instance (singleton)
1079 if (!fgQAInstance) {
1080 if ( (strcmp(mode, "sim") != 0) && (strcmp(mode, "rec") != 0) )
1081 AliFatalClass("You must specify sim or rec") ;
1082 fgQAInstance = new AliQAManager(mode) ;
1084 fgQAInstance->Init();
1086 fgQAInstance->InitFromCache(entryCache,run);
1088 return fgQAInstance;
1091 //_____________________________________________________________________________
1092 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1094 //Runs all the QA data Maker for Raws only
1096 fCycleSame = sameCycle ;
1097 fRawReader = rawReader ;
1098 fDetectors = detectors ;
1099 fDetectorsW = detectors ;
1101 AliCDBManager* man = AliCDBManager::Instance() ;
1103 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1104 rawReader->NextEvent() ;
1105 man->SetRun(fRawReader->GetRunNumber()) ;
1106 rawReader->RewindEvents() ;
1110 if ( !InitQA(AliQAv1::kRAWS) )
1112 fRawReaderDelete = kFALSE ;
1114 DoIt(AliQAv1::kRAWS) ;
1115 return fDetectorsW ;
1118 //_____________________________________________________________________________
1119 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1121 //Runs all the QA data Maker for Raws only
1123 fCycleSame = sameCycle ;
1124 fDetectors = detectors ;
1125 fDetectorsW = detectors ;
1127 AliCDBManager* man = AliCDBManager::Instance() ;
1128 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1129 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1131 AliFatal("galice.root file not found in current directory") ;
1135 if ( ! rl->GetAliRun() ) {
1136 AliFatal("AliRun not found in galice.root") ;
1139 man->SetRun(rl->GetHeader()->GetRun());
1145 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1148 DoIt(AliQAv1::kRAWS) ;
1149 return fDetectorsW ;
1152 //_____________________________________________________________________________
1153 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1155 // Runs all the QA data Maker for every detector
1157 fCycleSame = sameCycle ;
1158 fDetectors = detectors ;
1159 fDetectorsW = detectors ;
1161 AliCDBManager* man = AliCDBManager::Instance() ;
1162 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1163 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1165 AliFatal("galice.root file not found in current directory") ;
1169 if ( ! rl->GetAliRun() ) {
1170 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1173 man->SetRun(rl->GetHeader()->GetRun()) ;
1177 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1178 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1179 if ( fTasks.Contains(Form("%d", task)) ) {
1181 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1183 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1188 if ( !InitQA(taskIndex, fileName) )
1192 return fDetectorsW ;
1195 //_____________________________________________________________________________
1196 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1198 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1201 AliCodeTimerAuto("") ;
1202 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1203 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1204 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1206 AliQADataMaker *qadm = GetQADataMaker(iDet);
1209 if ( qadm->IsCycleDone() ) {
1210 qadm->EndOfCycle() ;
1212 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1213 qadm->SetEventSpecie(fEventSpecie) ;
1214 if ( qadm->GetRecoParam() )
1215 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1216 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1217 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1218 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1223 //_____________________________________________________________________________
1224 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1226 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1228 AliCodeTimerAuto("") ;
1229 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1230 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1231 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1233 AliQADataMaker *qadm = GetQADataMaker(iDet);
1236 qadm->SetEventSpecie(fEventSpecie) ;
1237 if ( qadm->GetRecoParam() )
1238 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1239 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1240 if ( qadm->IsCycleDone() ) {
1241 qadm->EndOfCycle() ;
1243 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1244 qadm->Exec(AliQAv1::kESDS, esd) ;
1245 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1250 //_____________________________________________________________________________
1251 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1253 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1255 TString test(tree->GetName()) ;
1256 AliCodeTimerAuto("") ;
1257 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1258 if (IsSelected(AliQAv1::GetDetName(det))) {
1259 AliQADataMaker *qadm = GetQADataMaker(det);
1261 qadm->SetEventSpecie(fEventSpecie) ;
1262 if ( qadm->GetRecoParam() )
1263 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1264 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1265 if ( qadm->IsCycleDone() ) {
1266 qadm->EndOfCycle() ;
1268 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1269 if (test.Contains("TreeD")) {
1270 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1271 AliCodeTimerStop(Form("running Digits quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1272 } else if (test.Contains("TreeR")) {
1273 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1274 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1281 //_____________________________________________________________________________
1282 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1284 // take the locasl QA data merge into a single file and save in OCDB
1286 TString tmp(AliQAv1::GetQARefStorage()) ;
1287 if ( tmp.IsNull() ) {
1288 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1291 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1292 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1295 TString sdet(detectors) ;
1298 if ( sdet.Contains("ALL") ) {
1299 rv = Merge(runNumber) ;
1302 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1303 inputFile = TFile::Open(inputFileName.Data()) ;
1304 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1306 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1307 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1308 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1309 inputFile = TFile::Open(inputFileName.Data()) ;
1310 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1317 //_____________________________________________________________________________
1318 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1320 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1322 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1323 if ( ! IsDefaultStorageSet() ) {
1324 TString tmp( AliQAv1::GetQARefStorage() ) ;
1325 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1326 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1328 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1330 tmp1.Append("?user=alidaq") ;
1331 Instance()->SetDefaultStorage(tmp1.Data()) ;
1334 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1336 Instance()->SetRun(runNumber);
1338 AliCDBMetaData mdr ;
1339 mdr.SetResponsible("yves schutz");
1341 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1342 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1344 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1345 AliQAv1::SetQARefDataDirName(es) ;
1346 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1347 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1348 TList * listDetQAD = new TList() ;
1349 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1350 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1351 listDetQAD->SetName(listName) ;
1352 TList * taskList = detDir->GetListOfKeys() ;
1353 TIter nextTask(taskList) ;
1355 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
1356 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1357 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1358 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1359 TObjArray * listTaskQAD = new TObjArray(100) ;
1360 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1361 listDetQAD->Add(listTaskQAD) ;
1362 TList * histList = esDir->GetListOfKeys() ;
1363 TIter nextHist(histList) ;
1365 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1366 TObject * odata = esDir->Get(histKey->GetName()) ;
1368 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1370 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1371 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1372 TList * expertHistList = expertDir->GetListOfKeys() ;
1373 TIter nextExpertHist(expertHistList) ;
1374 TKey * expertHistKey ;
1375 while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) {
1376 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1377 if ( !expertOdata ) {
1378 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1380 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1381 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1382 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1383 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1384 listTaskQAD->Add(hExpertdata) ;
1389 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1390 if ( odata->IsA()->InheritsFrom("TH1") ) {
1391 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1392 TH1 * hdata = static_cast<TH1*>(odata) ;
1393 listTaskQAD->Add(hdata) ;
1398 Instance()->Put(listDetQAD, idr, &mdr) ;
1404 //_____________________________________________________________________________
1405 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1407 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1409 AliQAv1::Instance()->SetEventSpecie(es) ;
1412 //_____________________________________________________________________________
1413 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1415 // Set custom reconstruction parameters for a given detector
1416 // Single set of parameters for all the events
1417 GetQADataMaker(det)->SetRecoParam(par) ;
1420 //_____________________________________________________________________________
1421 void AliQAManager::SetWriteExpert()
1423 // enable the writing of QA expert data
1424 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1425 if (IsSelected(AliQAv1::GetDetName(iDet)))
1426 fQAWriteExpert[iDet] = kTRUE ;