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),
97 fMaxEvents = fNumberOfEvents ;
98 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
99 if (IsSelected(AliQAv1::GetDetName(iDet))) {
100 fLoader[iDet] = NULL ;
101 fQADataMaker[iDet] = NULL ;
102 fQACycles[iDet] = 999999 ;
108 //_____________________________________________________________________________
109 AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
117 fGAliceFileName(gAliceFilename),
120 fMode(AliQAv1::GetModeName(mode)),
121 fNumberOfEvents(999999),
125 fRawReaderDelete(kTRUE),
128 fEventSpecie(AliRecoParam::kDefault),
133 fMaxEvents = fNumberOfEvents ;
134 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
135 if (IsSelected(AliQAv1::GetDetName(iDet))) {
136 fLoader[iDet] = NULL ;
137 fQADataMaker[iDet] = NULL ;
138 fQACycles[iDet] = 999999 ;
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),
166 fSaveData(qas.fSaveData)
170 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
171 fLoader[iDet] = qas.fLoader[iDet] ;
172 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
173 fQACycles[iDet] = qas.fQACycles[iDet] ;
174 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
178 //_____________________________________________________________________________
179 AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
181 // assignment operator
182 this->~AliQAManager() ;
183 new(this) AliQAManager(qas) ;
187 //_____________________________________________________________________________
188 AliQAManager::~AliQAManager()
191 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
192 if (IsSelected(AliQAv1::GetDetName(iDet))) {
193 fLoader[iDet] = NULL;
194 if (fQADataMaker[iDet]) {
195 (fQADataMaker[iDet])->Finish() ;
196 delete fQADataMaker[iDet] ;
200 if (fRawReaderDelete) {
207 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()));
210 //_____________________________________________________________________________
211 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
213 // Runs all the QA data Maker for every detector
216 // Fill QA data in event loop
217 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
220 if ( iEvent%10 == 0 )
221 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
222 if ( taskIndex == AliQAv1::kRAWS ) {
223 if ( !fRawReader->NextEvent() )
225 } else if ( taskIndex == AliQAv1::kESDS ) {
226 if ( fESDTree->GetEntry(iEvent) == 0 )
229 if ( fRunLoader->GetEvent(iEvent) != 0 )
232 // loop over active loaders
233 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
234 if (IsSelected(AliQAv1::GetDetName(iDet))) {
235 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
236 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
237 if ( qadm->IsCycleDone() ) {
238 qadm->EndOfCycle(taskIndex) ;
240 TTree * data = NULL ;
241 AliLoader* loader = GetLoader(qadm->GetUniqueID());
243 case AliQAv1::kNULLTASKINDEX :
245 case AliQAv1::kRAWS :
246 qadm->Exec(taskIndex, fRawReader) ;
248 case AliQAv1::kHITS :
251 data = loader->TreeH() ;
253 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
256 qadm->Exec(taskIndex, data) ;
259 case AliQAv1::kSDIGITS :
261 loader->LoadSDigits() ;
262 data = loader->TreeS() ;
264 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
267 qadm->Exec(taskIndex, data) ;
270 case AliQAv1::kDIGITS :
272 loader->LoadDigits() ;
273 data = loader->TreeD() ;
275 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
278 qadm->Exec(taskIndex, data) ;
281 case AliQAv1::kDIGITSR :
283 loader->LoadDigits() ;
284 data = loader->TreeD() ;
286 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
289 qadm->Exec(taskIndex, data) ;
292 case AliQAv1::kRECPOINTS :
294 loader->LoadRecPoints() ;
295 data = loader->TreeR() ;
297 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ;
300 qadm->Exec(taskIndex, data) ;
303 case AliQAv1::kTRACKSEGMENTS :
305 case AliQAv1::kRECPARTICLES :
307 case AliQAv1::kESDS :
308 qadm->Exec(taskIndex, fESD) ;
310 case AliQAv1::kNTASKINDEX :
315 Increment(taskIndex) ;
317 // Save QA data for all detectors
319 rv = Finish(taskIndex) ;
321 if ( taskIndex == AliQAv1::kRAWS )
322 fRawReader->RewindEvents() ;
327 //_____________________________________________________________________________
328 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
330 // write output to file for all detectors
332 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
334 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
335 if (IsSelected(AliQAv1::GetDetName(iDet))) {
336 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
338 qadm->EndOfCycle(taskIndex) ;
344 //_____________________________________________________________________________
345 TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const
347 // Retrieve the list of QA data for a given detector and a given task
348 TObjArray * rv = NULL ;
349 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
350 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
353 if ( ! IsDefaultStorageSet() ) {
354 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
357 Instance()->SetDefaultStorage(tmp.Data()) ;
358 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
360 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
361 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
362 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
363 TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ;
365 rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
369 //_____________________________________________________________________________
370 TCanvas ** AliQAManager::GetImage(Char_t * detName)
372 // retrieves QA Image for the given detector
373 TCanvas ** rv = NULL ;
374 Int_t detIndex = AliQAv1::GetDetIndex(detName) ;
375 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
376 rv = qac->GetImage() ;
380 //_____________________________________________________________________________
381 AliLoader * AliQAManager::GetLoader(Int_t iDet)
383 // get the loader for a detector
385 if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL )
388 TString detName = AliQAv1::GetDetName(iDet) ;
389 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
391 return fLoader[iDet] ;
393 // load the QA data maker object
394 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
395 TString loaderName = "Ali" + detName + "Loader" ;
397 AliLoader * loader = NULL ;
398 // first check if a plugin is defined for the quality assurance data maker
399 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
400 // if not, add a plugin for it
401 if (!pluginHandler) {
402 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
403 TString libs = gSystem->GetLibraries() ;
404 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
405 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
407 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
409 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
411 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
412 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
415 fLoader[iDet] = loader ;
419 //_____________________________________________________________________________
420 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
422 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
423 Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
424 TFile * tagFile = TFile::Open(fileName) ;
426 AliError(Form("File %s not found", fileName)) ;
429 TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ;
431 AliError(Form("Tree T not found in %s", fileName)) ;
435 AliRunTag * tag = new AliRunTag ;
436 tagTree->SetBranchAddress("AliTAG", &tag) ;
437 tagTree->GetEntry(evt) ;
438 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
443 //_____________________________________________________________________________
444 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
446 // get the quality assurance data maker for a detector
448 AliQADataMaker * qadm = fQADataMaker[iDet] ;
452 qadm->SetEventSpecie(fEventSpecie) ;
453 if ( qadm->GetRecoParam() )
454 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
455 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
457 } else if (iDet == AliQAv1::kGLOBAL) { //Global QA
459 qadm = new AliGlobalQADataMaker();
460 qadm->SetName(AliQAv1::GetDetName(iDet));
461 qadm->SetUniqueID(iDet);
462 fQADataMaker[iDet] = qadm;
463 qadm->SetEventSpecie(fEventSpecie) ;
464 if ( qadm->GetRecoParam() )
465 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
466 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
468 } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), "Rec") == 0 ) { //the data maker for correlations among detectors
469 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
470 qadm->SetName(AliQAv1::GetDetName(iDet));
471 qadm->SetUniqueID(iDet);
472 fQADataMaker[iDet] = qadm;
473 qadm->SetEventSpecie(fEventSpecie) ;
474 if ( qadm->GetRecoParam() )
475 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
476 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
478 } else if ( iDet < AliQAv1::kHLT ) {
480 // load the QA data maker object
481 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
482 TString detName = AliQAv1::GetDetName(iDet) ;
483 TString qadmName = "Ali" + detName + "QADataMaker" + GetMode() ;
485 // first check if a plugin is defined for the quality assurance data maker
486 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
487 // if not, add a plugin for it
488 if (!pluginHandler) {
489 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
490 TString libs = gSystem->GetLibraries() ;
491 TString temp(GetMode()) ;
493 if (libs.Contains("lib" + detName + GetMode() + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
494 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
496 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
498 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
500 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
501 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
504 qadm->SetName(AliQAv1::GetDetName(iDet));
505 qadm->SetUniqueID(iDet);
506 fQADataMaker[iDet] = qadm ;
507 qadm->SetEventSpecie(fEventSpecie) ;
508 if ( qadm->GetRecoParam() )
509 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
510 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
516 //_____________________________________________________________________________
517 void AliQAManager::EndOfCycle(TObjArray * detArray)
519 // End of cycle QADataMakers
521 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
524 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
526 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
527 if (IsSelected(AliQAv1::GetDetName(iDet))) {
528 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
529 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
532 // skip non active detectors
534 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
535 if (!det || !det->IsActive())
538 qac->SetPrintImage(fPrintImage) ;
541 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
542 if ( fTasks.Contains(Form("%d", taskIndex)) )
543 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
551 //_____________________________________________________________________________
552 void AliQAManager::EndOfCycle(TString detectors)
554 // End of cycle QADataMakers
556 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
559 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
561 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
562 if (IsSelected(AliQAv1::GetDetName(iDet))) {
563 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
564 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
567 // skip non active detectors
568 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
570 qac->SetPrintImage(fPrintImage) ;
572 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
573 if ( fTasks.Contains(Form("%d", taskIndex)) )
574 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
582 //_____________________________________________________________________________
583 void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
585 // Increments the cycle counter for all QA Data Makers
586 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
587 if (currentTask == taskIndex)
590 currentTask = taskIndex ;
591 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
592 if (IsSelected(AliQAv1::GetDetName(iDet))) {
593 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
600 //_____________________________________________________________________________
601 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
603 // Initialize the event source and QA data makers
605 fTasks += Form("%d", taskIndex) ;
607 if (taskIndex == AliQAv1::kRAWS) {
609 fRawReader = AliRawReader::Create(input);
613 fRawReaderDelete = kTRUE ;
614 fRawReader->NextEvent() ;
615 fRunNumber = fRawReader->GetRunNumber() ;
617 fRawReader->RewindEvents();
618 fNumberOfEvents = 999999 ;
619 if ( fMaxEvents < 0 )
620 fMaxEvents = fNumberOfEvents ;
621 } else if (taskIndex == AliQAv1::kESDS) {
622 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
623 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
624 TFile * esdFile = TFile::Open("AliESDs.root") ;
625 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
627 AliError("esdTree not found") ;
630 fESD = new AliESDEvent() ;
631 fESD->ReadFromTree(fESDTree) ;
632 fESDTree->GetEntry(0) ;
633 fRunNumber = fESD->GetRunNumber() ;
634 fNumberOfEvents = fESDTree->GetEntries() ;
635 if ( fMaxEvents < 0 )
636 fMaxEvents = fNumberOfEvents ;
639 AliError("AliESDs.root not found") ;
643 if ( !InitRunLoader() ) {
644 AliWarning("No Run Loader not found") ;
646 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
647 if ( fMaxEvents < 0 )
648 fMaxEvents = fNumberOfEvents ;
653 TObjArray* detArray = NULL ;
654 if (fRunLoader) // check if RunLoader exists
655 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
656 detArray = fRunLoader->GetAliRun()->Detectors() ;
657 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
660 // Initialize all QA data makers for all detectors
661 fRunNumber = AliCDBManager::Instance()->GetRun() ;
662 if ( ! AliGeomManager::GetGeometry() )
663 AliGeomManager::LoadGeometry() ;
665 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
668 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
673 //_____________________________________________________________________________
674 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
676 // Initializes The QADataMaker for all active detectors and for all active tasks
678 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
679 if (IsSelected(AliQAv1::GetDetName(iDet))) {
680 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
682 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
683 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
685 if (fQAWriteExpert[iDet])
686 qadm->SetWriteExpert() ;
687 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
688 // skip non active detectors
690 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
691 if (!det || !det->IsActive())
694 // Set default reco params
695 Bool_t sameCycle = kFALSE ;
696 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
697 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
698 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
699 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
709 //_____________________________________________________________________________
710 Bool_t AliQAManager::InitRunLoader()
712 // get or create the run loader
716 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
717 // load all base libraries to get the loader classes
718 TString libs = gSystem->GetLibraries() ;
719 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
720 if (!IsSelected(AliQAv1::GetDetName(iDet)))
722 TString detName = AliQAv1::GetDetName(iDet) ;
723 if (detName == "HLT")
725 if (libs.Contains("lib" + detName + "base.so"))
727 gSystem->Load("lib" + detName + "base.so");
729 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
731 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
734 fRunLoader->CdGAFile();
735 if (fRunLoader->LoadgAlice() == 0) {
736 gAlice = fRunLoader->GetAliRun();
740 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
744 } else { // galice.root does not exist
745 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
751 fRunLoader->LoadHeader();
752 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
757 //_____________________________________________________________________________
758 Bool_t AliQAManager::IsSelected(const Char_t * det)
760 // check whether detName is contained in detectors
761 // if yes, it is removed from detectors
764 const TString detName(det) ;
765 // always activates Correlation
766 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
769 // check if all detectors are selected
770 if (fDetectors.Contains("ALL")) {
773 } else if ((fDetectors.CompareTo(detName) == 0) ||
774 fDetectors.BeginsWith(detName+" ") ||
775 fDetectors.EndsWith(" "+detName) ||
776 fDetectors.Contains(" "+detName+" ")) {
783 //_____________________________________________________________________________
784 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
786 // Merge data from all detectors from a given run in one single file
787 // Merge the QA results from all the data chunks in one run
788 // The 'fileName' is name of the output file with merged QA data
789 if ( runNumber == -1)
790 runNumber = fRunNumber ;
791 Bool_t rv = MergeData(runNumber,fileName) ;
792 //rv *= MergeResults(runNumber) ; // not needed for the time being
796 //______________________________________________________________________
797 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
799 // merges files listed in a xml collection
800 // usage Merge(collection, outputFile))
801 // collection: is a xml collection
805 if ( strstr(collectionFile, ".xml") == 0 ) {
806 AliError("Input collection file must be an \".xml\" file\n") ;
811 TGrid::Connect("alien://");
815 // Open the file collection
816 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
818 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
819 TGridResult* result = collection->GetGridResult("", 0, 0);
822 const Char_t * turl ;
823 TFileMerger merger(kFALSE) ;
825 TString tempo(collectionFile) ;
827 tempo.ReplaceAll(".xml", subFile) ;
829 tempo.ReplaceAll(".xml", "_Merged.root") ;
830 outFile = tempo.Data() ;
832 merger.OutputFile(outFile) ;
834 while ( (turl = result->GetKey(index, "turl")) ) {
837 file = Form("%s#%s", turl, subFile) ;
839 file = Form("%s", turl) ;
841 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
842 merger.AddFile(file) ;
849 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
855 //_____________________________________________________________________________
856 void AliQAManager::MergeCustom() const
858 // Custom Merge of QA data from all detectors for all runs in one single file
859 // search all the run numbers
860 // search all the run numbers
861 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
863 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
866 TIter nextRun(&srunList) ;
867 TObjString * srun = NULL ;
868 Int_t loRun = 999999999 ;
870 while ( QAfile.Gets(QAfiles) ) {
871 Bool_t runExist = kFALSE ;
872 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
873 Int_t cuRun = srunNew.Atoi() ;
878 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
879 if ( cuRun == (srun->String()).Atoi() ) {
886 srunList.Add(new TObjString(srunNew.Data()));
889 Int_t runNumber = 0 ;
890 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
891 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
892 // create the structure into the merged file
893 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
894 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
895 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
897 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
898 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
900 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
902 gDirectory->mkdir(AliQAv1::GetExpert()) ;
906 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
907 runNumber = (srun->String()).Atoi() ;
908 hisRun->Fill(runNumber) ;
909 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
910 // search all QA files for runNumber in the current directory
911 Char_t * fileList[AliQAv1::kNDET] ;
913 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
914 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
916 fileList[index++] = file ;
919 AliError("No QA data file found\n") ;
922 for ( Int_t i = 0 ; i < index ; i++) {
923 TFile * inFile = TFile::Open(fileList[i]) ;
924 TList * listOfKeys =inFile->GetListOfKeys() ;
925 TIter nextkey(listOfKeys) ;
927 TString dirName("") ;
928 while ( (obj1 = nextkey()) ) {
929 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
930 if ( directoryDet ) {
931 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
932 dirName += Form("%s/", directoryDet->GetName() ) ;
934 TList * listOfTasks = directoryDet->GetListOfKeys() ;
935 TIter nextTask(listOfTasks) ;
937 while ( (obj2 = nextTask()) ) {
938 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
939 if ( directoryTask ) {
940 dirName += Form("%s", obj2->GetName()) ;
941 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
942 directoryTask->cd() ;
943 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
944 TIter nextEventSpecie(listOfEventSpecie) ;
946 while ( (obj3 = nextEventSpecie()) ) {
947 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
948 if ( directoryEventSpecie ) {
949 dirName += Form("/%s/", obj3->GetName()) ;
950 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
951 directoryEventSpecie->cd() ;
952 // histograms are here
953 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
954 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
955 TIter nextData(listOfData) ;
957 while ( (key = static_cast<TKey *>(nextData())) ) {
958 TString className(key->GetClassName()) ;
959 if ( className.Contains("TH") || className.Contains("TProfile") ) {
960 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
961 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
962 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
963 mergedDirectory->cd() ;
967 histOu->Add(histIn) ;
968 histOu->Write(histOu->GetName(), kOverwrite) ;
971 else if ( className.Contains("TDirectoryFile") ) {
972 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
974 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
975 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
976 TIter nextExpertData(listOfExpertData) ;
978 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
979 TString classNameExpert(keykey->GetClassName()) ;
980 if (classNameExpert.Contains("TH")) {
981 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
982 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
983 mergedDirectoryExpert->cd() ;
984 if ( ! histOuExpert ) {
985 histInExpert->Write() ;
987 histOuExpert->Add(histInExpert) ;
988 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
993 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
996 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
999 dirName.ReplaceAll(obj2->GetName(), "") ;
1009 mergedFile.Close() ;
1013 //_____________________________________________________________________________
1014 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
1016 // Merge QA data from all detectors for a given run in one single file
1018 TFileMerger merger(kFALSE) ;
1019 TString outFileName = fileName;
1020 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1021 merger.OutputFile(outFileName.Data()) ;
1022 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1023 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1025 merger.AddFile(file) ;
1031 //_____________________________________________________________________________
1032 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1034 // Merge the QA result from all the data chunks in a run
1035 // to be revised whwn it will be used (see MergeData)
1037 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1038 gROOT->ProcessLine(cmd.Data()) ;
1039 ifstream in("tempo.txt") ;
1040 const Int_t chunkMax = 100 ;
1041 TString fileList[chunkMax] ;
1046 in >> fileList[index] ;
1049 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1054 AliError("No QA Result File found") ;
1058 TFileMerger merger ;
1059 TString outFileName ;
1060 if (runNumber != -1)
1061 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1063 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1064 merger.OutputFile(outFileName.Data()) ;
1065 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1066 TString file = fileList[ifile] ;
1067 merger.AddFile(file) ;
1074 //_____________________________________________________________________________
1075 void AliQAManager::Reset(const Bool_t sameCycle)
1077 // Reset the default data members
1079 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1080 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1081 AliQADataMaker * qadm = GetQADataMaker(iDet);
1085 if (fRawReaderDelete) {
1090 fCycleSame = sameCycle ;
1094 fNumberOfEvents = 999999 ;
1097 //_____________________________________________________________________________
1098 AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run)
1100 // returns AliQAManager instance (singleton)
1102 if (!fgQAInstance) {
1103 if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) {
1104 AliErrorClass("You must specify kSIMMODE or kRECMODE") ;
1107 fgQAInstance = new AliQAManager(mode) ;
1109 fgQAInstance->Init();
1111 fgQAInstance->InitFromCache(entryCache,run);
1113 return fgQAInstance;
1116 //_____________________________________________________________________________
1117 AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1119 // returns AliQAManager instance (singleton)
1120 return QAManager(AliQAv1::Mode(task)) ;
1123 //_____________________________________________________________________________
1124 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1126 //Runs all the QA data Maker for Raws only
1128 fCycleSame = sameCycle ;
1129 fRawReader = rawReader ;
1130 fDetectors = detectors ;
1131 fDetectorsW = detectors ;
1133 AliCDBManager* man = AliCDBManager::Instance() ;
1135 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1136 rawReader->NextEvent() ;
1137 man->SetRun(fRawReader->GetRunNumber()) ;
1138 rawReader->RewindEvents() ;
1142 if ( !InitQA(AliQAv1::kRAWS) )
1144 fRawReaderDelete = kFALSE ;
1146 DoIt(AliQAv1::kRAWS) ;
1147 return fDetectorsW ;
1150 //_____________________________________________________________________________
1151 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1153 //Runs all the QA data Maker for Raws only
1155 fCycleSame = sameCycle ;
1156 fDetectors = detectors ;
1157 fDetectorsW = detectors ;
1159 AliCDBManager* man = AliCDBManager::Instance() ;
1160 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1161 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1163 AliFatal("galice.root file not found in current directory") ;
1167 if ( ! rl->GetAliRun() ) {
1168 AliFatal("AliRun not found in galice.root") ;
1171 man->SetRun(rl->GetHeader()->GetRun());
1177 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1180 DoIt(AliQAv1::kRAWS) ;
1181 return fDetectorsW ;
1184 //_____________________________________________________________________________
1185 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1187 // Runs all the QA data Maker for every detector
1189 fCycleSame = sameCycle ;
1190 fDetectors = detectors ;
1191 fDetectorsW = detectors ;
1193 AliCDBManager* man = AliCDBManager::Instance() ;
1194 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1195 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1197 AliFatal("galice.root file not found in current directory") ;
1201 if ( ! rl->GetAliRun() ) {
1202 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1205 man->SetRun(rl->GetHeader()->GetRun()) ;
1209 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1210 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1211 if ( fTasks.Contains(Form("%d", task)) ) {
1213 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1215 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1220 if ( !InitQA(taskIndex, fileName) )
1224 return fDetectorsW ;
1227 //_____________________________________________________________________________
1228 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1230 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1233 AliCodeTimerAuto("",0) ;
1234 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1235 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1236 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1238 AliQADataMaker *qadm = GetQADataMaker(iDet);
1241 if ( qadm->IsCycleDone() ) {
1242 qadm->EndOfCycle() ;
1244 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1245 qadm->SetEventSpecie(fEventSpecie) ;
1246 if ( qadm->GetRecoParam() )
1247 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1248 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1249 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1250 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1255 //_____________________________________________________________________________
1256 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1258 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1260 AliCodeTimerAuto("",0) ;
1261 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1262 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1263 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1265 AliQADataMaker *qadm = GetQADataMaker(iDet);
1268 qadm->SetEventSpecie(fEventSpecie) ;
1269 if ( qadm->GetRecoParam() )
1270 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1271 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1272 if ( qadm->IsCycleDone() ) {
1273 qadm->EndOfCycle() ;
1275 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1276 qadm->Exec(AliQAv1::kESDS, esd) ;
1277 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1282 //_____________________________________________________________________________
1283 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1285 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1287 TString test(tree->GetName()) ;
1288 AliCodeTimerAuto("",0) ;
1289 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1290 if (IsSelected(AliQAv1::GetDetName(det))) {
1291 AliQADataMaker *qadm = GetQADataMaker(det);
1293 qadm->SetEventSpecie(fEventSpecie) ;
1294 if ( qadm->GetRecoParam() ) {
1295 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1296 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1298 AliFatal(Form("%d is not an event specie", qadm->GetRecoParam()->GetEventSpecie())) ;
1300 if ( qadm->IsCycleDone() ) {
1301 qadm->EndOfCycle() ;
1303 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1304 if (test.Contains("TreeD")) {
1305 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1306 } else if (test.Contains("TreeR")) {
1307 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1308 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1315 //_____________________________________________________________________________
1316 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1318 // take the locasl QA data merge into a single file and save in OCDB
1320 TString tmp(AliQAv1::GetQARefStorage()) ;
1321 if ( tmp.IsNull() ) {
1322 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1325 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1326 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1329 TString sdet(detectors) ;
1332 if ( sdet.Contains("ALL") ) {
1333 rv = Merge(runNumber) ;
1336 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1337 inputFile = TFile::Open(inputFileName.Data()) ;
1338 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1340 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1341 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1342 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1343 inputFile = TFile::Open(inputFileName.Data()) ;
1344 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1351 //_____________________________________________________________________________
1352 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1354 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1356 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1357 if ( ! IsDefaultStorageSet() ) {
1358 TString tmp( AliQAv1::GetQARefStorage() ) ;
1359 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1360 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1362 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1364 tmp1.Append("?user=alidaq") ;
1365 Instance()->SetDefaultStorage(tmp1.Data()) ;
1368 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1370 Instance()->SetRun(runNumber);
1372 AliCDBMetaData mdr ;
1373 mdr.SetResponsible("yves schutz");
1375 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1376 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1378 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1379 AliQAv1::SetQARefDataDirName(es) ;
1380 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1381 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1382 TList * listDetQAD = new TList() ;
1383 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1384 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1385 listDetQAD->SetName(listName) ;
1386 TList * taskList = detDir->GetListOfKeys() ;
1387 TIter nextTask(taskList) ;
1389 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1390 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1391 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1392 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1393 TObjArray * listTaskQAD = new TObjArray(100) ;
1394 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1395 listDetQAD->Add(listTaskQAD) ;
1396 TList * histList = esDir->GetListOfKeys() ;
1397 TIter nextHist(histList) ;
1399 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1400 TObject * odata = esDir->Get(histKey->GetName()) ;
1402 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1404 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1405 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1406 TList * expertHistList = expertDir->GetListOfKeys() ;
1407 TIter nextExpertHist(expertHistList) ;
1408 TKey * expertHistKey ;
1409 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1410 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1411 if ( !expertOdata ) {
1412 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1414 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1415 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1416 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1417 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1418 listTaskQAD->Add(hExpertdata) ;
1423 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1424 if ( odata->IsA()->InheritsFrom("TH1") ) {
1425 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1426 TH1 * hdata = static_cast<TH1*>(odata) ;
1427 listTaskQAD->Add(hdata) ;
1432 Instance()->Put(listDetQAD, idr, &mdr) ;
1438 //_____________________________________________________________________________
1439 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1441 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1443 AliQAv1::Instance()->SetEventSpecie(es) ;
1446 //_____________________________________________________________________________
1447 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1449 // Set custom reconstruction parameters for a given detector
1450 // Single set of parameters for all the events
1451 GetQADataMaker(det)->SetRecoParam(par) ;
1454 //_____________________________________________________________________________
1455 void AliQAManager::SetWriteExpert()
1457 // enable the writing of QA expert data
1458 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1459 if (IsSelected(AliQAv1::GetDetName(iDet)))
1460 fQAWriteExpert[iDet] = kTRUE ;
1464 //_____________________________________________________________________________
1465 void AliQAManager::Destroy() {
1466 // delete AliQAManager instance and
1467 // all associated objects
1470 delete fgQAInstance ;
1471 fgQAInstance = NULL ;
1475 //_____________________________________________________________________________
1476 void AliQAManager::ShowQA() {
1477 // Show the result of the QA checking
1478 // for all detectors
1479 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1480 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;