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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // class for running the QA makers //
21 // AliQADataMakerSteer qas; //
22 // qas.Run(AliQA::kRAWS, rawROOTFileName); //
23 // qas.Run(AliQA::kHITS); //
24 // qas.Run(AliQA::kSDIGITS); //
25 // qas.Run(AliQA::kDIGITS); //
26 // qas.Run(AliQA::kRECPOINTS); //
27 // qas.Run(AliQA::kESDS); //
29 ///////////////////////////////////////////////////////////////////////////////
33 #include <TFileMerger.h>
34 #include <TPluginManager.h>
39 #include "AliCDBManager.h"
40 #include "AliCDBEntry.h"
42 #include "AliCDBMetaData.h"
43 #include "AliCodeTimer.h"
44 #include "AliDetectorRecoParam.h"
45 #include "AliESDEvent.h"
46 #include "AliGeomManager.h"
47 #include "AliGlobalQADataMaker.h"
48 #include "AliHeader.h"
50 #include "AliModule.h"
52 #include "AliQADataMakerRec.h"
53 #include "AliQADataMakerSim.h"
54 #include "AliQADataMakerSteer.h"
55 #include "AliRawReaderDate.h"
56 #include "AliRawReaderFile.h"
57 #include "AliRawReaderRoot.h"
59 #include "AliRunLoader.h"
61 ClassImp(AliQADataMakerSteer)
63 //_____________________________________________________________________________
64 AliQADataMakerSteer::AliQADataMakerSteer(char * mode, const char* gAliceFilename, const char * name, const char * title) :
72 fGAliceFileName(gAliceFilename),
76 fNumberOfEvents(999999),
80 fRawReaderDelete(kTRUE),
85 fMaxEvents = fNumberOfEvents ;
86 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
87 if (IsSelected(AliQA::GetDetName(iDet))) {
88 fLoader[iDet] = NULL ;
89 fQADataMaker[iDet] = NULL ;
90 fQACycles[iDet] = 999999 ;
95 //_____________________________________________________________________________
96 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
98 fCurrentEvent(qas.fCurrentEvent),
100 fDetectors(qas.fDetectors),
101 fDetectorsW(qas.fDetectorsW),
104 fGAliceFileName(qas.fGAliceFileName),
105 fFirstEvent(qas.fFirstEvent),
106 fMaxEvents(qas.fMaxEvents),
108 fNumberOfEvents(qas.fNumberOfEvents),
110 fRunNumber(qas.fRunNumber),
112 fRawReaderDelete(kTRUE),
117 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
118 fLoader[iDet] = qas.fLoader[iDet] ;
119 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
120 fQACycles[iDet] = qas.fQACycles[iDet] ;
124 //_____________________________________________________________________________
125 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
127 // assignment operator
128 this->~AliQADataMakerSteer() ;
129 new(this) AliQADataMakerSteer(qas) ;
133 //_____________________________________________________________________________
134 AliQADataMakerSteer::~AliQADataMakerSteer()
137 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
138 if (IsSelected(AliQA::GetDetName(iDet))) {
139 fLoader[iDet] = NULL;
140 if (fQADataMaker[iDet]) {
141 (fQADataMaker[iDet])->Finish() ;
142 delete fQADataMaker[iDet] ;
146 if (fRawReaderDelete) {
153 //_____________________________________________________________________________
154 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
156 // Runs all the QA data Maker for every detector
159 // Fill QA data in event loop
160 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
163 if ( iEvent%10 == 0 )
164 AliInfo(Form("processing event %d", iEvent));
165 if ( taskIndex == AliQA::kRAWS ) {
166 if ( !fRawReader->NextEvent() )
168 } else if ( taskIndex == AliQA::kESDS ) {
169 if ( fESDTree->GetEntry(iEvent) == 0 )
172 if ( fRunLoader->GetEvent(iEvent) != 0 )
175 // loop over active loaders
176 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
177 if (IsSelected(AliQA::GetDetName(iDet))) {
178 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
179 if ( qadm->IsCycleDone() ) {
180 qadm->EndOfCycle(AliQA::kRAWS) ;
181 qadm->StartOfCycle(AliQA::kRAWS) ;
184 AliLoader* loader = GetLoader(qadm->GetUniqueID());
186 case AliQA::kNULLTASKINDEX :
189 qadm->Exec(taskIndex, fRawReader) ;
193 data = loader->TreeH() ;
195 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
197 qadm->Exec(taskIndex, data) ;
200 case AliQA::kSDIGITS :
201 loader->LoadSDigits() ;
202 data = loader->TreeS() ;
204 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
206 qadm->Exec(taskIndex, data) ;
209 case AliQA::kDIGITS :
210 loader->LoadDigits() ;
211 data = loader->TreeD() ;
213 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
215 qadm->Exec(taskIndex, data) ;
218 case AliQA::kRECPOINTS :
219 loader->LoadRecPoints() ;
220 data = loader->TreeR() ;
222 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
224 qadm->Exec(taskIndex, data) ;
227 case AliQA::kTRACKSEGMENTS :
229 case AliQA::kRECPARTICLES :
232 qadm->Exec(taskIndex, fESD) ;
234 case AliQA::kNTASKINDEX :
240 // Save QA data for all detectors
241 rv = Finish(taskIndex) ;
243 if ( taskIndex == AliQA::kRAWS )
244 fRawReader->RewindEvents() ;
249 //_____________________________________________________________________________
250 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
252 // write output to file for all detectors
253 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
254 if (IsSelected(AliQA::GetDetName(iDet))) {
255 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
256 qadm->EndOfCycle(taskIndex) ;
262 //_____________________________________________________________________________
263 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
265 // Retrieve the list of QA data for a given detector and a given task
266 TObjArray * rv = NULL ;
267 if ( !strlen(AliQA::GetQARefStorage()) ) {
268 AliError("No storage defined, use AliQA::SetQARefStorage") ;
271 AliCDBManager* man = AliCDBManager::Instance() ;
272 if ( ! man->IsDefaultStorageSet() ) {
273 TString tmp(AliQA::GetQARefDefaultStorage()) ;
276 man->SetDefaultStorage(tmp.Data()) ;
277 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
279 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
280 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
281 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
282 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
284 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
288 //_____________________________________________________________________________
289 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
291 // get the loader for a detector
296 TString detName = AliQA::GetDetName(iDet) ;
297 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
299 return fLoader[iDet] ;
301 // load the QA data maker object
302 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
303 TString loaderName = "Ali" + detName + "Loader" ;
305 AliLoader * loader = NULL ;
306 // first check if a plugin is defined for the quality assurance data maker
307 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
308 // if not, add a plugin for it
309 if (!pluginHandler) {
310 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
311 TString libs = gSystem->GetLibraries() ;
312 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
313 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
315 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
317 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
319 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
320 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
323 fLoader[iDet] = loader ;
327 //_____________________________________________________________________________
328 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
330 // get the quality assurance data maker for a detector
332 if (fQADataMaker[iDet])
333 return fQADataMaker[iDet] ;
335 AliQADataMaker * qadm = NULL ;
337 if (iDet == AliQA::kGLOBAL) { //Global QA
338 qadm = new AliGlobalQADataMaker();
339 fQADataMaker[iDet] = qadm;
343 // load the QA data maker object
344 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
345 TString detName = AliQA::GetDetName(iDet) ;
347 if (tmp.Contains("sim"))
348 tmp.ReplaceAll("s", "S") ;
349 else if (tmp.Contains("rec"))
350 tmp.ReplaceAll("r", "R") ;
352 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
354 // first check if a plugin is defined for the quality assurance data maker
355 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
356 // if not, add a plugin for it
357 if (!pluginHandler) {
358 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
359 TString libs = gSystem->GetLibraries() ;
360 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
361 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
363 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
365 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
367 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
368 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
371 fQADataMaker[iDet] = qadm ;
372 qadm->SetName(AliQA::GetDetName(iDet));
373 qadm->SetUniqueID(iDet);
379 //_____________________________________________________________________________
380 void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray)
382 // End of cycle QADataMakers
384 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
385 if (IsSelected(AliQA::GetDetName(iDet))) {
386 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
389 // skip non active detectors
391 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
392 if (!det || !det->IsActive())
395 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
396 if ( fTasks.Contains(Form("%d", taskIndex)) )
397 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
404 //_____________________________________________________________________________
405 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
407 // Initialize the event source and QA data makers
409 //fTasks = AliQA::GetTaskName(taskIndex) ;
411 if (taskIndex == AliQA::kRAWS) {
413 fRawReader = AliRawReader::Create(input);
417 fRawReaderDelete = kTRUE ;
418 fRawReader->NextEvent() ;
419 fRunNumber = fRawReader->GetRunNumber() ;
420 AliCDBManager::Instance()->SetRun(fRunNumber) ;
421 fRawReader->RewindEvents();
422 fNumberOfEvents = 999999 ;
423 if ( fMaxEvents < 0 )
424 fMaxEvents = fNumberOfEvents ;
425 } else if (taskIndex == AliQA::kESDS) {
426 fTasks = AliQA::GetTaskName(AliQA::kESDS) ;
427 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
428 TFile * esdFile = TFile::Open("AliESDs.root") ;
429 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
431 AliError("esdTree not found") ;
434 fESD = new AliESDEvent() ;
435 fESD->ReadFromTree(fESDTree) ;
436 fESDTree->GetEntry(0) ;
437 fRunNumber = fESD->GetRunNumber() ;
438 fNumberOfEvents = fESDTree->GetEntries() ;
439 if ( fMaxEvents < 0 )
440 fMaxEvents = fNumberOfEvents ;
443 AliError("AliESDs.root not found") ;
447 if ( !InitRunLoader() ) {
448 AliWarning("No Run Loader not found") ;
450 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
451 if ( fMaxEvents < 0 )
452 fMaxEvents = fNumberOfEvents ;
457 TObjArray* detArray = NULL ;
458 if (fRunLoader) // check if RunLoader exists
459 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
460 detArray = fRunLoader->GetAliRun()->Detectors() ;
461 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
464 // Initialize all QA data makers for all detectors
465 fRunNumber = AliCDBManager::Instance()->GetRun() ;
466 if ( ! AliGeomManager::GetGeometry() )
467 AliGeomManager::LoadGeometry() ;
469 InitQADataMaker(fRunNumber, fRecoParam, fCycleSame, detArray) ;
473 //_____________________________________________________________________________
474 void AliQADataMakerSteer::InitQADataMaker(UInt_t run, const AliRecoParam & par, Bool_t sameCycle, Bool_t startOption, TObjArray * detArray)
476 // Initializes The QADataMaker for all active detectors and for all active tasks
478 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
479 if (IsSelected(AliQA::GetDetName(iDet))) {
480 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
482 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
483 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
485 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
486 // skip non active detectors
488 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
489 if (!det || !det->IsActive())
492 // Set default reco params
493 qadm->SetRecoParam(par.GetDetRecoParam(iDet));
494 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
495 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
496 qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, GetQACycles(qadm->GetUniqueID())) ;
498 qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), sameCycle) ;
508 //_____________________________________________________________________________
509 Bool_t AliQADataMakerSteer::InitRunLoader()
511 // get or create the run loader
515 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
516 // load all base libraries to get the loader classes
517 TString libs = gSystem->GetLibraries() ;
518 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
519 if (!IsSelected(AliQA::GetDetName(iDet)))
521 TString detName = AliQA::GetDetName(iDet) ;
522 if (detName == "HLT")
524 if (libs.Contains("lib" + detName + "base.so"))
526 gSystem->Load("lib" + detName + "base.so");
528 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
530 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
533 fRunLoader->CdGAFile();
534 if (fRunLoader->LoadgAlice() == 0) {
535 gAlice = fRunLoader->GetAliRun();
539 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
543 } else { // galice.root does not exist
544 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
550 fRunLoader->LoadHeader();
551 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
556 //_____________________________________________________________________________
557 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
559 // check whether detName is contained in detectors
560 // if yes, it is removed from detectors
563 const TString detName(det) ;
564 // check if all detectors are selected
565 if (fDetectors.Contains("ALL")) {
568 } else if ((fDetectors.CompareTo(detName) == 0) ||
569 fDetectors.BeginsWith(detName+" ") ||
570 fDetectors.EndsWith(" "+detName) ||
571 fDetectors.Contains(" "+detName+" ")) {
578 //_____________________________________________________________________________
579 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
581 // Merge all the cycles from all detectors in one single file per run
583 if ( runNumber == -1 )
584 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
586 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
587 gROOT->ProcessLine(cmd.Data()) ;
588 ifstream in("tempo.txt") ;
589 const Int_t runMax = 10 ;
590 TString file[AliQA::kNDET*runMax] ;
591 Int_t run[AliQA::kNDET*runMax] = {-1} ;
598 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
603 AliError(Form("run number %d not found", runNumber)) ;
608 Int_t runIndexMax = 0 ;
609 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
610 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
611 TString tmp(file[ifile]) ;
612 tmp.ReplaceAll(".root", "") ;
613 TString det = tmp(0, tmp.Index(".")) ;
614 tmp.Remove(0, tmp.Index(stmp)+4) ;
615 TString ttmp = tmp(0, tmp.Index(".")) ;
616 Int_t newRun = ttmp.Atoi() ;
617 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
618 if (newRun == run[irun])
620 run[runIndex] = newRun ;
623 runIndexMax = runIndex ;
624 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
625 Int_t cycle = ttmp.Atoi() ;
626 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
628 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
630 TString outFileName(Form("Merged.%s.%d.root",AliQA::GetQADataFileName(),run[irun]));
631 merger.OutputFile(outFileName.Data()) ;
632 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
633 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
634 TString tmp(file[ifile]) ;
635 if (tmp.Contains(pattern)) {
636 merger.AddFile(tmp) ;
645 //_____________________________________________________________________________
646 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
648 // Reset the default data members
650 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
651 if (IsSelected(AliQA::GetDetName(iDet))) {
652 AliQADataMaker * qadm = GetQADataMaker(iDet);
653 qadm->Reset(sameCycle);
656 if (fRawReaderDelete) {
661 fCycleSame = sameCycle ;
665 fNumberOfEvents = 999999 ;
668 //_____________________________________________________________________________
669 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
671 //Runs all the QA data Maker for Raws only
673 fCycleSame = sameCycle ;
674 fRawReader = rawReader ;
675 fDetectors = detectors ;
676 fDetectorsW = detectors ;
678 AliCDBManager* man = AliCDBManager::Instance() ;
680 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
681 rawReader->NextEvent() ;
682 man->SetRun(fRawReader->GetRunNumber()) ;
683 rawReader->RewindEvents() ;
686 if ( !Init(AliQA::kRAWS) )
688 fRawReaderDelete = kFALSE ;
694 //_____________________________________________________________________________
695 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
697 //Runs all the QA data Maker for Raws only
699 fCycleSame = sameCycle ;
700 fDetectors = detectors ;
701 fDetectorsW = detectors ;
703 AliCDBManager* man = AliCDBManager::Instance() ;
704 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
705 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
707 AliFatal("galice.root file not found in current directory") ;
711 if ( ! rl->GetAliRun() ) {
712 AliFatal("AliRun not found in galice.root") ;
715 man->SetRun(rl->GetHeader()->GetRun());
720 if ( !Init(AliQA::kRAWS, fileName) )
727 //_____________________________________________________________________________
728 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
730 // Runs all the QA data Maker for every detector
732 fCycleSame = sameCycle ;
733 fDetectors = detectors ;
734 fDetectorsW = detectors ;
736 AliCDBManager* man = AliCDBManager::Instance() ;
737 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
738 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
740 AliFatal("galice.root file not found in current directory") ;
744 if ( ! rl->GetAliRun() ) {
745 AliInfo("AliRun not found in galice.root") ;
748 man->SetRun(rl->GetHeader()->GetRun()) ;
754 if ( taskIndex == AliQA::kNULLTASKINDEX) {
755 for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
756 if ( fTasks.Contains(Form("%d", task)) ) {
757 if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) )
759 DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
763 if ( !Init(taskIndex, fileName) )
772 //_____________________________________________________________________________
773 void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader)
775 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
777 AliCodeTimerAuto("") ;
778 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
779 if (!IsSelected(AliQA::GetDetName(iDet)))
781 AliQADataMaker *qadm = GetQADataMaker(iDet);
784 if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
785 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
786 qadm->Exec(AliQA::kRAWS, rawReader) ;
787 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
792 //_____________________________________________________________________________
793 void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd)
795 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
797 AliCodeTimerAuto("") ;
798 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
799 if (!IsSelected(AliQA::GetDetName(iDet)))
801 AliQADataMaker *qadm = GetQADataMaker(iDet);
804 if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
805 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
806 qadm->Exec(AliQA::kESDS, esd) ;
807 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
812 //_____________________________________________________________________________
813 void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree)
815 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
816 AliCodeTimerAuto("") ;
817 if (!IsSelected(AliQA::GetDetName(det))) {
818 AliQADataMaker *qadm = GetQADataMaker(det);
820 if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
821 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
822 qadm->Exec(AliQA::kRECPOINTS, tree) ;
823 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
829 //_____________________________________________________________________________
830 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
832 // take the locasl QA data merge into a single file and save in OCDB
834 TString tmp(AliQA::GetQARefStorage()) ;
835 if ( tmp.IsNull() ) {
836 AliError("No storage defined, use AliQA::SetQARefStorage") ;
839 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
840 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
843 TString sdet(detectors) ;
846 if ( sdet.Contains("ALL") ) {
847 rv = Merge(runNumber) ;
850 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
851 inputFile = TFile::Open(inputFileName.Data()) ;
852 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
854 for (Int_t index = 0; index < AliQA::kNDET; index++) {
855 if (sdet.Contains(AliQA::GetDetName(index))) {
856 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
857 inputFile = TFile::Open(inputFileName.Data()) ;
858 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
865 //_____________________________________________________________________________
866 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
868 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
870 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
871 AliCDBManager* man = AliCDBManager::Instance() ;
872 if ( ! man->IsDefaultStorageSet() ) {
873 TString tmp( AliQA::GetQARefStorage() ) ;
874 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
875 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
877 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
879 tmp1.Append("?user=alidaq") ;
880 man->SetDefaultStorage(tmp1.Data()) ;
883 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
884 if(man->GetRun() < 0)
885 man->SetRun(runNumber);
888 mdr.SetResponsible("yves schutz");
890 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
891 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
893 AliInfo(Form("Entering %s", detDir->GetName())) ;
894 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
895 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
896 TList * listDetQAD = new TList() ;
897 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
898 mdr.SetComment("HMPID QA stuff");
899 listDetQAD->SetName(listName) ;
900 TList * taskList = detDir->GetListOfKeys() ;
901 TIter nextTask(taskList) ;
903 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
904 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
905 AliInfo(Form("Saving %s", taskDir->GetName())) ;
906 TObjArray * listTaskQAD = new TObjArray(100) ;
907 listTaskQAD->SetName(taskKey->GetName()) ;
908 listDetQAD->Add(listTaskQAD) ;
909 TList * histList = taskDir->GetListOfKeys() ;
910 TIter nextHist(histList) ;
912 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
913 TObject * odata = taskDir->Get(histKey->GetName()) ;
915 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
917 AliInfo(Form("Adding %s", histKey->GetName())) ;
918 if ( odata->IsA()->InheritsFrom("TH1") ) {
919 AliInfo(Form("Adding %s", histKey->GetName())) ;
920 TH1 * hdata = static_cast<TH1*>(odata) ;
921 listTaskQAD->Add(hdata) ;
926 man->Put(listDetQAD, idr, &mdr) ;
932 //_____________________________________________________________________________
933 void AliQADataMakerSteer::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
935 // Set custom reconstruction parameters for a given detector
936 // Single set of parameters for all the events
937 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
938 if(!strcmp(detector, AliQA::GetDetName(iDet))) {
940 fRecoParam.AddDetRecoParam(iDet,par);