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 "AliESDEvent.h"
44 #include "AliGeomManager.h"
45 #include "AliGlobalQADataMaker.h"
46 #include "AliHeader.h"
48 #include "AliModule.h"
50 #include "AliQADataMakerRec.h"
51 #include "AliQADataMakerSim.h"
52 #include "AliQADataMakerSteer.h"
53 #include "AliRawReaderDate.h"
54 #include "AliRawReaderFile.h"
55 #include "AliRawReaderRoot.h"
57 #include "AliRunLoader.h"
59 ClassImp(AliQADataMakerSteer)
61 //_____________________________________________________________________________
62 AliQADataMakerSteer::AliQADataMakerSteer(char * mode, const char* gAliceFilename, const char * name, const char * title) :
70 fGAliceFileName(gAliceFilename),
74 fNumberOfEvents(999999),
77 fRawReaderDelete(kTRUE),
81 fMaxEvents = fNumberOfEvents ;
82 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
83 if (IsSelected(AliQA::GetDetName(iDet))) {
84 fLoader[iDet] = NULL ;
85 fQADataMaker[iDet] = NULL ;
86 fQACycles[iDet] = 999999 ;
91 //_____________________________________________________________________________
92 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
94 fCurrentEvent(qas.fCurrentEvent),
96 fDetectors(qas.fDetectors),
97 fDetectorsW(qas.fDetectorsW),
100 fGAliceFileName(qas.fGAliceFileName),
101 fFirstEvent(qas.fFirstEvent),
102 fMaxEvents(qas.fMaxEvents),
104 fNumberOfEvents(qas.fNumberOfEvents),
105 fRunNumber(qas.fRunNumber),
107 fRawReaderDelete(kTRUE),
111 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
112 fLoader[iDet] = qas.fLoader[iDet] ;
113 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
114 fQACycles[iDet] = qas.fQACycles[iDet] ;
118 //_____________________________________________________________________________
119 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
121 // assignment operator
122 this->~AliQADataMakerSteer() ;
123 new(this) AliQADataMakerSteer(qas) ;
127 //_____________________________________________________________________________
128 AliQADataMakerSteer::~AliQADataMakerSteer()
131 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
132 if (IsSelected(AliQA::GetDetName(iDet))) {
133 fLoader[iDet] = NULL;
134 if (fQADataMaker[iDet]) {
135 (fQADataMaker[iDet])->Finish() ;
136 delete fQADataMaker[iDet] ;
140 if (fRawReaderDelete) {
147 //_____________________________________________________________________________
148 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
150 // Runs all the QA data Maker for every detector
153 // Fill QA data in event loop
154 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
157 if ( iEvent%10 == 0 )
158 AliInfo(Form("processing event %d", iEvent));
159 if ( taskIndex == AliQA::kRAWS ) {
160 if ( !fRawReader->NextEvent() )
162 } else if ( taskIndex == AliQA::kESDS ) {
163 if ( fESDTree->GetEntry(iEvent) == 0 )
166 if ( fRunLoader->GetEvent(iEvent) != 0 )
169 // loop over active loaders
170 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
171 if (IsSelected(AliQA::GetDetName(iDet))) {
172 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
173 if ( qadm->IsCycleDone() ) {
174 qadm->EndOfCycle(AliQA::kRAWS) ;
175 qadm->StartOfCycle(AliQA::kRAWS) ;
178 AliLoader* loader = GetLoader(qadm->GetUniqueID());
181 qadm->Exec(taskIndex, fRawReader) ;
185 data = loader->TreeH() ;
187 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
189 qadm->Exec(taskIndex, data) ;
192 case AliQA::kSDIGITS :
193 loader->LoadSDigits() ;
194 data = loader->TreeS() ;
196 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
198 qadm->Exec(taskIndex, data) ;
201 case AliQA::kDIGITS :
202 loader->LoadDigits() ;
203 data = loader->TreeD() ;
205 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
207 qadm->Exec(taskIndex, data) ;
210 case AliQA::kRECPOINTS :
211 loader->LoadRecPoints() ;
212 data = loader->TreeR() ;
214 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
216 qadm->Exec(taskIndex, data) ;
219 case AliQA::kTRACKSEGMENTS :
221 case AliQA::kRECPARTICLES :
224 qadm->Exec(taskIndex, fESD) ;
226 case AliQA::kNTASKINDEX :
232 // Save QA data for all detectors
233 rv = Finish(taskIndex) ;
235 if ( taskIndex == AliQA::kRAWS )
236 fRawReader->RewindEvents() ;
241 //_____________________________________________________________________________
242 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
244 // write output to file for all detectors
245 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
246 if (IsSelected(AliQA::GetDetName(iDet))) {
247 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
248 qadm->EndOfCycle(taskIndex) ;
254 //_____________________________________________________________________________
255 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
257 // Retrieve the list of QA data for a given detector and a given task
258 TObjArray * rv = NULL ;
259 if ( !strlen(AliQA::GetQARefStorage()) ) {
260 AliError("No storage defined, use AliQA::SetQARefStorage") ;
263 AliCDBManager* man = AliCDBManager::Instance() ;
264 if ( ! man->IsDefaultStorageSet() ) {
265 TString tmp(AliQA::GetQARefDefaultStorage()) ;
268 man->SetDefaultStorage(tmp.Data()) ;
269 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
271 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
272 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
273 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
274 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
276 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
280 //_____________________________________________________________________________
281 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
283 // get the loader for a detector
288 TString detName = AliQA::GetDetName(iDet) ;
289 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
291 return fLoader[iDet] ;
293 // load the QA data maker object
294 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
295 TString loaderName = "Ali" + detName + "Loader" ;
297 AliLoader * loader = NULL ;
298 // first check if a plugin is defined for the quality assurance data maker
299 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
300 // if not, add a plugin for it
301 if (!pluginHandler) {
302 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
303 TString libs = gSystem->GetLibraries() ;
304 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
305 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
307 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
309 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
311 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
312 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
315 fLoader[iDet] = loader ;
319 //_____________________________________________________________________________
320 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
322 // get the quality assurance data maker for a detector
324 if (fQADataMaker[iDet])
325 return fQADataMaker[iDet] ;
327 AliQADataMaker * qadm = NULL ;
329 if (iDet == AliQA::kGLOBAL) { //Global QA
330 qadm = new AliGlobalQADataMaker();
331 fQADataMaker[iDet] = qadm;
335 // load the QA data maker object
336 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
337 TString detName = AliQA::GetDetName(iDet) ;
339 if (tmp.Contains("sim"))
340 tmp.ReplaceAll("s", "S") ;
341 else if (tmp.Contains("rec"))
342 tmp.ReplaceAll("r", "R") ;
344 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
346 // first check if a plugin is defined for the quality assurance data maker
347 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
348 // if not, add a plugin for it
349 if (!pluginHandler) {
350 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
351 TString libs = gSystem->GetLibraries() ;
352 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
353 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
355 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
357 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
359 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
360 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
363 fQADataMaker[iDet] = qadm ;
367 //_____________________________________________________________________________
368 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
370 // Initialize the event source and QA data makers
372 if (taskIndex == AliQA::kRAWS) {
374 fRawReader = AliRawReader::Create(input);
378 fRawReaderDelete = kTRUE ;
379 fRawReader->NextEvent() ;
380 fRunNumber = fRawReader->GetRunNumber() ;
381 AliCDBManager::Instance()->SetRun(fRunNumber) ;
382 fRawReader->RewindEvents();
383 fNumberOfEvents = 999999 ;
384 if ( fMaxEvents < 0 )
385 fMaxEvents = fNumberOfEvents ;
386 } else if (taskIndex == AliQA::kESDS) {
387 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
388 TFile * esdFile = TFile::Open("AliESDs.root") ;
389 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
391 AliError("esdTree not found") ;
394 fESD = new AliESDEvent() ;
395 fESD->ReadFromTree(fESDTree) ;
396 fESDTree->GetEntry(0) ;
397 fRunNumber = fESD->GetRunNumber() ;
398 fNumberOfEvents = fESDTree->GetEntries() ;
399 if ( fMaxEvents < 0 )
400 fMaxEvents = fNumberOfEvents ;
403 AliError("AliESDs.root not found") ;
407 if ( !InitRunLoader() ) {
408 AliWarning("No Run Loader not found") ;
410 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
411 if ( fMaxEvents < 0 )
412 fMaxEvents = fNumberOfEvents ;
418 TObjArray* detArray = NULL ;
419 if (fRunLoader) // check if RunLoader exists
420 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
421 detArray = fRunLoader->GetAliRun()->Detectors() ;
422 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
425 // Initialize all QA data makers for all detectors
426 fRunNumber = AliCDBManager::Instance()->GetRun() ;
427 if ( ! AliGeomManager::GetGeometry() )
428 AliGeomManager::LoadGeometry() ;
430 // Build array of QA data makers for all detectors
431 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
432 if (IsSelected(AliQA::GetDetName(iDet))) {
433 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
435 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
436 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
438 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
439 // skip non active detectors
441 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
442 if (!det || !det->IsActive())
445 qadm->SetName(AliQA::GetDetName(iDet));
446 qadm->SetUniqueID(iDet);
447 qadm->Init(taskIndex, fRunNumber, GetQACycles(qadm->GetUniqueID())) ;
448 qadm->StartOfCycle(taskIndex, fCycleSame) ;
455 //_____________________________________________________________________________
456 Bool_t AliQADataMakerSteer::InitRunLoader()
458 // get or create the run loader
462 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
463 // load all base libraries to get the loader classes
464 TString libs = gSystem->GetLibraries() ;
465 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
466 if (!IsSelected(AliQA::GetDetName(iDet)))
468 TString detName = AliQA::GetDetName(iDet) ;
469 if (detName == "HLT")
471 if (libs.Contains("lib" + detName + "base.so"))
473 gSystem->Load("lib" + detName + "base.so");
475 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
477 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
480 fRunLoader->CdGAFile();
481 if (fRunLoader->LoadgAlice() == 0) {
482 gAlice = fRunLoader->GetAliRun();
486 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
490 } else { // galice.root does not exist
491 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
497 fRunLoader->LoadHeader();
498 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
503 //_____________________________________________________________________________
504 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
506 // check whether detName is contained in detectors
507 // if yes, it is removed from detectors
510 const TString detName(det) ;
511 // check if all detectors are selected
512 if (fDetectors.Contains("ALL")) {
515 } else if ((fDetectors.CompareTo(detName) == 0) ||
516 fDetectors.BeginsWith(detName+" ") ||
517 fDetectors.EndsWith(" "+detName) ||
518 fDetectors.Contains(" "+detName+" ")) {
525 //_____________________________________________________________________________
526 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
528 // Merge all the cycles from all detectors in one single file per run
530 if ( runNumber == -1 )
531 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
533 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
534 gROOT->ProcessLine(cmd.Data()) ;
535 ifstream in("tempo.txt") ;
536 const Int_t runMax = 10 ;
537 TString file[AliQA::kNDET*runMax] ;
538 Int_t run[AliQA::kNDET*runMax] = {-1} ;
545 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
550 AliError(Form("run number %d not found", runNumber)) ;
555 Int_t runIndexMax = 0 ;
556 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
557 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
558 TString tmp(file[ifile]) ;
559 tmp.ReplaceAll(".root", "") ;
560 TString det = tmp(0, tmp.Index(".")) ;
561 tmp.Remove(0, tmp.Index(stmp)+4) ;
562 TString ttmp = tmp(0, tmp.Index(".")) ;
563 Int_t newRun = ttmp.Atoi() ;
564 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
565 if (newRun == run[irun])
567 run[runIndex] = newRun ;
570 runIndexMax = runIndex ;
571 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
572 Int_t cycle = ttmp.Atoi() ;
573 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
575 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
577 TString outFileName(Form("Merged.%s.%d.root",AliQA::GetQADataFileName(),run[irun]));
578 merger.OutputFile(outFileName.Data()) ;
579 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
580 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
581 TString tmp(file[ifile]) ;
582 if (tmp.Contains(pattern)) {
583 merger.AddFile(tmp) ;
592 //_____________________________________________________________________________
593 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
595 // Reset the default data members
597 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
598 if (IsSelected(AliQA::GetDetName(iDet))) {
599 AliQADataMaker * qadm = GetQADataMaker(iDet);
600 qadm->Reset(sameCycle);
603 if (fRawReaderDelete) {
608 fCycleSame = sameCycle ;
612 fNumberOfEvents = 999999 ;
615 //_____________________________________________________________________________
616 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
618 //Runs all the QA data Maker for Raws only
620 fCycleSame = sameCycle ;
621 fRawReader = rawReader ;
622 fDetectors = detectors ;
623 fDetectorsW = detectors ;
625 AliCDBManager* man = AliCDBManager::Instance() ;
627 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
628 rawReader->NextEvent() ;
629 man->SetRun(fRawReader->GetRunNumber()) ;
630 rawReader->RewindEvents() ;
633 if ( !Init(AliQA::kRAWS) )
635 fRawReaderDelete = kFALSE ;
641 //_____________________________________________________________________________
642 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
644 //Runs all the QA data Maker for Raws only
646 fCycleSame = sameCycle ;
647 fDetectors = detectors ;
648 fDetectorsW = detectors ;
650 AliCDBManager* man = AliCDBManager::Instance() ;
651 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
652 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
654 AliFatal("galice.root file not found in current directory") ;
658 if ( ! rl->GetAliRun() ) {
659 AliFatal("AliRun not found in galice.root") ;
662 man->SetRun(rl->GetHeader()->GetRun());
667 if ( !Init(AliQA::kRAWS, fileName) )
674 //_____________________________________________________________________________
675 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
677 // Runs all the QA data Maker for every detector
679 fCycleSame = sameCycle ;
680 fDetectors = detectors ;
681 fDetectorsW = detectors ;
683 AliCDBManager* man = AliCDBManager::Instance() ;
684 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
685 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
687 AliFatal("galice.root file not found in current directory") ;
691 if ( ! rl->GetAliRun() ) {
692 AliInfo("AliRun not found in galice.root") ;
695 man->SetRun(rl->GetHeader()->GetRun()) ;
700 if ( !Init(taskIndex, fileName) )
709 //_____________________________________________________________________________
710 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
712 // take the locasl QA data merge into a single file and save in OCDB
714 TString tmp(AliQA::GetQARefStorage()) ;
715 if ( tmp.IsNull() ) {
716 AliError("No storage defined, use AliQA::SetQARefStorage") ;
719 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
720 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
723 TString sdet(detectors) ;
726 if ( sdet.Contains("ALL") ) {
727 rv = Merge(runNumber) ;
730 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
731 inputFile = TFile::Open(inputFileName.Data()) ;
732 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
734 for (Int_t index = 0; index < AliQA::kNDET; index++) {
735 if (sdet.Contains(AliQA::GetDetName(index))) {
736 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
737 inputFile = TFile::Open(inputFileName.Data()) ;
738 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
745 //_____________________________________________________________________________
746 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
748 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
750 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
751 AliCDBManager* man = AliCDBManager::Instance() ;
752 if ( ! man->IsDefaultStorageSet() ) {
753 TString tmp( AliQA::GetQARefStorage() ) ;
754 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
755 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
757 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
759 tmp1.Append("?user=alidaq") ;
760 man->SetDefaultStorage(tmp1.Data()) ;
763 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
764 if(man->GetRun() < 0)
765 man->SetRun(runNumber);
768 mdr.SetResponsible("yves schutz");
770 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
771 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
773 AliInfo(Form("Entering %s", detDir->GetName())) ;
774 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
775 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
776 TList * listDetQAD = new TList() ;
777 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
778 mdr.SetComment("HMPID QA stuff");
779 listDetQAD->SetName(listName) ;
780 TList * taskList = detDir->GetListOfKeys() ;
781 TIter nextTask(taskList) ;
783 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
784 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
785 AliInfo(Form("Saving %s", taskDir->GetName())) ;
786 TObjArray * listTaskQAD = new TObjArray(100) ;
787 listTaskQAD->SetName(taskKey->GetName()) ;
788 listDetQAD->Add(listTaskQAD) ;
789 TList * histList = taskDir->GetListOfKeys() ;
790 TIter nextHist(histList) ;
792 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
793 TObject * odata = taskDir->Get(histKey->GetName()) ;
795 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
797 AliInfo(Form("Adding %s", histKey->GetName())) ;
798 if ( odata->IsA()->InheritsFrom("TH1") ) {
799 AliInfo(Form("Adding %s", histKey->GetName())) ;
800 TH1 * hdata = static_cast<TH1*>(odata) ;
801 listTaskQAD->Add(hdata) ;
806 man->Put(listDetQAD, idr, &mdr) ;