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>
42 #include <TStopwatch.h>
44 #include "AliCDBManager.h"
45 #include "AliCDBEntry.h"
47 #include "AliCDBMetaData.h"
48 #include "AliCodeTimer.h"
49 #include "AliCorrQADataMakerRec.h"
50 #include "AliDetectorRecoParam.h"
51 #include "AliESDEvent.h"
52 #include "AliGeomManager.h"
53 #include "AliGlobalQADataMaker.h"
54 #include "AliHeader.h"
56 #include "AliModule.h"
58 #include "AliQAChecker.h"
59 #include "AliQACheckerBase.h"
60 #include "AliQADataMakerRec.h"
61 #include "AliQADataMakerSim.h"
62 #include "AliQAManager.h"
63 #include "AliRawReaderDate.h"
64 #include "AliRawReaderFile.h"
65 #include "AliRawReaderRoot.h"
67 #include "AliRunLoader.h"
68 #include "AliRunTag.h"
70 ClassImp(AliQAManager)
71 AliQAManager* AliQAManager::fgQAInstance = 0x0;
73 //_____________________________________________________________________________
74 AliQAManager::AliQAManager() :
86 fNumberOfEvents(999999),
90 fRawReaderDelete(kTRUE),
93 fEventSpecie(AliRecoParam::kDefault),
98 fMaxEvents = fNumberOfEvents ;
99 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
100 if (IsSelected(AliQAv1::GetDetName(iDet))) {
101 fLoader[iDet] = NULL ;
102 fQADataMaker[iDet] = NULL ;
103 fQACycles[iDet] = 999999 ;
109 //_____________________________________________________________________________
110 AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
118 fGAliceFileName(gAliceFilename),
121 fMode(AliQAv1::GetModeName(mode)),
122 fNumberOfEvents(999999),
126 fRawReaderDelete(kTRUE),
129 fEventSpecie(AliRecoParam::kDefault),
134 fMaxEvents = fNumberOfEvents ;
135 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
136 if (IsSelected(AliQAv1::GetDetName(iDet))) {
137 fLoader[iDet] = NULL ;
138 fQADataMaker[iDet] = NULL ;
139 fQACycles[iDet] = 999999 ;
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),
167 fSaveData(qas.fSaveData)
171 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
172 fLoader[iDet] = qas.fLoader[iDet] ;
173 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
174 fQACycles[iDet] = qas.fQACycles[iDet] ;
175 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
179 //_____________________________________________________________________________
180 AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
182 // assignment operator
183 this->~AliQAManager() ;
184 new(this) AliQAManager(qas) ;
188 //_____________________________________________________________________________
189 AliQAManager::~AliQAManager()
192 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
193 if (IsSelected(AliQAv1::GetDetName(iDet))) {
194 fLoader[iDet] = NULL;
195 if (fQADataMaker[iDet]) {
196 (fQADataMaker[iDet])->Finish() ;
197 delete fQADataMaker[iDet] ;
201 if (fRawReaderDelete) {
208 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps");
211 //_____________________________________________________________________________
212 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
214 // Runs all the QA data Maker for every detector
217 // Fill QA data in event loop
218 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
221 if ( iEvent%10 == 0 )
222 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
223 if ( taskIndex == AliQAv1::kRAWS ) {
224 if ( !fRawReader->NextEvent() )
226 } else if ( taskIndex == AliQAv1::kESDS ) {
227 if ( fESDTree->GetEntry(iEvent) == 0 )
230 if ( fRunLoader->GetEvent(iEvent) != 0 )
233 // loop over active loaders
234 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
235 if (IsSelected(AliQAv1::GetDetName(iDet))) {
236 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
237 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
238 if ( qadm->IsCycleDone() ) {
239 qadm->EndOfCycle(taskIndex) ;
241 TTree * data = NULL ;
242 AliLoader* loader = GetLoader(qadm->GetUniqueID());
244 case AliQAv1::kNULLTASKINDEX :
246 case AliQAv1::kRAWS :
247 qadm->Exec(taskIndex, fRawReader) ;
249 case AliQAv1::kHITS :
252 data = loader->TreeH() ;
254 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
257 qadm->Exec(taskIndex, data) ;
260 case AliQAv1::kSDIGITS :
263 TString fileName(Form("%s.SDigits.root", AliQAv1::GetDetName(iDet))) ;
264 if (gSystem->FindFile("./", fileName)) {
266 loader->LoadSDigits() ;
267 data = loader->TreeS() ;
269 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
272 qadm->Exec(taskIndex, data) ;
277 case AliQAv1::kDIGITS :
279 loader->LoadDigits() ;
280 data = loader->TreeD() ;
282 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
285 qadm->Exec(taskIndex, data) ;
288 case AliQAv1::kDIGITSR :
290 loader->LoadDigits() ;
291 data = loader->TreeD() ;
293 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
296 qadm->Exec(taskIndex, data) ;
299 case AliQAv1::kRECPOINTS :
301 loader->LoadRecPoints() ;
302 data = loader->TreeR() ;
304 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ;
307 qadm->Exec(taskIndex, data) ;
310 case AliQAv1::kTRACKSEGMENTS :
312 case AliQAv1::kRECPARTICLES :
314 case AliQAv1::kESDS :
315 qadm->Exec(taskIndex, fESD) ;
317 case AliQAv1::kNTASKINDEX :
322 Increment(taskIndex) ;
324 // Save QA data for all detectors
326 rv = Finish(taskIndex) ;
328 if ( taskIndex == AliQAv1::kRAWS )
329 fRawReader->RewindEvents() ;
334 //_____________________________________________________________________________
335 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
337 // write output to file for all detectors
339 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
341 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
342 if (IsSelected(AliQAv1::GetDetName(iDet))) {
343 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
345 qadm->EndOfCycle(taskIndex) ;
351 //_____________________________________________________________________________
352 TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const
354 // Retrieve the list of QA data for a given detector and a given task
355 TObjArray * rv = NULL ;
356 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
357 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
360 if ( ! IsDefaultStorageSet() ) {
361 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
364 Instance()->SetDefaultStorage(tmp.Data()) ;
365 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
367 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
368 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
369 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
370 TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ;
372 rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
376 //_____________________________________________________________________________
377 TCanvas ** AliQAManager::GetImage(Char_t * detName)
379 // retrieves QA Image for the given detector
380 TCanvas ** rv = NULL ;
381 Int_t detIndex = AliQAv1::GetDetIndex(detName) ;
382 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
383 rv = qac->GetImage() ;
387 //_____________________________________________________________________________
388 AliLoader * AliQAManager::GetLoader(Int_t iDet)
390 // get the loader for a detector
392 if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL )
395 TString detName = AliQAv1::GetDetName(iDet) ;
396 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
398 return fLoader[iDet] ;
400 // load the QA data maker object
401 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
402 TString loaderName = "Ali" + detName + "Loader" ;
404 AliLoader * loader = NULL ;
405 // first check if a plugin is defined for the quality assurance data maker
406 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
407 // if not, add a plugin for it
408 if (!pluginHandler) {
409 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
410 TString libs = gSystem->GetLibraries() ;
411 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
412 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
414 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
416 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
418 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
419 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
422 fLoader[iDet] = loader ;
426 //_____________________________________________________________________________
427 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
429 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
430 Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
431 TFile * tagFile = TFile::Open(fileName) ;
433 AliError(Form("File %s not found", fileName)) ;
436 TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ;
438 AliError(Form("Tree T not found in %s", fileName)) ;
442 AliRunTag * tag = new AliRunTag ;
443 tagTree->SetBranchAddress("AliTAG", &tag) ;
444 tagTree->GetEntry(evt) ;
445 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
450 //_____________________________________________________________________________
451 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
453 // get the quality assurance data maker for a detector
455 AliQADataMaker * qadm = fQADataMaker[iDet] ;
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::kGLOBAL) { //Global QA
466 qadm = new AliGlobalQADataMaker();
467 qadm->SetName(AliQAv1::GetDetName(iDet));
468 qadm->SetUniqueID(iDet);
469 fQADataMaker[iDet] = qadm;
470 qadm->SetEventSpecie(fEventSpecie) ;
471 if ( qadm->GetRecoParam() )
472 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
473 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
475 } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
476 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
477 qadm->SetName(AliQAv1::GetDetName(iDet));
478 qadm->SetUniqueID(iDet);
479 fQADataMaker[iDet] = qadm;
480 qadm->SetEventSpecie(fEventSpecie) ;
481 if ( qadm->GetRecoParam() )
482 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
483 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
485 } else if ( iDet < AliQAv1::kGLOBAL ) {
487 // load the QA data maker object
488 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
489 TString detName = AliQAv1::GetDetName(iDet) ;
490 TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
492 // first check if a plugin is defined for the quality assurance data maker
493 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
494 // if not, add a plugin for it
495 if (!pluginHandler) {
496 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
497 TString libs = gSystem->GetLibraries() ;
498 TString temp(GetMode()) ;
500 if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
501 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
503 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
505 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
507 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
508 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
511 qadm->SetName(AliQAv1::GetDetName(iDet));
512 qadm->SetUniqueID(iDet);
513 fQADataMaker[iDet] = qadm ;
514 qadm->SetEventSpecie(fEventSpecie) ;
515 if ( qadm->GetRecoParam() )
516 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
517 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
523 //_____________________________________________________________________________
524 void AliQAManager::EndOfCycle(TObjArray * detArray)
526 // End of cycle QADataMakers
528 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
531 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
533 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
534 if (IsSelected(AliQAv1::GetDetName(iDet))) {
535 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
536 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
539 // skip non active detectors
541 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
542 if (!det || !det->IsActive())
546 qac->SetPrintImage(fPrintImage) ;
549 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
550 if ( fTasks.Contains(Form("%d", taskIndex)) )
551 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
559 //_____________________________________________________________________________
560 void AliQAManager::EndOfCycle(TString detectors)
562 // End of cycle QADataMakers
564 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
567 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
569 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
570 if (IsSelected(AliQAv1::GetDetName(iDet))) {
571 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
572 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
575 // skip non active detectors
576 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
579 qac->SetPrintImage(fPrintImage) ;
581 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
582 if ( fTasks.Contains(Form("%d", taskIndex)) )
583 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
591 //_____________________________________________________________________________
592 void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
594 // Increments the cycle counter for all QA Data Makers
595 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
596 if (currentTask == taskIndex)
599 currentTask = taskIndex ;
600 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
601 if (IsSelected(AliQAv1::GetDetName(iDet))) {
602 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
609 //_____________________________________________________________________________
610 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
612 // Initialize the event source and QA data makers
614 fTasks += Form("%d", taskIndex) ;
616 if (taskIndex == AliQAv1::kRAWS) {
618 fRawReader = AliRawReader::Create(input);
622 fRawReaderDelete = kTRUE ;
623 fRawReader->NextEvent() ;
624 fRunNumber = fRawReader->GetRunNumber() ;
626 fRawReader->RewindEvents();
627 fNumberOfEvents = 999999 ;
628 if ( fMaxEvents < 0 )
629 fMaxEvents = fNumberOfEvents ;
630 } else if (taskIndex == AliQAv1::kESDS) {
631 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
632 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
633 TFile * esdFile = TFile::Open("AliESDs.root") ;
634 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
636 AliError("esdTree not found") ;
639 fESD = new AliESDEvent() ;
640 fESD->ReadFromTree(fESDTree) ;
641 fESDTree->GetEntry(0) ;
642 fRunNumber = fESD->GetRunNumber() ;
643 fNumberOfEvents = fESDTree->GetEntries() ;
644 if ( fMaxEvents < 0 )
645 fMaxEvents = fNumberOfEvents ;
648 AliError("AliESDs.root not found") ;
652 if ( !InitRunLoader() ) {
653 AliWarning("No Run Loader not found") ;
655 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
656 if ( fMaxEvents < 0 )
657 fMaxEvents = fNumberOfEvents ;
662 TObjArray* detArray = NULL ;
663 if (fRunLoader) // check if RunLoader exists
664 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
665 detArray = fRunLoader->GetAliRun()->Detectors() ;
666 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
669 // Initialize all QA data makers for all detectors
670 fRunNumber = AliCDBManager::Instance()->GetRun() ;
671 if ( ! AliGeomManager::GetGeometry() )
672 AliGeomManager::LoadGeometry() ;
674 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
679 while (timer.CpuTime()<5) {
681 gSystem->ProcessEvents();
683 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
688 //_____________________________________________________________________________
689 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
691 // Initializes The QADataMaker for all active detectors and for all active tasks
693 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
694 if (IsSelected(AliQAv1::GetDetName(iDet))) {
695 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
697 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
698 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
700 if (fQAWriteExpert[iDet])
701 qadm->SetWriteExpert() ;
702 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
703 // skip non active detectors
705 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
706 if (!det || !det->IsActive())
709 // Set default reco params
710 Bool_t sameCycle = kFALSE ;
711 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
712 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
713 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
714 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
724 //_____________________________________________________________________________
725 Bool_t AliQAManager::InitRunLoader()
727 // get or create the run loader
731 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
732 // load all base libraries to get the loader classes
733 TString libs = gSystem->GetLibraries() ;
734 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
735 if (!IsSelected(AliQAv1::GetDetName(iDet)))
737 TString detName = AliQAv1::GetDetName(iDet) ;
738 if (detName == "HLT")
740 if (libs.Contains("lib" + detName + "base.so"))
742 gSystem->Load("lib" + detName + "base.so");
744 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
746 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
749 fRunLoader->CdGAFile();
750 if (fRunLoader->LoadgAlice() == 0) {
751 gAlice = fRunLoader->GetAliRun();
755 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
759 } else { // galice.root does not exist
760 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
766 fRunLoader->LoadHeader();
767 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
772 //_____________________________________________________________________________
773 Bool_t AliQAManager::IsSelected(const Char_t * det)
775 // check whether detName is contained in detectors
776 // if yes, it is removed from detectors
779 const TString detName(det) ;
780 // always activates Correlation
781 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
784 // check if all detectors are selected
785 if (fDetectors.Contains("ALL")) {
788 } else if ((fDetectors.CompareTo(detName) == 0) ||
789 fDetectors.BeginsWith(detName+" ") ||
790 fDetectors.EndsWith(" "+detName) ||
791 fDetectors.Contains(" "+detName+" ")) {
798 //_____________________________________________________________________________
799 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
801 // Merge data from all detectors from a given run in one single file
802 // Merge the QA results from all the data chunks in one run
803 // The 'fileName' is name of the output file with merged QA data
804 if ( runNumber == -1)
805 runNumber = fRunNumber ;
806 Bool_t rv = MergeData(runNumber,fileName) ;
807 //rv *= MergeResults(runNumber) ; // not needed for the time being
811 //______________________________________________________________________
812 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
814 // merges files listed in a xml collection
815 // usage Merge(collection, outputFile))
816 // collection: is a xml collection
820 if ( strstr(collectionFile, ".xml") == 0 ) {
821 AliError("Input collection file must be an \".xml\" file\n") ;
826 TGrid::Connect("alien://");
830 // Open the file collection
831 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
833 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
834 TGridResult* result = collection->GetGridResult("", 0, 0);
837 const Char_t * turl ;
838 TFileMerger merger(kFALSE) ;
840 TString tempo(collectionFile) ;
842 tempo.ReplaceAll(".xml", subFile) ;
844 tempo.ReplaceAll(".xml", "_Merged.root") ;
845 outFile = tempo.Data() ;
847 merger.OutputFile(outFile) ;
849 while ( (turl = result->GetKey(index, "turl")) ) {
852 file = Form("%s#%s", turl, subFile) ;
854 file = Form("%s", turl) ;
856 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
857 merger.AddFile(file) ;
864 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
870 //_____________________________________________________________________________
871 void AliQAManager::MergeCustom() const
873 // Custom Merge of QA data from all detectors for all runs in one single file
874 // search all the run numbers
875 // search all the run numbers
876 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
878 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
881 TIter nextRun(&srunList) ;
882 TObjString * srun = NULL ;
883 Int_t loRun = 999999999 ;
885 while ( QAfile.Gets(QAfiles) ) {
886 Bool_t runExist = kFALSE ;
887 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
888 Int_t cuRun = srunNew.Atoi() ;
893 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
894 if ( cuRun == (srun->String()).Atoi() ) {
901 srunList.Add(new TObjString(srunNew.Data()));
904 Int_t runNumber = 0 ;
905 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
906 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
907 // create the structure into the merged file
908 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
909 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
910 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
912 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
913 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
915 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
917 gDirectory->mkdir(AliQAv1::GetExpert()) ;
921 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
922 runNumber = (srun->String()).Atoi() ;
923 hisRun->Fill(runNumber) ;
924 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
925 // search all QA files for runNumber in the current directory
926 Char_t * fileList[AliQAv1::kNDET] ;
928 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
929 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
931 fileList[index++] = file ;
934 AliError("No QA data file found\n") ;
937 for ( Int_t i = 0 ; i < index ; i++) {
938 TFile * inFile = TFile::Open(fileList[i]) ;
939 TList * listOfKeys =inFile->GetListOfKeys() ;
940 TIter nextkey(listOfKeys) ;
942 TString dirName("") ;
943 while ( (obj1 = nextkey()) ) {
944 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
945 if ( directoryDet ) {
946 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
947 dirName += Form("%s/", directoryDet->GetName() ) ;
949 TList * listOfTasks = directoryDet->GetListOfKeys() ;
950 TIter nextTask(listOfTasks) ;
952 while ( (obj2 = nextTask()) ) {
953 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
954 if ( directoryTask ) {
955 dirName += Form("%s", obj2->GetName()) ;
956 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
957 directoryTask->cd() ;
958 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
959 TIter nextEventSpecie(listOfEventSpecie) ;
961 while ( (obj3 = nextEventSpecie()) ) {
962 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
963 if ( directoryEventSpecie ) {
964 dirName += Form("/%s/", obj3->GetName()) ;
965 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
966 directoryEventSpecie->cd() ;
967 // histograms are here
968 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
969 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
970 TIter nextData(listOfData) ;
972 while ( (key = static_cast<TKey *>(nextData())) ) {
973 TString className(key->GetClassName()) ;
974 if ( className.Contains("TH") || className.Contains("TProfile") ) {
975 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
976 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
977 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
978 mergedDirectory->cd() ;
982 histOu->Add(histIn) ;
983 histOu->Write(histOu->GetName(), kOverwrite) ;
986 else if ( className.Contains("TDirectoryFile") ) {
987 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
989 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
990 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
991 TIter nextExpertData(listOfExpertData) ;
993 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
994 TString classNameExpert(keykey->GetClassName()) ;
995 if (classNameExpert.Contains("TH")) {
996 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
997 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
998 mergedDirectoryExpert->cd() ;
999 if ( ! histOuExpert ) {
1000 histInExpert->Write() ;
1002 histOuExpert->Add(histInExpert) ;
1003 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
1008 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
1011 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
1014 dirName.ReplaceAll(obj2->GetName(), "") ;
1024 mergedFile.Close() ;
1028 //_____________________________________________________________________________
1029 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
1031 // Merge QA data from all detectors for a given run in one single file
1033 TFileMerger merger(kFALSE) ;
1034 TString outFileName = fileName;
1035 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1036 merger.OutputFile(outFileName.Data()) ;
1037 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1038 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1040 merger.AddFile(file) ;
1046 //_____________________________________________________________________________
1047 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1049 // Merge the QA result from all the data chunks in a run
1050 // to be revised whwn it will be used (see MergeData)
1052 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1053 gROOT->ProcessLine(cmd.Data()) ;
1054 ifstream in("tempo.txt") ;
1055 const Int_t chunkMax = 100 ;
1056 TString fileList[chunkMax] ;
1061 in >> fileList[index] ;
1064 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1069 AliError("No QA Result File found") ;
1073 TFileMerger merger ;
1074 TString outFileName ;
1075 if (runNumber != -1)
1076 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1078 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1079 merger.OutputFile(outFileName.Data()) ;
1080 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1081 TString file = fileList[ifile] ;
1082 merger.AddFile(file) ;
1089 //_____________________________________________________________________________
1090 void AliQAManager::Reset(const Bool_t sameCycle)
1092 // Reset the default data members
1094 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1095 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1096 AliQADataMaker * qadm = GetQADataMaker(iDet);
1100 if (fRawReaderDelete) {
1105 fCycleSame = sameCycle ;
1109 fNumberOfEvents = 999999 ;
1112 //_____________________________________________________________________________
1113 AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run)
1115 // returns AliQAManager instance (singleton)
1117 if (!fgQAInstance) {
1118 if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) {
1119 AliErrorClass("You must specify kSIMMODE or kRECMODE") ;
1122 fgQAInstance = new AliQAManager(mode) ;
1124 fgQAInstance->Init();
1126 fgQAInstance->InitFromCache(entryCache,run);
1128 return fgQAInstance;
1131 //_____________________________________________________________________________
1132 AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1134 // returns AliQAManager instance (singleton)
1135 return QAManager(AliQAv1::Mode(task)) ;
1138 //_____________________________________________________________________________
1139 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1141 //Runs all the QA data Maker for Raws only
1143 fCycleSame = sameCycle ;
1144 fRawReader = rawReader ;
1145 fDetectors = detectors ;
1146 fDetectorsW = detectors ;
1148 AliCDBManager* man = AliCDBManager::Instance() ;
1150 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1151 rawReader->NextEvent() ;
1152 man->SetRun(fRawReader->GetRunNumber()) ;
1153 rawReader->RewindEvents() ;
1157 if ( !InitQA(AliQAv1::kRAWS) )
1159 fRawReaderDelete = kFALSE ;
1161 DoIt(AliQAv1::kRAWS) ;
1162 return fDetectorsW ;
1165 //_____________________________________________________________________________
1166 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1168 //Runs all the QA data Maker for Raws only
1170 fCycleSame = sameCycle ;
1171 fDetectors = detectors ;
1172 fDetectorsW = detectors ;
1174 AliCDBManager* man = AliCDBManager::Instance() ;
1175 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1176 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1178 AliFatal("galice.root file not found in current directory") ;
1182 if ( ! rl->GetAliRun() ) {
1183 AliFatal("AliRun not found in galice.root") ;
1186 man->SetRun(rl->GetHeader()->GetRun());
1192 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1195 DoIt(AliQAv1::kRAWS) ;
1196 return fDetectorsW ;
1199 //_____________________________________________________________________________
1200 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1202 // Runs all the QA data Maker for every detector
1204 fCycleSame = sameCycle ;
1205 fDetectors = detectors ;
1206 fDetectorsW = detectors ;
1208 AliCDBManager* man = AliCDBManager::Instance() ;
1209 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1210 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1212 AliFatal("galice.root file not found in current directory") ;
1216 if ( ! rl->GetAliRun() ) {
1217 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1220 man->SetRun(rl->GetHeader()->GetRun()) ;
1224 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1225 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1226 if ( fTasks.Contains(Form("%d", task)) ) {
1228 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1230 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1235 if ( !InitQA(taskIndex, fileName) )
1239 return fDetectorsW ;
1242 //_____________________________________________________________________________
1243 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1245 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1248 AliCodeTimerAuto("",0) ;
1249 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1250 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1251 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1253 AliQADataMaker *qadm = GetQADataMaker(iDet);
1256 if ( qadm->IsCycleDone() ) {
1257 qadm->EndOfCycle() ;
1259 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1260 qadm->SetEventSpecie(fEventSpecie) ;
1261 if ( qadm->GetRecoParam() )
1262 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1263 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1264 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1265 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1270 //_____________________________________________________________________________
1271 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1273 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1275 AliCodeTimerAuto("",0) ;
1276 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1277 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1278 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1280 AliQADataMaker *qadm = GetQADataMaker(iDet);
1283 qadm->SetEventSpecie(fEventSpecie) ;
1284 if ( qadm->GetRecoParam() )
1285 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1286 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1287 if ( qadm->IsCycleDone() ) {
1288 qadm->EndOfCycle() ;
1290 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1291 qadm->Exec(AliQAv1::kESDS, esd) ;
1292 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1297 //_____________________________________________________________________________
1298 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1300 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1302 TString test(tree->GetName()) ;
1303 AliCodeTimerAuto("",0) ;
1304 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1305 if (IsSelected(AliQAv1::GetDetName(det))) {
1306 AliQADataMaker *qadm = GetQADataMaker(det);
1308 qadm->SetEventSpecie(fEventSpecie) ;
1309 if ( qadm->GetRecoParam() ) {
1310 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1311 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1313 AliError(Form("%d defined by %s is not an event specie", qadm->GetRecoParam()->GetEventSpecie(), qadm->GetName())) ;
1315 if ( qadm->IsCycleDone() ) {
1316 qadm->EndOfCycle() ;
1318 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1319 if (test.Contains("TreeD")) {
1320 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1321 } else if (test.Contains("TreeR")) {
1322 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1323 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1330 //_____________________________________________________________________________
1331 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1333 // take the locasl QA data merge into a single file and save in OCDB
1335 TString tmp(AliQAv1::GetQARefStorage()) ;
1336 if ( tmp.IsNull() ) {
1337 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1340 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1341 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1344 TString sdet(detectors) ;
1347 if ( sdet.Contains("ALL") ) {
1348 rv = Merge(runNumber) ;
1351 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1352 inputFile = TFile::Open(inputFileName.Data()) ;
1353 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1355 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1356 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1357 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1358 inputFile = TFile::Open(inputFileName.Data()) ;
1359 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1366 //_____________________________________________________________________________
1367 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1369 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1371 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1372 if ( ! IsDefaultStorageSet() ) {
1373 TString tmp( AliQAv1::GetQARefStorage() ) ;
1374 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1375 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1377 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1379 tmp1.Append("?user=alidaq") ;
1380 Instance()->SetDefaultStorage(tmp1.Data()) ;
1383 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1385 Instance()->SetRun(runNumber);
1387 AliCDBMetaData mdr ;
1388 mdr.SetResponsible("yves schutz");
1390 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1391 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1393 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1394 AliQAv1::SetQARefDataDirName(es) ;
1395 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1396 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1397 TList * listDetQAD = new TList() ;
1398 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1399 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1400 listDetQAD->SetName(listName) ;
1401 TList * taskList = detDir->GetListOfKeys() ;
1402 TIter nextTask(taskList) ;
1404 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1405 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1406 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1407 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1408 TObjArray * listTaskQAD = new TObjArray(100) ;
1409 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1410 listDetQAD->Add(listTaskQAD) ;
1411 TList * histList = esDir->GetListOfKeys() ;
1412 TIter nextHist(histList) ;
1414 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1415 TObject * odata = esDir->Get(histKey->GetName()) ;
1417 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1419 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1420 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1421 TList * expertHistList = expertDir->GetListOfKeys() ;
1422 TIter nextExpertHist(expertHistList) ;
1423 TKey * expertHistKey ;
1424 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1425 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1426 if ( !expertOdata ) {
1427 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1429 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1430 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1431 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1432 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1433 listTaskQAD->Add(hExpertdata) ;
1438 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1439 if ( odata->IsA()->InheritsFrom("TH1") ) {
1440 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1441 TH1 * hdata = static_cast<TH1*>(odata) ;
1442 listTaskQAD->Add(hdata) ;
1447 Instance()->Put(listDetQAD, idr, &mdr) ;
1453 //_____________________________________________________________________________
1455 void AliQAManager::SetCheckerExternParam(AliQAv1::DETECTORINDEX_t detIndex, TList * parameterList)
1457 // set the external parameters list for the detector checkers
1458 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
1459 qac->SetExternParamlist(parameterList) ;
1460 qac->PrintExternParam() ;
1463 //_____________________________________________________________________________
1464 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1466 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1468 AliQAv1::Instance()->SetEventSpecie(es) ;
1471 //_____________________________________________________________________________
1472 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1474 // Set custom reconstruction parameters for a given detector
1475 // Single set of parameters for all the events
1476 GetQADataMaker(det)->SetRecoParam(par) ;
1479 //_____________________________________________________________________________
1480 void AliQAManager::SetWriteExpert()
1482 // enable the writing of QA expert data
1483 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1484 if (IsSelected(AliQAv1::GetDetName(iDet)))
1485 fQAWriteExpert[iDet] = kTRUE ;
1489 //_____________________________________________________________________________
1490 void AliQAManager::Destroy() {
1491 // delete AliQAManager instance and
1492 // all associated objects
1495 delete fgQAInstance ;
1496 fgQAInstance = NULL ;
1500 //_____________________________________________________________________________
1501 void AliQAManager::ShowQA() {
1502 // Show the result of the QA checking
1503 // for all detectors
1504 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1505 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;