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 "AliQAChecker.h"
58 #include "AliQACheckerBase.h"
59 #include "AliQADataMakerRec.h"
60 #include "AliQADataMakerSim.h"
61 #include "AliQAManager.h"
62 #include "AliRawReaderDate.h"
63 #include "AliRawReaderFile.h"
64 #include "AliRawReaderRoot.h"
66 #include "AliRunLoader.h"
67 #include "AliRunTag.h"
69 ClassImp(AliQAManager)
70 AliQAManager* AliQAManager::fgQAInstance = 0x0;
72 //_____________________________________________________________________________
73 AliQAManager::AliQAManager() :
85 fNumberOfEvents(999999),
89 fRawReaderDelete(kTRUE),
92 fEventSpecie(AliRecoParam::kDefault),
96 fMaxEvents = fNumberOfEvents ;
97 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
98 if (IsSelected(AliQAv1::GetDetName(iDet))) {
99 fLoader[iDet] = NULL ;
100 fQADataMaker[iDet] = NULL ;
101 fQACycles[iDet] = 999999 ;
107 //_____________________________________________________________________________
108 AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
116 fGAliceFileName(gAliceFilename),
119 fMode(AliQAv1::GetModeName(mode)),
120 fNumberOfEvents(999999),
124 fRawReaderDelete(kTRUE),
127 fEventSpecie(AliRecoParam::kDefault),
131 fMaxEvents = fNumberOfEvents ;
132 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
133 if (IsSelected(AliQAv1::GetDetName(iDet))) {
134 fLoader[iDet] = NULL ;
135 fQADataMaker[iDet] = NULL ;
136 fQACycles[iDet] = 999999 ;
142 //_____________________________________________________________________________
143 AliQAManager::AliQAManager(const AliQAManager & qas) :
145 fCurrentEvent(qas.fCurrentEvent),
147 fDetectors(qas.fDetectors),
148 fDetectorsW(qas.fDetectorsW),
151 fGAliceFileName(qas.fGAliceFileName),
152 fFirstEvent(qas.fFirstEvent),
153 fMaxEvents(qas.fMaxEvents),
155 fNumberOfEvents(qas.fNumberOfEvents),
157 fRunNumber(qas.fRunNumber),
159 fRawReaderDelete(kTRUE),
162 fEventSpecie(qas.fEventSpecie),
163 fPrintImage(qas.fPrintImage)
167 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
168 fLoader[iDet] = qas.fLoader[iDet] ;
169 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
170 fQACycles[iDet] = qas.fQACycles[iDet] ;
171 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
175 //_____________________________________________________________________________
176 AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
178 // assignment operator
179 this->~AliQAManager() ;
180 new(this) AliQAManager(qas) ;
184 //_____________________________________________________________________________
185 AliQAManager::~AliQAManager()
188 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
189 if (IsSelected(AliQAv1::GetDetName(iDet))) {
190 fLoader[iDet] = NULL;
191 if (fQADataMaker[iDet]) {
192 (fQADataMaker[iDet])->Finish() ;
193 delete fQADataMaker[iDet] ;
197 if (fRawReaderDelete) {
204 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()));
207 //_____________________________________________________________________________
208 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
210 // Runs all the QA data Maker for every detector
213 // Fill QA data in event loop
214 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
217 if ( iEvent%10 == 0 )
218 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
219 if ( taskIndex == AliQAv1::kRAWS ) {
220 if ( !fRawReader->NextEvent() )
222 } else if ( taskIndex == AliQAv1::kESDS ) {
223 if ( fESDTree->GetEntry(iEvent) == 0 )
226 if ( fRunLoader->GetEvent(iEvent) != 0 )
229 // loop over active loaders
230 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
231 if (IsSelected(AliQAv1::GetDetName(iDet))) {
232 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
233 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
234 if ( qadm->IsCycleDone() ) {
235 qadm->EndOfCycle(taskIndex) ;
237 TTree * data = NULL ;
238 AliLoader* loader = GetLoader(qadm->GetUniqueID());
240 case AliQAv1::kNULLTASKINDEX :
242 case AliQAv1::kRAWS :
243 qadm->Exec(taskIndex, fRawReader) ;
245 case AliQAv1::kHITS :
248 data = loader->TreeH() ;
250 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
253 qadm->Exec(taskIndex, data) ;
256 case AliQAv1::kSDIGITS :
258 loader->LoadSDigits() ;
259 data = loader->TreeS() ;
261 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
264 qadm->Exec(taskIndex, data) ;
267 case AliQAv1::kDIGITS :
269 loader->LoadDigits() ;
270 data = loader->TreeD() ;
272 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
275 qadm->Exec(taskIndex, data) ;
278 case AliQAv1::kDIGITSR :
280 loader->LoadDigits() ;
281 data = loader->TreeD() ;
283 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
286 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))) ;
297 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 :
312 Increment(taskIndex) ;
314 // Save QA data for all detectors
316 rv = Finish(taskIndex) ;
318 if ( taskIndex == AliQAv1::kRAWS )
319 fRawReader->RewindEvents() ;
324 //_____________________________________________________________________________
325 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
327 // write output to file for all detectors
329 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
331 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
332 if (IsSelected(AliQAv1::GetDetName(iDet))) {
333 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
335 qadm->EndOfCycle(taskIndex) ;
341 //_____________________________________________________________________________
342 TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const
344 // Retrieve the list of QA data for a given detector and a given task
345 TObjArray * rv = NULL ;
346 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
347 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
350 if ( ! IsDefaultStorageSet() ) {
351 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
354 Instance()->SetDefaultStorage(tmp.Data()) ;
355 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
357 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
358 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
359 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
360 TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ;
362 rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
366 //_____________________________________________________________________________
367 TCanvas ** AliQAManager::GetImage(Char_t * detName)
369 // retrieves QA Image for the given detector
370 TCanvas ** rv = NULL ;
371 Int_t detIndex = AliQAv1::GetDetIndex(detName) ;
372 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
373 rv = qac->GetImage() ;
377 //_____________________________________________________________________________
378 AliLoader * AliQAManager::GetLoader(Int_t iDet)
380 // get the loader for a detector
382 if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL )
385 TString detName = AliQAv1::GetDetName(iDet) ;
386 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
388 return fLoader[iDet] ;
390 // load the QA data maker object
391 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
392 TString loaderName = "Ali" + detName + "Loader" ;
394 AliLoader * loader = NULL ;
395 // first check if a plugin is defined for the quality assurance data maker
396 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
397 // if not, add a plugin for it
398 if (!pluginHandler) {
399 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
400 TString libs = gSystem->GetLibraries() ;
401 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
402 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
404 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
406 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
408 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
409 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
412 fLoader[iDet] = loader ;
416 //_____________________________________________________________________________
417 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
419 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
420 Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
421 TFile * tagFile = TFile::Open(fileName) ;
423 AliError(Form("File %s not found", fileName)) ;
426 TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ;
428 AliError(Form("Tree T not found in %s", fileName)) ;
432 AliRunTag * tag = new AliRunTag ;
433 tagTree->SetBranchAddress("AliTAG", &tag) ;
434 tagTree->GetEntry(evt) ;
435 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
440 //_____________________________________________________________________________
441 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
443 // get the quality assurance data maker for a detector
445 AliQADataMaker * qadm = fQADataMaker[iDet] ;
449 qadm->SetEventSpecie(fEventSpecie) ;
450 if ( qadm->GetRecoParam() )
451 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
452 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
454 } else if (iDet == AliQAv1::kGLOBAL) { //Global QA
456 qadm = new AliGlobalQADataMaker();
457 qadm->SetName(AliQAv1::GetDetName(iDet));
458 qadm->SetUniqueID(iDet);
459 fQADataMaker[iDet] = qadm;
460 qadm->SetEventSpecie(fEventSpecie) ;
461 if ( qadm->GetRecoParam() )
462 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
463 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
465 } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
466 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
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::kHLT ) {
477 // load the QA data maker object
478 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
479 TString detName = AliQAv1::GetDetName(iDet) ;
480 TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
482 // first check if a plugin is defined for the quality assurance data maker
483 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
484 // if not, add a plugin for it
485 if (!pluginHandler) {
486 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
487 TString libs = gSystem->GetLibraries() ;
488 TString temp(GetMode()) ;
490 if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
491 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
493 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
495 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
497 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
498 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
501 qadm->SetName(AliQAv1::GetDetName(iDet));
502 qadm->SetUniqueID(iDet);
503 fQADataMaker[iDet] = qadm ;
504 qadm->SetEventSpecie(fEventSpecie) ;
505 if ( qadm->GetRecoParam() )
506 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
507 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
513 //_____________________________________________________________________________
514 void AliQAManager::EndOfCycle(TObjArray * detArray)
516 // End of cycle QADataMakers
518 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
521 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
523 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
524 if (IsSelected(AliQAv1::GetDetName(iDet))) {
525 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
526 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
529 // skip non active detectors
531 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
532 if (!det || !det->IsActive())
535 qac->SetPrintImage(fPrintImage) ;
537 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
538 if ( fTasks.Contains(Form("%d", taskIndex)) )
539 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
546 //_____________________________________________________________________________
547 void AliQAManager::EndOfCycle(TString detectors)
549 // End of cycle QADataMakers
551 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
554 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
556 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
557 if (IsSelected(AliQAv1::GetDetName(iDet))) {
558 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
559 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
562 // skip non active detectors
563 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
565 qac->SetPrintImage(fPrintImage) ;
566 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
567 if ( fTasks.Contains(Form("%d", taskIndex)) )
568 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
575 //_____________________________________________________________________________
576 void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
578 // Increments the cycle counter for all QA Data Makers
579 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
580 if (currentTask == taskIndex)
583 currentTask = taskIndex ;
584 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
585 if (IsSelected(AliQAv1::GetDetName(iDet))) {
586 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
593 //_____________________________________________________________________________
594 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
596 // Initialize the event source and QA data makers
598 fTasks += Form("%d", taskIndex) ;
600 if (taskIndex == AliQAv1::kRAWS) {
602 fRawReader = AliRawReader::Create(input);
606 fRawReaderDelete = kTRUE ;
607 fRawReader->NextEvent() ;
608 fRunNumber = fRawReader->GetRunNumber() ;
610 fRawReader->RewindEvents();
611 fNumberOfEvents = 999999 ;
612 if ( fMaxEvents < 0 )
613 fMaxEvents = fNumberOfEvents ;
614 } else if (taskIndex == AliQAv1::kESDS) {
615 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
616 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
617 TFile * esdFile = TFile::Open("AliESDs.root") ;
618 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
620 AliError("esdTree not found") ;
623 fESD = new AliESDEvent() ;
624 fESD->ReadFromTree(fESDTree) ;
625 fESDTree->GetEntry(0) ;
626 fRunNumber = fESD->GetRunNumber() ;
627 fNumberOfEvents = fESDTree->GetEntries() ;
628 if ( fMaxEvents < 0 )
629 fMaxEvents = fNumberOfEvents ;
632 AliError("AliESDs.root not found") ;
636 if ( !InitRunLoader() ) {
637 AliWarning("No Run Loader not found") ;
639 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
640 if ( fMaxEvents < 0 )
641 fMaxEvents = fNumberOfEvents ;
646 TObjArray* detArray = NULL ;
647 if (fRunLoader) // check if RunLoader exists
648 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
649 detArray = fRunLoader->GetAliRun()->Detectors() ;
650 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
653 // Initialize all QA data makers for all detectors
654 fRunNumber = AliCDBManager::Instance()->GetRun() ;
655 if ( ! AliGeomManager::GetGeometry() )
656 AliGeomManager::LoadGeometry() ;
658 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
661 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
666 //_____________________________________________________________________________
667 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
669 // Initializes The QADataMaker for all active detectors and for all active tasks
671 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
672 if (IsSelected(AliQAv1::GetDetName(iDet))) {
673 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
675 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
676 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
678 if (fQAWriteExpert[iDet])
679 qadm->SetWriteExpert() ;
680 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
681 // skip non active detectors
683 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
684 if (!det || !det->IsActive())
687 // Set default reco params
688 Bool_t sameCycle = kFALSE ;
689 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
690 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
691 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
692 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
702 //_____________________________________________________________________________
703 Bool_t AliQAManager::InitRunLoader()
705 // get or create the run loader
709 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
710 // load all base libraries to get the loader classes
711 TString libs = gSystem->GetLibraries() ;
712 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
713 if (!IsSelected(AliQAv1::GetDetName(iDet)))
715 TString detName = AliQAv1::GetDetName(iDet) ;
716 if (detName == "HLT")
718 if (libs.Contains("lib" + detName + "base.so"))
720 gSystem->Load("lib" + detName + "base.so");
722 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
724 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
727 fRunLoader->CdGAFile();
728 if (fRunLoader->LoadgAlice() == 0) {
729 gAlice = fRunLoader->GetAliRun();
733 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
737 } else { // galice.root does not exist
738 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
744 fRunLoader->LoadHeader();
745 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
750 //_____________________________________________________________________________
751 Bool_t AliQAManager::IsSelected(const Char_t * det)
753 // check whether detName is contained in detectors
754 // if yes, it is removed from detectors
757 const TString detName(det) ;
758 // always activates Correlation
759 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
762 // check if all detectors are selected
763 if (fDetectors.Contains("ALL")) {
766 } else if ((fDetectors.CompareTo(detName) == 0) ||
767 fDetectors.BeginsWith(detName+" ") ||
768 fDetectors.EndsWith(" "+detName) ||
769 fDetectors.Contains(" "+detName+" ")) {
776 //_____________________________________________________________________________
777 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
779 // Merge data from all detectors from a given run in one single file
780 // Merge the QA results from all the data chunks in one run
781 // The 'fileName' is name of the output file with merged QA data
782 if ( runNumber == -1)
783 runNumber = fRunNumber ;
784 Bool_t rv = MergeData(runNumber,fileName) ;
785 //rv *= MergeResults(runNumber) ; // not needed for the time being
789 //______________________________________________________________________
790 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
792 // merges files listed in a xml collection
793 // usage Merge(collection, outputFile))
794 // collection: is a xml collection
798 if ( strstr(collectionFile, ".xml") == 0 ) {
799 AliError("Input collection file must be an \".xml\" file\n") ;
804 TGrid::Connect("alien://");
808 // Open the file collection
809 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
811 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
812 TGridResult* result = collection->GetGridResult("", 0, 0);
815 const Char_t * turl ;
816 TFileMerger merger(kFALSE) ;
818 TString tempo(collectionFile) ;
820 tempo.ReplaceAll(".xml", subFile) ;
822 tempo.ReplaceAll(".xml", "_Merged.root") ;
823 outFile = tempo.Data() ;
825 merger.OutputFile(outFile) ;
827 while ( (turl = result->GetKey(index, "turl")) ) {
830 file = Form("%s#%s", turl, subFile) ;
832 file = Form("%s", turl) ;
834 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
835 merger.AddFile(file) ;
842 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
848 //_____________________________________________________________________________
849 void AliQAManager::MergeCustom() const
851 // Custom Merge of QA data from all detectors for all runs in one single file
852 // search all the run numbers
853 // search all the run numbers
854 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
856 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
859 TIter nextRun(&srunList) ;
860 TObjString * srun = NULL ;
861 Int_t loRun = 999999999 ;
863 while ( QAfile.Gets(QAfiles) ) {
864 Bool_t runExist = kFALSE ;
865 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
866 Int_t cuRun = srunNew.Atoi() ;
871 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
872 if ( cuRun == (srun->String()).Atoi() ) {
879 srunList.Add(new TObjString(srunNew.Data()));
882 Int_t runNumber = 0 ;
883 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
884 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
885 // create the structure into the merged file
886 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
887 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
888 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
890 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
891 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
893 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
895 gDirectory->mkdir(AliQAv1::GetExpert()) ;
899 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
900 runNumber = (srun->String()).Atoi() ;
901 hisRun->Fill(runNumber) ;
902 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
903 // search all QA files for runNumber in the current directory
904 Char_t * fileList[AliQAv1::kNDET] ;
906 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
907 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
909 fileList[index++] = file ;
912 AliError("No QA data file found\n") ;
915 for ( Int_t i = 0 ; i < index ; i++) {
916 TFile * inFile = TFile::Open(fileList[i]) ;
917 TList * listOfKeys =inFile->GetListOfKeys() ;
918 TIter nextkey(listOfKeys) ;
920 TString dirName("") ;
921 while ( (obj1 = nextkey()) ) {
922 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
923 if ( directoryDet ) {
924 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
925 dirName += Form("%s/", directoryDet->GetName() ) ;
927 TList * listOfTasks = directoryDet->GetListOfKeys() ;
928 TIter nextTask(listOfTasks) ;
930 while ( (obj2 = nextTask()) ) {
931 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
932 if ( directoryTask ) {
933 dirName += Form("%s", obj2->GetName()) ;
934 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
935 directoryTask->cd() ;
936 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
937 TIter nextEventSpecie(listOfEventSpecie) ;
939 while ( (obj3 = nextEventSpecie()) ) {
940 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
941 if ( directoryEventSpecie ) {
942 dirName += Form("/%s/", obj3->GetName()) ;
943 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
944 directoryEventSpecie->cd() ;
945 // histograms are here
946 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
947 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
948 TIter nextData(listOfData) ;
950 while ( (key = static_cast<TKey *>(nextData())) ) {
951 TString className(key->GetClassName()) ;
952 if ( className.Contains("TH") || className.Contains("TProfile") ) {
953 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
954 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
955 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
956 mergedDirectory->cd() ;
960 histOu->Add(histIn) ;
961 histOu->Write(histOu->GetName(), kOverwrite) ;
964 else if ( className.Contains("TDirectoryFile") ) {
965 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
967 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
968 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
969 TIter nextExpertData(listOfExpertData) ;
971 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
972 TString classNameExpert(keykey->GetClassName()) ;
973 if (classNameExpert.Contains("TH")) {
974 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
975 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
976 mergedDirectoryExpert->cd() ;
977 if ( ! histOuExpert ) {
978 histInExpert->Write() ;
980 histOuExpert->Add(histInExpert) ;
981 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
986 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
989 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
992 dirName.ReplaceAll(obj2->GetName(), "") ;
1002 mergedFile.Close() ;
1006 //_____________________________________________________________________________
1007 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
1009 // Merge QA data from all detectors for a given run in one single file
1011 TFileMerger merger(kFALSE) ;
1012 TString outFileName = fileName;
1013 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1014 merger.OutputFile(outFileName.Data()) ;
1015 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1016 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1018 merger.AddFile(file) ;
1024 //_____________________________________________________________________________
1025 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1027 // Merge the QA result from all the data chunks in a run
1028 // to be revised whwn it will be used (see MergeData)
1030 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1031 gROOT->ProcessLine(cmd.Data()) ;
1032 ifstream in("tempo.txt") ;
1033 const Int_t chunkMax = 100 ;
1034 TString fileList[chunkMax] ;
1039 in >> fileList[index] ;
1042 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1047 AliError("No QA Result File found") ;
1051 TFileMerger merger ;
1052 TString outFileName ;
1053 if (runNumber != -1)
1054 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1056 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1057 merger.OutputFile(outFileName.Data()) ;
1058 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1059 TString file = fileList[ifile] ;
1060 merger.AddFile(file) ;
1067 //_____________________________________________________________________________
1068 void AliQAManager::Reset(const Bool_t sameCycle)
1070 // Reset the default data members
1072 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1073 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1074 AliQADataMaker * qadm = GetQADataMaker(iDet);
1078 if (fRawReaderDelete) {
1083 fCycleSame = sameCycle ;
1087 fNumberOfEvents = 999999 ;
1090 //_____________________________________________________________________________
1091 AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run)
1093 // returns AliQAManager instance (singleton)
1095 if (!fgQAInstance) {
1096 if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) {
1097 AliErrorClass("You must specify kSIMMODE or kRECMODE") ;
1100 fgQAInstance = new AliQAManager(mode) ;
1102 fgQAInstance->Init();
1104 fgQAInstance->InitFromCache(entryCache,run);
1106 return fgQAInstance;
1109 //_____________________________________________________________________________
1110 AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1112 // returns AliQAManager instance (singleton)
1113 return QAManager(AliQAv1::Mode(task)) ;
1116 //_____________________________________________________________________________
1117 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1119 //Runs all the QA data Maker for Raws only
1121 fCycleSame = sameCycle ;
1122 fRawReader = rawReader ;
1123 fDetectors = detectors ;
1124 fDetectorsW = detectors ;
1126 AliCDBManager* man = AliCDBManager::Instance() ;
1128 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1129 rawReader->NextEvent() ;
1130 man->SetRun(fRawReader->GetRunNumber()) ;
1131 rawReader->RewindEvents() ;
1135 if ( !InitQA(AliQAv1::kRAWS) )
1137 fRawReaderDelete = kFALSE ;
1139 DoIt(AliQAv1::kRAWS) ;
1140 return fDetectorsW ;
1143 //_____________________________________________________________________________
1144 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1146 //Runs all the QA data Maker for Raws only
1148 fCycleSame = sameCycle ;
1149 fDetectors = detectors ;
1150 fDetectorsW = detectors ;
1152 AliCDBManager* man = AliCDBManager::Instance() ;
1153 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1154 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1156 AliFatal("galice.root file not found in current directory") ;
1160 if ( ! rl->GetAliRun() ) {
1161 AliFatal("AliRun not found in galice.root") ;
1164 man->SetRun(rl->GetHeader()->GetRun());
1170 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1173 DoIt(AliQAv1::kRAWS) ;
1174 return fDetectorsW ;
1177 //_____________________________________________________________________________
1178 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1180 // Runs all the QA data Maker for every detector
1182 fCycleSame = sameCycle ;
1183 fDetectors = detectors ;
1184 fDetectorsW = detectors ;
1186 AliCDBManager* man = AliCDBManager::Instance() ;
1187 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1188 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1190 AliFatal("galice.root file not found in current directory") ;
1194 if ( ! rl->GetAliRun() ) {
1195 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1198 man->SetRun(rl->GetHeader()->GetRun()) ;
1202 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1203 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1204 if ( fTasks.Contains(Form("%d", task)) ) {
1206 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1208 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1213 if ( !InitQA(taskIndex, fileName) )
1217 return fDetectorsW ;
1220 //_____________________________________________________________________________
1221 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1223 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1226 AliCodeTimerAuto("") ;
1227 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1228 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1229 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1231 AliQADataMaker *qadm = GetQADataMaker(iDet);
1234 if ( qadm->IsCycleDone() ) {
1235 qadm->EndOfCycle() ;
1237 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(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 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1243 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1248 //_____________________________________________________________________________
1249 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1251 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1253 AliCodeTimerAuto("") ;
1254 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1255 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1256 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1258 AliQADataMaker *qadm = GetQADataMaker(iDet);
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 ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1269 qadm->Exec(AliQAv1::kESDS, esd) ;
1270 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1275 //_____________________________________________________________________________
1276 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1278 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1280 TString test(tree->GetName()) ;
1281 AliCodeTimerAuto("") ;
1282 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1283 if (IsSelected(AliQAv1::GetDetName(det))) {
1284 AliQADataMaker *qadm = GetQADataMaker(det);
1286 qadm->SetEventSpecie(fEventSpecie) ;
1287 if ( qadm->GetRecoParam() )
1288 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1289 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1290 if ( qadm->IsCycleDone() ) {
1291 qadm->EndOfCycle() ;
1293 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1294 if (test.Contains("TreeD")) {
1295 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1296 } else if (test.Contains("TreeR")) {
1297 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1298 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1305 //_____________________________________________________________________________
1306 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1308 // take the locasl QA data merge into a single file and save in OCDB
1310 TString tmp(AliQAv1::GetQARefStorage()) ;
1311 if ( tmp.IsNull() ) {
1312 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1315 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1316 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1319 TString sdet(detectors) ;
1322 if ( sdet.Contains("ALL") ) {
1323 rv = Merge(runNumber) ;
1326 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1327 inputFile = TFile::Open(inputFileName.Data()) ;
1328 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1330 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1331 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1332 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1333 inputFile = TFile::Open(inputFileName.Data()) ;
1334 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1341 //_____________________________________________________________________________
1342 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1344 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1346 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1347 if ( ! IsDefaultStorageSet() ) {
1348 TString tmp( AliQAv1::GetQARefStorage() ) ;
1349 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1350 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1352 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1354 tmp1.Append("?user=alidaq") ;
1355 Instance()->SetDefaultStorage(tmp1.Data()) ;
1358 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1360 Instance()->SetRun(runNumber);
1362 AliCDBMetaData mdr ;
1363 mdr.SetResponsible("yves schutz");
1365 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1366 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1368 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1369 AliQAv1::SetQARefDataDirName(es) ;
1370 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1371 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1372 TList * listDetQAD = new TList() ;
1373 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1374 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1375 listDetQAD->SetName(listName) ;
1376 TList * taskList = detDir->GetListOfKeys() ;
1377 TIter nextTask(taskList) ;
1379 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1380 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1381 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1382 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1383 TObjArray * listTaskQAD = new TObjArray(100) ;
1384 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1385 listDetQAD->Add(listTaskQAD) ;
1386 TList * histList = esDir->GetListOfKeys() ;
1387 TIter nextHist(histList) ;
1389 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1390 TObject * odata = esDir->Get(histKey->GetName()) ;
1392 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1394 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1395 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1396 TList * expertHistList = expertDir->GetListOfKeys() ;
1397 TIter nextExpertHist(expertHistList) ;
1398 TKey * expertHistKey ;
1399 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1400 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1401 if ( !expertOdata ) {
1402 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1404 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1405 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1406 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1407 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1408 listTaskQAD->Add(hExpertdata) ;
1413 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1414 if ( odata->IsA()->InheritsFrom("TH1") ) {
1415 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1416 TH1 * hdata = static_cast<TH1*>(odata) ;
1417 listTaskQAD->Add(hdata) ;
1422 Instance()->Put(listDetQAD, idr, &mdr) ;
1428 //_____________________________________________________________________________
1429 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1431 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1433 AliQAv1::Instance()->SetEventSpecie(es) ;
1436 //_____________________________________________________________________________
1437 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1439 // Set custom reconstruction parameters for a given detector
1440 // Single set of parameters for all the events
1441 GetQADataMaker(det)->SetRecoParam(par) ;
1444 //_____________________________________________________________________________
1445 void AliQAManager::SetWriteExpert()
1447 // enable the writing of QA expert data
1448 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1449 if (IsSelected(AliQAv1::GetDetName(iDet)))
1450 fQAWriteExpert[iDet] = kTRUE ;
1454 //_____________________________________________________________________________
1455 void AliQAManager::Destroy() {
1456 // delete AliQAManager instance and
1457 // all associated objects
1460 delete fgQAInstance ;
1461 fgQAInstance = NULL ;
1465 //_____________________________________________________________________________
1466 void AliQAManager::ShowQA() {
1467 // Show the result of the QA checking
1468 // for all detectors
1469 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1470 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;