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) continue; // This detector doesn't have any QA (for example, HLT)
181 if ( qadm->IsCycleDone() ) {
182 qadm->EndOfCycle(taskIndex) ;
184 TTree * data = NULL ;
185 AliLoader* loader = GetLoader(qadm->GetUniqueID());
187 case AliQA::kNULLTASKINDEX :
190 qadm->Exec(taskIndex, fRawReader) ;
195 data = loader->TreeH() ;
197 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
201 qadm->Exec(taskIndex, data) ;
203 case AliQA::kSDIGITS :
205 loader->LoadSDigits() ;
206 data = loader->TreeS() ;
208 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
212 qadm->Exec(taskIndex, data) ;
214 case AliQA::kDIGITS :
216 loader->LoadDigits() ;
217 data = loader->TreeD() ;
219 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
223 qadm->Exec(taskIndex, data) ;
225 case AliQA::kRECPOINTS :
227 loader->LoadRecPoints() ;
228 data = loader->TreeR() ;
230 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
234 qadm->Exec(taskIndex, data) ;
236 case AliQA::kTRACKSEGMENTS :
238 case AliQA::kRECPARTICLES :
241 qadm->Exec(taskIndex, fESD) ;
243 case AliQA::kNTASKINDEX :
250 // Save QA data for all detectors
251 rv = Finish(taskIndex) ;
253 if ( taskIndex == AliQA::kRAWS )
254 fRawReader->RewindEvents() ;
259 //_____________________________________________________________________________
260 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
262 // write output to file for all detectors
263 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
264 if (IsSelected(AliQA::GetDetName(iDet))) {
265 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
266 if (qadm) qadm->EndOfCycle(taskIndex) ;
272 //_____________________________________________________________________________
273 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
275 // Retrieve the list of QA data for a given detector and a given task
276 TObjArray * rv = NULL ;
277 if ( !strlen(AliQA::GetQARefStorage()) ) {
278 AliError("No storage defined, use AliQA::SetQARefStorage") ;
281 AliCDBManager* man = AliCDBManager::Instance() ;
282 if ( ! man->IsDefaultStorageSet() ) {
283 TString tmp(AliQA::GetQARefDefaultStorage()) ;
286 man->SetDefaultStorage(tmp.Data()) ;
287 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
289 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
290 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
291 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
292 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
294 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
298 //_____________________________________________________________________________
299 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
301 // get the loader for a detector
303 if ( !fRunLoader || iDet == AliQA::kCORR)
306 TString detName = AliQA::GetDetName(iDet) ;
307 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
309 return fLoader[iDet] ;
311 // load the QA data maker object
312 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
313 TString loaderName = "Ali" + detName + "Loader" ;
315 AliLoader * loader = NULL ;
316 // first check if a plugin is defined for the quality assurance data maker
317 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
318 // if not, add a plugin for it
319 if (!pluginHandler) {
320 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
321 TString libs = gSystem->GetLibraries() ;
322 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
323 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
325 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
327 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
329 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
330 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
333 fLoader[iDet] = loader ;
337 //_____________________________________________________________________________
338 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
340 // get the quality assurance data maker for a detector
342 if (fQADataMaker[iDet])
343 return fQADataMaker[iDet] ;
345 AliQADataMaker * qadm = NULL ;
347 if (iDet == AliQA::kGLOBAL) { //Global QA
348 qadm = new AliGlobalQADataMaker();
349 qadm->SetName(AliQA::GetDetName(iDet));
350 qadm->SetUniqueID(iDet);
351 fQADataMaker[iDet] = qadm;
355 if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors
356 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
357 qadm->SetName(AliQA::GetDetName(iDet));
358 qadm->SetUniqueID(iDet);
359 fQADataMaker[iDet] = qadm;
363 // load the QA data maker object
364 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
365 TString detName = AliQA::GetDetName(iDet) ;
367 if (tmp.Contains("sim"))
368 tmp.ReplaceAll("s", "S") ;
369 else if (tmp.Contains("rec"))
370 tmp.ReplaceAll("r", "R") ;
372 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
374 // first check if a plugin is defined for the quality assurance data maker
375 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
376 // if not, add a plugin for it
377 if (!pluginHandler) {
378 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
379 TString libs = gSystem->GetLibraries() ;
380 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
381 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
383 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
385 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
387 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
388 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
391 qadm->SetName(AliQA::GetDetName(iDet));
392 qadm->SetUniqueID(iDet);
393 fQADataMaker[iDet] = qadm ;
399 //_____________________________________________________________________________
400 void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray)
402 // End of cycle QADataMakers
404 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
405 if (IsSelected(AliQA::GetDetName(iDet))) {
406 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
409 // skip non active detectors
411 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
412 if (!det || !det->IsActive())
415 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
416 if ( fTasks.Contains(Form("%d", taskIndex)) )
417 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
424 //_____________________________________________________________________________
425 void AliQADataMakerSteer::Increment()
427 // Increments the cycle counter for all QA Data Makers
428 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
429 if (IsSelected(AliQA::GetDetName(iDet))) {
430 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
437 //_____________________________________________________________________________
438 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
440 // Initialize the event source and QA data makers
442 //fTasks = AliQA::GetTaskName(taskIndex) ;
444 if (taskIndex == AliQA::kRAWS) {
446 fRawReader = AliRawReader::Create(input);
450 fRawReaderDelete = kTRUE ;
451 fRawReader->NextEvent() ;
452 fRunNumber = fRawReader->GetRunNumber() ;
453 AliCDBManager::Instance()->SetRun(fRunNumber) ;
454 fRawReader->RewindEvents();
455 fNumberOfEvents = 999999 ;
456 if ( fMaxEvents < 0 )
457 fMaxEvents = fNumberOfEvents ;
458 } else if (taskIndex == AliQA::kESDS) {
459 fTasks = AliQA::GetTaskName(AliQA::kESDS) ;
460 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
461 TFile * esdFile = TFile::Open("AliESDs.root") ;
462 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
464 AliError("esdTree not found") ;
467 fESD = new AliESDEvent() ;
468 fESD->ReadFromTree(fESDTree) ;
469 fESDTree->GetEntry(0) ;
470 fRunNumber = fESD->GetRunNumber() ;
471 fNumberOfEvents = fESDTree->GetEntries() ;
472 if ( fMaxEvents < 0 )
473 fMaxEvents = fNumberOfEvents ;
476 AliError("AliESDs.root not found") ;
480 if ( !InitRunLoader() ) {
481 AliWarning("No Run Loader not found") ;
483 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
484 if ( fMaxEvents < 0 )
485 fMaxEvents = fNumberOfEvents ;
490 TObjArray* detArray = NULL ;
491 if (fRunLoader) // check if RunLoader exists
492 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
493 detArray = fRunLoader->GetAliRun()->Detectors() ;
494 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
497 // Initialize all QA data makers for all detectors
498 fRunNumber = AliCDBManager::Instance()->GetRun() ;
499 if ( ! AliGeomManager::GetGeometry() )
500 AliGeomManager::LoadGeometry() ;
502 InitQADataMaker(fRunNumber, fRecoParam, detArray) ; //, fCycleSame, kTRUE, detArray) ;
506 //_____________________________________________________________________________
507 void AliQADataMakerSteer::InitQADataMaker(UInt_t run, const AliRecoParam & par, TObjArray * detArray)
509 // Initializes The QADataMaker for all active detectors and for all active tasks
511 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
512 if (IsSelected(AliQA::GetDetName(iDet))) {
513 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
515 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
516 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
518 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
519 // skip non active detectors
521 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
522 if (!det || !det->IsActive())
525 // Set default reco params
526 qadm->SetRecoParam(par.GetDetRecoParam(iDet));
527 Bool_t sameCycle = kFALSE ;
528 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
529 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
530 qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, sameCycle) ;
531 qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
541 //_____________________________________________________________________________
542 Bool_t AliQADataMakerSteer::InitRunLoader()
544 // get or create the run loader
548 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
549 // load all base libraries to get the loader classes
550 TString libs = gSystem->GetLibraries() ;
551 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
552 if (!IsSelected(AliQA::GetDetName(iDet)))
554 TString detName = AliQA::GetDetName(iDet) ;
555 if (detName == "HLT")
557 if (libs.Contains("lib" + detName + "base.so"))
559 gSystem->Load("lib" + detName + "base.so");
561 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
563 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
566 fRunLoader->CdGAFile();
567 if (fRunLoader->LoadgAlice() == 0) {
568 gAlice = fRunLoader->GetAliRun();
572 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
576 } else { // galice.root does not exist
577 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
583 fRunLoader->LoadHeader();
584 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
589 //_____________________________________________________________________________
590 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
592 // check whether detName is contained in detectors
593 // if yes, it is removed from detectors
596 const TString detName(det) ;
597 // always activates Correlation
598 if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) {
601 // check if all detectors are selected
602 if (fDetectors.Contains("ALL")) {
605 } else if ((fDetectors.CompareTo(detName) == 0) ||
606 fDetectors.BeginsWith(detName+" ") ||
607 fDetectors.EndsWith(" "+detName) ||
608 fDetectors.Contains(" "+detName+" ")) {
615 //_____________________________________________________________________________
616 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
618 // Merge data from all the cycles from all detectors in one single file per run
619 // Merge the QA results from all the data chunks in one run
620 Bool_t rv = MergeData(runNumber) ;
621 rv *= MergeResults(runNumber) ;
626 //_____________________________________________________________________________
627 Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const
629 // Merge all the cycles from all detectors in one single file per run
632 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
634 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
635 gROOT->ProcessLine(cmd.Data()) ;
636 ifstream in("tempo.txt") ;
637 const Int_t runMax = 10 ;
638 TString file[AliQA::kNDET*runMax] ;
639 Int_t run[AliQA::kNDET*runMax] = {-1} ;
646 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
651 AliError(Form("run number %d not found", runNumber)) ;
656 Int_t runIndexMax = 0 ;
657 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
658 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
659 TString tmp(file[ifile]) ;
660 tmp.ReplaceAll(".root", "") ;
661 TString det = tmp(0, tmp.Index(".")) ;
662 tmp.Remove(0, tmp.Index(stmp)+4) ;
663 TString ttmp = tmp(0, tmp.Index(".")) ;
664 Int_t newRun = ttmp.Atoi() ;
665 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
666 if (newRun == run[irun])
668 run[runIndex] = newRun ;
671 runIndexMax = runIndex ;
672 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
673 Int_t cycle = ttmp.Atoi() ;
674 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
676 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
678 TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),run[irun]));
679 merger.OutputFile(outFileName.Data()) ;
680 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
681 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
682 TString tmp(file[ifile]) ;
683 if (tmp.Contains(pattern)) {
684 merger.AddFile(tmp) ;
693 //_____________________________________________________________________________
694 Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const
696 // Merge the QA result from all the data chunks in a run
698 cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ;
699 gROOT->ProcessLine(cmd.Data()) ;
700 ifstream in("tempo.txt") ;
701 const Int_t chunkMax = 100 ;
702 TString fileList[chunkMax] ;
707 in >> fileList[index] ;
710 AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ;
715 AliError("No QA Result File found") ;
720 TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber));
721 merger.OutputFile(outFileName.Data()) ;
722 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
723 TString file = fileList[ifile] ;
724 merger.AddFile(file) ;
731 //_____________________________________________________________________________
732 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
734 // Reset the default data members
736 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
737 if (IsSelected(AliQA::GetDetName(iDet))) {
738 AliQADataMaker * qadm = GetQADataMaker(iDet);
742 if (fRawReaderDelete) {
747 fCycleSame = sameCycle ;
751 fNumberOfEvents = 999999 ;
754 //_____________________________________________________________________________
755 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
757 //Runs all the QA data Maker for Raws only
759 fCycleSame = sameCycle ;
760 fRawReader = rawReader ;
761 fDetectors = detectors ;
762 fDetectorsW = detectors ;
764 AliCDBManager* man = AliCDBManager::Instance() ;
766 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
767 rawReader->NextEvent() ;
768 man->SetRun(fRawReader->GetRunNumber()) ;
769 rawReader->RewindEvents() ;
772 if ( !Init(AliQA::kRAWS) )
774 fRawReaderDelete = kFALSE ;
780 //_____________________________________________________________________________
781 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
783 //Runs all the QA data Maker for Raws only
785 fCycleSame = sameCycle ;
786 fDetectors = detectors ;
787 fDetectorsW = detectors ;
789 AliCDBManager* man = AliCDBManager::Instance() ;
790 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
791 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
793 AliFatal("galice.root file not found in current directory") ;
797 if ( ! rl->GetAliRun() ) {
798 AliFatal("AliRun not found in galice.root") ;
801 man->SetRun(rl->GetHeader()->GetRun());
806 if ( !Init(AliQA::kRAWS, fileName) )
813 //_____________________________________________________________________________
814 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
816 // Runs all the QA data Maker for every detector
818 fCycleSame = sameCycle ;
819 fDetectors = detectors ;
820 fDetectorsW = detectors ;
822 AliCDBManager* man = AliCDBManager::Instance() ;
823 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
824 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
826 AliFatal("galice.root file not found in current directory") ;
830 if ( ! rl->GetAliRun() ) {
831 AliInfo("AliRun not found in galice.root") ;
834 man->SetRun(rl->GetHeader()->GetRun()) ;
840 if ( taskIndex == AliQA::kNULLTASKINDEX) {
841 for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
842 if ( fTasks.Contains(Form("%d", task)) ) {
843 if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) )
845 DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
849 if ( !Init(taskIndex, fileName) )
858 //_____________________________________________________________________________
859 void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader)
861 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
864 AliCodeTimerAuto("") ;
865 if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
866 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
867 if (!IsSelected(AliQA::GetDetName(iDet)))
869 AliQADataMaker *qadm = GetQADataMaker(iDet);
872 if ( qadm->IsCycleDone() ) {
875 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
876 qadm->Exec(AliQA::kRAWS, rawReader) ;
877 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
882 //_____________________________________________________________________________
883 void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd)
885 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
887 AliCodeTimerAuto("") ;
888 if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
889 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
890 if (!IsSelected(AliQA::GetDetName(iDet)))
892 AliQADataMaker *qadm = GetQADataMaker(iDet);
895 if ( qadm->IsCycleDone() ) {
898 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
899 qadm->Exec(AliQA::kESDS, esd) ;
900 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
905 //_____________________________________________________________________________
906 void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree)
908 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
909 AliCodeTimerAuto("") ;
910 if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
911 if (IsSelected(AliQA::GetDetName(det))) {
912 AliQADataMaker *qadm = GetQADataMaker(det);
914 if ( qadm->IsCycleDone() ) {
917 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
918 qadm->Exec(AliQA::kRECPOINTS, tree) ;
919 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
925 //_____________________________________________________________________________
926 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
928 // take the locasl QA data merge into a single file and save in OCDB
930 TString tmp(AliQA::GetQARefStorage()) ;
931 if ( tmp.IsNull() ) {
932 AliError("No storage defined, use AliQA::SetQARefStorage") ;
935 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
936 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
939 TString sdet(detectors) ;
942 if ( sdet.Contains("ALL") ) {
943 rv = Merge(runNumber) ;
946 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
947 inputFile = TFile::Open(inputFileName.Data()) ;
948 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
950 for (Int_t index = 0; index < AliQA::kNDET; index++) {
951 if (sdet.Contains(AliQA::GetDetName(index))) {
952 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
953 inputFile = TFile::Open(inputFileName.Data()) ;
954 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
961 //_____________________________________________________________________________
962 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
964 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
966 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
967 AliCDBManager* man = AliCDBManager::Instance() ;
968 if ( ! man->IsDefaultStorageSet() ) {
969 TString tmp( AliQA::GetQARefStorage() ) ;
970 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
971 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
973 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
975 tmp1.Append("?user=alidaq") ;
976 man->SetDefaultStorage(tmp1.Data()) ;
979 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
980 if(man->GetRun() < 0)
981 man->SetRun(runNumber);
984 mdr.SetResponsible("yves schutz");
986 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
987 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
989 AliInfo(Form("Entering %s", detDir->GetName())) ;
990 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
991 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
992 TList * listDetQAD = new TList() ;
993 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
994 mdr.SetComment("HMPID QA stuff");
995 listDetQAD->SetName(listName) ;
996 TList * taskList = detDir->GetListOfKeys() ;
997 TIter nextTask(taskList) ;
999 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
1000 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1001 AliInfo(Form("Saving %s", taskDir->GetName())) ;
1002 TObjArray * listTaskQAD = new TObjArray(100) ;
1003 listTaskQAD->SetName(taskKey->GetName()) ;
1004 listDetQAD->Add(listTaskQAD) ;
1005 TList * histList = taskDir->GetListOfKeys() ;
1006 TIter nextHist(histList) ;
1008 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1009 TObject * odata = taskDir->Get(histKey->GetName()) ;
1011 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1013 AliInfo(Form("Adding %s", histKey->GetName())) ;
1014 if ( odata->IsA()->InheritsFrom("TH1") ) {
1015 AliInfo(Form("Adding %s", histKey->GetName())) ;
1016 TH1 * hdata = static_cast<TH1*>(odata) ;
1017 listTaskQAD->Add(hdata) ;
1022 man->Put(listDetQAD, idr, &mdr) ;
1028 //_____________________________________________________________________________
1029 void AliQADataMakerSteer::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
1031 // Set custom reconstruction parameters for a given detector
1032 // Single set of parameters for all the events
1033 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1034 if(!strcmp(detector, AliQA::GetDetName(iDet))) {
1035 par->SetAsDefault();
1036 fRecoParam.AddDetRecoParam(iDet,par);