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),
72 fNumberOfEvents(999999),
75 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),
101 fGAliceFileName(qas.fGAliceFileName),
102 fFirstEvent(qas.fFirstEvent),
103 fMaxEvents(qas.fMaxEvents),
104 fNumberOfEvents(qas.fNumberOfEvents),
105 fRunNumber(qas.fRunNumber),
107 fRawReaderDelete(kTRUE),
112 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
113 fLoader[iDet] = qas.fLoader[iDet] ;
114 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
115 fQACycles[iDet] = qas.fQACycles[iDet] ;
119 //_____________________________________________________________________________
120 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
122 // assignment operator
123 this->~AliQADataMakerSteer() ;
124 new(this) AliQADataMakerSteer(qas) ;
128 //_____________________________________________________________________________
129 AliQADataMakerSteer::~AliQADataMakerSteer()
132 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
133 if (IsSelected(AliQA::GetDetName(iDet))) {
134 fLoader[iDet] = NULL;
135 if (fQADataMaker[iDet]) {
136 (fQADataMaker[iDet])->Finish() ;
137 delete fQADataMaker[iDet] ;
138 fQADataMaker[iDet] = NULL ;
143 if (fRawReaderDelete) {
150 //_____________________________________________________________________________
151 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex, const char * mode)
153 // Runs all the QA data Maker for every detector
156 // Fill QA data in event loop
157 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
160 if ( iEvent%10 == 0 )
161 AliInfo(Form("processing event %d", iEvent));
162 if ( taskIndex == AliQA::kRAWS ) {
163 if ( !fRawReader->NextEvent() )
165 } else if ( taskIndex == AliQA::kESDS ) {
166 if ( fESDTree->GetEntry(iEvent) == 0 )
169 if ( fRunLoader->GetEvent(iEvent) != 0 )
172 // loop over active loaders
173 for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
174 AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i)) ;
175 if ( qadm->IsCycleDone() ) {
176 qadm->EndOfCycle(AliQA::kRAWS) ;
177 qadm->StartOfCycle(AliQA::kRAWS) ;
180 Int_t iDet = qadm->GetUniqueID();
181 AliLoader* loader = GetLoader(iDet);
184 qadm->Exec(taskIndex, fRawReader) ;
188 data = loader->TreeH() ;
190 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
192 qadm->Exec(taskIndex, data) ;
195 case AliQA::kSDIGITS :
196 loader->LoadSDigits() ;
197 data = loader->TreeS() ;
199 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
201 qadm->Exec(taskIndex, data) ;
204 case AliQA::kDIGITS :
205 loader->LoadDigits() ;
206 data = loader->TreeD() ;
208 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
210 qadm->Exec(taskIndex, data) ;
213 case AliQA::kRECPOINTS :
214 loader->LoadRecPoints() ;
215 data = loader->TreeR() ;
217 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
219 qadm->Exec(taskIndex, data) ;
222 case AliQA::kTRACKSEGMENTS :
224 case AliQA::kRECPARTICLES :
227 qadm->Exec(taskIndex, fESD) ;
229 case AliQA::kNTASKINDEX :
232 //qadm->Increment() ;
235 // // Save QA data for all detectors
236 rv = Finish(taskIndex, mode) ;
241 //_____________________________________________________________________________
242 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex, const char * /*mode*/)
244 // write output to file for all detectors
245 for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
246 AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i));
247 qadm->EndOfCycle(taskIndex) ;
252 //_____________________________________________________________________________
253 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
255 // Retrieve the list of QA data for a given detector and a given task
256 TObjArray * rv = NULL ;
257 TString tmp(AliQA::GetQARefStorage()) ;
258 if ( tmp.IsNull() ) {
259 AliError("No storage defined, use AliQA::SetQARefStorage") ;
262 AliCDBManager* man = AliCDBManager::Instance() ;
263 if ( ! man->IsDefaultStorageSet() ) {
264 TString tmp(AliQA::GetQARefDefaultStorage()) ;
267 man->SetDefaultStorage(tmp.Data()) ;
268 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
270 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
271 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
272 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
273 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
275 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
279 //_____________________________________________________________________________
280 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
282 // get the loader for a detector
287 TString detName = AliQA::GetDetName(iDet) ;
288 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
290 return fLoader[iDet] ;
292 // load the QA data maker object
293 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
294 TString loaderName = "Ali" + detName + "Loader" ;
296 AliLoader * loader = NULL ;
297 // first check if a plugin is defined for the quality assurance data maker
298 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
299 // if not, add a plugin for it
300 if (!pluginHandler) {
301 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
302 TString libs = gSystem->GetLibraries() ;
303 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
304 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
306 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
308 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
310 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
311 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
314 fLoader[iDet] = loader ;
318 //_____________________________________________________________________________
319 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet, const char * mode )
321 // get the quality assurance data maker for a detector
323 if (fQADataMaker[iDet])
324 return fQADataMaker[iDet] ;
326 AliQADataMaker * qadm = NULL ;
329 // load the QA data maker object
330 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
331 TString detName = AliQA::GetDetName(iDet) ;
333 if (tmp.Contains("sim"))
334 tmp.ReplaceAll("s", "S") ;
335 else if (tmp.Contains("rec"))
336 tmp.ReplaceAll("r", "R") ;
337 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
339 // first check if a plugin is defined for the quality assurance data maker
340 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
341 // if not, add a plugin for it
342 if (!pluginHandler) {
343 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
344 TString libs = gSystem->GetLibraries() ;
345 if (libs.Contains("lib" + detName + mode + ".so") || (gSystem->Load("lib" + detName + mode + ".so") >= 0)) {
346 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
348 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
350 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
352 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
353 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
356 fQADataMaker[iDet] = qadm ;
361 //_____________________________________________________________________________
362 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * mode, const char * input )
364 // Initialize the event source and QA data makers
366 if (taskIndex == AliQA::kRAWS) {
368 fRawReader = AliRawReader::Create(input);
372 fRawReaderDelete = kTRUE ;
373 fRawReader->NextEvent() ;
374 fRunNumber = fRawReader->GetRunNumber() ;
375 AliCDBManager::Instance()->SetRun(fRunNumber) ;
376 fRawReader->RewindEvents();
377 fNumberOfEvents = 999999 ;
378 if ( fMaxEvents < 0 )
379 fMaxEvents = fNumberOfEvents ;
380 } else if (taskIndex == AliQA::kESDS) {
381 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
382 TFile * esdFile = TFile::Open("AliESDs.root") ;
383 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
385 AliError("esdTree not found") ;
388 fESD = new AliESDEvent() ;
389 fESD->ReadFromTree(fESDTree) ;
390 fESDTree->GetEntry(0) ;
391 fRunNumber = fESD->GetRunNumber() ;
392 fNumberOfEvents = fESDTree->GetEntries() ;
393 if ( fMaxEvents < 0 )
394 fMaxEvents = fNumberOfEvents ;
397 AliError("AliESDs.root not found") ;
401 if ( !InitRunLoader() ) {
402 AliWarning("No Run Loader not found") ;
404 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
405 if ( fMaxEvents < 0 )
406 fMaxEvents = fNumberOfEvents ;
412 TObjArray* detArray = NULL ;
413 if (fRunLoader) // check if RunLoader exists
414 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
415 detArray = fRunLoader->GetAliRun()->Detectors() ;
416 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
418 // Build array of QA data makers for all detectors
419 fQADataMakers.Clear();
420 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
421 if (IsSelected(AliQA::GetDetName(iDet))) {
422 AliQADataMaker * qadm = GetQADataMaker(iDet, mode) ;
424 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
425 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
427 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
428 // skip non active detectors
430 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
431 if (!det || !det->IsActive())
434 qadm->SetName(AliQA::GetDetName(iDet));
435 qadm->SetUniqueID(iDet);
436 fQADataMakers.Add(qadm);
440 // Initialize all QA data makers for all detectors
441 for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
442 AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i));
443 qadm->Init(taskIndex, fRunNumber, GetQACycles(qadm->GetUniqueID())) ;
444 qadm->StartOfCycle(taskIndex, fCycleSame) ;
450 //_____________________________________________________________________________
451 Bool_t AliQADataMakerSteer::InitRunLoader()
453 // get or create the run loader
457 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
458 // load all base libraries to get the loader classes
459 TString libs = gSystem->GetLibraries() ;
460 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
461 if (!IsSelected(AliQA::GetDetName(iDet)))
463 TString detName = AliQA::GetDetName(iDet) ;
464 if (detName == "HLT")
466 if (libs.Contains("lib" + detName + "base.so"))
468 gSystem->Load("lib" + detName + "base.so");
470 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
472 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
475 fRunLoader->CdGAFile();
476 if (fRunLoader->LoadgAlice() == 0) {
477 gAlice = fRunLoader->GetAliRun();
481 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
485 } else { // galice.root does not exist
486 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
492 fRunLoader->LoadHeader();
493 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
498 //_____________________________________________________________________________
499 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
501 // check whether detName is contained in detectors
502 // if yes, it is removed from detectors
505 const TString detName(det) ;
506 // check if all detectors are selected
507 if (fDetectors.Contains("ALL")) {
510 } else if ((fDetectors.CompareTo(detName) == 0) ||
511 fDetectors.BeginsWith(detName+" ") ||
512 fDetectors.EndsWith(" "+detName) ||
513 fDetectors.Contains(" "+detName+" ")) {
514 // fDetectors.ReplaceAll(detName, "");
518 // clean up the detectors string
519 // while (fDetectors.Contains(" "))
520 // fDetectors.ReplaceAll(" ", " ");
521 // while (fDetectors.BeginsWith(" "))
522 // fDetectors.Remove(0, 1);
523 // while (fDetectors.EndsWith(" "))
524 // fDetectors.Remove(fDetectors.Length()-1, 1);
529 //_____________________________________________________________________________
530 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
532 // Merge all the cycles from all detectors in one single file per run
534 if ( runNumber == -1 )
535 cmd = Form(".! ls *%s*.*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
537 cmd = Form(".! ls *%s*.%d.*.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
538 gROOT->ProcessLine(cmd.Data()) ;
539 ifstream in("tempo.txt") ;
540 const Int_t runMax = 10 ;
541 TString file[AliQA::kNDET*runMax] ;
542 Int_t run[AliQA::kNDET*runMax] = {-1} ;
549 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
554 AliError(Form("run number %d not found", runNumber)) ;
559 Int_t runIndexMax = 0 ;
560 TString stmp(Form(".%s.", AliQA::GetQADataFileName())) ;
561 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
562 TString tmp(file[ifile]) ;
563 tmp.ReplaceAll(".root", "") ;
564 TString det = tmp(0, tmp.Index(".")) ;
565 tmp.Remove(0, tmp.Index(stmp)+4) ;
566 TString ttmp = tmp(0, tmp.Index(".")) ;
567 Int_t newRun = ttmp.Atoi() ;
568 for (Int_t irun = 0; irun <= runIndexMax; irun++) {
569 if (newRun == run[irun])
571 run[runIndex] = newRun ;
574 runIndexMax = runIndex ;
575 ttmp = tmp(tmp.Index(".")+1, tmp.Length()) ;
576 Int_t cycle = ttmp.Atoi() ;
577 AliDebug(1, Form("%s : det = %s run = %d cycle = %d \n", file[ifile].Data(), det.Data(), newRun, cycle)) ;
579 for (Int_t irun = 0 ; irun < runIndexMax ; irun++) {
581 TString outFileName(Form("Merged.%s.%d.root",AliQA::GetQADataFileName(),run[irun]));
582 merger.OutputFile(outFileName.Data()) ;
583 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
584 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), run[irun])) ;
585 TString tmp(file[ifile]) ;
586 if (tmp.Contains(pattern)) {
587 merger.AddFile(tmp) ;
596 //_____________________________________________________________________________
597 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
599 // Reset the default data members
601 for (Int_t i = 0; i < fQADataMakers.GetEntriesFast() ; i++) {
602 AliQADataMaker * qadm = static_cast<AliQADataMaker *>(fQADataMakers.At(i));
603 qadm->Reset(sameCycle);
605 if (fRawReaderDelete) {
610 fCycleSame = sameCycle ;
614 fNumberOfEvents = 999999 ;
617 //_____________________________________________________________________________
618 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
620 //Runs all the QA data Maker for Raws only
622 fCycleSame = sameCycle ;
623 fRawReader = rawReader ;
624 fDetectors = detectors ;
625 fDetectorsW = detectors ;
627 AliCDBManager* man = AliCDBManager::Instance() ;
628 if ( ! man->GetLock() ) {
629 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
630 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
633 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
634 rawReader->NextEvent() ;
635 man->SetRun(fRawReader->GetRunNumber()) ;
636 rawReader->RewindEvents() ;
639 if ( !Init(AliQA::kRAWS, "rec") )
641 fRawReaderDelete = kFALSE ;
643 DoIt(AliQA::kRAWS, "rec") ;
647 //_____________________________________________________________________________
648 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
650 //Runs all the QA data Maker for Raws only
652 fCycleSame = sameCycle ;
653 fDetectors = detectors ;
654 fDetectorsW = detectors ;
656 AliCDBManager* man = AliCDBManager::Instance() ;
657 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
658 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
660 AliFatal("galice.root file not found in current directory") ;
664 if ( ! rl->GetAliRun() ) {
665 AliFatal("AliRun not found in galice.root") ;
668 man->SetRun(rl->GetHeader()->GetRun());
673 if ( !Init(AliQA::kRAWS, "rec", fileName) )
676 DoIt(AliQA::kRAWS, "rec") ;
680 //_____________________________________________________________________________
681 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
683 // Runs all the QA data Maker for every detector
685 fCycleSame = sameCycle ;
686 fDetectors = detectors ;
687 fDetectorsW = detectors ;
690 if ( (taskIndex == AliQA::kHITS) || (taskIndex == AliQA::kSDIGITS) || (taskIndex == AliQA::kDIGITS) )
692 else if ( (taskIndex == AliQA::kRAWS) || (taskIndex == AliQA::kRECPOINTS) || (taskIndex == AliQA::kESDS) )
695 AliError(Form("%s not implemented", AliQA::GetTaskName(taskIndex).Data())) ;
699 AliCDBManager* man = AliCDBManager::Instance() ;
700 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
701 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
703 AliFatal("galice.root file not found in current directory") ;
707 if ( ! rl->GetAliRun() ) {
708 AliFatal("AliRun not found in galice.root") ;
711 man->SetRun(rl->GetHeader()->GetRun()) ;
716 if ( !Init(taskIndex, mode.Data(), fileName) )
719 DoIt(taskIndex, mode.Data()) ;
725 //_____________________________________________________________________________
726 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, const char * year, const Int_t cycleNumber, const char * detectors) const
728 // take the locasl QA data merge into a single file and save in OCDB
730 TString tmp(AliQA::GetQARefStorage()) ;
731 if ( tmp.IsNull() ) {
732 AliError("No storage defined, use AliQA::SetQARefStorage") ;
735 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
736 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
739 TString sdet(detectors) ;
742 if ( sdet.Contains("ALL") ) {
743 rv = Merge(runNumber) ;
746 TString inputFileName(Form("Merged.%s.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
747 inputFile = TFile::Open(inputFileName.Data()) ;
748 rv = SaveIt2OCDB(runNumber, inputFile, year) ;
750 for (Int_t index = 0; index < AliQA::kNDET; index++) {
751 if (sdet.Contains(AliQA::GetDetName(index))) {
752 TString inputFileName(Form("%s.%s.%d.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber, cycleNumber)) ;
753 inputFile = TFile::Open(inputFileName.Data()) ;
754 rv *= SaveIt2OCDB(runNumber, inputFile, year) ;
761 //_____________________________________________________________________________
762 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year) const
764 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
766 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
767 AliCDBManager* man = AliCDBManager::Instance() ;
768 if ( ! man->IsDefaultStorageSet() ) {
769 TString tmp( AliQA::GetQARefStorage() ) ;
770 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
771 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
773 TString tmp(AliQA::GetQARefDefaultStorage()) ;
775 tmp.Append("?user=alidaq") ;
776 man->SetDefaultStorage(tmp.Data()) ;
779 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
780 if(man->GetRun() < 0)
781 man->SetRun(runNumber);
784 mdr.SetResponsible("yves schutz");
786 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
787 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
789 AliInfo(Form("Entering %s", detDir->GetName())) ;
790 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
791 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
792 TList * listDetQAD = new TList() ;
793 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
794 mdr.SetComment("HMPID QA stuff");
795 listDetQAD->SetName(listName) ;
796 TList * taskList = detDir->GetListOfKeys() ;
797 TIter nextTask(taskList) ;
799 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
800 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
801 AliInfo(Form("Saving %s", taskDir->GetName())) ;
802 TObjArray * listTaskQAD = new TObjArray(100) ;
803 listTaskQAD->SetName(taskKey->GetName()) ;
804 listDetQAD->Add(listTaskQAD) ;
805 TList * histList = taskDir->GetListOfKeys() ;
806 TIter nextHist(histList) ;
808 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
809 TObject * odata = taskDir->Get(histKey->GetName()) ;
811 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
813 AliInfo(Form("Adding %s", histKey->GetName())) ;
814 if ( odata->IsA()->InheritsFrom("TH1") ) {
815 AliInfo(Form("Adding %s", histKey->GetName())) ;
816 TH1 * hdata = static_cast<TH1*>(odata) ;
817 listTaskQAD->Add(hdata) ;
822 man->Put(listDetQAD, idr, &mdr) ;