1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliQAManager.cxx 30894 2009-02-05 13:46:48Z schutz $ */
17 ///////////////////////////////////////////////////////////////////////////////
19 // class for running the QA makers //
21 // AliQAManager qas; //
22 // qas.Run(AliQAv1::kRAWS, rawROOTFileName); //
23 // qas.Run(AliQAv1::kHITS); //
24 // qas.Run(AliQAv1::kSDIGITS); //
25 // qas.Run(AliQAv1::kDIGITS); //
26 // qas.Run(AliQAv1::kRECPOINTS); //
27 // qas.Run(AliQAv1::kESDS); //
29 ///////////////////////////////////////////////////////////////////////////////
34 #include <TFileMerger.h>
36 #include <TGridCollection.h>
37 #include <TGridResult.h>
38 #include <TPluginManager.h>
43 #include "AliCDBManager.h"
44 #include "AliCDBEntry.h"
46 #include "AliCDBMetaData.h"
47 #include "AliCodeTimer.h"
48 #include "AliCorrQADataMakerRec.h"
49 #include "AliDetectorRecoParam.h"
50 #include "AliESDEvent.h"
51 #include "AliGeomManager.h"
52 #include "AliGlobalQADataMaker.h"
53 #include "AliHeader.h"
55 #include "AliModule.h"
57 #include "AliQADataMakerRec.h"
58 #include "AliQADataMakerSim.h"
59 #include "AliQAManager.h"
60 #include "AliRawReaderDate.h"
61 #include "AliRawReaderFile.h"
62 #include "AliRawReaderRoot.h"
64 #include "AliRunLoader.h"
65 #include "AliRunTag.h"
67 ClassImp(AliQAManager)
68 AliQAManager* AliQAManager::fgQAInstance = 0x0;
70 //_____________________________________________________________________________
71 AliQAManager::AliQAManager() :
83 fNumberOfEvents(999999),
87 fRawReaderDelete(kTRUE),
90 fEventSpecie(AliRecoParam::kDefault),
94 fMaxEvents = fNumberOfEvents ;
95 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
96 if (IsSelected(AliQAv1::GetDetName(iDet))) {
97 fLoader[iDet] = NULL ;
98 fQADataMaker[iDet] = NULL ;
99 fQACycles[iDet] = 999999 ;
105 //_____________________________________________________________________________
106 AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
114 fGAliceFileName(gAliceFilename),
118 fNumberOfEvents(999999),
122 fRawReaderDelete(kTRUE),
125 fEventSpecie(AliRecoParam::kDefault),
129 fMaxEvents = fNumberOfEvents ;
130 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
131 if (IsSelected(AliQAv1::GetDetName(iDet))) {
132 fLoader[iDet] = NULL ;
133 fQADataMaker[iDet] = NULL ;
134 fQACycles[iDet] = 999999 ;
139 if (fMode.Contains("sim"))
140 fMode.ReplaceAll("s", "S") ;
141 else if (fMode.Contains("rec"))
142 fMode.ReplaceAll("r", "R") ;
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)
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
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 AliQADataMaker * qadm = GetQADataMaker(detIndex) ;
373 rv = qadm->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
520 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
522 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
523 if (IsSelected(AliQAv1::GetDetName(iDet))) {
524 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
527 // skip non active detectors
529 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
530 if (!det || !det->IsActive())
533 qadm->SetPrintImage(fPrintImage) ;
535 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
536 if ( fTasks.Contains(Form("%d", taskIndex)) )
537 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
544 //_____________________________________________________________________________
545 void AliQAManager::EndOfCycle(TString detectors)
547 // End of cycle QADataMakers
551 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
553 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
554 if (IsSelected(AliQAv1::GetDetName(iDet))) {
555 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
558 // skip non active detectors
559 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
561 qadm->SetPrintImage(fPrintImage) ;
562 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
563 if ( fTasks.Contains(Form("%d", taskIndex)) )
564 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
571 //_____________________________________________________________________________
572 void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
574 // Increments the cycle counter for all QA Data Makers
575 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
576 if (currentTask == taskIndex)
579 currentTask = taskIndex ;
580 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
581 if (IsSelected(AliQAv1::GetDetName(iDet))) {
582 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
589 //_____________________________________________________________________________
590 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
592 // Initialize the event source and QA data makers
594 fTasks += Form("%d", taskIndex) ;
596 if (taskIndex == AliQAv1::kRAWS) {
598 fRawReader = AliRawReader::Create(input);
602 fRawReaderDelete = kTRUE ;
603 fRawReader->NextEvent() ;
604 fRunNumber = fRawReader->GetRunNumber() ;
606 fRawReader->RewindEvents();
607 fNumberOfEvents = 999999 ;
608 if ( fMaxEvents < 0 )
609 fMaxEvents = fNumberOfEvents ;
610 } else if (taskIndex == AliQAv1::kESDS) {
611 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
612 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
613 TFile * esdFile = TFile::Open("AliESDs.root") ;
614 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
616 AliError("esdTree not found") ;
619 fESD = new AliESDEvent() ;
620 fESD->ReadFromTree(fESDTree) ;
621 fESDTree->GetEntry(0) ;
622 fRunNumber = fESD->GetRunNumber() ;
623 fNumberOfEvents = fESDTree->GetEntries() ;
624 if ( fMaxEvents < 0 )
625 fMaxEvents = fNumberOfEvents ;
628 AliError("AliESDs.root not found") ;
632 if ( !InitRunLoader() ) {
633 AliWarning("No Run Loader not found") ;
635 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
636 if ( fMaxEvents < 0 )
637 fMaxEvents = fNumberOfEvents ;
642 TObjArray* detArray = NULL ;
643 if (fRunLoader) // check if RunLoader exists
644 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
645 detArray = fRunLoader->GetAliRun()->Detectors() ;
646 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
649 // Initialize all QA data makers for all detectors
650 fRunNumber = AliCDBManager::Instance()->GetRun() ;
651 if ( ! AliGeomManager::GetGeometry() )
652 AliGeomManager::LoadGeometry() ;
654 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
657 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat())) ;
662 //_____________________________________________________________________________
663 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
665 // Initializes The QADataMaker for all active detectors and for all active tasks
667 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
668 if (IsSelected(AliQAv1::GetDetName(iDet))) {
669 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
671 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
672 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
674 if (fQAWriteExpert[iDet])
675 qadm->SetWriteExpert() ;
676 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
677 // skip non active detectors
679 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
680 if (!det || !det->IsActive())
683 // Set default reco params
684 Bool_t sameCycle = kFALSE ;
685 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
686 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
687 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
688 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
698 //_____________________________________________________________________________
699 Bool_t AliQAManager::InitRunLoader()
701 // get or create the run loader
705 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
706 // load all base libraries to get the loader classes
707 TString libs = gSystem->GetLibraries() ;
708 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
709 if (!IsSelected(AliQAv1::GetDetName(iDet)))
711 TString detName = AliQAv1::GetDetName(iDet) ;
712 if (detName == "HLT")
714 if (libs.Contains("lib" + detName + "base.so"))
716 gSystem->Load("lib" + detName + "base.so");
718 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
720 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
723 fRunLoader->CdGAFile();
724 if (fRunLoader->LoadgAlice() == 0) {
725 gAlice = fRunLoader->GetAliRun();
729 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
733 } else { // galice.root does not exist
734 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
740 fRunLoader->LoadHeader();
741 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
746 //_____________________________________________________________________________
747 Bool_t AliQAManager::IsSelected(const Char_t * det)
749 // check whether detName is contained in detectors
750 // if yes, it is removed from detectors
753 const TString detName(det) ;
754 // always activates Correlation
755 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
758 // check if all detectors are selected
759 if (fDetectors.Contains("ALL")) {
762 } else if ((fDetectors.CompareTo(detName) == 0) ||
763 fDetectors.BeginsWith(detName+" ") ||
764 fDetectors.EndsWith(" "+detName) ||
765 fDetectors.Contains(" "+detName+" ")) {
772 //_____________________________________________________________________________
773 Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
775 // Merge data from all detectors from a given run in one single file
776 // Merge the QA results from all the data chunks in one run
777 // The 'fileName' is name of the output file with merged QA data
778 if ( runNumber == -1)
779 runNumber = fRunNumber ;
780 Bool_t rv = MergeData(runNumber,fileName) ;
781 //rv *= MergeResults(runNumber) ; // not needed for the time being
785 //______________________________________________________________________
786 Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
788 // merges files listed in a xml collection
789 // usage Merge(collection, outputFile))
790 // collection: is a xml collection
794 if ( strstr(collectionFile, ".xml") == 0 ) {
795 AliError("Input collection file must be an \".xml\" file\n") ;
800 TGrid::Connect("alien://");
804 // Open the file collection
805 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
807 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
808 TGridResult* result = collection->GetGridResult("", 0, 0);
811 const Char_t * turl ;
812 TFileMerger merger(kFALSE) ;
814 TString tempo(collectionFile) ;
816 tempo.ReplaceAll(".xml", subFile) ;
818 tempo.ReplaceAll(".xml", "_Merged.root") ;
819 outFile = tempo.Data() ;
821 merger.OutputFile(outFile) ;
823 while ( (turl = result->GetKey(index, "turl")) ) {
826 file = Form("%s#%s", turl, subFile) ;
828 file = Form("%s", turl) ;
830 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
831 merger.AddFile(file) ;
838 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
844 //_____________________________________________________________________________
845 void AliQAManager::MergeCustom() const
847 // Custom Merge of QA data from all detectors for all runs in one single file
848 // search all the run numbers
849 // search all the run numbers
850 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
852 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
855 TIter nextRun(&srunList) ;
856 TObjString * srun = NULL ;
857 Int_t loRun = 999999999 ;
859 while ( QAfile.Gets(QAfiles) ) {
860 Bool_t runExist = kFALSE ;
861 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
862 Int_t cuRun = srunNew.Atoi() ;
867 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
868 if ( cuRun == (srun->String()).Atoi() ) {
875 srunList.Add(new TObjString(srunNew.Data()));
878 Int_t runNumber = 0 ;
879 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
880 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
881 // create the structure into the merged file
882 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
883 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
884 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
886 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
887 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
889 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
891 gDirectory->mkdir(AliQAv1::GetExpert()) ;
895 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
896 runNumber = (srun->String()).Atoi() ;
897 hisRun->Fill(runNumber) ;
898 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
899 // search all QA files for runNumber in the current directory
900 Char_t * fileList[AliQAv1::kNDET] ;
902 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
903 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
905 fileList[index++] = file ;
908 AliError("No QA data file found\n") ;
911 for ( Int_t i = 0 ; i < index ; i++) {
912 TFile * inFile = TFile::Open(fileList[i]) ;
913 TList * listOfKeys =inFile->GetListOfKeys() ;
914 TIter nextkey(listOfKeys) ;
916 TString dirName("") ;
917 while ( (obj1 = nextkey()) ) {
918 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
919 if ( directoryDet ) {
920 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
921 dirName += Form("%s/", directoryDet->GetName() ) ;
923 TList * listOfTasks = directoryDet->GetListOfKeys() ;
924 TIter nextTask(listOfTasks) ;
926 while ( (obj2 = nextTask()) ) {
927 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
928 if ( directoryTask ) {
929 dirName += Form("%s", obj2->GetName()) ;
930 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
931 directoryTask->cd() ;
932 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
933 TIter nextEventSpecie(listOfEventSpecie) ;
935 while ( (obj3 = nextEventSpecie()) ) {
936 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
937 if ( directoryEventSpecie ) {
938 dirName += Form("/%s/", obj3->GetName()) ;
939 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
940 directoryEventSpecie->cd() ;
941 // histograms are here
942 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
943 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
944 TIter nextData(listOfData) ;
946 while ( (key = static_cast<TKey *>(nextData())) ) {
947 TString className(key->GetClassName()) ;
948 if ( className.Contains("TH") || className.Contains("TProfile") ) {
949 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
950 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
951 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
952 mergedDirectory->cd() ;
956 histOu->Add(histIn) ;
957 histOu->Write(histOu->GetName(), kOverwrite) ;
960 else if ( className.Contains("TDirectoryFile") ) {
961 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
963 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
964 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
965 TIter nextExpertData(listOfExpertData) ;
967 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
968 TString classNameExpert(keykey->GetClassName()) ;
969 if (classNameExpert.Contains("TH")) {
970 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
971 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
972 mergedDirectoryExpert->cd() ;
973 if ( ! histOuExpert ) {
974 histInExpert->Write() ;
976 histOuExpert->Add(histInExpert) ;
977 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
982 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
985 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
988 dirName.ReplaceAll(obj2->GetName(), "") ;
1002 //_____________________________________________________________________________
1003 Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
1005 // Merge QA data from all detectors for a given run in one single file
1007 TFileMerger merger(kFALSE) ;
1008 TString outFileName = fileName;
1009 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
1010 merger.OutputFile(outFileName.Data()) ;
1011 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1012 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
1014 merger.AddFile(file) ;
1020 //_____________________________________________________________________________
1021 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1023 // Merge the QA result from all the data chunks in a run
1024 // to be revised whwn it will be used (see MergeData)
1026 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1027 gROOT->ProcessLine(cmd.Data()) ;
1028 ifstream in("tempo.txt") ;
1029 const Int_t chunkMax = 100 ;
1030 TString fileList[chunkMax] ;
1035 in >> fileList[index] ;
1038 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1043 AliError("No QA Result File found") ;
1047 TFileMerger merger ;
1048 TString outFileName ;
1049 if (runNumber != -1)
1050 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
1052 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
1053 merger.OutputFile(outFileName.Data()) ;
1054 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1055 TString file = fileList[ifile] ;
1056 merger.AddFile(file) ;
1063 //_____________________________________________________________________________
1064 void AliQAManager::Reset(const Bool_t sameCycle)
1066 // Reset the default data members
1068 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1069 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1070 AliQADataMaker * qadm = GetQADataMaker(iDet);
1074 if (fRawReaderDelete) {
1079 fCycleSame = sameCycle ;
1083 fNumberOfEvents = 999999 ;
1086 //_____________________________________________________________________________
1087 AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, Int_t run)
1089 // returns AliQAManager instance (singleton)
1091 if (!fgQAInstance) {
1092 if ( (strcmp(mode, "sim") != 0) && (strcmp(mode, "rec") != 0) ) {
1093 AliErrorClass("You must specify sim or rec") ;
1096 fgQAInstance = new AliQAManager(mode) ;
1098 fgQAInstance->Init();
1100 fgQAInstance->InitFromCache(entryCache,run);
1102 return fgQAInstance;
1105 //_____________________________________________________________________________
1106 AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1108 // returns AliQAManager instance (singleton)
1110 case AliQAv1::kRAWS:
1111 return QAManager("rec") ;
1113 case AliQAv1::kHITS:
1114 return QAManager("sim") ;
1116 case AliQAv1::kSDIGITS:
1117 return QAManager("sim") ;
1119 case AliQAv1::kDIGITS:
1120 return QAManager("sim") ;
1122 case AliQAv1::kDIGITSR:
1123 return QAManager("rec") ;
1125 case AliQAv1::kRECPOINTS:
1126 return QAManager("rec") ;
1127 case AliQAv1::kTRACKSEGMENTS:
1130 case AliQAv1::kRECPARTICLES:
1133 case AliQAv1::kESDS:
1134 return QAManager("rec") ;
1142 //_____________________________________________________________________________
1143 TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1145 //Runs all the QA data Maker for Raws only
1147 fCycleSame = sameCycle ;
1148 fRawReader = rawReader ;
1149 fDetectors = detectors ;
1150 fDetectorsW = detectors ;
1152 AliCDBManager* man = AliCDBManager::Instance() ;
1154 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1155 rawReader->NextEvent() ;
1156 man->SetRun(fRawReader->GetRunNumber()) ;
1157 rawReader->RewindEvents() ;
1161 if ( !InitQA(AliQAv1::kRAWS) )
1163 fRawReaderDelete = kFALSE ;
1165 DoIt(AliQAv1::kRAWS) ;
1166 return fDetectorsW ;
1169 //_____________________________________________________________________________
1170 TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
1172 //Runs all the QA data Maker for Raws only
1174 fCycleSame = sameCycle ;
1175 fDetectors = detectors ;
1176 fDetectorsW = detectors ;
1178 AliCDBManager* man = AliCDBManager::Instance() ;
1179 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1180 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1182 AliFatal("galice.root file not found in current directory") ;
1186 if ( ! rl->GetAliRun() ) {
1187 AliFatal("AliRun not found in galice.root") ;
1190 man->SetRun(rl->GetHeader()->GetRun());
1196 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1199 DoIt(AliQAv1::kRAWS) ;
1200 return fDetectorsW ;
1203 //_____________________________________________________________________________
1204 TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
1206 // Runs all the QA data Maker for every detector
1208 fCycleSame = sameCycle ;
1209 fDetectors = detectors ;
1210 fDetectorsW = detectors ;
1212 AliCDBManager* man = AliCDBManager::Instance() ;
1213 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1214 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1216 AliFatal("galice.root file not found in current directory") ;
1220 if ( ! rl->GetAliRun() ) {
1221 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1224 man->SetRun(rl->GetHeader()->GetRun()) ;
1228 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1229 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1230 if ( fTasks.Contains(Form("%d", task)) ) {
1232 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1234 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1239 if ( !InitQA(taskIndex, fileName) )
1243 return fDetectorsW ;
1246 //_____________________________________________________________________________
1247 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1249 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1252 AliCodeTimerAuto("") ;
1253 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1254 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1255 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1257 AliQADataMaker *qadm = GetQADataMaker(iDet);
1260 if ( qadm->IsCycleDone() ) {
1261 qadm->EndOfCycle() ;
1263 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1264 qadm->SetEventSpecie(fEventSpecie) ;
1265 if ( qadm->GetRecoParam() )
1266 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1267 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1268 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1269 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1274 //_____________________________________________________________________________
1275 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1277 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1279 AliCodeTimerAuto("") ;
1280 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1281 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1282 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1284 AliQADataMaker *qadm = GetQADataMaker(iDet);
1287 qadm->SetEventSpecie(fEventSpecie) ;
1288 if ( qadm->GetRecoParam() )
1289 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1290 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1291 if ( qadm->IsCycleDone() ) {
1292 qadm->EndOfCycle() ;
1294 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1295 qadm->Exec(AliQAv1::kESDS, esd) ;
1296 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1301 //_____________________________________________________________________________
1302 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1304 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1306 TString test(tree->GetName()) ;
1307 AliCodeTimerAuto("") ;
1308 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1309 if (IsSelected(AliQAv1::GetDetName(det))) {
1310 AliQADataMaker *qadm = GetQADataMaker(det);
1312 qadm->SetEventSpecie(fEventSpecie) ;
1313 if ( qadm->GetRecoParam() )
1314 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
1315 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1316 if ( qadm->IsCycleDone() ) {
1317 qadm->EndOfCycle() ;
1319 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1320 if (test.Contains("TreeD")) {
1321 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
1322 } else if (test.Contains("TreeR")) {
1323 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1324 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1331 //_____________________________________________________________________________
1332 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
1334 // take the locasl QA data merge into a single file and save in OCDB
1336 TString tmp(AliQAv1::GetQARefStorage()) ;
1337 if ( tmp.IsNull() ) {
1338 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1341 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1342 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1345 TString sdet(detectors) ;
1348 if ( sdet.Contains("ALL") ) {
1349 rv = Merge(runNumber) ;
1352 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1353 inputFile = TFile::Open(inputFileName.Data()) ;
1354 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1356 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1357 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1358 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1359 inputFile = TFile::Open(inputFileName.Data()) ;
1360 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1367 //_____________________________________________________________________________
1368 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
1370 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1372 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1373 if ( ! IsDefaultStorageSet() ) {
1374 TString tmp( AliQAv1::GetQARefStorage() ) ;
1375 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1376 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1378 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1380 tmp1.Append("?user=alidaq") ;
1381 Instance()->SetDefaultStorage(tmp1.Data()) ;
1384 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1386 Instance()->SetRun(runNumber);
1388 AliCDBMetaData mdr ;
1389 mdr.SetResponsible("yves schutz");
1391 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1392 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1394 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1395 AliQAv1::SetQARefDataDirName(es) ;
1396 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1397 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1398 TList * listDetQAD = new TList() ;
1399 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1400 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1401 listDetQAD->SetName(listName) ;
1402 TList * taskList = detDir->GetListOfKeys() ;
1403 TIter nextTask(taskList) ;
1405 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1406 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1407 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1408 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1409 TObjArray * listTaskQAD = new TObjArray(100) ;
1410 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1411 listDetQAD->Add(listTaskQAD) ;
1412 TList * histList = esDir->GetListOfKeys() ;
1413 TIter nextHist(histList) ;
1415 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1416 TObject * odata = esDir->Get(histKey->GetName()) ;
1418 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1420 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1421 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1422 TList * expertHistList = expertDir->GetListOfKeys() ;
1423 TIter nextExpertHist(expertHistList) ;
1424 TKey * expertHistKey ;
1425 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1426 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1427 if ( !expertOdata ) {
1428 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1430 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1431 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1432 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1433 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1434 listTaskQAD->Add(hExpertdata) ;
1439 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1440 if ( odata->IsA()->InheritsFrom("TH1") ) {
1441 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1442 TH1 * hdata = static_cast<TH1*>(odata) ;
1443 listTaskQAD->Add(hdata) ;
1448 Instance()->Put(listDetQAD, idr, &mdr) ;
1454 //_____________________________________________________________________________
1455 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1457 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1459 AliQAv1::Instance()->SetEventSpecie(es) ;
1462 //_____________________________________________________________________________
1463 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1465 // Set custom reconstruction parameters for a given detector
1466 // Single set of parameters for all the events
1467 GetQADataMaker(det)->SetRecoParam(par) ;
1470 //_____________________________________________________________________________
1471 void AliQAManager::SetWriteExpert()
1473 // enable the writing of QA expert data
1474 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1475 if (IsSelected(AliQAv1::GetDetName(iDet)))
1476 fQAWriteExpert[iDet] = kTRUE ;
1480 //_____________________________________________________________________________
1481 void AliQAManager::Destroy() {
1482 // delete AliQAManager instance and
1483 // all associated objects
1486 delete fgQAInstance ;
1487 fgQAInstance = NULL ;
1491 //_____________________________________________________________________________
1492 void AliQAManager::ShowQA() {
1493 // Show the result of the QA checking
1494 // for all detectors
1495 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1496 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;