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::kHLT ) {
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())) ;
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())
545 qac->SetPrintImage(fPrintImage) ;
548 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
549 if ( fTasks.Contains(Form("%d", taskIndex)) )
550 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
558 //_____________________________________________________________________________
559 void AliQAManager::EndOfCycle(TString detectors)
561 // End of cycle QADataMakers
563 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
566 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
568 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
569 if (IsSelected(AliQAv1::GetDetName(iDet))) {
570 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
571 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
574 // skip non active detectors
575 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
577 qac->SetPrintImage(fPrintImage) ;
579 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
580 if ( fTasks.Contains(Form("%d", taskIndex)) )
581 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
589 //_____________________________________________________________________________
590 void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
592 // Increments the cycle counter for all QA Data Makers
593 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
594 if (currentTask == taskIndex)
597 currentTask = taskIndex ;
598 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
599 if (IsSelected(AliQAv1::GetDetName(iDet))) {
600 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
607 //_____________________________________________________________________________
608 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
610 // Initialize the event source and QA data makers
612 fTasks += Form("%d", taskIndex) ;
614 if (taskIndex == AliQAv1::kRAWS) {
616 fRawReader = AliRawReader::Create(input);
620 fRawReaderDelete = kTRUE ;
621 fRawReader->NextEvent() ;
622 fRunNumber = fRawReader->GetRunNumber() ;
624 fRawReader->RewindEvents();
625 fNumberOfEvents = 999999 ;
626 if ( fMaxEvents < 0 )
627 fMaxEvents = fNumberOfEvents ;
628 } else if (taskIndex == AliQAv1::kESDS) {
629 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
630 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
631 TFile * esdFile = TFile::Open("AliESDs.root") ;
632 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
634 AliError("esdTree not found") ;
637 fESD = new AliESDEvent() ;
638 fESD->ReadFromTree(fESDTree) ;
639 fESDTree->GetEntry(0) ;
640 fRunNumber = fESD->GetRunNumber() ;
641 fNumberOfEvents = fESDTree->GetEntries() ;
642 if ( fMaxEvents < 0 )
643 fMaxEvents = fNumberOfEvents ;
646 AliError("AliESDs.root not found") ;
650 if ( !InitRunLoader() ) {
651 AliWarning("No Run Loader not found") ;
653 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
654 if ( fMaxEvents < 0 )
655 fMaxEvents = fNumberOfEvents ;
660 TObjArray* detArray = NULL ;
661 if (fRunLoader) // check if RunLoader exists
662 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
663 detArray = fRunLoader->GetAliRun()->Detectors() ;
664 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
667 // Initialize all QA data makers for all detectors
668 fRunNumber = AliCDBManager::Instance()->GetRun() ;
669 if ( ! AliGeomManager::GetGeometry() )
670 AliGeomManager::LoadGeometry() ;
672 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
677 while (timer.CpuTime()<5) {
679 gSystem->ProcessEvents();
681 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
686 //_____________________________________________________________________________
687 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
689 // Initializes The QADataMaker for all active detectors and for all active tasks
691 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
692 if (IsSelected(AliQAv1::GetDetName(iDet))) {
693 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
695 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
696 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
698 if (fQAWriteExpert[iDet])
699 qadm->SetWriteExpert() ;
700 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
701 // skip non active detectors
703 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
704 if (!det || !det->IsActive())
707 // Set default reco params
708 Bool_t sameCycle = kFALSE ;
709 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
710 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
711 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
712 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
722 //_____________________________________________________________________________
723 Bool_t AliQAManager::InitRunLoader()
725 // get or create the run loader
729 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
730 // load all base libraries to get the loader classes
731 TString libs = gSystem->GetLibraries() ;
732 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
733 if (!IsSelected(AliQAv1::GetDetName(iDet)))
735 TString detName = AliQAv1::GetDetName(iDet) ;
736 if (detName == "HLT")
738 if (libs.Contains("lib" + detName + "base.so"))
740 gSystem->Load("lib" + detName + "base.so");
742 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
744 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
747 fRunLoader->CdGAFile();
748 if (fRunLoader->LoadgAlice() == 0) {
749 gAlice = fRunLoader->GetAliRun();
753 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
757 } else { // galice.root does not exist
758 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
764 fRunLoader->LoadHeader();
765 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
770 //_____________________________________________________________________________
771 Bool_t AliQAManager::IsSelected(const Char_t * det)
773 // check whether detName is contained in detectors
774 // if yes, it is removed from detectors
777 const TString detName(det) ;
778 // always activates Correlation
779 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
782 // check if all detectors are selected
783 if (fDetectors.Contains("ALL")) {
786 } else if ((fDetectors.CompareTo(detName) == 0) ||
787 fDetectors.BeginsWith(detName+" ") ||
788 fDetectors.EndsWith(" "+detName) ||
789 fDetectors.Contains(" "+detName+" ")) {
796 //_____________________________________________________________________________
797 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
799 // Merge data from all detectors from a given run in one single file
800 // Merge the QA results from all the data chunks in one run
801 // The 'fileName' is name of the output file with merged QA data
802 if ( runNumber == -1)
803 runNumber = fRunNumber ;
804 Bool_t rv = MergeData(runNumber,fileName) ;
805 //rv *= MergeResults(runNumber) ; // not needed for the time being
809 //______________________________________________________________________
810 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
812 // merges files listed in a xml collection
813 // usage Merge(collection, outputFile))
814 // collection: is a xml collection
818 if ( strstr(collectionFile, ".xml") == 0 ) {
819 AliError("Input collection file must be an \".xml\" file\n") ;
824 TGrid::Connect("alien://");
828 // Open the file collection
829 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
831 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
832 TGridResult* result = collection->GetGridResult("", 0, 0);
835 const Char_t * turl ;
836 TFileMerger merger(kFALSE) ;
838 TString tempo(collectionFile) ;
840 tempo.ReplaceAll(".xml", subFile) ;
842 tempo.ReplaceAll(".xml", "_Merged.root") ;
843 outFile = tempo.Data() ;
845 merger.OutputFile(outFile) ;
847 while ( (turl = result->GetKey(index, "turl")) ) {
850 file = Form("%s#%s", turl, subFile) ;
852 file = Form("%s", turl) ;
854 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
855 merger.AddFile(file) ;
862 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
868 //_____________________________________________________________________________
869 void AliQAManager::MergeCustom() const
871 // Custom Merge of QA data from all detectors for all runs in one single file
872 // search all the run numbers
873 // search all the run numbers
874 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
876 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
879 TIter nextRun(&srunList) ;
880 TObjString * srun = NULL ;
881 Int_t loRun = 999999999 ;
883 while ( QAfile.Gets(QAfiles) ) {
884 Bool_t runExist = kFALSE ;
885 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
886 Int_t cuRun = srunNew.Atoi() ;
891 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
892 if ( cuRun == (srun->String()).Atoi() ) {
899 srunList.Add(new TObjString(srunNew.Data()));
902 Int_t runNumber = 0 ;
903 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
904 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
905 // create the structure into the merged file
906 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
907 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
908 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
910 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
911 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
913 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
915 gDirectory->mkdir(AliQAv1::GetExpert()) ;
919 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
920 runNumber = (srun->String()).Atoi() ;
921 hisRun->Fill(runNumber) ;
922 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
923 // search all QA files for runNumber in the current directory
924 Char_t * fileList[AliQAv1::kNDET] ;
926 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
927 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
929 fileList[index++] = file ;
932 AliError("No QA data file found\n") ;
935 for ( Int_t i = 0 ; i < index ; i++) {
936 TFile * inFile = TFile::Open(fileList[i]) ;
937 TList * listOfKeys =inFile->GetListOfKeys() ;
938 TIter nextkey(listOfKeys) ;
940 TString dirName("") ;
941 while ( (obj1 = nextkey()) ) {
942 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
943 if ( directoryDet ) {
944 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
945 dirName += Form("%s/", directoryDet->GetName() ) ;
947 TList * listOfTasks = directoryDet->GetListOfKeys() ;
948 TIter nextTask(listOfTasks) ;
950 while ( (obj2 = nextTask()) ) {
951 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
952 if ( directoryTask ) {
953 dirName += Form("%s", obj2->GetName()) ;
954 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
955 directoryTask->cd() ;
956 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
957 TIter nextEventSpecie(listOfEventSpecie) ;
959 while ( (obj3 = nextEventSpecie()) ) {
960 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
961 if ( directoryEventSpecie ) {
962 dirName += Form("/%s/", obj3->GetName()) ;
963 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
964 directoryEventSpecie->cd() ;
965 // histograms are here
966 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
967 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
968 TIter nextData(listOfData) ;
970 while ( (key = static_cast<TKey *>(nextData())) ) {
971 TString className(key->GetClassName()) ;
972 if ( className.Contains("TH") || className.Contains("TProfile") ) {
973 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
974 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
975 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
976 mergedDirectory->cd() ;
980 histOu->Add(histIn) ;
981 histOu->Write(histOu->GetName(), kOverwrite) ;
984 else if ( className.Contains("TDirectoryFile") ) {
985 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
987 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
988 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
989 TIter nextExpertData(listOfExpertData) ;
991 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
992 TString classNameExpert(keykey->GetClassName()) ;
993 if (classNameExpert.Contains("TH")) {
994 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
995 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
996 mergedDirectoryExpert->cd() ;
997 if ( ! histOuExpert ) {
998 histInExpert->Write() ;
1000 histOuExpert->Add(histInExpert) ;
1001 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
1006 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
1009 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
1012 dirName.ReplaceAll(obj2->GetName(), "") ;
1022 mergedFile.Close() ;
1026 //_____________________________________________________________________________
1027 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
1029 // Merge QA data from all detectors for a given run in one single file
1031 TFileMerger merger(kFALSE) ;
1032 TString outFileName = fileName;
1033 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1034 merger.OutputFile(outFileName.Data()) ;
1035 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1036 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1038 merger.AddFile(file) ;
1044 //_____________________________________________________________________________
1045 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1047 // Merge the QA result from all the data chunks in a run
1048 // to be revised whwn it will be used (see MergeData)
1050 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1051 gROOT->ProcessLine(cmd.Data()) ;
1052 ifstream in("tempo.txt") ;
1053 const Int_t chunkMax = 100 ;
1054 TString fileList[chunkMax] ;
1059 in >> fileList[index] ;
1062 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1067 AliError("No QA Result File found") ;
1071 TFileMerger merger ;
1072 TString outFileName ;
1073 if (runNumber != -1)
1074 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1076 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1077 merger.OutputFile(outFileName.Data()) ;
1078 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1079 TString file = fileList[ifile] ;
1080 merger.AddFile(file) ;
1087 //_____________________________________________________________________________
1088 void AliQAManager::Reset(const Bool_t sameCycle)
1090 // Reset the default data members
1092 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1093 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1094 AliQADataMaker * qadm = GetQADataMaker(iDet);
1098 if (fRawReaderDelete) {
1103 fCycleSame = sameCycle ;
1107 fNumberOfEvents = 999999 ;
1110 //_____________________________________________________________________________
1111 AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run)
1113 // returns AliQAManager instance (singleton)
1115 if (!fgQAInstance) {
1116 if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) ) {
1117 AliErrorClass("You must specify kSIMMODE or kRECMODE") ;
1120 fgQAInstance = new AliQAManager(mode) ;
1122 fgQAInstance->Init();
1124 fgQAInstance->InitFromCache(entryCache,run);
1126 return fgQAInstance;
1129 //_____________________________________________________________________________
1130 AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1132 // returns AliQAManager instance (singleton)
1133 return QAManager(AliQAv1::Mode(task)) ;
1136 //_____________________________________________________________________________
1137 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1139 //Runs all the QA data Maker for Raws only
1141 fCycleSame = sameCycle ;
1142 fRawReader = rawReader ;
1143 fDetectors = detectors ;
1144 fDetectorsW = detectors ;
1146 AliCDBManager* man = AliCDBManager::Instance() ;
1148 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1149 rawReader->NextEvent() ;
1150 man->SetRun(fRawReader->GetRunNumber()) ;
1151 rawReader->RewindEvents() ;
1155 if ( !InitQA(AliQAv1::kRAWS) )
1157 fRawReaderDelete = kFALSE ;
1159 DoIt(AliQAv1::kRAWS) ;
1160 return fDetectorsW ;
1163 //_____________________________________________________________________________
1164 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1166 //Runs all the QA data Maker for Raws only
1168 fCycleSame = sameCycle ;
1169 fDetectors = detectors ;
1170 fDetectorsW = detectors ;
1172 AliCDBManager* man = AliCDBManager::Instance() ;
1173 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1174 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1176 AliFatal("galice.root file not found in current directory") ;
1180 if ( ! rl->GetAliRun() ) {
1181 AliFatal("AliRun not found in galice.root") ;
1184 man->SetRun(rl->GetHeader()->GetRun());
1190 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1193 DoIt(AliQAv1::kRAWS) ;
1194 return fDetectorsW ;
1197 //_____________________________________________________________________________
1198 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1200 // Runs all the QA data Maker for every detector
1202 fCycleSame = sameCycle ;
1203 fDetectors = detectors ;
1204 fDetectorsW = detectors ;
1206 AliCDBManager* man = AliCDBManager::Instance() ;
1207 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1208 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1210 AliFatal("galice.root file not found in current directory") ;
1214 if ( ! rl->GetAliRun() ) {
1215 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1218 man->SetRun(rl->GetHeader()->GetRun()) ;
1222 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1223 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1224 if ( fTasks.Contains(Form("%d", task)) ) {
1226 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1228 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1233 if ( !InitQA(taskIndex, fileName) )
1237 return fDetectorsW ;
1240 //_____________________________________________________________________________
1241 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1243 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1246 AliCodeTimerAuto("",0) ;
1247 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1248 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1249 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1251 AliQADataMaker *qadm = GetQADataMaker(iDet);
1254 if ( qadm->IsCycleDone() ) {
1255 qadm->EndOfCycle() ;
1257 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1258 qadm->SetEventSpecie(fEventSpecie) ;
1259 if ( qadm->GetRecoParam() )
1260 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1261 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1262 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1263 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1268 //_____________________________________________________________________________
1269 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1271 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1273 AliCodeTimerAuto("",0) ;
1274 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1275 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1276 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1278 AliQADataMaker *qadm = GetQADataMaker(iDet);
1281 qadm->SetEventSpecie(fEventSpecie) ;
1282 if ( qadm->GetRecoParam() )
1283 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1284 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1285 if ( qadm->IsCycleDone() ) {
1286 qadm->EndOfCycle() ;
1288 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1289 qadm->Exec(AliQAv1::kESDS, esd) ;
1290 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1295 //_____________________________________________________________________________
1296 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1298 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1300 TString test(tree->GetName()) ;
1301 AliCodeTimerAuto("",0) ;
1302 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1303 if (IsSelected(AliQAv1::GetDetName(det))) {
1304 AliQADataMaker *qadm = GetQADataMaker(det);
1306 qadm->SetEventSpecie(fEventSpecie) ;
1307 if ( qadm->GetRecoParam() ) {
1308 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1309 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1311 AliError(Form("%d defined by %s is not an event specie", qadm->GetRecoParam()->GetEventSpecie(), qadm->GetName())) ;
1313 if ( qadm->IsCycleDone() ) {
1314 qadm->EndOfCycle() ;
1316 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1317 if (test.Contains("TreeD")) {
1318 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1319 } else if (test.Contains("TreeR")) {
1320 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1321 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1328 //_____________________________________________________________________________
1329 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1331 // take the locasl QA data merge into a single file and save in OCDB
1333 TString tmp(AliQAv1::GetQARefStorage()) ;
1334 if ( tmp.IsNull() ) {
1335 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1338 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1339 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1342 TString sdet(detectors) ;
1345 if ( sdet.Contains("ALL") ) {
1346 rv = Merge(runNumber) ;
1349 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1350 inputFile = TFile::Open(inputFileName.Data()) ;
1351 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1353 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1354 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1355 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1356 inputFile = TFile::Open(inputFileName.Data()) ;
1357 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1364 //_____________________________________________________________________________
1365 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1367 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1369 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1370 if ( ! IsDefaultStorageSet() ) {
1371 TString tmp( AliQAv1::GetQARefStorage() ) ;
1372 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1373 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1375 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1377 tmp1.Append("?user=alidaq") ;
1378 Instance()->SetDefaultStorage(tmp1.Data()) ;
1381 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1383 Instance()->SetRun(runNumber);
1385 AliCDBMetaData mdr ;
1386 mdr.SetResponsible("yves schutz");
1388 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1389 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1391 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1392 AliQAv1::SetQARefDataDirName(es) ;
1393 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1394 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1395 TList * listDetQAD = new TList() ;
1396 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1397 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1398 listDetQAD->SetName(listName) ;
1399 TList * taskList = detDir->GetListOfKeys() ;
1400 TIter nextTask(taskList) ;
1402 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1403 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1404 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1405 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1406 TObjArray * listTaskQAD = new TObjArray(100) ;
1407 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1408 listDetQAD->Add(listTaskQAD) ;
1409 TList * histList = esDir->GetListOfKeys() ;
1410 TIter nextHist(histList) ;
1412 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1413 TObject * odata = esDir->Get(histKey->GetName()) ;
1415 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1417 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1418 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1419 TList * expertHistList = expertDir->GetListOfKeys() ;
1420 TIter nextExpertHist(expertHistList) ;
1421 TKey * expertHistKey ;
1422 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1423 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1424 if ( !expertOdata ) {
1425 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1427 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1428 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1429 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1430 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1431 listTaskQAD->Add(hExpertdata) ;
1436 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1437 if ( odata->IsA()->InheritsFrom("TH1") ) {
1438 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1439 TH1 * hdata = static_cast<TH1*>(odata) ;
1440 listTaskQAD->Add(hdata) ;
1445 Instance()->Put(listDetQAD, idr, &mdr) ;
1451 //_____________________________________________________________________________
1453 void AliQAManager::SetCheckerExternParam(AliQAv1::DETECTORINDEX_t detIndex, TList * parameterList)
1455 // set the external parameters list for the detector checkers
1456 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
1457 qac->SetExternParamlist(parameterList) ;
1458 qac->PrintExternParam() ;
1461 //_____________________________________________________________________________
1462 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1464 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1466 AliQAv1::Instance()->SetEventSpecie(es) ;
1469 //_____________________________________________________________________________
1470 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1472 // Set custom reconstruction parameters for a given detector
1473 // Single set of parameters for all the events
1474 GetQADataMaker(det)->SetRecoParam(par) ;
1477 //_____________________________________________________________________________
1478 void AliQAManager::SetWriteExpert()
1480 // enable the writing of QA expert data
1481 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1482 if (IsSelected(AliQAv1::GetDetName(iDet)))
1483 fQAWriteExpert[iDet] = kTRUE ;
1487 //_____________________________________________________________________________
1488 void AliQAManager::Destroy() {
1489 // delete AliQAManager instance and
1490 // all associated objects
1493 delete fgQAInstance ;
1494 fgQAInstance = NULL ;
1498 //_____________________________________________________________________________
1499 void AliQAManager::ShowQA() {
1500 // Show the result of the QA checking
1501 // for all detectors
1502 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1503 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;