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() ;
138 if (fQADataMaker[iDet])
139 delete fQADataMaker[iDet] ;
141 if (fRawReaderDelete) {
148 //_____________________________________________________________________________
149 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
151 // Runs all the QA data Maker for every detector
154 // Fill QA data in event loop
155 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
158 if ( iEvent%10 == 0 )
159 AliInfo(Form("processing event %d", iEvent));
160 if ( taskIndex == AliQA::kRAWS ) {
161 if ( !fRawReader->NextEvent() )
163 } else if ( taskIndex == AliQA::kESDS ) {
164 if ( fESDTree->GetEntry(iEvent) == 0 )
167 if ( fRunLoader->GetEvent(iEvent) != 0 )
170 // loop over active loaders
171 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
172 if (IsSelected(AliQA::GetDetName(iDet))) {
173 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
174 if ( qadm->IsCycleDone() ) {
175 qadm->EndOfCycle(AliQA::kRAWS) ;
176 qadm->StartOfCycle(AliQA::kRAWS) ;
179 AliLoader* loader = GetLoader(qadm->GetUniqueID());
182 qadm->Exec(taskIndex, fRawReader) ;
186 data = loader->TreeH() ;
188 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
190 qadm->Exec(taskIndex, data) ;
193 case AliQA::kSDIGITS :
194 loader->LoadSDigits() ;
195 data = loader->TreeS() ;
197 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
199 qadm->Exec(taskIndex, data) ;
202 case AliQA::kDIGITS :
203 loader->LoadDigits() ;
204 data = loader->TreeD() ;
206 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
208 qadm->Exec(taskIndex, data) ;
211 case AliQA::kRECPOINTS :
212 loader->LoadRecPoints() ;
213 data = loader->TreeR() ;
215 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
217 qadm->Exec(taskIndex, data) ;
220 case AliQA::kTRACKSEGMENTS :
222 case AliQA::kRECPARTICLES :
225 qadm->Exec(taskIndex, fESD) ;
227 case AliQA::kNTASKINDEX :
233 // Save QA data for all detectors
234 rv = Finish(taskIndex) ;
236 if ( taskIndex == AliQA::kRAWS )
237 fRawReader->RewindEvents() ;
242 //_____________________________________________________________________________
243 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
245 // write output to file for all detectors
246 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
247 if (IsSelected(AliQA::GetDetName(iDet))) {
248 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
249 qadm->EndOfCycle(taskIndex) ;
255 //_____________________________________________________________________________
256 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
258 // Retrieve the list of QA data for a given detector and a given task
259 TObjArray * rv = NULL ;
260 if ( !strlen(AliQA::GetQARefStorage()) ) {
261 AliError("No storage defined, use AliQA::SetQARefStorage") ;
264 AliCDBManager* man = AliCDBManager::Instance() ;
265 if ( ! man->IsDefaultStorageSet() ) {
266 TString tmp(AliQA::GetQARefDefaultStorage()) ;
269 man->SetDefaultStorage(tmp.Data()) ;
270 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
272 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
273 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
274 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
275 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
277 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
281 //_____________________________________________________________________________
282 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
284 // get the loader for a detector
289 TString detName = AliQA::GetDetName(iDet) ;
290 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
292 return fLoader[iDet] ;
294 // load the QA data maker object
295 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
296 TString loaderName = "Ali" + detName + "Loader" ;
298 AliLoader * loader = NULL ;
299 // first check if a plugin is defined for the quality assurance data maker
300 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
301 // if not, add a plugin for it
302 if (!pluginHandler) {
303 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
304 TString libs = gSystem->GetLibraries() ;
305 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
306 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
308 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
310 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
312 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
313 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
316 fLoader[iDet] = loader ;
320 //_____________________________________________________________________________
321 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
323 // get the quality assurance data maker for a detector
325 if (fQADataMaker[iDet])
326 return fQADataMaker[iDet] ;
328 AliQADataMaker * qadm = NULL ;
330 if (iDet == AliQA::kGLOBAL) { //Global QA
331 qadm = new AliGlobalQADataMaker();
332 fQADataMaker[iDet] = qadm;
336 // load the QA data maker object
337 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
338 TString detName = AliQA::GetDetName(iDet) ;
340 if (tmp.Contains("sim"))
341 tmp.ReplaceAll("s", "S") ;
342 else if (tmp.Contains("rec"))
343 tmp.ReplaceAll("r", "R") ;
345 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
347 // first check if a plugin is defined for the quality assurance data maker
348 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
349 // if not, add a plugin for it
350 if (!pluginHandler) {
351 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
352 TString libs = gSystem->GetLibraries() ;
353 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
354 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
356 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
358 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
360 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
361 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
364 fQADataMaker[iDet] = qadm ;
368 //_____________________________________________________________________________
369 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
371 // Initialize the event source and QA data makers
373 if (taskIndex == AliQA::kRAWS) {
375 fRawReader = AliRawReader::Create(input);
379 fRawReaderDelete = kTRUE ;
380 fRawReader->NextEvent() ;
381 fRunNumber = fRawReader->GetRunNumber() ;
382 AliCDBManager::Instance()->SetRun(fRunNumber) ;
383 fRawReader->RewindEvents();
384 fNumberOfEvents = 999999 ;
385 if ( fMaxEvents < 0 )
386 fMaxEvents = fNumberOfEvents ;
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() ;
400 if ( fMaxEvents < 0 )
401 fMaxEvents = fNumberOfEvents ;
404 AliError("AliESDs.root not found") ;
408 if ( !InitRunLoader() ) {
409 AliWarning("No Run Loader not found") ;
411 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
412 if ( fMaxEvents < 0 )
413 fMaxEvents = fNumberOfEvents ;
419 TObjArray* detArray = NULL ;
420 if (fRunLoader) // check if RunLoader exists
421 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
422 detArray = fRunLoader->GetAliRun()->Detectors() ;
423 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
426 // Initialize all QA data makers for all detectors
427 fRunNumber = AliCDBManager::Instance()->GetRun() ;
428 if ( ! AliGeomManager::GetGeometry() )
429 AliGeomManager::LoadGeometry() ;
431 // Build array of QA data makers for all detectors
432 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
433 if (IsSelected(AliQA::GetDetName(iDet))) {
434 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
436 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
437 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
439 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
440 // skip non active detectors
442 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
443 if (!det || !det->IsActive())
446 qadm->SetName(AliQA::GetDetName(iDet));
447 qadm->SetUniqueID(iDet);
448 qadm->Init(taskIndex, fRunNumber, GetQACycles(qadm->GetUniqueID())) ;
449 qadm->StartOfCycle(taskIndex, fCycleSame) ;
456 //_____________________________________________________________________________
457 Bool_t AliQADataMakerSteer::InitRunLoader()
459 // get or create the run loader
463 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
464 // load all base libraries to get the loader classes
465 TString libs = gSystem->GetLibraries() ;
466 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
467 if (!IsSelected(AliQA::GetDetName(iDet)))
469 TString detName = AliQA::GetDetName(iDet) ;
470 if (detName == "HLT")
472 if (libs.Contains("lib" + detName + "base.so"))
474 gSystem->Load("lib" + detName + "base.so");
476 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
478 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
481 fRunLoader->CdGAFile();
482 if (fRunLoader->LoadgAlice() == 0) {
483 gAlice = fRunLoader->GetAliRun();
487 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
491 } else { // galice.root does not exist
492 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
498 fRunLoader->LoadHeader();
499 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
504 //_____________________________________________________________________________
505 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
507 // check whether detName is contained in detectors
508 // if yes, it is removed from detectors
511 const TString detName(det) ;
512 // check if all detectors are selected
513 if (fDetectors.Contains("ALL")) {
516 } else if ((fDetectors.CompareTo(detName) == 0) ||
517 fDetectors.BeginsWith(detName+" ") ||
518 fDetectors.EndsWith(" "+detName) ||
519 fDetectors.Contains(" "+detName+" ")) {
526 //_____________________________________________________________________________
527 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
529 // Merge all the cycles from all detectors in one single file per run
531 if ( runNumber == -1 )
532 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
534 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
535 gROOT->ProcessLine(cmd.Data()) ;
536 ifstream in("tempo.txt") ;
537 const Int_t runMax = 10 ;
538 TString file[AliQA::kNDET*runMax] ;
539 Int_t run[AliQA::kNDET*runMax] = {-1} ;
546 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
551 AliError(Form("run number %d not found", runNumber)) ;
556 Int_t runIndexMax = 0 ;
557 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
558 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
559 TString tmp(file[ifile]) ;
560 tmp.ReplaceAll(".root", "") ;
561 TString det = tmp(0, tmp.Index(".")) ;
562 tmp.Remove(0, tmp.Index(stmp)+4) ;
563 TString ttmp = tmp(0, tmp.Index(".")) ;
564 Int_t newRun = ttmp.Atoi() ;
565 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
566 if (newRun == run[irun])
568 run[runIndex] = newRun ;
571 runIndexMax = runIndex ;
572 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
573 Int_t cycle = ttmp.Atoi() ;
574 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
576 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
578 TString outFileName(Form("Merged.%s.%d.root",AliQA::GetQADataFileName(),run[irun]));
579 merger.OutputFile(outFileName.Data()) ;
580 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
581 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
582 TString tmp(file[ifile]) ;
583 if (tmp.Contains(pattern)) {
584 merger.AddFile(tmp) ;
593 //_____________________________________________________________________________
594 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
596 // Reset the default data members
598 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
599 if (IsSelected(AliQA::GetDetName(iDet))) {
600 AliQADataMaker * qadm = GetQADataMaker(iDet);
601 qadm->Reset(sameCycle);
604 if (fRawReaderDelete) {
609 fCycleSame = sameCycle ;
613 fNumberOfEvents = 999999 ;
616 //_____________________________________________________________________________
617 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
619 //Runs all the QA data Maker for Raws only
621 fCycleSame = sameCycle ;
622 fRawReader = rawReader ;
623 fDetectors = detectors ;
624 fDetectorsW = detectors ;
626 AliCDBManager* man = AliCDBManager::Instance() ;
628 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
629 rawReader->NextEvent() ;
630 man->SetRun(fRawReader->GetRunNumber()) ;
631 rawReader->RewindEvents() ;
634 if ( !Init(AliQA::kRAWS) )
636 fRawReaderDelete = kFALSE ;
642 //_____________________________________________________________________________
643 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
645 //Runs all the QA data Maker for Raws only
647 fCycleSame = sameCycle ;
648 fDetectors = detectors ;
649 fDetectorsW = detectors ;
651 AliCDBManager* man = AliCDBManager::Instance() ;
652 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
653 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
655 AliFatal("galice.root file not found in current directory") ;
659 if ( ! rl->GetAliRun() ) {
660 AliFatal("AliRun not found in galice.root") ;
663 man->SetRun(rl->GetHeader()->GetRun());
668 if ( !Init(AliQA::kRAWS, fileName) )
675 //_____________________________________________________________________________
676 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
678 // Runs all the QA data Maker for every detector
680 fCycleSame = sameCycle ;
681 fDetectors = detectors ;
682 fDetectorsW = detectors ;
684 AliCDBManager* man = AliCDBManager::Instance() ;
685 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
686 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
688 AliFatal("galice.root file not found in current directory") ;
692 if ( ! rl->GetAliRun() ) {
693 AliInfo("AliRun not found in galice.root") ;
696 man->SetRun(rl->GetHeader()->GetRun()) ;
701 if ( !Init(taskIndex, fileName) )
710 //_____________________________________________________________________________
711 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
713 // take the locasl QA data merge into a single file and save in OCDB
715 TString tmp(AliQA::GetQARefStorage()) ;
716 if ( tmp.IsNull() ) {
717 AliError("No storage defined, use AliQA::SetQARefStorage") ;
720 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
721 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
724 TString sdet(detectors) ;
727 if ( sdet.Contains("ALL") ) {
728 rv = Merge(runNumber) ;
731 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
732 inputFile = TFile::Open(inputFileName.Data()) ;
733 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
735 for (Int_t index = 0; index < AliQA::kNDET; index++) {
736 if (sdet.Contains(AliQA::GetDetName(index))) {
737 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
738 inputFile = TFile::Open(inputFileName.Data()) ;
739 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
746 //_____________________________________________________________________________
747 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
749 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
751 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
752 AliCDBManager* man = AliCDBManager::Instance() ;
753 if ( ! man->IsDefaultStorageSet() ) {
754 TString tmp( AliQA::GetQARefStorage() ) ;
755 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
756 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
758 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
760 tmp1.Append("?user=alidaq") ;
761 man->SetDefaultStorage(tmp1.Data()) ;
764 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
765 if(man->GetRun() < 0)
766 man->SetRun(runNumber);
769 mdr.SetResponsible("yves schutz");
771 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
772 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
774 AliInfo(Form("Entering %s", detDir->GetName())) ;
775 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
776 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
777 TList * listDetQAD = new TList() ;
778 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
779 mdr.SetComment("HMPID QA stuff");
780 listDetQAD->SetName(listName) ;
781 TList * taskList = detDir->GetListOfKeys() ;
782 TIter nextTask(taskList) ;
784 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
785 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
786 AliInfo(Form("Saving %s", taskDir->GetName())) ;
787 TObjArray * listTaskQAD = new TObjArray(100) ;
788 listTaskQAD->SetName(taskKey->GetName()) ;
789 listDetQAD->Add(listTaskQAD) ;
790 TList * histList = taskDir->GetListOfKeys() ;
791 TIter nextHist(histList) ;
793 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
794 TObject * odata = taskDir->Get(histKey->GetName()) ;
796 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
798 AliInfo(Form("Adding %s", histKey->GetName())) ;
799 if ( odata->IsA()->InheritsFrom("TH1") ) {
800 AliInfo(Form("Adding %s", histKey->GetName())) ;
801 TH1 * hdata = static_cast<TH1*>(odata) ;
802 listTaskQAD->Add(hdata) ;
807 man->Put(listDetQAD, idr, &mdr) ;