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 **************************************************************************/
20 #include <TFileMerger.h>
21 #include <TPluginManager.h>
26 #include "AliCDBManager.h"
27 #include "AliCDBEntry.h"
29 #include "AliCDBMetaData.h"
30 #include "AliESDEvent.h"
31 #include "AliHeader.h"
33 #include "AliModule.h"
35 #include "AliQADataMakerRec.h"
36 #include "AliQADataMakerSim.h"
37 #include "AliQADataMakerSteer.h"
38 #include "AliRawReaderDate.h"
39 #include "AliRawReaderFile.h"
40 #include "AliRawReaderRoot.h"
42 #include "AliRunLoader.h"
44 ClassImp(AliQADataMakerSteer)
46 //_____________________________________________________________________________
47 AliQADataMakerSteer::AliQADataMakerSteer(const char* gAliceFilename, const char * name, const char * title) :
55 fGAliceFileName(gAliceFilename),
57 fNumberOfEvents(999999),
59 fRawReaderDelete(kTRUE),
63 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
64 if (IsSelected(AliQA::GetDetName(iDet))) {
65 fLoader[iDet] = NULL ;
66 fQADataMaker[iDet] = NULL ;
67 fQACycles[iDet] = 999999 ;
72 //_____________________________________________________________________________
73 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
76 fDetectors(qas.fDetectors),
77 fDetectorsW(qas.fDetectorsW),
81 fGAliceFileName(qas.fGAliceFileName),
82 fRunNumber(qas.fRunNumber),
83 fNumberOfEvents(qas.fNumberOfEvents),
85 fRawReaderDelete(kTRUE),
89 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
90 fLoader[iDet] = qas.fLoader[iDet] ;
91 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
92 fQACycles[iDet] = qas.fQACycles[iDet] ;
96 //_____________________________________________________________________________
97 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
99 // assignment operator
100 this->~AliQADataMakerSteer() ;
101 new(this) AliQADataMakerSteer(qas) ;
105 //_____________________________________________________________________________
106 AliQADataMakerSteer::~AliQADataMakerSteer()
109 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
110 if (IsSelected(AliQA::GetDetName(iDet))) {
111 fLoader[iDet] = NULL;
112 if (fQADataMaker[iDet]) {
113 (fQADataMaker[iDet])->Finish() ;
114 delete fQADataMaker[iDet] ;
115 fQADataMaker[iDet] = NULL ;
120 if (fRawReaderDelete) {
127 //_____________________________________________________________________________
128 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX taskIndex, const char * mode)
130 // Runs all the QA data Maker for every detector
133 // Fill QA data in event loop
134 for (UInt_t iEvent = 0 ; iEvent < fNumberOfEvents ; iEvent++) {
136 if ( iEvent%10 == 0 )
137 AliInfo(Form("processing event %d", iEvent));
138 if ( taskIndex == AliQA::kRAWS ) {
139 if ( !fRawReader->NextEvent() )
141 } else if ( taskIndex == AliQA::kESDS ) {
142 if ( fESDTree->GetEntry(iEvent) == 0 )
145 if ( fRunLoader->GetEvent(iEvent) != 0 )
148 // loop over detectors
149 TObjArray* detArray = NULL ;
150 if (fRunLoader) // check if RunLoader exists
151 if ( fRunLoader->GetAliRun() ) // check if AliRun exists in gAlice.root
152 detArray = fRunLoader->GetAliRun()->Detectors() ;
153 for (UInt_t iDet = 0 ; iDet < fgkNDetectors ; iDet++) {
155 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
156 if (!det || !det->IsActive())
159 if (!IsSelected(AliQA::GetDetName(iDet)))
161 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
165 if ( qadm->IsCycleDone() ) {
166 qadm->EndOfCycle(AliQA::kRAWS) ;
167 qadm->StartOfCycle(AliQA::kRAWS) ;
172 qadm->Exec(taskIndex, fRawReader) ;
175 GetLoader(iDet)->LoadHits() ;
176 data = GetLoader(iDet)->TreeH() ;
178 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
180 qadm->Exec(taskIndex, data) ;
183 case AliQA::kSDIGITS :
184 GetLoader(iDet)->LoadSDigits() ;
185 data = GetLoader(iDet)->TreeS() ;
187 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
189 qadm->Exec(taskIndex, data) ;
192 case AliQA::kDIGITS :
193 GetLoader(iDet)->LoadDigits() ;
194 data = GetLoader(iDet)->TreeD() ;
196 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
198 qadm->Exec(taskIndex, data) ;
201 case AliQA::kRECPOINTS :
202 GetLoader(iDet)->LoadRecPoints() ;
203 data = GetLoader(iDet)->TreeR() ;
205 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
207 qadm->Exec(taskIndex, data) ;
210 case AliQA::kTRACKSEGMENTS :
212 case AliQA::kRECPARTICLES :
215 qadm->Exec(taskIndex, fESD) ;
217 case AliQA::kNTASKINDEX :
220 //qadm->Increment() ;
224 // // Save QA data for all detectors
225 rv = Finish(taskIndex, mode) ;
230 //_____________________________________________________________________________
231 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX taskIndex, const char * mode)
233 // write output to file for all detectors
234 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
235 if (IsSelected(AliQA::GetDetName(iDet))) {
236 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
238 qadm->EndOfCycle(taskIndex) ;
245 //_____________________________________________________________________________
246 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task) const
248 // Retrieve the list of QA data for a given detector and a given task
249 TObjArray * rv = NULL ;
250 TString tmp(AliQA::GetQARefStorage()) ;
251 if ( tmp.IsNull() ) {
252 AliError("No storage defined, use AliQA::SetQARefStorage") ;
255 AliCDBManager* man = AliCDBManager::Instance() ;
256 if ( ! man->IsDefaultStorageSet() ) {
257 man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
258 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
260 char detOCDBDir[10] ;
261 sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName()) ;
262 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir, AliQA::GetTaskName(task).Data())) ;
263 AliCDBEntry* entry = man->Get(detOCDBDir, 0) ; //FIXME 0 --> Run Number
264 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
266 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
270 //_____________________________________________________________________________
271 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
273 // get the loader for a detector
275 TString detName = AliQA::GetDetName(iDet) ;
276 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
278 return fLoader[iDet] ;
280 // load the QA data maker object
281 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
282 TString loaderName = "Ali" + detName + "Loader" ;
284 AliLoader * loader = NULL ;
285 // first check if a plugin is defined for the quality assurance data maker
286 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
287 // if not, add a plugin for it
288 if (!pluginHandler) {
289 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
290 TString libs = gSystem->GetLibraries() ;
291 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
292 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
294 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
296 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
298 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
299 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
302 fLoader[iDet] = loader ;
306 //_____________________________________________________________________________
307 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet, const char * mode )
309 // get the quality assurance data maker for a detector
311 if (fQADataMaker[iDet])
312 return fQADataMaker[iDet] ;
314 AliQADataMaker * qadm = NULL ;
317 // load the QA data maker object
318 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
319 TString detName = AliQA::GetDetName(iDet) ;
321 if (tmp.Contains("sim"))
322 tmp.ReplaceAll("s", "S") ;
323 else if (tmp.Contains("rec"))
324 tmp.ReplaceAll("r", "R") ;
325 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
327 // first check if a plugin is defined for the quality assurance data maker
328 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
329 // if not, add a plugin for it
330 if (!pluginHandler) {
331 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
332 TString libs = gSystem->GetLibraries() ;
333 if (libs.Contains("lib" + detName + mode + ".so") || (gSystem->Load("lib" + detName + mode + ".so") >= 0)) {
334 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
336 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
338 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
340 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
341 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
344 fQADataMaker[iDet] = qadm ;
349 //_____________________________________________________________________________
350 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX taskIndex, const char * mode, const char * input )
352 // Initialize the event source and QA data makers
354 if (taskIndex == AliQA::kRAWS) {
356 TString fileName(input);
357 if (fileName.EndsWith("/")) {
358 fRawReader = new AliRawReaderFile(fileName);
359 } else if (fileName.EndsWith(".root")) {
360 fRawReader = new AliRawReaderRoot(fileName);
361 } else if (!fileName.IsNull()) {
362 fRawReader = new AliRawReaderDate(fileName);
363 fRawReader->SelectEvents(7);
368 fRawReaderDelete = kTRUE ;
369 fRawReader->NextEvent() ;
370 fRunNumber = fRawReader->GetRunNumber() ;
371 AliCDBManager::Instance()->SetRun(fRunNumber) ;
372 fRawReader->RewindEvents();
373 fNumberOfEvents = 999999 ;
374 } else if (taskIndex == AliQA::kESDS) {
375 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
376 TFile * esdFile = TFile::Open("AliESDs.root") ;
377 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
379 AliError("esdTree not found") ;
382 fESD = new AliESDEvent() ;
383 fESD->ReadFromTree(fESDTree) ;
384 fESDTree->GetEntry(0) ;
385 fRunNumber = fESD->GetRunNumber() ;
386 fNumberOfEvents = fESDTree->GetEntries() ;
389 AliError("AliESDs.root not found") ;
393 if ( !InitRunLoader() ) {
394 AliWarning("No Run Loader not found") ;
396 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
399 // Initialize all QA data makers for all detectors
400 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
402 if (IsSelected(AliQA::GetDetName(iDet))) {
403 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
405 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
406 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
408 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
409 qadm->Init(taskIndex, fRunNumber, GetQACycles(iDet)) ;
410 qadm->StartOfCycle(taskIndex, fCycleSame) ;
418 //_____________________________________________________________________________
419 Bool_t AliQADataMakerSteer::InitRunLoader()
421 // get or create the run loader
427 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
428 // load all base libraries to get the loader classes
429 TString libs = gSystem->GetLibraries() ;
430 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
431 if (!IsSelected(AliQA::GetDetName(iDet)))
433 TString detName = AliQA::GetDetName(iDet) ;
434 if (detName == "HLT")
436 if (libs.Contains("lib" + detName + "base.so"))
438 gSystem->Load("lib" + detName + "base.so");
440 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
442 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
445 fRunLoader->CdGAFile();
446 if (fRunLoader->LoadgAlice() == 0) {
447 gAlice = fRunLoader->GetAliRun();
451 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
455 } else { // galice.root does not exist
456 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
463 //_____________________________________________________________________________
464 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
466 // check whether detName is contained in detectors
467 // if yes, it is removed from detectors
469 const TString detName(det) ;
470 // check if all detectors are selected
471 if ((fDetectors.CompareTo("ALL") == 0) ||
472 fDetectors.BeginsWith("ALL ") ||
473 fDetectors.EndsWith(" ALL") ||
474 fDetectors.Contains(" ALL ")) {
479 // search for the given detector
481 //AliInfo(Form("SSSSSSSSSSSSS fd = %s det = %s ", fDetectors.Data(), det)) ;
482 if ((fDetectors.CompareTo(detName) == 0) ||
483 fDetectors.BeginsWith(detName+" ") ||
484 fDetectors.EndsWith(" "+detName) ||
485 fDetectors.Contains(" "+detName+" ")) {
486 // fDetectors.ReplaceAll(detName, "");
490 // clean up the detectors string
491 // while (fDetectors.Contains(" "))
492 // fDetectors.ReplaceAll(" ", " ");
493 // while (fDetectors.BeginsWith(" "))
494 // fDetectors.Remove(0, 1);
495 // while (fDetectors.EndsWith(" "))
496 // fDetectors.Remove(fDetectors.Length()-1, 1);
501 //_____________________________________________________________________________
502 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
504 // Merge all the cycles from all detectors in one single file per run
506 if ( runNumber == -1 )
507 sprintf(cmd, ".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
509 sprintf(cmd, ".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
510 gROOT->ProcessLine(cmd) ;
511 ifstream in("tempo.txt") ;
512 const Int_t runMax = 10 ;
513 TString file[AliQA::kNDET*runMax] ;
514 Int_t run[AliQA::kNDET*runMax] ;
519 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
526 AliError(Form("run number %d not found", runNumber)) ;
531 Int_t runIndexMax = 0 ;
533 sprintf(stmp, ".%s.", AliQA::GetQADataFileName()) ;
534 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
535 TString tmp(file[ifile]) ;
536 tmp.ReplaceAll(".root", "") ;
537 TString det = tmp(0, tmp.Index(".")) ;
538 tmp.Remove(0, tmp.Index(stmp)+4) ;
539 TString ttmp = tmp(0, tmp.Index(".")) ;
540 Int_t newRun = ttmp.Atoi() ;
541 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
542 if (newRun == run[irun])
544 run[runIndex] = newRun ;
547 runIndexMax = runIndex ;
548 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
549 Int_t cycle = ttmp.Atoi() ;
550 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
552 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
554 char outFileName[20] ;
555 sprintf(outFileName, "Merged.%s.%d.root", AliQA::GetQADataFileName(), run[irun]) ;
556 merger.OutputFile(outFileName) ;
557 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
559 sprintf(pattern, "%s.%d.", AliQA::GetQADataFileName(), run[irun]) ;
560 TString tmp(file[ifile]) ;
561 if (tmp.Contains(pattern)) {
562 merger.AddFile(tmp) ;
571 //_____________________________________________________________________________
572 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
574 // Reset the default data members
575 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
576 if (IsSelected(AliQA::GetDetName(iDet))) {
577 fLoader[iDet] = NULL;
578 if (fQADataMaker[iDet]) {
579 (fQADataMaker[iDet])->Reset(sameCycle) ;
580 //delete fQADataMaker[iDet] ;
581 //fQADataMaker[iDet] = NULL ;
586 if (fRawReaderDelete) {
591 fCycleSame = sameCycle ;
595 fNumberOfEvents = 999999 ;
598 //_____________________________________________________________________________
599 Bool_t AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader)
601 //Runs all the QA data Maker for Raws only
602 fRawReader = rawReader ;
603 fRawReaderDelete = kFALSE ;
605 fDetectors = detectors ;
607 // Initialize all QA data makers for all detectors
608 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
609 if (IsSelected(AliQA::GetDetName(iDet))) {
610 AliQADataMaker * qadm = GetQADataMaker(iDet, "rec") ;
612 AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
614 AliInfo(Form("Data Maker found for %s", qadm->GetName())) ;
615 qadm->Init(AliQA::kRAWS, fRunNumber, GetQACycles(iDet)) ;
616 qadm->StartOfCycle(AliQA::kRAWS, fCycleSame) ;
622 return DoIt(AliQA::kRAWS, "rec") ;
625 //_____________________________________________________________________________
626 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName)
628 //Runs all the QA data Maker for Raws only
629 //fCycleSame = kTRUE ;
630 fDetectors = detectors ;
631 fDetectorsW = detectors ;
634 if ( !Init(AliQA::kRAWS, "rec", fileName) )
637 // Initialize all QA data makers for all detectors
638 //for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
639 // if (IsSelected(AliQA::GetDetName(iDet))) {
640 // AliQADataMaker * qadm = GetQADataMaker(iDet, "rec") ;
642 // AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
644 // AliInfo(Form("Data Maker found for %s", qadm->GetName())) ;
645 // qadm->Init(AliQA::kRAWS, fRunNumber, GetQACycles(iDet)) ;
646 // qadm->StartOfCycle(AliQA::kRAWS, fCycleSame) ;
651 DoIt(AliQA::kRAWS, "rec") ;
655 //_____________________________________________________________________________
656 Bool_t AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX taskIndex, const char * fileName )
658 // Runs all the QA data Maker for every detector
661 fDetectors = detectors ;
664 if ( (taskIndex == AliQA::kHITS) || (taskIndex == AliQA::kSDIGITS) || (taskIndex == AliQA::kDIGITS) )
666 else if ( (taskIndex == AliQA::kRAWS) || (taskIndex == AliQA::kRECPOINTS) || (taskIndex == AliQA::kESDS) )
669 AliError(Form("%s not implemented", AliQA::GetTaskName(taskIndex).Data())) ;
673 if ( !Init(taskIndex, mode, fileName) )
676 rv = DoIt(taskIndex, mode) ;
682 //_____________________________________________________________________________
683 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const Int_t cycleNumber, const char * detectors) const
685 // take the locasl QA data merge into a single file and save in OCDB
687 TString tmp(AliQA::GetQARefStorage()) ;
688 if ( tmp.IsNull() ) {
689 AliError("No storage defined, use AliQA::SetQARefStorage") ;
692 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
693 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
696 TString sdet(detectors) ;
699 if ( sdet.Contains("ALL") ) {
700 rv = Merge(runNumber) ;
703 char inputFileName[20] ;
704 sprintf(inputFileName, "Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber) ;
705 inputFile = TFile::Open(inputFileName) ;
706 rv = SaveIt2OCDB(runNumber, inputFile) ;
708 for (Int_t index = 0; index < AliQA::kNDET; index++) {
709 if (sdet.Contains(AliQA::GetDetName(index))) {
710 char inputFileName[20] ;
711 sprintf(inputFileName, "%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber) ;
712 inputFile = TFile::Open(inputFileName) ;
713 rv *= SaveIt2OCDB(runNumber, inputFile) ;
720 //_____________________________________________________________________________
721 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile) const
723 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
725 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
726 AliCDBManager* man = AliCDBManager::Instance() ;
727 if ( ! man->IsDefaultStorageSet() ) {
728 man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
729 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
731 if(man->GetRun() < 0)
732 man->SetRun(runNumber);
734 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
735 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
737 AliInfo(Form("Entering %s", detDir->GetName())) ;
738 char detOCDBDir[20] ;
739 sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName()) ;
740 AliCDBId idr(detOCDBDir, runNumber, 999999999) ;
741 TList * listDetQAD = new TList() ;
743 sprintf(listName, "%s QA data Reference", AliQA::GetDetName(detIndex)) ;
744 listDetQAD->SetName(listName) ;
745 TList * taskList = detDir->GetListOfKeys() ;
746 TIter nextTask(taskList) ;
748 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
749 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
750 AliInfo(Form("Saving %s", taskDir->GetName())) ;
751 TObjArray * listTaskQAD = new TObjArray(100) ;
752 listTaskQAD->SetName(taskKey->GetName()) ;
753 listDetQAD->Add(listTaskQAD) ;
754 TList * histList = taskDir->GetListOfKeys() ;
755 TIter nextHist(histList) ;
757 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
758 TObject * odata = taskDir->Get(histKey->GetName()) ;
759 if ( odata->IsA()->InheritsFrom("TH1") ) {
760 AliInfo(Form("Adding %s", histKey->GetName())) ;
761 TH1 * hdata = static_cast<TH1*>(odata) ;
762 listTaskQAD->Add(hdata) ;
767 man->Put(listDetQAD, idr, &mdr) ;