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 qadm->SetName(AliQA::GetDetName(iDet));
340 qadm->SetUniqueID(iDet);
341 fQADataMaker[iDet] = qadm;
345 // load the QA data maker object
346 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
347 TString detName = AliQA::GetDetName(iDet) ;
349 if (tmp.Contains("sim"))
350 tmp.ReplaceAll("s", "S") ;
351 else if (tmp.Contains("rec"))
352 tmp.ReplaceAll("r", "R") ;
354 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
356 // first check if a plugin is defined for the quality assurance data maker
357 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
358 // if not, add a plugin for it
359 if (!pluginHandler) {
360 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
361 TString libs = gSystem->GetLibraries() ;
362 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
363 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
365 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
367 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
369 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
370 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
373 qadm->SetName(AliQA::GetDetName(iDet));
374 qadm->SetUniqueID(iDet);
375 fQADataMaker[iDet] = qadm ;
381 //_____________________________________________________________________________
382 void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray)
384 // End of cycle QADataMakers
386 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
387 if (IsSelected(AliQA::GetDetName(iDet))) {
388 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
391 // skip non active detectors
393 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
394 if (!det || !det->IsActive())
397 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
398 if ( fTasks.Contains(Form("%d", taskIndex)) )
399 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
406 //_____________________________________________________________________________
407 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
409 // Initialize the event source and QA data makers
411 //fTasks = AliQA::GetTaskName(taskIndex) ;
413 if (taskIndex == AliQA::kRAWS) {
415 fRawReader = AliRawReader::Create(input);
419 fRawReaderDelete = kTRUE ;
420 fRawReader->NextEvent() ;
421 fRunNumber = fRawReader->GetRunNumber() ;
422 AliCDBManager::Instance()->SetRun(fRunNumber) ;
423 fRawReader->RewindEvents();
424 fNumberOfEvents = 999999 ;
425 if ( fMaxEvents < 0 )
426 fMaxEvents = fNumberOfEvents ;
427 } else if (taskIndex == AliQA::kESDS) {
428 fTasks = AliQA::GetTaskName(AliQA::kESDS) ;
429 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
430 TFile * esdFile = TFile::Open("AliESDs.root") ;
431 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
433 AliError("esdTree not found") ;
436 fESD = new AliESDEvent() ;
437 fESD->ReadFromTree(fESDTree) ;
438 fESDTree->GetEntry(0) ;
439 fRunNumber = fESD->GetRunNumber() ;
440 fNumberOfEvents = fESDTree->GetEntries() ;
441 if ( fMaxEvents < 0 )
442 fMaxEvents = fNumberOfEvents ;
445 AliError("AliESDs.root not found") ;
449 if ( !InitRunLoader() ) {
450 AliWarning("No Run Loader not found") ;
452 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
453 if ( fMaxEvents < 0 )
454 fMaxEvents = fNumberOfEvents ;
459 TObjArray* detArray = NULL ;
460 if (fRunLoader) // check if RunLoader exists
461 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
462 detArray = fRunLoader->GetAliRun()->Detectors() ;
463 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
466 // Initialize all QA data makers for all detectors
467 fRunNumber = AliCDBManager::Instance()->GetRun() ;
468 if ( ! AliGeomManager::GetGeometry() )
469 AliGeomManager::LoadGeometry() ;
471 InitQADataMaker(fRunNumber, fRecoParam, fCycleSame, kTRUE, detArray) ;
475 //_____________________________________________________________________________
476 void AliQADataMakerSteer::InitQADataMaker(UInt_t run, const AliRecoParam & par, Bool_t sameCycle, Bool_t startOption, TObjArray * detArray)
478 // Initializes The QADataMaker for all active detectors and for all active tasks
480 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
481 if (IsSelected(AliQA::GetDetName(iDet))) {
482 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
484 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
485 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
487 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
488 // skip non active detectors
490 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
491 if (!det || !det->IsActive())
494 // Set default reco params
495 qadm->SetRecoParam(par.GetDetRecoParam(iDet));
496 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
497 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
498 qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, GetQACycles(qadm->GetUniqueID())) ;
500 qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), sameCycle) ;
510 //_____________________________________________________________________________
511 Bool_t AliQADataMakerSteer::InitRunLoader()
513 // get or create the run loader
517 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
518 // load all base libraries to get the loader classes
519 TString libs = gSystem->GetLibraries() ;
520 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
521 if (!IsSelected(AliQA::GetDetName(iDet)))
523 TString detName = AliQA::GetDetName(iDet) ;
524 if (detName == "HLT")
526 if (libs.Contains("lib" + detName + "base.so"))
528 gSystem->Load("lib" + detName + "base.so");
530 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
532 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
535 fRunLoader->CdGAFile();
536 if (fRunLoader->LoadgAlice() == 0) {
537 gAlice = fRunLoader->GetAliRun();
541 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
545 } else { // galice.root does not exist
546 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
552 fRunLoader->LoadHeader();
553 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
558 //_____________________________________________________________________________
559 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
561 // check whether detName is contained in detectors
562 // if yes, it is removed from detectors
565 const TString detName(det) ;
566 // check if all detectors are selected
567 if (fDetectors.Contains("ALL")) {
570 } else if ((fDetectors.CompareTo(detName) == 0) ||
571 fDetectors.BeginsWith(detName+" ") ||
572 fDetectors.EndsWith(" "+detName) ||
573 fDetectors.Contains(" "+detName+" ")) {
580 //_____________________________________________________________________________
581 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
583 // Merge data from all the cycles from all detectors in one single file per run
584 // Merge the QA results from all the data chunks in one run
585 Bool_t rv = MergeData(runNumber) ;
586 rv *= MergeResults(runNumber) ;
591 //_____________________________________________________________________________
592 Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const
594 // Merge all the cycles from all detectors in one single file per run
597 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
599 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
600 gROOT->ProcessLine(cmd.Data()) ;
601 ifstream in("tempo.txt") ;
602 const Int_t runMax = 10 ;
603 TString file[AliQA::kNDET*runMax] ;
604 Int_t run[AliQA::kNDET*runMax] = {-1} ;
611 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
616 AliError(Form("run number %d not found", runNumber)) ;
621 Int_t runIndexMax = 0 ;
622 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
623 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
624 TString tmp(file[ifile]) ;
625 tmp.ReplaceAll(".root", "") ;
626 TString det = tmp(0, tmp.Index(".")) ;
627 tmp.Remove(0, tmp.Index(stmp)+4) ;
628 TString ttmp = tmp(0, tmp.Index(".")) ;
629 Int_t newRun = ttmp.Atoi() ;
630 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
631 if (newRun == run[irun])
633 run[runIndex] = newRun ;
636 runIndexMax = runIndex ;
637 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
638 Int_t cycle = ttmp.Atoi() ;
639 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
641 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
643 TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),run[irun]));
644 merger.OutputFile(outFileName.Data()) ;
645 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
646 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
647 TString tmp(file[ifile]) ;
648 if (tmp.Contains(pattern)) {
649 merger.AddFile(tmp) ;
658 //_____________________________________________________________________________
659 Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const
661 // Merge the QA result from all the data chunks in a run
663 cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ;
664 gROOT->ProcessLine(cmd.Data()) ;
665 ifstream in("tempo.txt") ;
666 const Int_t chunkMax = 100 ;
667 TString fileList[chunkMax] ;
672 in >> fileList[index] ;
675 AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ;
680 AliError("No QA Result File found") ;
685 TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber));
686 merger.OutputFile(outFileName.Data()) ;
687 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
688 TString file = fileList[ifile] ;
689 merger.AddFile(file) ;
696 //_____________________________________________________________________________
697 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
699 // Reset the default data members
701 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
702 if (IsSelected(AliQA::GetDetName(iDet))) {
703 AliQADataMaker * qadm = GetQADataMaker(iDet);
704 qadm->Reset(sameCycle);
707 if (fRawReaderDelete) {
712 fCycleSame = sameCycle ;
716 fNumberOfEvents = 999999 ;
719 //_____________________________________________________________________________
720 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
722 //Runs all the QA data Maker for Raws only
724 fCycleSame = sameCycle ;
725 fRawReader = rawReader ;
726 fDetectors = detectors ;
727 fDetectorsW = detectors ;
729 AliCDBManager* man = AliCDBManager::Instance() ;
731 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
732 rawReader->NextEvent() ;
733 man->SetRun(fRawReader->GetRunNumber()) ;
734 rawReader->RewindEvents() ;
737 if ( !Init(AliQA::kRAWS) )
739 fRawReaderDelete = kFALSE ;
745 //_____________________________________________________________________________
746 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
748 //Runs all the QA data Maker for Raws only
750 fCycleSame = sameCycle ;
751 fDetectors = detectors ;
752 fDetectorsW = detectors ;
754 AliCDBManager* man = AliCDBManager::Instance() ;
755 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
756 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
758 AliFatal("galice.root file not found in current directory") ;
762 if ( ! rl->GetAliRun() ) {
763 AliFatal("AliRun not found in galice.root") ;
766 man->SetRun(rl->GetHeader()->GetRun());
771 if ( !Init(AliQA::kRAWS, fileName) )
778 //_____________________________________________________________________________
779 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
781 // Runs all the QA data Maker for every detector
783 fCycleSame = sameCycle ;
784 fDetectors = detectors ;
785 fDetectorsW = detectors ;
787 AliCDBManager* man = AliCDBManager::Instance() ;
788 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
789 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
791 AliFatal("galice.root file not found in current directory") ;
795 if ( ! rl->GetAliRun() ) {
796 AliInfo("AliRun not found in galice.root") ;
799 man->SetRun(rl->GetHeader()->GetRun()) ;
805 if ( taskIndex == AliQA::kNULLTASKINDEX) {
806 for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
807 if ( fTasks.Contains(Form("%d", task)) ) {
808 if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) )
810 DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
814 if ( !Init(taskIndex, fileName) )
823 //_____________________________________________________________________________
824 void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader)
826 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
828 AliCodeTimerAuto("") ;
829 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
830 if (!IsSelected(AliQA::GetDetName(iDet)))
832 AliQADataMaker *qadm = GetQADataMaker(iDet);
835 if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
836 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
837 qadm->Exec(AliQA::kRAWS, rawReader) ;
838 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
843 //_____________________________________________________________________________
844 void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd)
846 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
848 AliCodeTimerAuto("") ;
849 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
850 if (!IsSelected(AliQA::GetDetName(iDet)))
852 AliQADataMaker *qadm = GetQADataMaker(iDet);
855 if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
856 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
857 qadm->Exec(AliQA::kESDS, esd) ;
858 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
863 //_____________________________________________________________________________
864 void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree)
866 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
867 AliCodeTimerAuto("") ;
868 if (!IsSelected(AliQA::GetDetName(det))) {
869 AliQADataMaker *qadm = GetQADataMaker(det);
871 if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
872 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
873 qadm->Exec(AliQA::kRECPOINTS, tree) ;
874 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
880 //_____________________________________________________________________________
881 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
883 // take the locasl QA data merge into a single file and save in OCDB
885 TString tmp(AliQA::GetQARefStorage()) ;
886 if ( tmp.IsNull() ) {
887 AliError("No storage defined, use AliQA::SetQARefStorage") ;
890 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
891 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
894 TString sdet(detectors) ;
897 if ( sdet.Contains("ALL") ) {
898 rv = Merge(runNumber) ;
901 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
902 inputFile = TFile::Open(inputFileName.Data()) ;
903 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
905 for (Int_t index = 0; index < AliQA::kNDET; index++) {
906 if (sdet.Contains(AliQA::GetDetName(index))) {
907 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
908 inputFile = TFile::Open(inputFileName.Data()) ;
909 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
916 //_____________________________________________________________________________
917 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
919 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
921 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
922 AliCDBManager* man = AliCDBManager::Instance() ;
923 if ( ! man->IsDefaultStorageSet() ) {
924 TString tmp( AliQA::GetQARefStorage() ) ;
925 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
926 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
928 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
930 tmp1.Append("?user=alidaq") ;
931 man->SetDefaultStorage(tmp1.Data()) ;
934 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
935 if(man->GetRun() < 0)
936 man->SetRun(runNumber);
939 mdr.SetResponsible("yves schutz");
941 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
942 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
944 AliInfo(Form("Entering %s", detDir->GetName())) ;
945 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
946 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
947 TList * listDetQAD = new TList() ;
948 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
949 mdr.SetComment("HMPID QA stuff");
950 listDetQAD->SetName(listName) ;
951 TList * taskList = detDir->GetListOfKeys() ;
952 TIter nextTask(taskList) ;
954 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
955 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
956 AliInfo(Form("Saving %s", taskDir->GetName())) ;
957 TObjArray * listTaskQAD = new TObjArray(100) ;
958 listTaskQAD->SetName(taskKey->GetName()) ;
959 listDetQAD->Add(listTaskQAD) ;
960 TList * histList = taskDir->GetListOfKeys() ;
961 TIter nextHist(histList) ;
963 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
964 TObject * odata = taskDir->Get(histKey->GetName()) ;
966 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
968 AliInfo(Form("Adding %s", histKey->GetName())) ;
969 if ( odata->IsA()->InheritsFrom("TH1") ) {
970 AliInfo(Form("Adding %s", histKey->GetName())) ;
971 TH1 * hdata = static_cast<TH1*>(odata) ;
972 listTaskQAD->Add(hdata) ;
977 man->Put(listDetQAD, idr, &mdr) ;
983 //_____________________________________________________________________________
984 void AliQADataMakerSteer::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
986 // Set custom reconstruction parameters for a given detector
987 // Single set of parameters for all the events
988 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
989 if(!strcmp(detector, AliQA::GetDetName(iDet))) {
991 fRecoParam.AddDetRecoParam(iDet,par);