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 "AliHeader.h"
46 #include "AliModule.h"
48 #include "AliQADataMakerRec.h"
49 #include "AliQADataMakerSim.h"
50 #include "AliQADataMakerSteer.h"
51 #include "AliRawReaderDate.h"
52 #include "AliRawReaderFile.h"
53 #include "AliRawReaderRoot.h"
55 #include "AliRunLoader.h"
57 ClassImp(AliQADataMakerSteer)
59 //_____________________________________________________________________________
60 AliQADataMakerSteer::AliQADataMakerSteer(const char* gAliceFilename, const char * name, const char * title) :
69 fGAliceFileName(gAliceFilename),
71 fNumberOfEvents(999999),
73 fRawReaderDelete(kTRUE),
77 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
78 if (IsSelected(AliQA::GetDetName(iDet))) {
79 fLoader[iDet] = NULL ;
80 fQADataMaker[iDet] = NULL ;
81 fQACycles[iDet] = 999999 ;
86 //_____________________________________________________________________________
87 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
89 fCurrentEvent(qas.fCurrentEvent),
91 fDetectors(qas.fDetectors),
92 fDetectorsW(qas.fDetectorsW),
96 fGAliceFileName(qas.fGAliceFileName),
97 fRunNumber(qas.fRunNumber),
98 fNumberOfEvents(qas.fNumberOfEvents),
100 fRawReaderDelete(kTRUE),
104 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
105 fLoader[iDet] = qas.fLoader[iDet] ;
106 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
107 fQACycles[iDet] = qas.fQACycles[iDet] ;
111 //_____________________________________________________________________________
112 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
114 // assignment operator
115 this->~AliQADataMakerSteer() ;
116 new(this) AliQADataMakerSteer(qas) ;
120 //_____________________________________________________________________________
121 AliQADataMakerSteer::~AliQADataMakerSteer()
124 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
125 if (IsSelected(AliQA::GetDetName(iDet))) {
126 fLoader[iDet] = NULL;
127 if (fQADataMaker[iDet]) {
128 (fQADataMaker[iDet])->Finish() ;
129 delete fQADataMaker[iDet] ;
130 fQADataMaker[iDet] = NULL ;
135 if (fRawReaderDelete) {
142 //_____________________________________________________________________________
143 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX taskIndex, const char * mode)
145 // Runs all the QA data Maker for every detector
148 // Fill QA data in event loop
149 for (UInt_t iEvent = 0 ; iEvent < fNumberOfEvents ; iEvent++) {
152 if ( iEvent%10 == 0 )
153 AliInfo(Form("processing event %d", iEvent));
154 if ( taskIndex == AliQA::kRAWS ) {
155 if ( !fRawReader->NextEvent() )
157 } else if ( taskIndex == AliQA::kESDS ) {
158 if ( fESDTree->GetEntry(iEvent) == 0 )
161 if ( fRunLoader->GetEvent(iEvent) != 0 )
164 // loop over detectors
165 TObjArray* detArray = NULL ;
166 if (fRunLoader) // check if RunLoader exists
167 if ( fRunLoader->GetAliRun() ) // check if AliRun exists in gAlice.root
168 detArray = fRunLoader->GetAliRun()->Detectors() ;
169 for (UInt_t iDet = 0 ; iDet < fgkNDetectors ; iDet++) {
171 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
172 if (!det || !det->IsActive())
175 if (!IsSelected(AliQA::GetDetName(iDet)))
177 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
181 if ( qadm->IsCycleDone() ) {
182 qadm->EndOfCycle(AliQA::kRAWS) ;
183 qadm->StartOfCycle(AliQA::kRAWS) ;
188 qadm->Exec(taskIndex, fRawReader) ;
191 GetLoader(iDet)->LoadHits() ;
192 data = GetLoader(iDet)->TreeH() ;
194 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
196 qadm->Exec(taskIndex, data) ;
199 case AliQA::kSDIGITS :
200 GetLoader(iDet)->LoadSDigits() ;
201 data = GetLoader(iDet)->TreeS() ;
203 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
205 qadm->Exec(taskIndex, data) ;
208 case AliQA::kDIGITS :
209 GetLoader(iDet)->LoadDigits() ;
210 data = GetLoader(iDet)->TreeD() ;
212 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
214 qadm->Exec(taskIndex, data) ;
217 case AliQA::kRECPOINTS :
218 GetLoader(iDet)->LoadRecPoints() ;
219 data = GetLoader(iDet)->TreeR() ;
221 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
223 qadm->Exec(taskIndex, data) ;
226 case AliQA::kTRACKSEGMENTS :
228 case AliQA::kRECPARTICLES :
231 qadm->Exec(taskIndex, fESD) ;
233 case AliQA::kNTASKINDEX :
236 //qadm->Increment() ;
240 // // Save QA data for all detectors
241 rv = Finish(taskIndex, mode) ;
246 //_____________________________________________________________________________
247 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX taskIndex, const char * mode)
249 // write output to file for all detectors
250 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
251 if (IsSelected(AliQA::GetDetName(iDet))) {
252 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
254 qadm->EndOfCycle(taskIndex) ;
261 //_____________________________________________________________________________
262 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task) const
264 // Retrieve the list of QA data for a given detector and a given task
265 TObjArray * rv = NULL ;
266 TString tmp(AliQA::GetQARefStorage()) ;
267 if ( tmp.IsNull() ) {
268 AliError("No storage defined, use AliQA::SetQARefStorage") ;
271 AliCDBManager* man = AliCDBManager::Instance() ;
272 if ( ! man->IsDefaultStorageSet() ) {
273 man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
274 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
276 char detOCDBDir[10] ;
277 sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName()) ;
278 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir, AliQA::GetTaskName(task).Data())) ;
279 AliCDBEntry* entry = man->Get(detOCDBDir, 0) ; //FIXME 0 --> Run Number
280 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
282 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
286 //_____________________________________________________________________________
287 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
289 // get the loader for a detector
291 TString detName = AliQA::GetDetName(iDet) ;
292 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
294 return fLoader[iDet] ;
296 // load the QA data maker object
297 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
298 TString loaderName = "Ali" + detName + "Loader" ;
300 AliLoader * loader = NULL ;
301 // first check if a plugin is defined for the quality assurance data maker
302 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
303 // if not, add a plugin for it
304 if (!pluginHandler) {
305 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
306 TString libs = gSystem->GetLibraries() ;
307 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
308 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
310 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
312 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
314 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
315 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
318 fLoader[iDet] = loader ;
322 //_____________________________________________________________________________
323 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet, const char * mode )
325 // get the quality assurance data maker for a detector
327 if (fQADataMaker[iDet])
328 return fQADataMaker[iDet] ;
330 AliQADataMaker * qadm = NULL ;
333 // load the QA data maker object
334 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
335 TString detName = AliQA::GetDetName(iDet) ;
337 if (tmp.Contains("sim"))
338 tmp.ReplaceAll("s", "S") ;
339 else if (tmp.Contains("rec"))
340 tmp.ReplaceAll("r", "R") ;
341 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
343 // first check if a plugin is defined for the quality assurance data maker
344 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
345 // if not, add a plugin for it
346 if (!pluginHandler) {
347 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
348 TString libs = gSystem->GetLibraries() ;
349 if (libs.Contains("lib" + detName + mode + ".so") || (gSystem->Load("lib" + detName + mode + ".so") >= 0)) {
350 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
352 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
354 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
356 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
357 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
360 fQADataMaker[iDet] = qadm ;
365 //_____________________________________________________________________________
366 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX taskIndex, const char * mode, const char * input )
368 // Initialize the event source and QA data makers
370 if (taskIndex == AliQA::kRAWS) {
372 TString fileName(input);
373 if (fileName.EndsWith("/")) {
374 fRawReader = new AliRawReaderFile(fileName);
375 } else if (fileName.EndsWith(".root")) {
376 fRawReader = new AliRawReaderRoot(fileName);
377 } else if (!fileName.IsNull()) {
378 fRawReader = new AliRawReaderDate(fileName);
379 fRawReader->SelectEvents(7);
384 fRawReaderDelete = kTRUE ;
385 fRawReader->NextEvent() ;
386 fRunNumber = fRawReader->GetRunNumber() ;
387 AliCDBManager::Instance()->SetRun(fRunNumber) ;
388 fRawReader->RewindEvents();
389 fNumberOfEvents = 999999 ;
390 } else if (taskIndex == AliQA::kESDS) {
391 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
392 TFile * esdFile = TFile::Open("AliESDs.root") ;
393 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
395 AliError("esdTree not found") ;
398 fESD = new AliESDEvent() ;
399 fESD->ReadFromTree(fESDTree) ;
400 fESDTree->GetEntry(0) ;
401 fRunNumber = fESD->GetRunNumber() ;
402 fNumberOfEvents = fESDTree->GetEntries() ;
405 AliError("AliESDs.root not found") ;
409 if ( !InitRunLoader() ) {
410 AliWarning("No Run Loader not found") ;
412 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
415 // Initialize all QA data makers for all detectors
416 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
418 if (IsSelected(AliQA::GetDetName(iDet))) {
419 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
421 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
422 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
424 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
425 qadm->Init(taskIndex, fRunNumber, GetQACycles(iDet)) ;
426 qadm->StartOfCycle(taskIndex, fCycleSame) ;
434 //_____________________________________________________________________________
435 Bool_t AliQADataMakerSteer::InitRunLoader()
437 // get or create the run loader
443 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
444 // load all base libraries to get the loader classes
445 TString libs = gSystem->GetLibraries() ;
446 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
447 if (!IsSelected(AliQA::GetDetName(iDet)))
449 TString detName = AliQA::GetDetName(iDet) ;
450 if (detName == "HLT")
452 if (libs.Contains("lib" + detName + "base.so"))
454 gSystem->Load("lib" + detName + "base.so");
456 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
458 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
461 fRunLoader->CdGAFile();
462 if (fRunLoader->LoadgAlice() == 0) {
463 gAlice = fRunLoader->GetAliRun();
467 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
471 } else { // galice.root does not exist
472 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
479 //_____________________________________________________________________________
480 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
482 // check whether detName is contained in detectors
483 // if yes, it is removed from detectors
485 const TString detName(det) ;
486 // check if all detectors are selected
487 if ((fDetectors.CompareTo("ALL") == 0) ||
488 fDetectors.BeginsWith("ALL ") ||
489 fDetectors.EndsWith(" ALL") ||
490 fDetectors.Contains(" ALL ")) {
495 // search for the given detector
497 //AliInfo(Form("SSSSSSSSSSSSS fd = %s det = %s ", fDetectors.Data(), det)) ;
498 if ((fDetectors.CompareTo(detName) == 0) ||
499 fDetectors.BeginsWith(detName+" ") ||
500 fDetectors.EndsWith(" "+detName) ||
501 fDetectors.Contains(" "+detName+" ")) {
502 // fDetectors.ReplaceAll(detName, "");
506 // clean up the detectors string
507 // while (fDetectors.Contains(" "))
508 // fDetectors.ReplaceAll(" ", " ");
509 // while (fDetectors.BeginsWith(" "))
510 // fDetectors.Remove(0, 1);
511 // while (fDetectors.EndsWith(" "))
512 // fDetectors.Remove(fDetectors.Length()-1, 1);
517 //_____________________________________________________________________________
518 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
520 // Merge all the cycles from all detectors in one single file per run
522 if ( runNumber == -1 )
523 sprintf(cmd, ".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
525 sprintf(cmd, ".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
526 gROOT->ProcessLine(cmd) ;
527 ifstream in("tempo.txt") ;
528 const Int_t runMax = 10 ;
529 TString file[AliQA::kNDET*runMax] ;
530 Int_t run[AliQA::kNDET*runMax] ;
535 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
542 AliError(Form("run number %d not found", runNumber)) ;
547 Int_t runIndexMax = 0 ;
549 sprintf(stmp, ".%s.", AliQA::GetQADataFileName()) ;
550 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
551 TString tmp(file[ifile]) ;
552 tmp.ReplaceAll(".root", "") ;
553 TString det = tmp(0, tmp.Index(".")) ;
554 tmp.Remove(0, tmp.Index(stmp)+4) ;
555 TString ttmp = tmp(0, tmp.Index(".")) ;
556 Int_t newRun = ttmp.Atoi() ;
557 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
558 if (newRun == run[irun])
560 run[runIndex] = newRun ;
563 runIndexMax = runIndex ;
564 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
565 Int_t cycle = ttmp.Atoi() ;
566 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
568 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
570 char outFileName[20] ;
571 sprintf(outFileName, "Merged.%s.%d.root", AliQA::GetQADataFileName(), run[irun]) ;
572 merger.OutputFile(outFileName) ;
573 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
575 sprintf(pattern, "%s.%d.", AliQA::GetQADataFileName(), run[irun]) ;
576 TString tmp(file[ifile]) ;
577 if (tmp.Contains(pattern)) {
578 merger.AddFile(tmp) ;
587 //_____________________________________________________________________________
588 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
590 // Reset the default data members
591 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
592 if (IsSelected(AliQA::GetDetName(iDet))) {
593 fLoader[iDet] = NULL;
594 if (fQADataMaker[iDet]) {
595 (fQADataMaker[iDet])->Reset(sameCycle) ;
596 //delete fQADataMaker[iDet] ;
597 //fQADataMaker[iDet] = NULL ;
602 if (fRawReaderDelete) {
607 fCycleSame = sameCycle ;
611 fNumberOfEvents = 999999 ;
614 //_____________________________________________________________________________
615 Bool_t AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader)
617 //Runs all the QA data Maker for Raws only
618 fRawReader = rawReader ;
619 fRawReaderDelete = kFALSE ;
621 fDetectors = detectors ;
623 // Initialize all QA data makers for all detectors
624 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
625 if (IsSelected(AliQA::GetDetName(iDet))) {
626 AliQADataMaker * qadm = GetQADataMaker(iDet, "rec") ;
628 AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
630 AliInfo(Form("Data Maker found for %s", qadm->GetName())) ;
631 qadm->Init(AliQA::kRAWS, fRunNumber, GetQACycles(iDet)) ;
632 qadm->StartOfCycle(AliQA::kRAWS, fCycleSame) ;
638 return DoIt(AliQA::kRAWS, "rec") ;
641 //_____________________________________________________________________________
642 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName)
644 //Runs all the QA data Maker for Raws only
645 //fCycleSame = kTRUE ;
646 fDetectors = detectors ;
647 fDetectorsW = detectors ;
650 if ( !Init(AliQA::kRAWS, "rec", fileName) )
653 // Initialize all QA data makers for all detectors
654 //for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
655 // if (IsSelected(AliQA::GetDetName(iDet))) {
656 // AliQADataMaker * qadm = GetQADataMaker(iDet, "rec") ;
658 // AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
660 // AliInfo(Form("Data Maker found for %s", qadm->GetName())) ;
661 // qadm->Init(AliQA::kRAWS, fRunNumber, GetQACycles(iDet)) ;
662 // qadm->StartOfCycle(AliQA::kRAWS, fCycleSame) ;
667 DoIt(AliQA::kRAWS, "rec") ;
671 //_____________________________________________________________________________
672 Bool_t AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX taskIndex, const char * fileName )
674 // Runs all the QA data Maker for every detector
677 fDetectors = detectors ;
680 if ( (taskIndex == AliQA::kHITS) || (taskIndex == AliQA::kSDIGITS) || (taskIndex == AliQA::kDIGITS) )
682 else if ( (taskIndex == AliQA::kRAWS) || (taskIndex == AliQA::kRECPOINTS) || (taskIndex == AliQA::kESDS) )
685 AliError(Form("%s not implemented", AliQA::GetTaskName(taskIndex).Data())) ;
689 if ( !Init(taskIndex, mode, fileName) )
692 rv = DoIt(taskIndex, mode) ;
698 //_____________________________________________________________________________
699 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const Int_t cycleNumber, const char * detectors) const
701 // take the locasl QA data merge into a single file and save in OCDB
703 TString tmp(AliQA::GetQARefStorage()) ;
704 if ( tmp.IsNull() ) {
705 AliError("No storage defined, use AliQA::SetQARefStorage") ;
708 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
709 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
712 TString sdet(detectors) ;
715 if ( sdet.Contains("ALL") ) {
716 rv = Merge(runNumber) ;
719 char inputFileName[20] ;
720 sprintf(inputFileName, "Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber) ;
721 inputFile = TFile::Open(inputFileName) ;
722 rv = SaveIt2OCDB(runNumber, inputFile) ;
724 for (Int_t index = 0; index < AliQA::kNDET; index++) {
725 if (sdet.Contains(AliQA::GetDetName(index))) {
726 char inputFileName[20] ;
727 sprintf(inputFileName, "%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber) ;
728 inputFile = TFile::Open(inputFileName) ;
729 rv *= SaveIt2OCDB(runNumber, inputFile) ;
736 //_____________________________________________________________________________
737 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile) const
739 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
741 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
742 AliCDBManager* man = AliCDBManager::Instance() ;
743 if ( ! man->IsDefaultStorageSet() ) {
744 man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
745 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
747 if(man->GetRun() < 0)
748 man->SetRun(runNumber);
750 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
751 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
753 AliInfo(Form("Entering %s", detDir->GetName())) ;
754 char detOCDBDir[20] ;
755 sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName()) ;
756 AliCDBId idr(detOCDBDir, runNumber, 999999999) ;
757 TList * listDetQAD = new TList() ;
759 sprintf(listName, "%s QA data Reference", AliQA::GetDetName(detIndex)) ;
760 listDetQAD->SetName(listName) ;
761 TList * taskList = detDir->GetListOfKeys() ;
762 TIter nextTask(taskList) ;
764 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
765 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
766 AliInfo(Form("Saving %s", taskDir->GetName())) ;
767 TObjArray * listTaskQAD = new TObjArray(100) ;
768 listTaskQAD->SetName(taskKey->GetName()) ;
769 listDetQAD->Add(listTaskQAD) ;
770 TList * histList = taskDir->GetListOfKeys() ;
771 TIter nextHist(histList) ;
773 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
774 TObject * odata = taskDir->Get(histKey->GetName()) ;
775 if ( odata->IsA()->InheritsFrom("TH1") ) {
776 AliInfo(Form("Adding %s", histKey->GetName())) ;
777 TH1 * hdata = static_cast<TH1*>(odata) ;
778 listTaskQAD->Add(hdata) ;
783 man->Put(listDetQAD, idr, &mdr) ;