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 "AliCorrQADataMakerRec.h"
45 #include "AliDetectorRecoParam.h"
46 #include "AliESDEvent.h"
47 #include "AliGeomManager.h"
48 #include "AliGlobalQADataMaker.h"
49 #include "AliHeader.h"
51 #include "AliModule.h"
53 #include "AliQADataMakerRec.h"
54 #include "AliQADataMakerSim.h"
55 #include "AliQADataMakerSteer.h"
56 #include "AliRawReaderDate.h"
57 #include "AliRawReaderFile.h"
58 #include "AliRawReaderRoot.h"
60 #include "AliRunLoader.h"
62 ClassImp(AliQADataMakerSteer)
64 //_____________________________________________________________________________
65 AliQADataMakerSteer::AliQADataMakerSteer(char * mode, const char* gAliceFilename, const char * name, const char * title) :
73 fGAliceFileName(gAliceFilename),
77 fNumberOfEvents(999999),
81 fRawReaderDelete(kTRUE),
86 fMaxEvents = fNumberOfEvents ;
87 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
88 if (IsSelected(AliQA::GetDetName(iDet))) {
89 fLoader[iDet] = NULL ;
90 fQADataMaker[iDet] = NULL ;
91 fQACycles[iDet] = 999999 ;
96 //_____________________________________________________________________________
97 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
99 fCurrentEvent(qas.fCurrentEvent),
101 fDetectors(qas.fDetectors),
102 fDetectorsW(qas.fDetectorsW),
105 fGAliceFileName(qas.fGAliceFileName),
106 fFirstEvent(qas.fFirstEvent),
107 fMaxEvents(qas.fMaxEvents),
109 fNumberOfEvents(qas.fNumberOfEvents),
111 fRunNumber(qas.fRunNumber),
113 fRawReaderDelete(kTRUE),
118 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
119 fLoader[iDet] = qas.fLoader[iDet] ;
120 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
121 fQACycles[iDet] = qas.fQACycles[iDet] ;
125 //_____________________________________________________________________________
126 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
128 // assignment operator
129 this->~AliQADataMakerSteer() ;
130 new(this) AliQADataMakerSteer(qas) ;
134 //_____________________________________________________________________________
135 AliQADataMakerSteer::~AliQADataMakerSteer()
138 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
139 if (IsSelected(AliQA::GetDetName(iDet))) {
140 fLoader[iDet] = NULL;
141 if (fQADataMaker[iDet]) {
142 (fQADataMaker[iDet])->Finish() ;
143 delete fQADataMaker[iDet] ;
147 if (fRawReaderDelete) {
154 //_____________________________________________________________________________
155 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
157 // Runs all the QA data Maker for every detector
160 // Fill QA data in event loop
161 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
164 if ( iEvent%10 == 0 )
165 AliInfo(Form("processing event %d", iEvent));
166 if ( taskIndex == AliQA::kRAWS ) {
167 if ( !fRawReader->NextEvent() )
169 } else if ( taskIndex == AliQA::kESDS ) {
170 if ( fESDTree->GetEntry(iEvent) == 0 )
173 if ( fRunLoader->GetEvent(iEvent) != 0 )
176 // loop over active loaders
177 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
178 if (IsSelected(AliQA::GetDetName(iDet))) {
179 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
180 if ( qadm->IsCycleDone() ) {
181 qadm->EndOfCycle(taskIndex) ;
183 TTree * data = NULL ;
184 AliLoader* loader = GetLoader(qadm->GetUniqueID());
186 case AliQA::kNULLTASKINDEX :
189 qadm->Exec(taskIndex, fRawReader) ;
194 data = loader->TreeH() ;
196 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
200 qadm->Exec(taskIndex, data) ;
202 case AliQA::kSDIGITS :
204 loader->LoadSDigits() ;
205 data = loader->TreeS() ;
207 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
211 qadm->Exec(taskIndex, data) ;
213 case AliQA::kDIGITS :
215 loader->LoadDigits() ;
216 data = loader->TreeD() ;
218 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
222 qadm->Exec(taskIndex, data) ;
224 case AliQA::kRECPOINTS :
226 loader->LoadRecPoints() ;
227 data = loader->TreeR() ;
229 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
233 qadm->Exec(taskIndex, data) ;
235 case AliQA::kTRACKSEGMENTS :
237 case AliQA::kRECPARTICLES :
240 qadm->Exec(taskIndex, fESD) ;
242 case AliQA::kNTASKINDEX :
249 // Save QA data for all detectors
250 rv = Finish(taskIndex) ;
252 if ( taskIndex == AliQA::kRAWS )
253 fRawReader->RewindEvents() ;
258 //_____________________________________________________________________________
259 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
261 // write output to file for all detectors
262 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
263 if (IsSelected(AliQA::GetDetName(iDet))) {
264 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
265 qadm->EndOfCycle(taskIndex) ;
271 //_____________________________________________________________________________
272 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
274 // Retrieve the list of QA data for a given detector and a given task
275 TObjArray * rv = NULL ;
276 if ( !strlen(AliQA::GetQARefStorage()) ) {
277 AliError("No storage defined, use AliQA::SetQARefStorage") ;
280 AliCDBManager* man = AliCDBManager::Instance() ;
281 if ( ! man->IsDefaultStorageSet() ) {
282 TString tmp(AliQA::GetQARefDefaultStorage()) ;
285 man->SetDefaultStorage(tmp.Data()) ;
286 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
288 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
289 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
290 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
291 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
293 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
297 //_____________________________________________________________________________
298 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
300 // get the loader for a detector
302 if ( !fRunLoader || iDet == AliQA::kCORR)
305 TString detName = AliQA::GetDetName(iDet) ;
306 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
308 return fLoader[iDet] ;
310 // load the QA data maker object
311 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
312 TString loaderName = "Ali" + detName + "Loader" ;
314 AliLoader * loader = NULL ;
315 // first check if a plugin is defined for the quality assurance data maker
316 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
317 // if not, add a plugin for it
318 if (!pluginHandler) {
319 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
320 TString libs = gSystem->GetLibraries() ;
321 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
322 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
324 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
326 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
328 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
329 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
332 fLoader[iDet] = loader ;
336 //_____________________________________________________________________________
337 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
339 // get the quality assurance data maker for a detector
341 if (fQADataMaker[iDet])
342 return fQADataMaker[iDet] ;
344 AliQADataMaker * qadm = NULL ;
346 if (iDet == AliQA::kGLOBAL) { //Global QA
347 qadm = new AliGlobalQADataMaker();
348 qadm->SetName(AliQA::GetDetName(iDet));
349 qadm->SetUniqueID(iDet);
350 fQADataMaker[iDet] = qadm;
354 if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors
355 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
356 qadm->SetName(AliQA::GetDetName(iDet));
357 qadm->SetUniqueID(iDet);
358 fQADataMaker[iDet] = qadm;
362 // load the QA data maker object
363 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
364 TString detName = AliQA::GetDetName(iDet) ;
366 if (tmp.Contains("sim"))
367 tmp.ReplaceAll("s", "S") ;
368 else if (tmp.Contains("rec"))
369 tmp.ReplaceAll("r", "R") ;
371 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
373 // first check if a plugin is defined for the quality assurance data maker
374 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
375 // if not, add a plugin for it
376 if (!pluginHandler) {
377 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
378 TString libs = gSystem->GetLibraries() ;
379 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
380 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
382 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
384 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
386 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
387 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
390 qadm->SetName(AliQA::GetDetName(iDet));
391 qadm->SetUniqueID(iDet);
392 fQADataMaker[iDet] = qadm ;
398 //_____________________________________________________________________________
399 void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray)
401 // End of cycle QADataMakers
403 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
404 if (IsSelected(AliQA::GetDetName(iDet))) {
405 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
408 // skip non active detectors
410 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
411 if (!det || !det->IsActive())
414 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
415 if ( fTasks.Contains(Form("%d", taskIndex)) )
416 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
423 //_____________________________________________________________________________
424 void AliQADataMakerSteer::Increment()
426 // Increments the cycle counter for all QA Data Makers
427 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
428 if (IsSelected(AliQA::GetDetName(iDet))) {
429 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
436 //_____________________________________________________________________________
437 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
439 // Initialize the event source and QA data makers
441 //fTasks = AliQA::GetTaskName(taskIndex) ;
443 if (taskIndex == AliQA::kRAWS) {
445 fRawReader = AliRawReader::Create(input);
449 fRawReaderDelete = kTRUE ;
450 fRawReader->NextEvent() ;
451 fRunNumber = fRawReader->GetRunNumber() ;
452 AliCDBManager::Instance()->SetRun(fRunNumber) ;
453 fRawReader->RewindEvents();
454 fNumberOfEvents = 999999 ;
455 if ( fMaxEvents < 0 )
456 fMaxEvents = fNumberOfEvents ;
457 } else if (taskIndex == AliQA::kESDS) {
458 fTasks = AliQA::GetTaskName(AliQA::kESDS) ;
459 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
460 TFile * esdFile = TFile::Open("AliESDs.root") ;
461 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
463 AliError("esdTree not found") ;
466 fESD = new AliESDEvent() ;
467 fESD->ReadFromTree(fESDTree) ;
468 fESDTree->GetEntry(0) ;
469 fRunNumber = fESD->GetRunNumber() ;
470 fNumberOfEvents = fESDTree->GetEntries() ;
471 if ( fMaxEvents < 0 )
472 fMaxEvents = fNumberOfEvents ;
475 AliError("AliESDs.root not found") ;
479 if ( !InitRunLoader() ) {
480 AliWarning("No Run Loader not found") ;
482 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
483 if ( fMaxEvents < 0 )
484 fMaxEvents = fNumberOfEvents ;
489 TObjArray* detArray = NULL ;
490 if (fRunLoader) // check if RunLoader exists
491 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
492 detArray = fRunLoader->GetAliRun()->Detectors() ;
493 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
496 // Initialize all QA data makers for all detectors
497 fRunNumber = AliCDBManager::Instance()->GetRun() ;
498 if ( ! AliGeomManager::GetGeometry() )
499 AliGeomManager::LoadGeometry() ;
501 InitQADataMaker(fRunNumber, fRecoParam, detArray) ; //, fCycleSame, kTRUE, detArray) ;
505 //_____________________________________________________________________________
506 void AliQADataMakerSteer::InitQADataMaker(UInt_t run, const AliRecoParam & par, TObjArray * detArray)
508 // Initializes The QADataMaker for all active detectors and for all active tasks
510 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
511 if (IsSelected(AliQA::GetDetName(iDet))) {
512 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
514 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
515 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
517 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
518 // skip non active detectors
520 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
521 if (!det || !det->IsActive())
524 // Set default reco params
525 qadm->SetRecoParam(par.GetDetRecoParam(iDet));
526 Bool_t sameCycle = kFALSE ;
527 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
528 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
529 qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, sameCycle) ;
530 qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
540 //_____________________________________________________________________________
541 Bool_t AliQADataMakerSteer::InitRunLoader()
543 // get or create the run loader
547 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
548 // load all base libraries to get the loader classes
549 TString libs = gSystem->GetLibraries() ;
550 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
551 if (!IsSelected(AliQA::GetDetName(iDet)))
553 TString detName = AliQA::GetDetName(iDet) ;
554 if (detName == "HLT")
556 if (libs.Contains("lib" + detName + "base.so"))
558 gSystem->Load("lib" + detName + "base.so");
560 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
562 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
565 fRunLoader->CdGAFile();
566 if (fRunLoader->LoadgAlice() == 0) {
567 gAlice = fRunLoader->GetAliRun();
571 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
575 } else { // galice.root does not exist
576 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
582 fRunLoader->LoadHeader();
583 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
588 //_____________________________________________________________________________
589 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
591 // check whether detName is contained in detectors
592 // if yes, it is removed from detectors
595 const TString detName(det) ;
596 // always activates Correlation
597 if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) {
600 // check if all detectors are selected
601 if (fDetectors.Contains("ALL")) {
604 } else if ((fDetectors.CompareTo(detName) == 0) ||
605 fDetectors.BeginsWith(detName+" ") ||
606 fDetectors.EndsWith(" "+detName) ||
607 fDetectors.Contains(" "+detName+" ")) {
614 //_____________________________________________________________________________
615 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
617 // Merge data from all the cycles from all detectors in one single file per run
618 // Merge the QA results from all the data chunks in one run
619 Bool_t rv = MergeData(runNumber) ;
620 rv *= MergeResults(runNumber) ;
625 //_____________________________________________________________________________
626 Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const
628 // Merge all the cycles from all detectors in one single file per run
631 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
633 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
634 gROOT->ProcessLine(cmd.Data()) ;
635 ifstream in("tempo.txt") ;
636 const Int_t runMax = 10 ;
637 TString file[AliQA::kNDET*runMax] ;
638 Int_t run[AliQA::kNDET*runMax] = {-1} ;
645 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
650 AliError(Form("run number %d not found", runNumber)) ;
655 Int_t runIndexMax = 0 ;
656 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
657 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
658 TString tmp(file[ifile]) ;
659 tmp.ReplaceAll(".root", "") ;
660 TString det = tmp(0, tmp.Index(".")) ;
661 tmp.Remove(0, tmp.Index(stmp)+4) ;
662 TString ttmp = tmp(0, tmp.Index(".")) ;
663 Int_t newRun = ttmp.Atoi() ;
664 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
665 if (newRun == run[irun])
667 run[runIndex] = newRun ;
670 runIndexMax = runIndex ;
671 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
672 Int_t cycle = ttmp.Atoi() ;
673 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
675 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
677 TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),run[irun]));
678 merger.OutputFile(outFileName.Data()) ;
679 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
680 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
681 TString tmp(file[ifile]) ;
682 if (tmp.Contains(pattern)) {
683 merger.AddFile(tmp) ;
692 //_____________________________________________________________________________
693 Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const
695 // Merge the QA result from all the data chunks in a run
697 cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ;
698 gROOT->ProcessLine(cmd.Data()) ;
699 ifstream in("tempo.txt") ;
700 const Int_t chunkMax = 100 ;
701 TString fileList[chunkMax] ;
706 in >> fileList[index] ;
709 AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ;
714 AliError("No QA Result File found") ;
719 TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber));
720 merger.OutputFile(outFileName.Data()) ;
721 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
722 TString file = fileList[ifile] ;
723 merger.AddFile(file) ;
730 //_____________________________________________________________________________
731 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
733 // Reset the default data members
735 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
736 if (IsSelected(AliQA::GetDetName(iDet))) {
737 AliQADataMaker * qadm = GetQADataMaker(iDet);
741 if (fRawReaderDelete) {
746 fCycleSame = sameCycle ;
750 fNumberOfEvents = 999999 ;
753 //_____________________________________________________________________________
754 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
756 //Runs all the QA data Maker for Raws only
758 fCycleSame = sameCycle ;
759 fRawReader = rawReader ;
760 fDetectors = detectors ;
761 fDetectorsW = detectors ;
763 AliCDBManager* man = AliCDBManager::Instance() ;
765 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
766 rawReader->NextEvent() ;
767 man->SetRun(fRawReader->GetRunNumber()) ;
768 rawReader->RewindEvents() ;
771 if ( !Init(AliQA::kRAWS) )
773 fRawReaderDelete = kFALSE ;
779 //_____________________________________________________________________________
780 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
782 //Runs all the QA data Maker for Raws only
784 fCycleSame = sameCycle ;
785 fDetectors = detectors ;
786 fDetectorsW = detectors ;
788 AliCDBManager* man = AliCDBManager::Instance() ;
789 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
790 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
792 AliFatal("galice.root file not found in current directory") ;
796 if ( ! rl->GetAliRun() ) {
797 AliFatal("AliRun not found in galice.root") ;
800 man->SetRun(rl->GetHeader()->GetRun());
805 if ( !Init(AliQA::kRAWS, fileName) )
812 //_____________________________________________________________________________
813 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
815 // Runs all the QA data Maker for every detector
817 fCycleSame = sameCycle ;
818 fDetectors = detectors ;
819 fDetectorsW = detectors ;
821 AliCDBManager* man = AliCDBManager::Instance() ;
822 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
823 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
825 AliFatal("galice.root file not found in current directory") ;
829 if ( ! rl->GetAliRun() ) {
830 AliInfo("AliRun not found in galice.root") ;
833 man->SetRun(rl->GetHeader()->GetRun()) ;
839 if ( taskIndex == AliQA::kNULLTASKINDEX) {
840 for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
841 if ( fTasks.Contains(Form("%d", task)) ) {
842 if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) )
844 DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
848 if ( !Init(taskIndex, fileName) )
857 //_____________________________________________________________________________
858 void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader)
860 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
863 AliCodeTimerAuto("") ;
864 if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
865 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
866 if (!IsSelected(AliQA::GetDetName(iDet)))
868 AliQADataMaker *qadm = GetQADataMaker(iDet);
871 if ( qadm->IsCycleDone() ) {
874 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
875 qadm->Exec(AliQA::kRAWS, rawReader) ;
876 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
881 //_____________________________________________________________________________
882 void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd)
884 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
886 AliCodeTimerAuto("") ;
887 if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
888 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
889 if (!IsSelected(AliQA::GetDetName(iDet)))
891 AliQADataMaker *qadm = GetQADataMaker(iDet);
894 if ( qadm->IsCycleDone() ) {
897 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
898 qadm->Exec(AliQA::kESDS, esd) ;
899 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
904 //_____________________________________________________________________________
905 void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree)
907 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
908 AliCodeTimerAuto("") ;
909 if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
910 if (IsSelected(AliQA::GetDetName(det))) {
911 AliQADataMaker *qadm = GetQADataMaker(det);
913 if ( qadm->IsCycleDone() ) {
916 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
917 qadm->Exec(AliQA::kRECPOINTS, tree) ;
918 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
924 //_____________________________________________________________________________
925 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
927 // take the locasl QA data merge into a single file and save in OCDB
929 TString tmp(AliQA::GetQARefStorage()) ;
930 if ( tmp.IsNull() ) {
931 AliError("No storage defined, use AliQA::SetQARefStorage") ;
934 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
935 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
938 TString sdet(detectors) ;
941 if ( sdet.Contains("ALL") ) {
942 rv = Merge(runNumber) ;
945 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
946 inputFile = TFile::Open(inputFileName.Data()) ;
947 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
949 for (Int_t index = 0; index < AliQA::kNDET; index++) {
950 if (sdet.Contains(AliQA::GetDetName(index))) {
951 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
952 inputFile = TFile::Open(inputFileName.Data()) ;
953 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
960 //_____________________________________________________________________________
961 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
963 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
965 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
966 AliCDBManager* man = AliCDBManager::Instance() ;
967 if ( ! man->IsDefaultStorageSet() ) {
968 TString tmp( AliQA::GetQARefStorage() ) ;
969 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
970 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
972 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
974 tmp1.Append("?user=alidaq") ;
975 man->SetDefaultStorage(tmp1.Data()) ;
978 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
979 if(man->GetRun() < 0)
980 man->SetRun(runNumber);
983 mdr.SetResponsible("yves schutz");
985 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
986 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
988 AliInfo(Form("Entering %s", detDir->GetName())) ;
989 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
990 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
991 TList * listDetQAD = new TList() ;
992 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
993 mdr.SetComment("HMPID QA stuff");
994 listDetQAD->SetName(listName) ;
995 TList * taskList = detDir->GetListOfKeys() ;
996 TIter nextTask(taskList) ;
998 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
999 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1000 AliInfo(Form("Saving %s", taskDir->GetName())) ;
1001 TObjArray * listTaskQAD = new TObjArray(100) ;
1002 listTaskQAD->SetName(taskKey->GetName()) ;
1003 listDetQAD->Add(listTaskQAD) ;
1004 TList * histList = taskDir->GetListOfKeys() ;
1005 TIter nextHist(histList) ;
1007 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1008 TObject * odata = taskDir->Get(histKey->GetName()) ;
1010 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1012 AliInfo(Form("Adding %s", histKey->GetName())) ;
1013 if ( odata->IsA()->InheritsFrom("TH1") ) {
1014 AliInfo(Form("Adding %s", histKey->GetName())) ;
1015 TH1 * hdata = static_cast<TH1*>(odata) ;
1016 listTaskQAD->Add(hdata) ;
1021 man->Put(listDetQAD, idr, &mdr) ;
1027 //_____________________________________________________________________________
1028 void AliQADataMakerSteer::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
1030 // Set custom reconstruction parameters for a given detector
1031 // Single set of parameters for all the events
1032 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1033 if(!strcmp(detector, AliQA::GetDetName(iDet))) {
1034 par->SetAsDefault();
1035 fRecoParam.AddDetRecoParam(iDet,par);