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"
61 #include "AliRunTag.h"
63 ClassImp(AliQADataMakerSteer)
65 //_____________________________________________________________________________
66 AliQADataMakerSteer::AliQADataMakerSteer(const Char_t * mode, const Char_t* gAliceFilename, const Char_t * name, const Char_t * title) :
74 fGAliceFileName(gAliceFilename),
78 fNumberOfEvents(999999),
82 fRawReaderDelete(kTRUE),
85 fEventSpecie(AliRecoParam::kDefault)
88 fMaxEvents = fNumberOfEvents ;
89 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
90 if (IsSelected(AliQA::GetDetName(iDet))) {
91 fLoader[iDet] = NULL ;
92 fQADataMaker[iDet] = NULL ;
93 fQACycles[iDet] = 999999 ;
94 fQAWriteExpert[iDet] = kTRUE ;
99 //_____________________________________________________________________________
100 AliQADataMakerSteer::AliQADataMakerSteer(const AliQADataMakerSteer & qas) :
102 fCurrentEvent(qas.fCurrentEvent),
104 fDetectors(qas.fDetectors),
105 fDetectorsW(qas.fDetectorsW),
108 fGAliceFileName(qas.fGAliceFileName),
109 fFirstEvent(qas.fFirstEvent),
110 fMaxEvents(qas.fMaxEvents),
112 fNumberOfEvents(qas.fNumberOfEvents),
114 fRunNumber(qas.fRunNumber),
116 fRawReaderDelete(kTRUE),
119 fEventSpecie(qas.fEventSpecie)
122 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
123 fLoader[iDet] = qas.fLoader[iDet] ;
124 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
125 fQACycles[iDet] = qas.fQACycles[iDet] ;
126 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
130 //_____________________________________________________________________________
131 AliQADataMakerSteer & AliQADataMakerSteer::operator = (const AliQADataMakerSteer & qas)
133 // assignment operator
134 this->~AliQADataMakerSteer() ;
135 new(this) AliQADataMakerSteer(qas) ;
139 //_____________________________________________________________________________
140 AliQADataMakerSteer::~AliQADataMakerSteer()
143 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
144 if (IsSelected(AliQA::GetDetName(iDet))) {
145 fLoader[iDet] = NULL;
146 if (fQADataMaker[iDet]) {
147 (fQADataMaker[iDet])->Finish() ;
148 delete fQADataMaker[iDet] ;
152 if (fRawReaderDelete) {
159 //_____________________________________________________________________________
160 Bool_t AliQADataMakerSteer::DoIt(const AliQA::TASKINDEX_t taskIndex)
162 // Runs all the QA data Maker for every detector
165 // Fill QA data in event loop
166 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
169 if ( iEvent%10 == 0 )
170 AliInfo(Form("processing event %d", iEvent));
171 if ( taskIndex == AliQA::kRAWS ) {
172 if ( !fRawReader->NextEvent() )
174 } else if ( taskIndex == AliQA::kESDS ) {
175 if ( fESDTree->GetEntry(iEvent) == 0 )
178 if ( fRunLoader->GetEvent(iEvent) != 0 )
181 // loop over active loaders
182 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
183 if (IsSelected(AliQA::GetDetName(iDet))) {
184 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
185 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
186 if ( qadm->IsCycleDone() ) {
187 qadm->EndOfCycle(taskIndex) ;
189 TTree * data = NULL ;
190 AliLoader* loader = GetLoader(qadm->GetUniqueID());
192 case AliQA::kNULLTASKINDEX :
195 qadm->Exec(taskIndex, fRawReader) ;
200 data = loader->TreeH() ;
202 AliWarning(Form(" Hit Tree not found for %s", AliQA::GetDetName(iDet))) ;
206 qadm->Exec(taskIndex, data) ;
208 case AliQA::kSDIGITS :
210 loader->LoadSDigits() ;
211 data = loader->TreeS() ;
213 AliWarning(Form(" SDigit Tree not found for %s", AliQA::GetDetName(iDet))) ;
217 qadm->Exec(taskIndex, data) ;
219 case AliQA::kDIGITS :
221 loader->LoadDigits() ;
222 data = loader->TreeD() ;
224 AliWarning(Form(" Digit Tree not found for %s", AliQA::GetDetName(iDet))) ;
228 qadm->Exec(taskIndex, data) ;
230 case AliQA::kRECPOINTS :
232 loader->LoadRecPoints() ;
233 data = loader->TreeR() ;
235 AliWarning(Form("RecPoints not found for %s", AliQA::GetDetName(iDet))) ;
239 qadm->Exec(taskIndex, data) ;
241 case AliQA::kTRACKSEGMENTS :
243 case AliQA::kRECPARTICLES :
246 qadm->Exec(taskIndex, fESD) ;
248 case AliQA::kNTASKINDEX :
255 // Save QA data for all detectors
256 rv = Finish(taskIndex) ;
258 if ( taskIndex == AliQA::kRAWS )
259 fRawReader->RewindEvents() ;
264 //_____________________________________________________________________________
265 Bool_t AliQADataMakerSteer::Finish(const AliQA::TASKINDEX_t taskIndex)
267 // write output to file for all detectors
268 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
269 if (IsSelected(AliQA::GetDetName(iDet))) {
270 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
272 qadm->EndOfCycle(taskIndex) ;
278 //_____________________________________________________________________________
279 TObjArray * AliQADataMakerSteer::GetFromOCDB(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, const char * year) const
281 // Retrieve the list of QA data for a given detector and a given task
282 TObjArray * rv = NULL ;
283 if ( !strlen(AliQA::GetQARefStorage()) ) {
284 AliError("No storage defined, use AliQA::SetQARefStorage") ;
287 AliCDBManager* man = AliCDBManager::Instance() ;
288 if ( ! man->IsDefaultStorageSet() ) {
289 TString tmp(AliQA::GetQARefDefaultStorage()) ;
292 man->SetDefaultStorage(tmp.Data()) ;
293 man->SetSpecificStorage(Form("%s/*", AliQA::GetQAName()), AliQA::GetQARefStorage()) ;
295 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetQAName(), AliQA::GetDetName((Int_t)det), AliQA::GetRefOCDBDirName())) ;
296 AliInfo(Form("Retrieving reference data from %s/%s for %s", AliQA::GetQARefStorage(), detOCDBDir.Data(), AliQA::GetTaskName(task).Data())) ;
297 AliCDBEntry* entry = man->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
298 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
300 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQA::GetTaskName(task))) ;
304 //_____________________________________________________________________________
305 AliLoader * AliQADataMakerSteer::GetLoader(Int_t iDet)
307 // get the loader for a detector
309 if ( !fRunLoader || iDet == AliQA::kCORR)
312 TString detName = AliQA::GetDetName(iDet) ;
313 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
315 return fLoader[iDet] ;
317 // load the QA data maker object
318 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
319 TString loaderName = "Ali" + detName + "Loader" ;
321 AliLoader * loader = NULL ;
322 // first check if a plugin is defined for the quality assurance data maker
323 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
324 // if not, add a plugin for it
325 if (!pluginHandler) {
326 AliDebug(1, Form("defining plugin for %s", loaderName.Data())) ;
327 TString libs = gSystem->GetLibraries() ;
328 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
329 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
331 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
333 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
335 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
336 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
339 fLoader[iDet] = loader ;
343 //_____________________________________________________________________________
344 AliQA * AliQADataMakerSteer::GetQA(UInt_t run, UInt_t evt)
346 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
347 char * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
348 TFile * tagFile = TFile::Open(fileName) ;
350 AliError(Form("File %s not found", fileName)) ;
353 TTree * tagTree = dynamic_cast<TTree *>(tagFile->Get("T")) ;
355 AliError(Form("Tree T not found in %s", fileName)) ;
359 AliRunTag * tag = new AliRunTag ;
360 tagTree->SetBranchAddress("AliTAG", &tag) ;
361 tagTree->GetEntry(evt) ;
362 AliQA * qa = AliQA::Instance(tag->GetQALength(), tag->GetQA(), tag->GetESLength(), tag->GetEventSpecies()) ;
367 //_____________________________________________________________________________
368 AliQADataMaker * AliQADataMakerSteer::GetQADataMaker(const Int_t iDet)
370 // get the quality assurance data maker for a detector
372 if (fQADataMaker[iDet]) {
373 fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ;
374 return fQADataMaker[iDet] ;
377 AliQADataMaker * qadm = NULL ;
379 if (iDet == AliQA::kGLOBAL) { //Global QA
380 qadm = new AliGlobalQADataMaker();
381 qadm->SetName(AliQA::GetDetName(iDet));
382 qadm->SetUniqueID(iDet);
383 fQADataMaker[iDet] = qadm;
384 qadm->SetEventSpecie(fEventSpecie) ;
388 if (iDet == AliQA::kCORR) { //the data maker for correlations among detectors
389 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
390 qadm->SetName(AliQA::GetDetName(iDet));
391 qadm->SetUniqueID(iDet);
392 fQADataMaker[iDet] = qadm;
393 qadm->SetEventSpecie(fEventSpecie) ;
397 // load the QA data maker object
398 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
399 TString detName = AliQA::GetDetName(iDet) ;
401 if (tmp.Contains("sim"))
402 tmp.ReplaceAll("s", "S") ;
403 else if (tmp.Contains("rec"))
404 tmp.ReplaceAll("r", "R") ;
406 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
408 // first check if a plugin is defined for the quality assurance data maker
409 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
410 // if not, add a plugin for it
411 if (!pluginHandler) {
412 AliDebug(1, Form("defining plugin for %s", qadmName.Data())) ;
413 TString libs = gSystem->GetLibraries() ;
414 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
415 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
417 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
419 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
421 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
422 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
425 qadm->SetName(AliQA::GetDetName(iDet));
426 qadm->SetUniqueID(iDet);
427 fQADataMaker[iDet] = qadm ;
428 qadm->SetEventSpecie(fEventSpecie) ;
434 //_____________________________________________________________________________
435 void AliQADataMakerSteer::EndOfCycle(TObjArray * detArray)
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
446 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
447 if (!det || !det->IsActive())
450 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
451 if ( fTasks.Contains(Form("%d", taskIndex)) )
452 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
459 //_____________________________________________________________________________
460 void AliQADataMakerSteer::EndOfCycle(TString detectors)
462 // End of cycle QADataMakers
464 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
465 if (IsSelected(AliQA::GetDetName(iDet))) {
466 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
469 // skip non active detectors
470 if (!detectors.Contains(AliQA::GetDetName(iDet)))
472 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
473 if ( fTasks.Contains(Form("%d", taskIndex)) )
474 qadm->EndOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex))) ;
481 //_____________________________________________________________________________
482 void AliQADataMakerSteer::Increment()
484 // Increments the cycle counter for all QA Data Makers
485 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
486 if (IsSelected(AliQA::GetDetName(iDet))) {
487 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
494 //_____________________________________________________________________________
495 Bool_t AliQADataMakerSteer::Init(const AliQA::TASKINDEX_t taskIndex, const char * input )
497 // Initialize the event source and QA data makers
499 fTasks += Form("%d", taskIndex) ;
501 if (taskIndex == AliQA::kRAWS) {
503 fRawReader = AliRawReader::Create(input);
507 fRawReaderDelete = kTRUE ;
508 fRawReader->NextEvent() ;
509 fRunNumber = fRawReader->GetRunNumber() ;
510 AliCDBManager::Instance()->SetRun(fRunNumber) ;
511 fRawReader->RewindEvents();
512 fNumberOfEvents = 999999 ;
513 if ( fMaxEvents < 0 )
514 fMaxEvents = fNumberOfEvents ;
515 } else if (taskIndex == AliQA::kESDS) {
516 fTasks = AliQA::GetTaskName(AliQA::kESDS) ;
517 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
518 TFile * esdFile = TFile::Open("AliESDs.root") ;
519 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
521 AliError("esdTree not found") ;
524 fESD = new AliESDEvent() ;
525 fESD->ReadFromTree(fESDTree) ;
526 fESDTree->GetEntry(0) ;
527 fRunNumber = fESD->GetRunNumber() ;
528 fNumberOfEvents = fESDTree->GetEntries() ;
529 if ( fMaxEvents < 0 )
530 fMaxEvents = fNumberOfEvents ;
533 AliError("AliESDs.root not found") ;
537 if ( !InitRunLoader() ) {
538 AliWarning("No Run Loader not found") ;
540 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
541 if ( fMaxEvents < 0 )
542 fMaxEvents = fNumberOfEvents ;
547 TObjArray* detArray = NULL ;
548 if (fRunLoader) // check if RunLoader exists
549 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
550 detArray = fRunLoader->GetAliRun()->Detectors() ;
551 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
554 // Initialize all QA data makers for all detectors
555 fRunNumber = AliCDBManager::Instance()->GetRun() ;
556 if ( ! AliGeomManager::GetGeometry() )
557 AliGeomManager::LoadGeometry() ;
559 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
563 //_____________________________________________________________________________
564 void AliQADataMakerSteer::InitQADataMaker(UInt_t run, TObjArray * detArray)
566 // Initializes The QADataMaker for all active detectors and for all active tasks
567 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
568 if (IsSelected(AliQA::GetDetName(iDet))) {
569 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
571 AliError(Form("AliQADataMaker not found for %s", AliQA::GetDetName(iDet))) ;
572 fDetectorsW.ReplaceAll(AliQA::GetDetName(iDet), "") ;
574 if (fQAWriteExpert[iDet])
575 qadm->SetWriteExpert() ;
576 AliDebug(1, Form("Data Maker found for %s", qadm->GetName())) ;
577 // skip non active detectors
579 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQA::GetDetName(iDet))) ;
580 if (!det || !det->IsActive())
583 if (fQAWriteExpert[iDet]) qadm->SetWriteExpert() ;
584 // Set default reco params
585 Bool_t sameCycle = kFALSE ;
586 for (UInt_t taskIndex = 0; taskIndex < AliQA::kNTASKINDEX; taskIndex++) {
587 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
588 qadm->Init(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
589 qadm->StartOfCycle(AliQA::GetTaskIndex(AliQA::GetTaskName(taskIndex)), run, sameCycle) ;
599 //_____________________________________________________________________________
600 Bool_t AliQADataMakerSteer::InitRunLoader()
602 // get or create the run loader
606 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
607 // load all base libraries to get the loader classes
608 TString libs = gSystem->GetLibraries() ;
609 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
610 if (!IsSelected(AliQA::GetDetName(iDet)))
612 TString detName = AliQA::GetDetName(iDet) ;
613 if (detName == "HLT")
615 if (libs.Contains("lib" + detName + "base.so"))
617 gSystem->Load("lib" + detName + "base.so");
619 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
621 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
624 fRunLoader->CdGAFile();
625 if (fRunLoader->LoadgAlice() == 0) {
626 gAlice = fRunLoader->GetAliRun();
630 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
634 } else { // galice.root does not exist
635 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
641 fRunLoader->LoadHeader();
642 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
647 //_____________________________________________________________________________
648 Bool_t AliQADataMakerSteer::IsSelected(const char * det)
650 // check whether detName is contained in detectors
651 // if yes, it is removed from detectors
654 const TString detName(det) ;
655 // always activates Correlation
656 if ( detName.Contains(AliQA::GetDetName(AliQA::kCORR))) {
659 // check if all detectors are selected
660 if (fDetectors.Contains("ALL")) {
663 } else if ((fDetectors.CompareTo(detName) == 0) ||
664 fDetectors.BeginsWith(detName+" ") ||
665 fDetectors.EndsWith(" "+detName) ||
666 fDetectors.Contains(" "+detName+" ")) {
673 //_____________________________________________________________________________
674 Bool_t AliQADataMakerSteer::Merge(const Int_t runNumber) const
676 // Merge data from all the cycles from all detectors in one single file per run
677 // Merge the QA results from all the data chunks in one run
678 Bool_t rv = MergeData(runNumber) ;
679 rv *= MergeResults(runNumber) ;
684 //_____________________________________________________________________________
685 Bool_t AliQADataMakerSteer::MergeData(const Int_t runNumber) const
687 // Merge all the cycles from all detectors in one single file per run
690 cmd = Form(".! ls *%s*.%d.root > tempo.txt", AliQA::GetQADataFileName(), runNumber) ;
692 cmd = Form(".! ls *%s*.*.root > tempo.txt", AliQA::GetQADataFileName()) ;
693 gROOT->ProcessLine(cmd.Data()) ;
694 ifstream in("tempo.txt") ;
695 const Int_t runMax = 10 ;
696 TString file[AliQA::kNDET*runMax] ;
703 AliInfo(Form("index = %d file = %s", index, (file[index]).Data())) ;
708 AliError(Form("run number %d not found", runNumber)) ;
713 TString outFileName(Form("Merged.%s.Data.%d.root",AliQA::GetQADataFileName(),runNumber));
714 merger.OutputFile(outFileName.Data()) ;
715 for (Int_t ifile = 0 ; ifile < index-1 ; ifile++) {
716 TString pattern(Form("%s.%d.", AliQA::GetQADataFileName(), runNumber));
717 TString tmp(file[ifile]) ;
718 if (tmp.Contains(pattern)) {
719 merger.AddFile(tmp) ;
726 //_____________________________________________________________________________
727 Bool_t AliQADataMakerSteer::MergeResults(const Int_t runNumber) const
729 // Merge the QA result from all the data chunks in a run
731 cmd = Form(".! ls %s*.root > tempo.txt", AliQA::GetQADataFileName()) ;
732 gROOT->ProcessLine(cmd.Data()) ;
733 ifstream in("tempo.txt") ;
734 const Int_t chunkMax = 100 ;
735 TString fileList[chunkMax] ;
740 in >> fileList[index] ;
743 AliInfo(Form("index = %d file = %s", index, (fileList[index].Data()))) ;
748 AliError("No QA Result File found") ;
753 TString outFileName(Form("Merged.%s.Result.%d.root", AliQA::GetQADataFileName(), runNumber));
754 merger.OutputFile(outFileName.Data()) ;
755 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
756 TString file = fileList[ifile] ;
757 merger.AddFile(file) ;
764 //_____________________________________________________________________________
765 void AliQADataMakerSteer::Reset(const Bool_t sameCycle)
767 // Reset the default data members
769 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
770 if (IsSelected(AliQA::GetDetName(iDet))) {
771 AliQADataMaker * qadm = GetQADataMaker(iDet);
775 if (fRawReaderDelete) {
780 fCycleSame = sameCycle ;
784 fNumberOfEvents = 999999 ;
787 //_____________________________________________________________________________
788 TString AliQADataMakerSteer::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
790 //Runs all the QA data Maker for Raws only
792 fCycleSame = sameCycle ;
793 fRawReader = rawReader ;
794 fDetectors = detectors ;
795 fDetectorsW = detectors ;
797 AliCDBManager* man = AliCDBManager::Instance() ;
799 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
800 rawReader->NextEvent() ;
801 man->SetRun(fRawReader->GetRunNumber()) ;
802 rawReader->RewindEvents() ;
806 if ( !Init(AliQA::kRAWS) )
808 fRawReaderDelete = kFALSE ;
814 //_____________________________________________________________________________
815 TString AliQADataMakerSteer::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
817 //Runs all the QA data Maker for Raws only
819 fCycleSame = sameCycle ;
820 fDetectors = detectors ;
821 fDetectorsW = detectors ;
823 AliCDBManager* man = AliCDBManager::Instance() ;
824 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
825 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
827 AliFatal("galice.root file not found in current directory") ;
831 if ( ! rl->GetAliRun() ) {
832 AliFatal("AliRun not found in galice.root") ;
835 man->SetRun(rl->GetHeader()->GetRun());
841 if ( !Init(AliQA::kRAWS, fileName) )
848 //_____________________________________________________________________________
849 TString AliQADataMakerSteer::Run(const char * detectors, const AliQA::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
851 // Runs all the QA data Maker for every detector
853 fCycleSame = sameCycle ;
854 fDetectors = detectors ;
855 fDetectorsW = detectors ;
857 AliCDBManager* man = AliCDBManager::Instance() ;
858 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
859 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
861 AliFatal("galice.root file not found in current directory") ;
865 if ( ! rl->GetAliRun() ) {
866 AliInfo("AliRun not found in galice.root") ;
869 man->SetRun(rl->GetHeader()->GetRun()) ;
875 if ( taskIndex == AliQA::kNULLTASKINDEX) {
876 for (UInt_t task = 0; task < AliQA::kNTASKINDEX; task++) {
877 if ( fTasks.Contains(Form("%d", task)) ) {
879 if ( !Init(AliQA::GetTaskIndex(AliQA::GetTaskName(task)), fileName) )
881 DoIt(AliQA::GetTaskIndex(AliQA::GetTaskName(task))) ;
886 if ( !Init(taskIndex, fileName) )
895 //_____________________________________________________________________________
896 void AliQADataMakerSteer::RunOneEvent(AliRawReader * rawReader)
898 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
901 AliCodeTimerAuto("") ;
902 if (fTasks.Contains(Form("%d", AliQA::kRAWS))){
903 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
904 if (!IsSelected(AliQA::GetDetName(iDet)))
906 AliQADataMaker *qadm = GetQADataMaker(iDet);
909 if ( qadm->IsCycleDone() ) {
912 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
913 qadm->SetEventSpecie(fEventSpecie) ;
914 qadm->Exec(AliQA::kRAWS, rawReader) ;
915 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQA::GetDetName(iDet)));
920 //_____________________________________________________________________________
921 void AliQADataMakerSteer::RunOneEvent(AliESDEvent *& esd)
923 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
925 AliCodeTimerAuto("") ;
926 if (fTasks.Contains(Form("%d", AliQA::kESDS))) {
927 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
928 if (!IsSelected(AliQA::GetDetName(iDet)))
930 AliQADataMaker *qadm = GetQADataMaker(iDet);
933 if ( qadm->IsCycleDone() ) {
936 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
937 qadm->Exec(AliQA::kESDS, esd) ;
938 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQA::GetDetName(iDet)));
943 //_____________________________________________________________________________
944 void AliQADataMakerSteer::RunOneEventInOneDetector(Int_t det, TTree * tree)
946 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
947 AliCodeTimerAuto("") ;
948 if (fTasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
949 if (IsSelected(AliQA::GetDetName(det))) {
950 AliQADataMaker *qadm = GetQADataMaker(det);
952 if ( qadm->IsCycleDone() ) {
955 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
956 qadm->Exec(AliQA::kRECPOINTS, tree) ;
957 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQA::GetDetName(det)));
963 //_____________________________________________________________________________
964 Bool_t AliQADataMakerSteer::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const char * year, const char * detectors) const
966 // take the locasl QA data merge into a single file and save in OCDB
968 TString tmp(AliQA::GetQARefStorage()) ;
969 if ( tmp.IsNull() ) {
970 AliError("No storage defined, use AliQA::SetQARefStorage") ;
973 if ( !(tmp.Contains(AliQA::GetLabLocalOCDB()) || tmp.Contains(AliQA::GetLabAliEnOCDB())) ) {
974 AliError(Form("%s is a wrong storage, use %s or %s", AliQA::GetQARefStorage(), AliQA::GetLabLocalOCDB().Data(), AliQA::GetLabAliEnOCDB().Data())) ;
977 TString sdet(detectors) ;
980 if ( sdet.Contains("ALL") ) {
981 rv = Merge(runNumber) ;
984 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQA::GetQADataFileName(), runNumber)) ;
985 inputFile = TFile::Open(inputFileName.Data()) ;
986 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
988 for (Int_t index = 0; index < AliQA::kNDET; index++) {
989 if (sdet.Contains(AliQA::GetDetName(index))) {
990 TString inputFileName(Form("%s.%s.%d.root", AliQA::GetDetName(index), AliQA::GetQADataFileName(), runNumber)) ;
991 inputFile = TFile::Open(inputFileName.Data()) ;
992 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
999 //_____________________________________________________________________________
1000 Bool_t AliQADataMakerSteer::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year, AliRecoParam::EventSpecie_t es) const
1002 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1004 AliInfo(Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQA::GetQARefStorage())) ;
1005 AliCDBManager* man = AliCDBManager::Instance() ;
1006 if ( ! man->IsDefaultStorageSet() ) {
1007 TString tmp( AliQA::GetQARefStorage() ) ;
1008 if ( tmp.Contains(AliQA::GetLabLocalOCDB()) )
1009 man->SetDefaultStorage(AliQA::GetQARefStorage()) ;
1011 TString tmp1(AliQA::GetQARefDefaultStorage()) ;
1013 tmp1.Append("?user=alidaq") ;
1014 man->SetDefaultStorage(tmp1.Data()) ;
1017 man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ;
1018 if(man->GetRun() < 0)
1019 man->SetRun(runNumber);
1021 AliCDBMetaData mdr ;
1022 mdr.SetResponsible("yves schutz");
1024 for ( Int_t detIndex = 0 ; detIndex < AliQA::kNDET ; detIndex++) {
1025 TDirectory * detDir = inputFile->GetDirectory(AliQA::GetDetName(detIndex)) ;
1027 AliInfo(Form("Entering %s", detDir->GetName())) ;
1028 AliQA::SetQARefDataDirName(es) ;
1029 TString detOCDBDir(Form("%s/%s/%s", AliQA::GetDetName(detIndex), AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName())) ;
1030 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1031 TList * listDetQAD = new TList() ;
1032 TString listName(Form("%s QA data Reference", AliQA::GetDetName(detIndex))) ;
1033 mdr.SetComment(Form("%s QA stuff", AliQA::GetDetName(detIndex)));
1034 listDetQAD->SetName(listName) ;
1035 TList * taskList = detDir->GetListOfKeys() ;
1036 TIter nextTask(taskList) ;
1038 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
1039 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1040 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1041 AliInfo(Form("Saving %s", esDir->GetName())) ;
1042 TObjArray * listTaskQAD = new TObjArray(100) ;
1043 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1044 listDetQAD->Add(listTaskQAD) ;
1045 TList * histList = esDir->GetListOfKeys() ;
1046 TIter nextHist(histList) ;
1048 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1049 TObject * odata = esDir->Get(histKey->GetName()) ;
1051 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1053 if ( AliQA::GetExpert() == histKey->GetName() ) {
1054 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1055 TList * expertHistList = expertDir->GetListOfKeys() ;
1056 TIter nextExpertHist(expertHistList) ;
1057 TKey * expertHistKey ;
1058 while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) {
1059 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1060 if ( !expertOdata ) {
1061 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1063 AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
1064 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1065 AliInfo(Form("Adding %s", expertHistKey->GetName())) ;
1066 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1067 listTaskQAD->Add(hExpertdata) ;
1072 AliInfo(Form("Adding %s", histKey->GetName())) ;
1073 if ( odata->IsA()->InheritsFrom("TH1") ) {
1074 AliInfo(Form("Adding %s", histKey->GetName())) ;
1075 TH1 * hdata = static_cast<TH1*>(odata) ;
1076 listTaskQAD->Add(hdata) ;
1081 man->Put(listDetQAD, idr, &mdr) ;
1087 //_____________________________________________________________________________
1088 void AliQADataMakerSteer::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1090 // set the current event specie and inform AliQA that this event specie has been encountered
1092 AliQA::Instance()->SetEventSpecie(es) ;
1095 //_____________________________________________________________________________
1096 void AliQADataMakerSteer::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1098 // Set custom reconstruction parameters for a given detector
1099 // Single set of parameters for all the events
1100 GetQADataMaker(det)->SetRecoParam(par) ;