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) :
68 fGAliceFileName(gAliceFilename),
70 fNumberOfEvents(999999),
72 fRawReaderDelete(kTRUE),
76 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
77 if (IsSelected(AliQA::GetDetName(iDet))) {
78 fLoader[iDet] = NULL ;
79 fQADataMaker[iDet] = NULL ;
80 fQACycles[iDet] = 999999 ;
85 //_____________________________________________________________________________
86 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
89 fDetectors(qas.fDetectors),
90 fDetectorsW(qas.fDetectorsW),
94 fGAliceFileName(qas.fGAliceFileName),
95 fRunNumber(qas.fRunNumber),
96 fNumberOfEvents(qas.fNumberOfEvents),
98 fRawReaderDelete(kTRUE),
102 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
103 fLoader[iDet] = qas.fLoader[iDet] ;
104 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
105 fQACycles[iDet] = qas.fQACycles[iDet] ;
109 //_____________________________________________________________________________
110 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
112 // assignment operator
113 this->~AliQADataMakerSteer() ;
114 new(this) AliQADataMakerSteer(qas) ;
118 //_____________________________________________________________________________
119 AliQADataMakerSteer::~AliQADataMakerSteer()
122 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
123 if (IsSelected(AliQA::GetDetName(iDet))) {
124 fLoader[iDet] = NULL;
125 if (fQADataMaker[iDet]) {
126 (fQADataMaker[iDet])->Finish() ;
127 delete fQADataMaker[iDet] ;
128 fQADataMaker[iDet] = NULL ;
133 if (fRawReaderDelete) {
140 //_____________________________________________________________________________
141 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX taskIndex, const char * mode)
143 // Runs all the QA data Maker for every detector
146 // Fill QA data in event loop
147 for (UInt_t iEvent = 0 ; iEvent < fNumberOfEvents ; iEvent++) {
149 if ( iEvent%10 == 0 )
150 AliInfo(Form("processing event %d", iEvent));
151 if ( taskIndex == AliQA::kRAWS ) {
152 if ( !fRawReader->NextEvent() )
154 } else if ( taskIndex == AliQA::kESDS ) {
155 if ( fESDTree->GetEntry(iEvent) == 0 )
158 if ( fRunLoader->GetEvent(iEvent) != 0 )
161 // loop over detectors
162 TObjArray* detArray = NULL ;
163 if (fRunLoader) // check if RunLoader exists
164 if ( fRunLoader->GetAliRun() ) // check if AliRun exists in gAlice.root
165 detArray = fRunLoader->GetAliRun()->Detectors() ;
166 for (UInt_t iDet = 0 ; iDet < fgkNDetectors ; iDet++) {
168 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
169 if (!det || !det->IsActive())
172 if (!IsSelected(AliQA::GetDetName(iDet)))
174 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
178 if ( qadm->IsCycleDone() ) {
179 qadm->EndOfCycle(AliQA::kRAWS) ;
180 qadm->StartOfCycle(AliQA::kRAWS) ;
185 qadm->Exec(taskIndex, fRawReader) ;
188 GetLoader(iDet)->LoadHits() ;
189 data = GetLoader(iDet)->TreeH() ;
191 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
193 qadm->Exec(taskIndex, data) ;
196 case AliQA::kSDIGITS :
197 GetLoader(iDet)->LoadSDigits() ;
198 data = GetLoader(iDet)->TreeS() ;
200 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
202 qadm->Exec(taskIndex, data) ;
205 case AliQA::kDIGITS :
206 GetLoader(iDet)->LoadDigits() ;
207 data = GetLoader(iDet)->TreeD() ;
209 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
211 qadm->Exec(taskIndex, data) ;
214 case AliQA::kRECPOINTS :
215 GetLoader(iDet)->LoadRecPoints() ;
216 data = GetLoader(iDet)->TreeR() ;
218 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
220 qadm->Exec(taskIndex, data) ;
223 case AliQA::kTRACKSEGMENTS :
225 case AliQA::kRECPARTICLES :
228 qadm->Exec(taskIndex, fESD) ;
230 case AliQA::kNTASKINDEX :
233 //qadm->Increment() ;
237 // // Save QA data for all detectors
238 rv = Finish(taskIndex, mode) ;
243 //_____________________________________________________________________________
244 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX taskIndex, const char * mode)
246 // write output to file for all detectors
247 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
248 if (IsSelected(AliQA::GetDetName(iDet))) {
249 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
251 qadm->EndOfCycle(taskIndex) ;
258 //_____________________________________________________________________________
259 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task) const
261 // Retrieve the list of QA data for a given detector and a given task
262 TObjArray * rv = NULL ;
263 TString tmp(AliQA::GetQARefStorage()) ;
264 if ( tmp.IsNull() ) {
265 AliError("No storage defined, use AliQA::SetQARefStorage") ;
268 AliCDBManager* man = AliCDBManager::Instance() ;
269 if ( ! man->IsDefaultStorageSet() ) {
270 man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
271 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
273 char detOCDBDir[10] ;
274 sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName()) ;
275 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir, AliQA::GetTaskName(task).Data())) ;
276 AliCDBEntry* entry = man->Get(detOCDBDir, 0) ; //FIXME 0 --> Run Number
277 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
279 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
283 //_____________________________________________________________________________
284 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
286 // 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, const char * mode )
322 // get the quality assurance data maker for a detector
324 if (fQADataMaker[iDet])
325 return fQADataMaker[iDet] ;
327 AliQADataMaker * qadm = NULL ;
330 // load the QA data maker object
331 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
332 TString detName = AliQA::GetDetName(iDet) ;
334 if (tmp.Contains("sim"))
335 tmp.ReplaceAll("s", "S") ;
336 else if (tmp.Contains("rec"))
337 tmp.ReplaceAll("r", "R") ;
338 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
340 // first check if a plugin is defined for the quality assurance data maker
341 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
342 // if not, add a plugin for it
343 if (!pluginHandler) {
344 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
345 TString libs = gSystem->GetLibraries() ;
346 if (libs.Contains("lib" + detName + mode + ".so") || (gSystem->Load("lib" + detName + mode + ".so") >= 0)) {
347 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
349 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
351 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
353 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
354 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
357 fQADataMaker[iDet] = qadm ;
362 //_____________________________________________________________________________
363 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX taskIndex, const char * mode, const char * input )
365 // Initialize the event source and QA data makers
367 if (taskIndex == AliQA::kRAWS) {
369 TString fileName(input);
370 if (fileName.EndsWith("/")) {
371 fRawReader = new AliRawReaderFile(fileName);
372 } else if (fileName.EndsWith(".root")) {
373 fRawReader = new AliRawReaderRoot(fileName);
374 } else if (!fileName.IsNull()) {
375 fRawReader = new AliRawReaderDate(fileName);
376 fRawReader->SelectEvents(7);
381 fRawReaderDelete = kTRUE ;
382 fRawReader->NextEvent() ;
383 fRunNumber = fRawReader->GetRunNumber() ;
384 AliCDBManager::Instance()->SetRun(fRunNumber) ;
385 fRawReader->RewindEvents();
386 fNumberOfEvents = 999999 ;
387 } else if (taskIndex == AliQA::kESDS) {
388 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
389 TFile * esdFile = TFile::Open("AliESDs.root") ;
390 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
392 AliError("esdTree not found") ;
395 fESD = new AliESDEvent() ;
396 fESD->ReadFromTree(fESDTree) ;
397 fESDTree->GetEntry(0) ;
398 fRunNumber = fESD->GetRunNumber() ;
399 fNumberOfEvents = fESDTree->GetEntries() ;
402 AliError("AliESDs.root not found") ;
406 if ( !InitRunLoader() ) {
407 AliWarning("No Run Loader not found") ;
409 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
412 // Initialize all QA data makers for all detectors
413 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
415 if (IsSelected(AliQA::GetDetName(iDet))) {
416 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
418 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
419 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
421 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
422 qadm->Init(taskIndex, fRunNumber, GetQACycles(iDet)) ;
423 qadm->StartOfCycle(taskIndex, fCycleSame) ;
431 //_____________________________________________________________________________
432 Bool_t AliQADataMakerSteer::InitRunLoader()
434 // get or create the run loader
440 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
441 // load all base libraries to get the loader classes
442 TString libs = gSystem->GetLibraries() ;
443 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
444 if (!IsSelected(AliQA::GetDetName(iDet)))
446 TString detName = AliQA::GetDetName(iDet) ;
447 if (detName == "HLT")
449 if (libs.Contains("lib" + detName + "base.so"))
451 gSystem->Load("lib" + detName + "base.so");
453 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
455 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
458 fRunLoader->CdGAFile();
459 if (fRunLoader->LoadgAlice() == 0) {
460 gAlice = fRunLoader->GetAliRun();
464 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
468 } else { // galice.root does not exist
469 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
476 //_____________________________________________________________________________
477 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
479 // check whether detName is contained in detectors
480 // if yes, it is removed from detectors
482 const TString detName(det) ;
483 // check if all detectors are selected
484 if ((fDetectors.CompareTo("ALL") == 0) ||
485 fDetectors.BeginsWith("ALL ") ||
486 fDetectors.EndsWith(" ALL") ||
487 fDetectors.Contains(" ALL ")) {
492 // search for the given detector
494 //AliInfo(Form("SSSSSSSSSSSSS fd = %s det = %s ", fDetectors.Data(), det)) ;
495 if ((fDetectors.CompareTo(detName) == 0) ||
496 fDetectors.BeginsWith(detName+" ") ||
497 fDetectors.EndsWith(" "+detName) ||
498 fDetectors.Contains(" "+detName+" ")) {
499 // fDetectors.ReplaceAll(detName, "");
503 // clean up the detectors string
504 // while (fDetectors.Contains(" "))
505 // fDetectors.ReplaceAll(" ", " ");
506 // while (fDetectors.BeginsWith(" "))
507 // fDetectors.Remove(0, 1);
508 // while (fDetectors.EndsWith(" "))
509 // fDetectors.Remove(fDetectors.Length()-1, 1);
514 //_____________________________________________________________________________
515 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
517 // Merge all the cycles from all detectors in one single file per run
519 if ( runNumber == -1 )
520 sprintf(cmd, ".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
522 sprintf(cmd, ".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
523 gROOT->ProcessLine(cmd) ;
524 ifstream in("tempo.txt") ;
525 const Int_t runMax = 10 ;
526 TString file[AliQA::kNDET*runMax] ;
527 Int_t run[AliQA::kNDET*runMax] ;
532 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
539 AliError(Form("run number %d not found", runNumber)) ;
544 Int_t runIndexMax = 0 ;
546 sprintf(stmp, ".%s.", AliQA::GetQADataFileName()) ;
547 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
548 TString tmp(file[ifile]) ;
549 tmp.ReplaceAll(".root", "") ;
550 TString det = tmp(0, tmp.Index(".")) ;
551 tmp.Remove(0, tmp.Index(stmp)+4) ;
552 TString ttmp = tmp(0, tmp.Index(".")) ;
553 Int_t newRun = ttmp.Atoi() ;
554 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
555 if (newRun == run[irun])
557 run[runIndex] = newRun ;
560 runIndexMax = runIndex ;
561 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
562 Int_t cycle = ttmp.Atoi() ;
563 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
565 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
567 char outFileName[20] ;
568 sprintf(outFileName, "Merged.%s.%d.root", AliQA::GetQADataFileName(), run[irun]) ;
569 merger.OutputFile(outFileName) ;
570 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
572 sprintf(pattern, "%s.%d.", AliQA::GetQADataFileName(), run[irun]) ;
573 TString tmp(file[ifile]) ;
574 if (tmp.Contains(pattern)) {
575 merger.AddFile(tmp) ;
584 //_____________________________________________________________________________
585 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
587 // Reset the default data members
588 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
589 if (IsSelected(AliQA::GetDetName(iDet))) {
590 fLoader[iDet] = NULL;
591 if (fQADataMaker[iDet]) {
592 (fQADataMaker[iDet])->Reset(sameCycle) ;
593 //delete fQADataMaker[iDet] ;
594 //fQADataMaker[iDet] = NULL ;
599 if (fRawReaderDelete) {
604 fCycleSame = sameCycle ;
608 fNumberOfEvents = 999999 ;
611 //_____________________________________________________________________________
612 Bool_t AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader)
614 //Runs all the QA data Maker for Raws only
615 fRawReader = rawReader ;
616 fRawReaderDelete = kFALSE ;
618 fDetectors = detectors ;
620 // Initialize all QA data makers for all detectors
621 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
622 if (IsSelected(AliQA::GetDetName(iDet))) {
623 AliQADataMaker * qadm = GetQADataMaker(iDet, "rec") ;
625 AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
627 AliInfo(Form("Data Maker found for %s", qadm->GetName())) ;
628 qadm->Init(AliQA::kRAWS, fRunNumber, GetQACycles(iDet)) ;
629 qadm->StartOfCycle(AliQA::kRAWS, fCycleSame) ;
635 return DoIt(AliQA::kRAWS, "rec") ;
638 //_____________________________________________________________________________
639 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName)
641 //Runs all the QA data Maker for Raws only
642 //fCycleSame = kTRUE ;
643 fDetectors = detectors ;
644 fDetectorsW = detectors ;
647 if ( !Init(AliQA::kRAWS, "rec", fileName) )
650 // Initialize all QA data makers for all detectors
651 //for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
652 // if (IsSelected(AliQA::GetDetName(iDet))) {
653 // AliQADataMaker * qadm = GetQADataMaker(iDet, "rec") ;
655 // AliWarning(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
657 // AliInfo(Form("Data Maker found for %s", qadm->GetName())) ;
658 // qadm->Init(AliQA::kRAWS, fRunNumber, GetQACycles(iDet)) ;
659 // qadm->StartOfCycle(AliQA::kRAWS, fCycleSame) ;
664 DoIt(AliQA::kRAWS, "rec") ;
668 //_____________________________________________________________________________
669 Bool_t AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX taskIndex, const char * fileName )
671 // Runs all the QA data Maker for every detector
674 fDetectors = detectors ;
677 if ( (taskIndex == AliQA::kHITS) || (taskIndex == AliQA::kSDIGITS) || (taskIndex == AliQA::kDIGITS) )
679 else if ( (taskIndex == AliQA::kRAWS) || (taskIndex == AliQA::kRECPOINTS) || (taskIndex == AliQA::kESDS) )
682 AliError(Form("%s not implemented", AliQA::GetTaskName(taskIndex).Data())) ;
686 if ( !Init(taskIndex, mode, fileName) )
689 rv = DoIt(taskIndex, mode) ;
695 //_____________________________________________________________________________
696 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const Int_t cycleNumber, const char * detectors) const
698 // take the locasl QA data merge into a single file and save in OCDB
700 TString tmp(AliQA::GetQARefStorage()) ;
701 if ( tmp.IsNull() ) {
702 AliError("No storage defined, use AliQA::SetQARefStorage") ;
705 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
706 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
709 TString sdet(detectors) ;
712 if ( sdet.Contains("ALL") ) {
713 rv = Merge(runNumber) ;
716 char inputFileName[20] ;
717 sprintf(inputFileName, "Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber) ;
718 inputFile = TFile::Open(inputFileName) ;
719 rv = SaveIt2OCDB(runNumber, inputFile) ;
721 for (Int_t index = 0; index < AliQA::kNDET; index++) {
722 if (sdet.Contains(AliQA::GetDetName(index))) {
723 char inputFileName[20] ;
724 sprintf(inputFileName, "%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber) ;
725 inputFile = TFile::Open(inputFileName) ;
726 rv *= SaveIt2OCDB(runNumber, inputFile) ;
733 //_____________________________________________________________________________
734 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile) const
736 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
738 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
739 AliCDBManager* man = AliCDBManager::Instance() ;
740 if ( ! man->IsDefaultStorageSet() ) {
741 man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
742 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
744 if(man->GetRun() < 0)
745 man->SetRun(runNumber);
747 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
748 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
750 AliInfo(Form("Entering %s", detDir->GetName())) ;
751 char detOCDBDir[20] ;
752 sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName()) ;
753 AliCDBId idr(detOCDBDir, runNumber, 999999999) ;
754 TList * listDetQAD = new TList() ;
756 sprintf(listName, "%s QA data Reference", AliQA::GetDetName(detIndex)) ;
757 listDetQAD->SetName(listName) ;
758 TList * taskList = detDir->GetListOfKeys() ;
759 TIter nextTask(taskList) ;
761 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
762 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
763 AliInfo(Form("Saving %s", taskDir->GetName())) ;
764 TObjArray * listTaskQAD = new TObjArray(100) ;
765 listTaskQAD->SetName(taskKey->GetName()) ;
766 listDetQAD->Add(listTaskQAD) ;
767 TList * histList = taskDir->GetListOfKeys() ;
768 TIter nextHist(histList) ;
770 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
771 TObject * odata = taskDir->Get(histKey->GetName()) ;
772 if ( odata->IsA()->InheritsFrom("TH1") ) {
773 AliInfo(Form("Adding %s", histKey->GetName())) ;
774 TH1 * hdata = static_cast<TH1*>(odata) ;
775 listTaskQAD->Add(hdata) ;
780 man->Put(listDetQAD, idr, &mdr) ;