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 "AliCodeTimer.h"
44 #include "AliCorrQADataMakerRec.h"
45 #include "AliDetectorRecoParam.h"
46 #include "AliESDEvent.h"
47 #include "AliGeomManager.h"
48 #include "AliGlobalQADataMaker.h"
49 #include "AliHeader.h"
51 #include "AliModule.h"
53 #include "AliQADataMakerRec.h"
54 #include "AliQADataMakerSim.h"
55 #include "AliQADataMakerSteer.h"
56 #include "AliRawReaderDate.h"
57 #include "AliRawReaderFile.h"
58 #include "AliRawReaderRoot.h"
60 #include "AliRunLoader.h"
62 ClassImp(AliQADataMakerSteer)
64 //_____________________________________________________________________________
65 AliQADataMakerSteer::AliQADataMakerSteer(const Char_t * mode, const Char_t* gAliceFilename, const Char_t * name, const Char_t * title) :
73 fGAliceFileName(gAliceFilename),
77 fNumberOfEvents(999999),
81 fRawReaderDelete(kTRUE),
84 fEventSpecie(AliRecoParam::kDefault)
87 fMaxEvents = fNumberOfEvents ;
88 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
89 if (IsSelected(AliQA::GetDetName(iDet))) {
90 fLoader[iDet] = NULL ;
91 fQADataMaker[iDet] = NULL ;
92 fQACycles[iDet] = 999999 ;
93 fQAWriteExpert[iDet] = kTRUE ;
98 //_____________________________________________________________________________
99 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
101 fCurrentEvent(qas.fCurrentEvent),
103 fDetectors(qas.fDetectors),
104 fDetectorsW(qas.fDetectorsW),
107 fGAliceFileName(qas.fGAliceFileName),
108 fFirstEvent(qas.fFirstEvent),
109 fMaxEvents(qas.fMaxEvents),
111 fNumberOfEvents(qas.fNumberOfEvents),
113 fRunNumber(qas.fRunNumber),
115 fRawReaderDelete(kTRUE),
118 fEventSpecie(qas.fEventSpecie)
121 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
122 fLoader[iDet] = qas.fLoader[iDet] ;
123 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
124 fQACycles[iDet] = qas.fQACycles[iDet] ;
125 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
129 //_____________________________________________________________________________
130 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
132 // assignment operator
133 this->~AliQADataMakerSteer() ;
134 new(this) AliQADataMakerSteer(qas) ;
138 //_____________________________________________________________________________
139 AliQADataMakerSteer::~AliQADataMakerSteer()
142 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
143 if (IsSelected(AliQA::GetDetName(iDet))) {
144 fLoader[iDet] = NULL;
145 if (fQADataMaker[iDet]) {
146 (fQADataMaker[iDet])->Finish() ;
147 delete fQADataMaker[iDet] ;
151 if (fRawReaderDelete) {
158 //_____________________________________________________________________________
159 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
161 // Runs all the QA data Maker for every detector
164 // Fill QA data in event loop
165 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
168 if ( iEvent%10 == 0 )
169 AliInfo(Form("processing event %d", iEvent));
170 if ( taskIndex == AliQA::kRAWS ) {
171 if ( !fRawReader->NextEvent() )
173 } else if ( taskIndex == AliQA::kESDS ) {
174 if ( fESDTree->GetEntry(iEvent) == 0 )
177 if ( fRunLoader->GetEvent(iEvent) != 0 )
180 // loop over active loaders
181 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
182 if (IsSelected(AliQA::GetDetName(iDet))) {
183 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
184 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
185 if ( qadm->IsCycleDone() ) {
186 qadm->EndOfCycle(taskIndex) ;
188 TTree * data = NULL ;
189 AliLoader* loader = GetLoader(qadm->GetUniqueID());
191 case AliQA::kNULLTASKINDEX :
194 qadm->Exec(taskIndex, fRawReader) ;
199 data = loader->TreeH() ;
201 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
205 qadm->Exec(taskIndex, data) ;
207 case AliQA::kSDIGITS :
209 loader->LoadSDigits() ;
210 data = loader->TreeS() ;
212 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
216 qadm->Exec(taskIndex, data) ;
218 case AliQA::kDIGITS :
220 loader->LoadDigits() ;
221 data = loader->TreeD() ;
223 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
227 qadm->Exec(taskIndex, data) ;
229 case AliQA::kRECPOINTS :
231 loader->LoadRecPoints() ;
232 data = loader->TreeR() ;
234 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
238 qadm->Exec(taskIndex, data) ;
240 case AliQA::kTRACKSEGMENTS :
242 case AliQA::kRECPARTICLES :
245 qadm->Exec(taskIndex, fESD) ;
247 case AliQA::kNTASKINDEX :
254 // Save QA data for all detectors
255 rv = Finish(taskIndex) ;
257 if ( taskIndex == AliQA::kRAWS )
258 fRawReader->RewindEvents() ;
263 //_____________________________________________________________________________
264 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
266 // write output to file for all detectors
267 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
268 if (IsSelected(AliQA::GetDetName(iDet))) {
269 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
271 qadm->EndOfCycle(taskIndex) ;
277 //_____________________________________________________________________________
278 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
280 // Retrieve the list of QA data for a given detector and a given task
281 TObjArray * rv = NULL ;
282 if ( !strlen(AliQA::GetQARefStorage()) ) {
283 AliError("No storage defined, use AliQA::SetQARefStorage") ;
286 AliCDBManager* man = AliCDBManager::Instance() ;
287 if ( ! man->IsDefaultStorageSet() ) {
288 TString tmp(AliQA::GetQARefDefaultStorage()) ;
291 man->SetDefaultStorage(tmp.Data()) ;
292 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
294 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
295 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
296 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
297 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
299 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
303 //_____________________________________________________________________________
304 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
306 // get the loader for a detector
308 if ( !fRunLoader || iDet == AliQA::kCORR)
311 TString detName = AliQA::GetDetName(iDet) ;
312 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
314 return fLoader[iDet] ;
316 // load the QA data maker object
317 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
318 TString loaderName = "Ali" + detName + "Loader" ;
320 AliLoader * loader = NULL ;
321 // first check if a plugin is defined for the quality assurance data maker
322 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
323 // if not, add a plugin for it
324 if (!pluginHandler) {
325 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
326 TString libs = gSystem->GetLibraries() ;
327 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
328 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
330 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
332 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
334 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
335 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
338 fLoader[iDet] = loader ;
342 //_____________________________________________________________________________
343 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
345 // get the quality assurance data maker for a detector
347 if (fQADataMaker[iDet]) {
348 fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ;
349 return fQADataMaker[iDet] ;
352 AliQADataMaker * qadm = NULL ;
354 if (iDet == AliQA::kGLOBAL) { //Global QA
355 qadm = new AliGlobalQADataMaker();
356 qadm->SetName(AliQA::GetDetName(iDet));
357 qadm->SetUniqueID(iDet);
358 fQADataMaker[iDet] = qadm;
359 qadm->SetEventSpecie(fEventSpecie) ;
363 if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors
364 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
365 qadm->SetName(AliQA::GetDetName(iDet));
366 qadm->SetUniqueID(iDet);
367 fQADataMaker[iDet] = qadm;
368 qadm->SetEventSpecie(fEventSpecie) ;
372 // load the QA data maker object
373 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
374 TString detName = AliQA::GetDetName(iDet) ;
376 if (tmp.Contains("sim"))
377 tmp.ReplaceAll("s", "S") ;
378 else if (tmp.Contains("rec"))
379 tmp.ReplaceAll("r", "R") ;
381 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
383 // first check if a plugin is defined for the quality assurance data maker
384 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
385 // if not, add a plugin for it
386 if (!pluginHandler) {
387 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
388 TString libs = gSystem->GetLibraries() ;
389 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
390 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
392 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
394 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
396 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
397 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
400 qadm->SetName(AliQA::GetDetName(iDet));
401 qadm->SetUniqueID(iDet);
402 fQADataMaker[iDet] = qadm ;
403 qadm->SetEventSpecie(fEventSpecie) ;
409 //_____________________________________________________________________________
410 void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray)
412 // End of cycle QADataMakers
414 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
415 if (IsSelected(AliQA::GetDetName(iDet))) {
416 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
419 // skip non active detectors
421 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
422 if (!det || !det->IsActive())
425 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
426 if ( fTasks.Contains(Form("%d", taskIndex)) )
427 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
434 //_____________________________________________________________________________
435 void AliQADataMakerSteer::EndOfCycle(TString detectors)
437 // End of cycle QADataMakers
439 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
440 if (IsSelected(AliQA::GetDetName(iDet))) {
441 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
444 // skip non active detectors
445 if (!detectors.Contains(AliQA::GetDetName(iDet)))
447 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
448 if ( fTasks.Contains(Form("%d", taskIndex)) )
449 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
456 //_____________________________________________________________________________
457 void AliQADataMakerSteer::Increment()
459 // Increments the cycle counter for all QA Data Makers
460 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
461 if (IsSelected(AliQA::GetDetName(iDet))) {
462 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
469 //_____________________________________________________________________________
470 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
472 // Initialize the event source and QA data makers
474 //fTasks = AliQA::GetTaskName(taskIndex) ;
476 if (taskIndex == AliQA::kRAWS) {
478 fRawReader = AliRawReader::Create(input);
482 fRawReaderDelete = kTRUE ;
483 fRawReader->NextEvent() ;
484 fRunNumber = fRawReader->GetRunNumber() ;
485 AliCDBManager::Instance()->SetRun(fRunNumber) ;
486 fRawReader->RewindEvents();
487 fNumberOfEvents = 999999 ;
488 if ( fMaxEvents < 0 )
489 fMaxEvents = fNumberOfEvents ;
490 } else if (taskIndex == AliQA::kESDS) {
491 fTasks = AliQA::GetTaskName(AliQA::kESDS) ;
492 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
493 TFile * esdFile = TFile::Open("AliESDs.root") ;
494 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
496 AliError("esdTree not found") ;
499 fESD = new AliESDEvent() ;
500 fESD->ReadFromTree(fESDTree) ;
501 fESDTree->GetEntry(0) ;
502 fRunNumber = fESD->GetRunNumber() ;
503 fNumberOfEvents = fESDTree->GetEntries() ;
504 if ( fMaxEvents < 0 )
505 fMaxEvents = fNumberOfEvents ;
508 AliError("AliESDs.root not found") ;
512 if ( !InitRunLoader() ) {
513 AliWarning("No Run Loader not found") ;
515 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
516 if ( fMaxEvents < 0 )
517 fMaxEvents = fNumberOfEvents ;
522 TObjArray* detArray = NULL ;
523 if (fRunLoader) // check if RunLoader exists
524 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
525 detArray = fRunLoader->GetAliRun()->Detectors() ;
526 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
529 // Initialize all QA data makers for all detectors
530 fRunNumber = AliCDBManager::Instance()->GetRun() ;
531 if ( ! AliGeomManager::GetGeometry() )
532 AliGeomManager::LoadGeometry() ;
534 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
538 //_____________________________________________________________________________
539 void AliQADataMakerSteer::InitQADataMaker(UInt_t run, TObjArray * detArray)
541 // Initializes The QADataMaker for all active detectors and for all active tasks
542 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
543 if (IsSelected(AliQA::GetDetName(iDet))) {
544 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
546 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
547 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
549 if (fQAWriteExpert[iDet])
550 qadm->SetWriteExpert() ;
551 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
552 // skip non active detectors
554 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
555 if (!det || !det->IsActive())
558 if (fQAWriteExpert[iDet]) qadm->SetWriteExpert() ;
559 // Set default reco params
560 Bool_t sameCycle = kFALSE ;
561 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
562 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
563 qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
564 qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, sameCycle) ;
574 //_____________________________________________________________________________
575 Bool_t AliQADataMakerSteer::InitRunLoader()
577 // get or create the run loader
581 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
582 // load all base libraries to get the loader classes
583 TString libs = gSystem->GetLibraries() ;
584 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
585 if (!IsSelected(AliQA::GetDetName(iDet)))
587 TString detName = AliQA::GetDetName(iDet) ;
588 if (detName == "HLT")
590 if (libs.Contains("lib" + detName + "base.so"))
592 gSystem->Load("lib" + detName + "base.so");
594 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
596 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
599 fRunLoader->CdGAFile();
600 if (fRunLoader->LoadgAlice() == 0) {
601 gAlice = fRunLoader->GetAliRun();
605 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
609 } else { // galice.root does not exist
610 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
616 fRunLoader->LoadHeader();
617 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
622 //_____________________________________________________________________________
623 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
625 // check whether detName is contained in detectors
626 // if yes, it is removed from detectors
629 const TString detName(det) ;
630 // always activates Correlation
631 if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) {
634 // check if all detectors are selected
635 if (fDetectors.Contains("ALL")) {
638 } else if ((fDetectors.CompareTo(detName) == 0) ||
639 fDetectors.BeginsWith(detName+" ") ||
640 fDetectors.EndsWith(" "+detName) ||
641 fDetectors.Contains(" "+detName+" ")) {
648 //_____________________________________________________________________________
649 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
651 // Merge data from all the cycles from all detectors in one single file per run
652 // Merge the QA results from all the data chunks in one run
653 Bool_t rv = MergeData(runNumber) ;
654 rv *= MergeResults(runNumber) ;
659 //_____________________________________________________________________________
660 Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const
662 // Merge all the cycles from all detectors in one single file per run
665 cmd = Form(".! ls *%s*.%d.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
667 cmd = Form(".! ls *%s*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
668 gROOT->ProcessLine(cmd.Data()) ;
669 ifstream in("tempo.txt") ;
670 const Int_t runMax = 10 ;
671 TString file[AliQA::kNDET*runMax] ;
678 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
683 AliError(Form("run number %d not found", runNumber)) ;
688 TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),runNumber));
689 merger.OutputFile(outFileName.Data()) ;
690 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
691 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), runNumber));
692 TString tmp(file[ifile]) ;
693 if (tmp.Contains(pattern)) {
694 merger.AddFile(tmp) ;
701 //_____________________________________________________________________________
702 Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const
704 // Merge the QA result from all the data chunks in a run
706 cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ;
707 gROOT->ProcessLine(cmd.Data()) ;
708 ifstream in("tempo.txt") ;
709 const Int_t chunkMax = 100 ;
710 TString fileList[chunkMax] ;
715 in >> fileList[index] ;
718 AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ;
723 AliError("No QA Result File found") ;
728 TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber));
729 merger.OutputFile(outFileName.Data()) ;
730 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
731 TString file = fileList[ifile] ;
732 merger.AddFile(file) ;
739 //_____________________________________________________________________________
740 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
742 // Reset the default data members
744 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
745 if (IsSelected(AliQA::GetDetName(iDet))) {
746 AliQADataMaker * qadm = GetQADataMaker(iDet);
750 if (fRawReaderDelete) {
755 fCycleSame = sameCycle ;
759 fNumberOfEvents = 999999 ;
762 //_____________________________________________________________________________
763 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
765 //Runs all the QA data Maker for Raws only
767 fCycleSame = sameCycle ;
768 fRawReader = rawReader ;
769 fDetectors = detectors ;
770 fDetectorsW = detectors ;
772 AliCDBManager* man = AliCDBManager::Instance() ;
774 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
775 rawReader->NextEvent() ;
776 man->SetRun(fRawReader->GetRunNumber()) ;
777 rawReader->RewindEvents() ;
781 if ( !Init(AliQA::kRAWS) )
783 fRawReaderDelete = kFALSE ;
789 //_____________________________________________________________________________
790 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
792 //Runs all the QA data Maker for Raws only
794 fCycleSame = sameCycle ;
795 fDetectors = detectors ;
796 fDetectorsW = detectors ;
798 AliCDBManager* man = AliCDBManager::Instance() ;
799 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
800 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
802 AliFatal("galice.root file not found in current directory") ;
806 if ( ! rl->GetAliRun() ) {
807 AliFatal("AliRun not found in galice.root") ;
810 man->SetRun(rl->GetHeader()->GetRun());
816 if ( !Init(AliQA::kRAWS, fileName) )
823 //_____________________________________________________________________________
824 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
826 // Runs all the QA data Maker for every detector
828 fCycleSame = sameCycle ;
829 fDetectors = detectors ;
830 fDetectorsW = detectors ;
832 AliCDBManager* man = AliCDBManager::Instance() ;
833 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
834 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
836 AliFatal("galice.root file not found in current directory") ;
840 if ( ! rl->GetAliRun() ) {
841 AliInfo("AliRun not found in galice.root") ;
844 man->SetRun(rl->GetHeader()->GetRun()) ;
850 if ( taskIndex == AliQA::kNULLTASKINDEX) {
851 for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
852 if ( fTasks.Contains(Form("%d", task)) ) {
854 if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) )
856 DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
861 if ( !Init(taskIndex, fileName) )
870 //_____________________________________________________________________________
871 void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader)
873 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
876 AliCodeTimerAuto("") ;
877 if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
878 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
879 if (!IsSelected(AliQA::GetDetName(iDet)))
881 AliQADataMaker *qadm = GetQADataMaker(iDet);
884 if ( qadm->IsCycleDone() ) {
887 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
888 qadm->SetEventSpecie(fEventSpecie) ;
889 qadm->Exec(AliQA::kRAWS, rawReader) ;
890 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
895 //_____________________________________________________________________________
896 void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd)
898 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
900 AliCodeTimerAuto("") ;
901 if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
902 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
903 if (!IsSelected(AliQA::GetDetName(iDet)))
905 AliQADataMaker *qadm = GetQADataMaker(iDet);
908 if ( qadm->IsCycleDone() ) {
911 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
912 qadm->Exec(AliQA::kESDS, esd) ;
913 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
918 //_____________________________________________________________________________
919 void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree)
921 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
922 AliCodeTimerAuto("") ;
923 if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
924 if (IsSelected(AliQA::GetDetName(det))) {
925 AliQADataMaker *qadm = GetQADataMaker(det);
927 if ( qadm->IsCycleDone() ) {
930 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
931 qadm->Exec(AliQA::kRECPOINTS, tree) ;
932 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
938 //_____________________________________________________________________________
939 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const char * year, const char * detectors) const
941 // take the locasl QA data merge into a single file and save in OCDB
943 TString tmp(AliQA::GetQARefStorage()) ;
944 if ( tmp.IsNull() ) {
945 AliError("No storage defined, use AliQA::SetQARefStorage") ;
948 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
949 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
952 TString sdet(detectors) ;
955 if ( sdet.Contains("ALL") ) {
956 rv = Merge(runNumber) ;
959 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
960 inputFile = TFile::Open(inputFileName.Data()) ;
961 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
963 for (Int_t index = 0; index < AliQA::kNDET; index++) {
964 if (sdet.Contains(AliQA::GetDetName(index))) {
965 TString inputFileName(Form("%s.%s.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber)) ;
966 inputFile = TFile::Open(inputFileName.Data()) ;
967 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
974 //_____________________________________________________________________________
975 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year, AliRecoParam::EventSpecie_t es) const
977 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
979 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
980 AliCDBManager* man = AliCDBManager::Instance() ;
981 if ( ! man->IsDefaultStorageSet() ) {
982 TString tmp( AliQA::GetQARefStorage() ) ;
983 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
984 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
986 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
988 tmp1.Append("?user=alidaq") ;
989 man->SetDefaultStorage(tmp1.Data()) ;
992 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
993 if(man->GetRun() < 0)
994 man->SetRun(runNumber);
997 mdr.SetResponsible("yves schutz");
999 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
1000 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
1002 AliInfo(Form("Entering %s", detDir->GetName())) ;
1003 AliQA::SetQARefDataDirName(es) ;
1004 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
1005 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1006 TList * listDetQAD = new TList() ;
1007 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
1008 mdr.SetComment(Form("%s QA stuff", AliQA::GetDetName(detIndex)));
1009 listDetQAD->SetName(listName) ;
1010 TList * taskList = detDir->GetListOfKeys() ;
1011 TIter nextTask(taskList) ;
1013 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
1014 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1015 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1016 AliInfo(Form("Saving %s", esDir->GetName())) ;
1017 TObjArray * listTaskQAD = new TObjArray(100) ;
1018 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1019 listDetQAD->Add(listTaskQAD) ;
1020 TList * histList = esDir->GetListOfKeys() ;
1021 TIter nextHist(histList) ;
1023 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1024 TObject * odata = esDir->Get(histKey->GetName()) ;
1026 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1028 if ( AliQA::GetExpert() == histKey->GetName() ) {
1029 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1030 TList * expertHistList = expertDir->GetListOfKeys() ;
1031 TIter nextExpertHist(expertHistList) ;
1032 TKey * expertHistKey ;
1033 while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) {
1034 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1035 if ( !expertOdata ) {
1036 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1038 AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
1039 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1040 AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
1041 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1042 listTaskQAD->Add(hExpertdata) ;
1047 AliInfo(Form("Adding %s", histKey->GetName())) ;
1048 if ( odata->IsA()->InheritsFrom("TH1") ) {
1049 AliInfo(Form("Adding %s", histKey->GetName())) ;
1050 TH1 * hdata = static_cast<TH1*>(odata) ;
1051 listTaskQAD->Add(hdata) ;
1056 man->Put(listDetQAD, idr, &mdr) ;
1062 //_____________________________________________________________________________
1063 void AliQADataMakerSteer::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1065 // set the current event specie and inform AliQA that this event specie has been encountered
1067 AliQA::Instance()->SetEventSpecie(es) ;
1070 //_____________________________________________________________________________
1071 void AliQADataMakerSteer::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1073 // Set custom reconstruction parameters for a given detector
1074 // Single set of parameters for all the events
1075 GetQADataMaker(det)->SetRecoParam(par) ;