Fixes for coverity.
[u/mrichter/AliRoot.git] / STEER / STEER / AliQAManager.cxx
CommitLineData
2e331c8b 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id: AliQAManager.cxx 30894 2009-02-05 13:46:48Z schutz $ */
17///////////////////////////////////////////////////////////////////////////////
18// //
19// class for running the QA makers //
20// //
bf76b847 21// AliQAManager qas; //
22// qas.Run(AliQAv1::kRAWS, rawROOTFileName); //
23// qas.Run(AliQAv1::kHITS); //
24// qas.Run(AliQAv1::kSDIGITS); //
25// qas.Run(AliQAv1::kDIGITS); //
26// qas.Run(AliQAv1::kRECPOINTS); //
27// qas.Run(AliQAv1::kESDS); //
2e331c8b 28// //
29///////////////////////////////////////////////////////////////////////////////
30
fec0891b 31#include <TCanvas.h>
2e331c8b 32#include <TKey.h>
33#include <TFile.h>
34#include <TFileMerger.h>
149a2367 35#include <TGrid.h>
36#include <TGridCollection.h>
37#include <TGridResult.h>
2e331c8b 38#include <TPluginManager.h>
39#include <TROOT.h>
40#include <TString.h>
41#include <TSystem.h>
7c9ff472 42#include <TStopwatch.h>
2e331c8b 43
44#include "AliCDBManager.h"
45#include "AliCDBEntry.h"
46#include "AliCDBId.h"
47#include "AliCDBMetaData.h"
48#include "AliCodeTimer.h"
49#include "AliCorrQADataMakerRec.h"
50#include "AliDetectorRecoParam.h"
51#include "AliESDEvent.h"
52#include "AliGeomManager.h"
53#include "AliGlobalQADataMaker.h"
54#include "AliHeader.h"
55#include "AliLog.h"
56#include "AliModule.h"
4e25ac79 57#include "AliQAv1.h"
634696f5 58#include "AliQAChecker.h"
59#include "AliQACheckerBase.h"
2e331c8b 60#include "AliQADataMakerRec.h"
61#include "AliQADataMakerSim.h"
62#include "AliQAManager.h"
63#include "AliRawReaderDate.h"
64#include "AliRawReaderFile.h"
65#include "AliRawReaderRoot.h"
66#include "AliRun.h"
67#include "AliRunLoader.h"
68#include "AliRunTag.h"
69
66b0310c 70using std::ifstream;
2e331c8b 71ClassImp(AliQAManager)
72AliQAManager* AliQAManager::fgQAInstance = 0x0;
73
74//_____________________________________________________________________________
75AliQAManager::AliQAManager() :
76 AliCDBManager(),
77 fCurrentEvent(0),
78 fCycleSame(kFALSE),
79 fDetectors("ALL"),
80 fDetectorsW("ALL"),
81 fESD(NULL),
82 fESDTree(NULL),
c3c10397 83 fEventInfo(NULL),
2e331c8b 84 fGAliceFileName(""),
85 fFirstEvent(0),
86 fMaxEvents(0),
87 fMode(""),
88 fNumberOfEvents(999999),
89 fRecoParam(),
90 fRunNumber(0),
91 fRawReader(NULL),
92 fRawReaderDelete(kTRUE),
93 fRunLoader(NULL),
bc8761a0 94 fTasks(""),
fec0891b 95 fEventSpecie(AliRecoParam::kDefault),
50dee02c 96 fPrintImage(kTRUE),
97 fSaveData(kTRUE)
2e331c8b 98{
92664bc8 99 // default ctor
100 fMaxEvents = fNumberOfEvents ;
101 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
102 if (IsSelected(AliQAv1::GetDetName(iDet))) {
103 fLoader[iDet] = NULL ;
104 fQADataMaker[iDet] = NULL ;
105 fQACycles[iDet] = 999999 ;
106 }
107 }
75373542 108 SetWriteExpert() ;
2e331c8b 109}
110
111//_____________________________________________________________________________
634696f5 112AliQAManager::AliQAManager(AliQAv1::MODE_t mode, const Char_t* gAliceFilename) :
2e331c8b 113 AliCDBManager(),
114 fCurrentEvent(0),
92664bc8 115 fCycleSame(kFALSE),
116 fDetectors("ALL"),
117 fDetectorsW("ALL"),
118 fESD(NULL),
119 fESDTree(NULL),
c3c10397 120 fEventInfo(NULL),
92664bc8 121 fGAliceFileName(gAliceFilename),
122 fFirstEvent(0),
123 fMaxEvents(0),
634696f5 124 fMode(AliQAv1::GetModeName(mode)),
92664bc8 125 fNumberOfEvents(999999),
2e331c8b 126 fRecoParam(),
92664bc8 127 fRunNumber(0),
128 fRawReader(NULL),
129 fRawReaderDelete(kTRUE),
130 fRunLoader(NULL),
bc8761a0 131 fTasks(""),
fec0891b 132 fEventSpecie(AliRecoParam::kDefault),
50dee02c 133 fPrintImage(kTRUE),
134 fSaveData(kTRUE)
2e331c8b 135{
92664bc8 136 // default ctor
137 fMaxEvents = fNumberOfEvents ;
138 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
139 if (IsSelected(AliQAv1::GetDetName(iDet))) {
140 fLoader[iDet] = NULL ;
141 fQADataMaker[iDet] = NULL ;
142 fQACycles[iDet] = 999999 ;
65660bf3 143 }
144 }
75373542 145 SetWriteExpert() ;
2e331c8b 146}
147
148//_____________________________________________________________________________
149AliQAManager::AliQAManager(const AliQAManager & qas) :
150 AliCDBManager(),
92664bc8 151 fCurrentEvent(qas.fCurrentEvent),
152 fCycleSame(kFALSE),
153 fDetectors(qas.fDetectors),
154 fDetectorsW(qas.fDetectorsW),
155 fESD(NULL),
156 fESDTree(NULL),
c3c10397 157 fEventInfo(NULL),
92664bc8 158 fGAliceFileName(qas.fGAliceFileName),
159 fFirstEvent(qas.fFirstEvent),
160 fMaxEvents(qas.fMaxEvents),
161 fMode(qas.fMode),
162 fNumberOfEvents(qas.fNumberOfEvents),
163 fRecoParam(),
164 fRunNumber(qas.fRunNumber),
165 fRawReader(NULL),
166 fRawReaderDelete(kTRUE),
167 fRunLoader(NULL),
bc8761a0 168 fTasks(qas.fTasks),
fec0891b 169 fEventSpecie(qas.fEventSpecie),
50dee02c 170 fPrintImage(qas.fPrintImage),
171 fSaveData(qas.fSaveData)
fec0891b 172
2e331c8b 173{
92664bc8 174 // cpy ctor
175 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
176 fLoader[iDet] = qas.fLoader[iDet] ;
177 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
178 fQACycles[iDet] = qas.fQACycles[iDet] ;
2e331c8b 179 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
180 }
181}
182
183//_____________________________________________________________________________
184AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
185{
92664bc8 186 // assignment operator
2e331c8b 187 this->~AliQAManager() ;
188 new(this) AliQAManager(qas) ;
189 return *this ;
190}
191
192//_____________________________________________________________________________
193AliQAManager::~AliQAManager()
194{
92664bc8 195 // dtor
196 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
197 if (IsSelected(AliQAv1::GetDetName(iDet))) {
198 fLoader[iDet] = NULL;
199 if (fQADataMaker[iDet]) {
200 (fQADataMaker[iDet])->Finish() ;
201 delete fQADataMaker[iDet] ;
202 }
203 }
204 }
205 if (fRawReaderDelete) {
206 fRunLoader = NULL ;
207 delete fRawReader ;
208 fRawReader = NULL ;
209 }
2e331c8b 210}
2e331c8b 211//_____________________________________________________________________________
4e25ac79 212Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
2e331c8b 213{
c3c10397 214 // Runs all the QA data Maker for every detector
215
92664bc8 216 Bool_t rv = kFALSE ;
c3c10397 217 // Fill QA data in event loop
92664bc8 218 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
219 fCurrentEvent++ ;
c3c10397 220 // Get the event
92664bc8 221 if ( iEvent%10 == 0 )
222 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
223 if ( taskIndex == AliQAv1::kRAWS ) {
224 if ( !fRawReader->NextEvent() )
c3c10397 225 break ;
92664bc8 226 } else if ( taskIndex == AliQAv1::kESDS ) {
227 if ( fESDTree->GetEntry(iEvent) == 0 )
c3c10397 228 break ;
92664bc8 229 } else {
230 if ( fRunLoader->GetEvent(iEvent) != 0 )
c3c10397 231 break ;
92664bc8 232 }
c3c10397 233 // loop over active loaders
234 TString detList ;
235 if ( GetEventInfo())
236 detList = GetEventInfo()->GetTriggerCluster() ;
92664bc8 237 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
c3c10397 238 if (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(iDet)))
239 continue ;
240 if (IsSelected(AliQAv1::GetDetName(iDet)) ){
241 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
242 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
243 if ( qadm->IsCycleDone() ) {
2e331c8b 244 qadm->EndOfCycle(taskIndex) ;
c3c10397 245 }
246 TTree * data = NULL ;
247 AliLoader* loader = GetLoader(qadm->GetUniqueID());
248 switch (taskIndex) {
249 case AliQAv1::kNULLTASKINDEX :
250 break ;
251 case AliQAv1::kRAWS :
252 qadm->Exec(taskIndex, fRawReader) ;
253 break ;
254 case AliQAv1::kHITS :
255 if( loader ) {
256 loader->LoadHits() ;
257 data = loader->TreeH() ;
258 if ( ! data ) {
259 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
260 break ;
261 }
262 qadm->Exec(taskIndex, data) ;
263 }
264 break ;
265 case AliQAv1::kSDIGITS :
95144eea 266 {
267
268 TString fileName(Form("%s.SDigits.root", AliQAv1::GetDetName(iDet))) ;
269 if (gSystem->FindFile("./", fileName)) {
270 if( loader ) {
271 loader->LoadSDigits() ;
272 data = loader->TreeS() ;
273 if ( ! data ) {
274 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
275 break ;
276 }
277 qadm->Exec(taskIndex, data) ;
278 }
2e331c8b 279 }
95144eea 280 }
c3c10397 281 break;
282 case AliQAv1::kDIGITS :
283 if( loader ) {
284 loader->LoadDigits() ;
285 data = loader->TreeD() ;
286 if ( ! data ) {
287 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
288 break ;
289 }
290 qadm->Exec(taskIndex, data) ;
291 }
292 break;
293 case AliQAv1::kDIGITSR :
294 if( loader ) {
295 loader->LoadDigits() ;
296 data = loader->TreeD() ;
297 if ( ! data ) {
298 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
299 break ;
300 }
301 qadm->Exec(taskIndex, data) ;
302 }
303 break;
304 case AliQAv1::kRECPOINTS :
305 if( loader ) {
306 loader->LoadRecPoints() ;
307 data = loader->TreeR() ;
308 if (!data) {
309 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ;
310 break ;
311 }
312 qadm->Exec(taskIndex, data) ;
313 }
314 break;
315 case AliQAv1::kTRACKSEGMENTS :
316 break;
317 case AliQAv1::kRECPARTICLES :
318 break;
319 case AliQAv1::kESDS :
320 qadm->Exec(taskIndex, fESD) ;
321 break;
322 case AliQAv1::kNTASKINDEX :
323 break;
324 } //task switch
92664bc8 325 }
326 } // detector loop
5e303886 327 Increment(taskIndex) ;
92664bc8 328 } // event loop
c3c10397 329 // Save QA data for all detectors
330
1c00473b 331 EndOfCycle() ;
c3c10397 332
92664bc8 333 if ( taskIndex == AliQAv1::kRAWS )
334 fRawReader->RewindEvents() ;
c3c10397 335
92664bc8 336 return rv ;
2e331c8b 337}
338
339//_____________________________________________________________________________
4e25ac79 340Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
2e331c8b 341{
92664bc8 342 // write output to file for all detectors
8fa875cb 343
344 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
345
92664bc8 346 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
347 if (IsSelected(AliQAv1::GetDetName(iDet))) {
348 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
349 if (qadm)
2e331c8b 350 qadm->EndOfCycle(taskIndex) ;
92664bc8 351 }
352 }
353 return kTRUE ;
2e331c8b 354}
355
356//_____________________________________________________________________________
fec0891b 357TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t * year) const
2e331c8b 358{
92664bc8 359 // Retrieve the list of QA data for a given detector and a given task
360 TObjArray * rv = NULL ;
361 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
362 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
363 return NULL ;
364 }
365 if ( ! IsDefaultStorageSet() ) {
366 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
367 tmp.Append(year) ;
368 tmp.Append("/") ;
369 Instance()->SetDefaultStorage(tmp.Data()) ;
370 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
371 }
372 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
373 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
374 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
375 TList * listDetQAD = static_cast<TList *>(entry->GetObject()) ;
376 if ( listDetQAD )
377 rv = static_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
378 return rv ;
2e331c8b 379}
380
381//_____________________________________________________________________________
fec0891b 382TCanvas ** AliQAManager::GetImage(Char_t * detName)
383{
384 // retrieves QA Image for the given detector
385 TCanvas ** rv = NULL ;
386 Int_t detIndex = AliQAv1::GetDetIndex(detName) ;
a5b7dd2a 387 if ( detIndex != AliQAv1::kNULLDET) {
388 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
389 rv = qac->GetImage() ;
390 }
fec0891b 391 return rv ;
392}
393
394//_____________________________________________________________________________
2e331c8b 395AliLoader * AliQAManager::GetLoader(Int_t iDet)
396{
92664bc8 397 // get the loader for a detector
2e331c8b 398
92664bc8 399 if ( !fRunLoader || iDet == AliQAv1::kCORR || iDet == AliQAv1::kGLOBAL )
400 return NULL ;
2e331c8b 401
92664bc8 402 TString detName = AliQAv1::GetDetName(iDet) ;
403 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
404 if (fLoader[iDet])
405 return fLoader[iDet] ;
2e331c8b 406
92664bc8 407 // load the QA data maker object
408 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
409 TString loaderName = "Ali" + detName + "Loader" ;
410
411 AliLoader * loader = NULL ;
412 // first check if a plugin is defined for the quality assurance data maker
413 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
414 // if not, add a plugin for it
415 if (!pluginHandler) {
416 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
417 TString libs = gSystem->GetLibraries() ;
418 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
419 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
420 } else {
421 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
422 }
423 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
424 }
425 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
426 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
427 }
428 if (loader)
429 fLoader[iDet] = loader ;
430 return loader ;
2e331c8b 431}
432
433//_____________________________________________________________________________
4e25ac79 434AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
2e331c8b 435{
92664bc8 436 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
fec0891b 437 Char_t * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
2e331c8b 438 TFile * tagFile = TFile::Open(fileName) ;
439 if ( !tagFile ) {
440 AliError(Form("File %s not found", fileName)) ;
441 return NULL ;
442 }
eca4fa66 443 TTree * tagTree = static_cast<TTree *>(tagFile->Get("T")) ;
2e331c8b 444 if ( !tagTree ) {
445 AliError(Form("Tree T not found in %s", fileName)) ;
446 tagFile->Close() ;
447 return NULL ;
448 }
449 AliRunTag * tag = new AliRunTag ;
450 tagTree->SetBranchAddress("AliTAG", &tag) ;
451 tagTree->GetEntry(evt) ;
4e25ac79 452 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
2e331c8b 453 tagFile->Close() ;
454 return qa ;
455}
456
457//_____________________________________________________________________________
458AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
459{
92664bc8 460 // get the quality assurance data maker for a detector
2e331c8b 461
eca4fa66 462 AliQADataMaker * qadm = fQADataMaker[iDet] ;
463
92664bc8 464 if (qadm) {
eca4fa66 465
5e232cd6 466 qadm->SetEventSpecie(fEventSpecie) ;
bc8761a0 467 if ( qadm->GetRecoParam() )
eca4fa66 468 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
5e232cd6 469 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
2e331c8b 470
5aae1dab 471 } else if (iDet == AliQAv1::kGLOBAL && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0) { //Global QA
eca4fa66 472
92664bc8 473 qadm = new AliGlobalQADataMaker();
474 qadm->SetName(AliQAv1::GetDetName(iDet));
475 qadm->SetUniqueID(iDet);
476 fQADataMaker[iDet] = qadm;
5e232cd6 477 qadm->SetEventSpecie(fEventSpecie) ;
bc8761a0 478 if ( qadm->GetRecoParam() )
5e232cd6 479 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
480 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
2e331c8b 481
92664bc8 482 } else if (iDet == AliQAv1::kCORR && strcmp(GetMode(), AliQAv1::GetModeName(AliQAv1::kRECMODE)) == 0 ) { //the data maker for correlations among detectors
eca4fa66 483 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
92664bc8 484 qadm->SetName(AliQAv1::GetDetName(iDet));
485 qadm->SetUniqueID(iDet);
486 fQADataMaker[iDet] = qadm;
5e232cd6 487 qadm->SetEventSpecie(fEventSpecie) ;
bc8761a0 488 if ( qadm->GetRecoParam() )
5e232cd6 489 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
490 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
2e331c8b 491
6090cc85 492 } else if ( iDet < AliQAv1::kGLOBAL ) {
5aae1dab 493 TString smode(GetMode()) ;
494 if (smode.Contains(AliQAv1::GetModeName(AliQAv1::kQAMODE)))
495 smode = AliQAv1::GetModeName(AliQAv1::kRECMODE) ;
eca4fa66 496 // load the QA data maker object
497 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
498 TString detName = AliQAv1::GetDetName(iDet) ;
5aae1dab 499 TString qadmName = "Ali" + detName + "QADataMaker" + smode ;
eca4fa66 500
501 // first check if a plugin is defined for the quality assurance data maker
502 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
503 // if not, add a plugin for it
504 if (!pluginHandler) {
505 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
506 TString libs = gSystem->GetLibraries() ;
5aae1dab 507 TString temp(smode) ;
bf76b847 508 temp.ToLower() ;
5aae1dab 509 if (libs.Contains("lib" + detName + smode + ".so") || (gSystem->Load("lib" + detName + temp.Data() + ".so") >= 0)) {
7b830a3f 510 if ( iDet == AliQAv1::kMUON ) {
511 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "(Bool_t,Bool_t)");
512 } else {
513 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()");
514 }
eca4fa66 515 } else {
7b830a3f 516 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()");
eca4fa66 517 }
518 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
519 }
520 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
7b830a3f 521 if ( iDet == AliQAv1::kMUON ) {
522 Bool_t mch = fActiveOnlineDetectors.Contains("MUONTRK");
523 Bool_t mtr = fActiveOnlineDetectors.Contains("MUONTRG");
524 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(2,mch,mtr);
525 }
526 else {
527 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0);
528 }
eca4fa66 529 }
530 if (qadm) {
531 qadm->SetName(AliQAv1::GetDetName(iDet));
532 qadm->SetUniqueID(iDet);
533 fQADataMaker[iDet] = qadm ;
534 qadm->SetEventSpecie(fEventSpecie) ;
535 if ( qadm->GetRecoParam() )
536 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
537 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
538 }
539 }
2e331c8b 540 return qadm ;
541}
542
543//_____________________________________________________________________________
544void AliQAManager::EndOfCycle(TObjArray * detArray)
545{
92664bc8 546 // End of cycle QADataMakers
2e331c8b 547
8fa875cb 548 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
cd2a0b54 549 TCanvas fakeCanvas ;
1c00473b 550
92664bc8 551 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
552 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
553 if (IsSelected(AliQAv1::GetDetName(iDet))) {
554 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
555 if (!qadm)
556 continue ;
557 // skip non active detectors
558 if (detArray) {
559 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
560 if (!det || !det->IsActive())
561 continue ;
562 }
563 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
6090cc85 564 if (qac)
565 qac->SetPrintImage(fPrintImage) ;
d338b679 566 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
567 if ( fTasks.Contains(Form("%d", taskIndex)) )
568 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
50dee02c 569 }
92664bc8 570 qadm->Finish();
571 }
572 }
cd2a0b54 573 if (fPrintImage)
574 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps");
2e331c8b 575}
576
577//_____________________________________________________________________________
578void AliQAManager::EndOfCycle(TString detectors)
579{
92664bc8 580 // End of cycle QADataMakers
581
634696f5 582 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
cd2a0b54 583 TCanvas fakeCanvas ;
584 if (fPrintImage)
1d46dcf4 585 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
fec0891b 586 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
92664bc8 587 if (IsSelected(AliQAv1::GetDetName(iDet))) {
588 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
589 if (!qadm)
590 continue ;
591 // skip non active detectors
4e25ac79 592 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
2e331c8b 593 continue ;
92664bc8 594 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
6090cc85 595 if (qac)
596 qac->SetPrintImage(fPrintImage) ;
d338b679 597 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
598 if ( fTasks.Contains(Form("%d", taskIndex)) )
599 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
50dee02c 600 }
92664bc8 601 qadm->Finish();
602 }
603 }
cd2a0b54 604 if (fPrintImage)
605 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps");
2e331c8b 606}
607
608//_____________________________________________________________________________
d34d00a9 609AliRecoParam::EventSpecie_t AliQAManager::GetEventSpecieFromESD()
610{
611 AliRecoParam::EventSpecie_t runtype = AliRecoParam::kDefault ;
612 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
613 TFile * esdFile = TFile::Open("AliESDs.root") ;
614 TTree * esdTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
615 if ( !esdTree ) {
616 AliError("esdTree not found") ;
617 } else {
618 AliESDEvent * esd = new AliESDEvent() ;
619 esd->ReadFromTree(esdTree) ;
620 esdTree->GetEntry(0) ;
bad8f87c 621 runtype = AliRecoParam::Convert(esd->GetEventType()) ;
d34d00a9 622 }
623 } else {
624 AliError("AliESDs.root not found") ;
625 }
626 return runtype ;
627}
628
629//_____________________________________________________________________________
5e303886 630void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
2e331c8b 631{
632 // Increments the cycle counter for all QA Data Makers
5e303886 633 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
de402dc0 634 if ( (currentTask == taskIndex) && taskIndex != AliQAv1::kNULLTASKINDEX )
5e303886 635 return ;
636 else
637 currentTask = taskIndex ;
92664bc8 638 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
639 if (IsSelected(AliQAv1::GetDetName(iDet))) {
640 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
641 if (qadm)
2e331c8b 642 qadm->Increment() ;
643 }
644 }
645}
646
647//_____________________________________________________________________________
fec0891b 648Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
2e331c8b 649{
92664bc8 650 // Initialize the event source and QA data makers
2e331c8b 651
92664bc8 652 fTasks += Form("%d", taskIndex) ;
653
654 if (taskIndex == AliQAv1::kRAWS) {
655 if (!fRawReader) {
656 fRawReader = AliRawReader::Create(input);
657 }
658 if ( ! fRawReader )
659 return kFALSE ;
660 fRawReaderDelete = kTRUE ;
661 fRawReader->NextEvent() ;
662 fRunNumber = fRawReader->GetRunNumber() ;
663 SetRun(fRunNumber) ;
664 fRawReader->RewindEvents();
665 fNumberOfEvents = 999999 ;
666 if ( fMaxEvents < 0 )
667 fMaxEvents = fNumberOfEvents ;
668 } else if (taskIndex == AliQAv1::kESDS) {
669 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
670 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
671 TFile * esdFile = TFile::Open("AliESDs.root") ;
672 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
673 if ( !fESDTree ) {
674 AliError("esdTree not found") ;
675 return kFALSE ;
2e331c8b 676 } else {
92664bc8 677 fESD = new AliESDEvent() ;
678 fESD->ReadFromTree(fESDTree) ;
679 fESDTree->GetEntry(0) ;
680 fRunNumber = fESD->GetRunNumber() ;
681 fNumberOfEvents = fESDTree->GetEntries() ;
682 if ( fMaxEvents < 0 )
683 fMaxEvents = fNumberOfEvents ;
2e331c8b 684 }
92664bc8 685 } else {
686 AliError("AliESDs.root not found") ;
687 return kFALSE ;
688 }
689 } else {
690 if ( !InitRunLoader() ) {
691 AliWarning("No Run Loader not found") ;
692 } else {
693 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
694 if ( fMaxEvents < 0 )
695 fMaxEvents = fNumberOfEvents ;
2e331c8b 696 }
92664bc8 697 }
2e331c8b 698
699 // Get Detectors
700 TObjArray* detArray = NULL ;
92664bc8 701 if (fRunLoader) // check if RunLoader exists
702 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
703 detArray = fRunLoader->GetAliRun()->Detectors() ;
704 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
705 }
706
707 // Initialize all QA data makers for all detectors
708 fRunNumber = AliCDBManager::Instance()->GetRun() ;
709 if ( ! AliGeomManager::GetGeometry() )
710 AliGeomManager::LoadGeometry() ;
2e331c8b 711
92664bc8 712 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
fec0891b 713 if (fPrintImage) {
714 TCanvas fakeCanvas ;
7c9ff472 715 TStopwatch timer ;
716 timer.Start() ;
717 while (timer.CpuTime()<5) {
718 timer.Continue();
719 gSystem->ProcessEvents();
720 }
1d46dcf4 721 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
fec0891b 722 }
92664bc8 723 return kTRUE ;
2e331c8b 724}
725
726//_____________________________________________________________________________
727void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
728{
92664bc8 729 // Initializes The QADataMaker for all active detectors and for all active tasks
fec0891b 730 fRunNumber = run ;
92664bc8 731 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
732 if (IsSelected(AliQAv1::GetDetName(iDet))) {
733 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
734 if (!qadm) {
735 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
736 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
737 } else {
2e331c8b 738 if (fQAWriteExpert[iDet])
739 qadm->SetWriteExpert() ;
92664bc8 740 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
741 // skip non active detectors
742 if (detArray) {
743 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
744 if (!det || !det->IsActive())
745 continue ;
746 }
747 // Set default reco params
2e331c8b 748 Bool_t sameCycle = kFALSE ;
92664bc8 749 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
750 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
751 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
4e25ac79 752 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
2e331c8b 753 sameCycle = kTRUE ;
92664bc8 754 }
2e331c8b 755 }
92664bc8 756 }
757 }
758 }
2e331c8b 759}
760
761
762//_____________________________________________________________________________
763Bool_t AliQAManager::InitRunLoader()
764{
92664bc8 765 // get or create the run loader
766 if (fRunLoader) {
767 fCycleSame = kTRUE ;
768 } else {
769 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
770 // load all base libraries to get the loader classes
771 TString libs = gSystem->GetLibraries() ;
772 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
773 if (!IsSelected(AliQAv1::GetDetName(iDet)))
774 continue ;
775 TString detName = AliQAv1::GetDetName(iDet) ;
776 if (detName == "HLT")
777 continue;
778 if (libs.Contains("lib" + detName + "base.so"))
779 continue;
780 gSystem->Load("lib" + detName + "base.so");
781 }
782 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
783 if (!fRunLoader) {
784 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
785 return kFALSE;
786 }
787 fRunLoader->CdGAFile();
788 if (fRunLoader->LoadgAlice() == 0) {
789 gAlice = fRunLoader->GetAliRun();
790 }
2e331c8b 791
92664bc8 792 if (!gAlice) {
793 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
794 return kFALSE;
795 }
796
797 } else { // galice.root does not exist
798 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
799 return kFALSE;
800 }
801 }
802
803 if (!fRunNumber) {
804 fRunLoader->LoadHeader();
805 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
806 }
807 return kTRUE;
2e331c8b 808}
809
810//_____________________________________________________________________________
fec0891b 811Bool_t AliQAManager::IsSelected(const Char_t * det)
2e331c8b 812{
813 // check whether detName is contained in detectors
92664bc8 814 // if yes, it is removed from detectors
2e331c8b 815
92664bc8 816 Bool_t rv = kFALSE;
817 const TString detName(det) ;
2e331c8b 818 // always activates Correlation
8fe40e49 819// if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR)) || detName.Contains(AliQAv1::GetDetName(AliQAv1::kGLOBAL))) {
820// rv = kTRUE ;
821// } else {
2e331c8b 822 // check if all detectors are selected
823 if (fDetectors.Contains("ALL")) {
824 fDetectors = "ALL";
825 rv = kTRUE;
826 } else if ((fDetectors.CompareTo(detName) == 0) ||
827 fDetectors.BeginsWith(detName+" ") ||
828 fDetectors.EndsWith(" "+detName) ||
829 fDetectors.Contains(" "+detName+" ")) {
830 rv = kTRUE;
831 }
8fe40e49 832// }
92664bc8 833 return rv ;
2e331c8b 834}
835
836//_____________________________________________________________________________
87da0921 837Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
2e331c8b 838{
92664bc8 839 // Merge data from all detectors from a given run in one single file
840 // Merge the QA results from all the data chunks in one run
87da0921 841 // The 'fileName' is name of the output file with merged QA data
92664bc8 842 if ( runNumber == -1)
843 runNumber = fRunNumber ;
844 Bool_t rv = MergeData(runNumber,fileName) ;
845 //rv *= MergeResults(runNumber) ; // not needed for the time being
846 return rv ;
2e331c8b 847}
848
149a2367 849//______________________________________________________________________
fec0891b 850Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
149a2367 851{
852 // merges files listed in a xml collection
853 // usage Merge(collection, outputFile))
854 // collection: is a xml collection
855
856 Bool_t rv = kFALSE ;
857
858 if ( strstr(collectionFile, ".xml") == 0 ) {
859 AliError("Input collection file must be an \".xml\" file\n") ;
860 return kFALSE ;
861 }
862
92664bc8 863 if ( !gGrid )
864 TGrid::Connect("alien://");
865 if ( !gGrid )
866 return kFALSE ;
149a2367 867
868 // Open the file collection
5e232cd6 869 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
149a2367 870
bededc30 871 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
149a2367 872 TGridResult* result = collection->GetGridResult("", 0, 0);
873
874 Int_t index = 0 ;
fec0891b 875 const Char_t * turl ;
adae62c9 876 TFileMerger merger(kFALSE) ;
149a2367 877 if (!outFile) {
878 TString tempo(collectionFile) ;
879 if ( subFile)
880 tempo.ReplaceAll(".xml", subFile) ;
881 else
882 tempo.ReplaceAll(".xml", "_Merged.root") ;
883 outFile = tempo.Data() ;
884 }
885 merger.OutputFile(outFile) ;
886
887 while ( (turl = result->GetKey(index, "turl")) ) {
fec0891b 888 Char_t * file ;
149a2367 889 if ( subFile )
890 file = Form("%s#%s", turl, subFile) ;
891 else
892 file = Form("%s", turl) ;
893
5379c4a3 894 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
149a2367 895 merger.AddFile(file) ;
896 index++ ;
897 }
898
899 if (index)
900 merger.Merge() ;
901
5379c4a3 902 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
149a2367 903
904 rv = kFALSE;
905 return rv ;
906}
907
2e331c8b 908//_____________________________________________________________________________
69a898e3 909void AliQAManager::MergeCustom() const
910{
92664bc8 911 // Custom Merge of QA data from all detectors for all runs in one single file
69a898e3 912 // search all the run numbers
913 // search all the run numbers
914 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
9025307b 915 TString theQAfile ;
916 FILE * theQAfiles = fopen("QAtempo.txt", "r") ;
69a898e3 917 Int_t index = 0 ;
918 TList srunList ;
919 TIter nextRun(&srunList) ;
920 TObjString * srun = NULL ;
921 Int_t loRun = 999999999 ;
922 Int_t hiRun = 0 ;
9025307b 923 while ( theQAfile.Gets(theQAfiles) ) {
69a898e3 924 Bool_t runExist = kFALSE ;
9025307b 925 TString srunNew(theQAfile(theQAfile.Index("QA.")+3, theQAfile.Index(".root")-(theQAfile.Index("QA.")+3))) ;
69a898e3 926 Int_t cuRun = srunNew.Atoi() ;
927 if (cuRun < loRun)
928 loRun = cuRun ;
929 if (cuRun > hiRun)
930 hiRun = cuRun ;
eca4fa66 931 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
69a898e3 932 if ( cuRun == (srun->String()).Atoi() ) {
933 runExist = kTRUE ;
934 break ;
935 }
936 }
937 nextRun.Reset() ;
938 if ( ! runExist )
939 srunList.Add(new TObjString(srunNew.Data()));
940 }
941 nextRun.Reset() ;
942 Int_t runNumber = 0 ;
4e25ac79 943 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
69a898e3 944 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
945 // create the structure into the merged file
4e25ac79 946 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
947 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
948 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
69a898e3 949 detDir->cd() ;
4e25ac79 950 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
69a898e3 951 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
952 taskDir->cd() ;
953 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
954 esDir->cd() ;
4e25ac79 955 gDirectory->mkdir(AliQAv1::GetExpert()) ;
69a898e3 956 }
957 }
958 }
eca4fa66 959 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
69a898e3 960 runNumber = (srun->String()).Atoi() ;
961 hisRun->Fill(runNumber) ;
5379c4a3 962 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
69a898e3 963 // search all QA files for runNumber in the current directory
fec0891b 964 Char_t * fileList[AliQAv1::kNDET] ;
69a898e3 965 index = 0 ;
4e25ac79 966 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
fec0891b 967 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
69a898e3 968 if (file)
969 fileList[index++] = file ;
970 }
971 if ( index == 0 ) {
972 AliError("No QA data file found\n") ;
973 return ;
974 }
975 for ( Int_t i = 0 ; i < index ; i++) {
976 TFile * inFile = TFile::Open(fileList[i]) ;
977 TList * listOfKeys =inFile->GetListOfKeys() ;
978 TIter nextkey(listOfKeys) ;
979 TObject * obj1 ;
980 TString dirName("") ;
981 while ( (obj1 = nextkey()) ) {
982 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
983 if ( directoryDet ) {
5379c4a3 984 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
69a898e3 985 dirName += Form("%s/", directoryDet->GetName() ) ;
986 directoryDet->cd() ;
987 TList * listOfTasks = directoryDet->GetListOfKeys() ;
988 TIter nextTask(listOfTasks) ;
989 TObject * obj2 ;
990 while ( (obj2 = nextTask()) ) {
991 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
992 if ( directoryTask ) {
993 dirName += Form("%s", obj2->GetName()) ;
5379c4a3 994 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
69a898e3 995 directoryTask->cd() ;
996 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
997 TIter nextEventSpecie(listOfEventSpecie) ;
998 TObject * obj3 ;
999 while ( (obj3 = nextEventSpecie()) ) {
1000 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
1001 if ( directoryEventSpecie ) {
1002 dirName += Form("/%s/", obj3->GetName()) ;
5379c4a3 1003 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
69a898e3 1004 directoryEventSpecie->cd() ;
1005 // histograms are here
1006 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
1007 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
1008 TIter nextData(listOfData) ;
1009 TKey * key ;
eca4fa66 1010 while ( (key = static_cast<TKey *>(nextData())) ) {
69a898e3 1011 TString className(key->GetClassName()) ;
1012 if ( className.Contains("TH") || className.Contains("TProfile") ) {
eca4fa66 1013 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
1014 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
65b25288 1015 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %p %p\n", key->GetName(), histIn, histOu)) ;
69a898e3 1016 mergedDirectory->cd() ;
1017 if ( ! histOu ) {
1018 histIn->Write() ;
1019 } else {
1020 histOu->Add(histIn) ;
1021 histOu->Write(histOu->GetName(), kOverwrite) ;
1022 }
1023 }
1024 else if ( className.Contains("TDirectoryFile") ) {
1025 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
1026 dirExpert->cd() ;
1027 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
1028 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
1029 TIter nextExpertData(listOfExpertData) ;
1030 TKey * keykey ;
eca4fa66 1031 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
69a898e3 1032 TString classNameExpert(keykey->GetClassName()) ;
1033 if (classNameExpert.Contains("TH")) {
eca4fa66 1034 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
1035 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
69a898e3 1036 mergedDirectoryExpert->cd() ;
1037 if ( ! histOuExpert ) {
1038 histInExpert->Write() ;
1039 } else {
1040 histOuExpert->Add(histInExpert) ;
1041 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
1042 }
1043 }
1044 }
1045 } else {
1046 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
1047 }
1048 }
1049 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
1050 }
1051 }
1052 dirName.ReplaceAll(obj2->GetName(), "") ;
1053 }
1054 }
1055 }
1056 }
1057 inFile->Close() ;
1058 }
1059 }
1060 mergedFile.cd() ;
1061 hisRun->Write() ;
1062 mergedFile.Close() ;
1063 srunList.Delete() ;
1064}
1065
1066//_____________________________________________________________________________
87da0921 1067Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
2e331c8b 1068{
92664bc8 1069 // Merge QA data from all detectors for a given run in one single file
bededc30 1070
87da0921 1071 TFileMerger merger(kFALSE) ;
1072 TString outFileName = fileName;
1073 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
2e331c8b 1074 merger.OutputFile(outFileName.Data()) ;
bededc30 1075 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
fec0891b 1076 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
bededc30 1077 if (file)
3136db6f 1078 merger.AddFile(file);
1079 delete[] file;
bededc30 1080 }
2e331c8b 1081 merger.Merge() ;
92664bc8 1082 return kTRUE ;
2e331c8b 1083}
1084
1085//_____________________________________________________________________________
1086Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1087{
92664bc8 1088 // Merge the QA result from all the data chunks in a run
bededc30 1089 // to be revised whwn it will be used (see MergeData)
92664bc8 1090 TString cmd ;
1091 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1092 gROOT->ProcessLine(cmd.Data()) ;
1093 ifstream in("tempo.txt") ;
1094 const Int_t chunkMax = 100 ;
1095 TString fileList[chunkMax] ;
2e331c8b 1096
92664bc8 1097 Int_t index = 0 ;
1098 while ( 1 ) {
1099 TString file ;
1100 in >> fileList[index] ;
1101 if ( !in.good() )
1102 break ;
1103 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1104 index++ ;
1105 }
2e331c8b 1106
92664bc8 1107 if ( index == 0 ) {
1108 AliError("No QA Result File found") ;
1109 return kFALSE ;
1110 }
2e331c8b 1111
92664bc8 1112 TFileMerger merger ;
fc07289e 1113 TString outFileName ;
1114 if (runNumber != -1)
4e25ac79 1115 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
fc07289e 1116 else
4e25ac79 1117 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
92664bc8 1118 merger.OutputFile(outFileName.Data()) ;
1119 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1120 TString file = fileList[ifile] ;
1121 merger.AddFile(file) ;
1122 }
1123 merger.Merge() ;
2e331c8b 1124
92664bc8 1125 return kTRUE ;
2e331c8b 1126}
1127
1128//_____________________________________________________________________________
1129void AliQAManager::Reset(const Bool_t sameCycle)
1130{
92664bc8 1131 // Reset the default data members
2e331c8b 1132
92664bc8 1133 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1134 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1135 AliQADataMaker * qadm = GetQADataMaker(iDet);
1136 if (qadm)
5aae1dab 1137 qadm->Reset();
92664bc8 1138 }
1139 }
1140 if (fRawReaderDelete) {
1141 delete fRawReader ;
1142 fRawReader = NULL ;
1143 }
2e331c8b 1144
92664bc8 1145 fCycleSame = sameCycle ;
1146 fESD = NULL ;
1147 fESDTree = NULL ;
1148 //fFirst = kTRUE ;
1149 fNumberOfEvents = 999999 ;
2e331c8b 1150}
1151
1152//_____________________________________________________________________________
9ac91920 1153void AliQAManager::ResetDetectors(AliQAv1::TASKINDEX_t task, AliQAv1::DETECTORINDEX_t det)
1154{
92664bc8 1155 //calls ResetDetector of specified or all detectors
9ac91920 1156 UInt_t iDet = 0 ;
1157 UInt_t iDetMax = fgkNDetectors ;
1158 if ( det != AliQAv1::kNULLDET ) {
1159 iDet = det ;
1160 iDetMax = det+1 ;
1161 }
1162
92664bc8 1163 for (iDet = 0; iDet < iDetMax ; iDet++) {
1164 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1165 AliQADataMaker * qadm = GetQADataMaker(iDet);
1166 qadm->ResetDetector(task);
1167 }
1168 }
9ac91920 1169}
1170
1171//_____________________________________________________________________________
634696f5 1172AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run)
2e331c8b 1173{
1174 // returns AliQAManager instance (singleton)
1175
92664bc8 1176 if (!fgQAInstance) {
5aae1dab 1177 if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) && (mode != AliQAv1::kQAMODE) ) {
1178 AliWarningClass("You must specify kSIMMODE or kRECMODE or kQAMODE") ;
bf76b847 1179 return NULL ;
1180 }
2e331c8b 1181 fgQAInstance = new AliQAManager(mode) ;
1182 if (!entryCache)
92664bc8 1183 fgQAInstance->Init();
1184 else
1185 fgQAInstance->InitFromCache(entryCache,run);
2e331c8b 1186 }
92664bc8 1187 return fgQAInstance;
2e331c8b 1188}
1189
1190//_____________________________________________________________________________
5e303886 1191AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1192{
1193 // returns AliQAManager instance (singleton)
634696f5 1194 return QAManager(AliQAv1::Mode(task)) ;
5e303886 1195}
1196
1197//_____________________________________________________________________________
fec0891b 1198TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
2e331c8b 1199{
92664bc8 1200 //Runs all the QA data Maker for Raws only
2e331c8b 1201
92664bc8 1202 fCycleSame = sameCycle ;
1203 fRawReader = rawReader ;
1204 fDetectors = detectors ;
1205 fDetectorsW = detectors ;
2e331c8b 1206
92664bc8 1207 AliCDBManager* man = AliCDBManager::Instance() ;
2e331c8b 1208
92664bc8 1209 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1210 rawReader->NextEvent() ;
1211 man->SetRun(fRawReader->GetRunNumber()) ;
1212 rawReader->RewindEvents() ;
1213 }
2e331c8b 1214
92664bc8 1215 if (!fCycleSame)
4e25ac79 1216 if ( !InitQA(AliQAv1::kRAWS) )
9b4aee57 1217 return "" ;
2e331c8b 1218 fRawReaderDelete = kFALSE ;
1219
92664bc8 1220 DoIt(AliQAv1::kRAWS) ;
1221 return fDetectorsW ;
2e331c8b 1222}
1223
1224//_____________________________________________________________________________
fec0891b 1225TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
2e331c8b 1226{
92664bc8 1227 //Runs all the QA data Maker for Raws only
2e331c8b 1228
92664bc8 1229 fCycleSame = sameCycle ;
1230 fDetectors = detectors ;
1231 fDetectorsW = detectors ;
2e331c8b 1232
92664bc8 1233 AliCDBManager* man = AliCDBManager::Instance() ;
1234 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1235 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1236 if ( ! rl ) {
1237 AliFatal("galice.root file not found in current directory") ;
1238 } else {
1239 rl->CdGAFile() ;
1240 rl->LoadgAlice() ;
1241 if ( ! rl->GetAliRun() ) {
1242 AliFatal("AliRun not found in galice.root") ;
1243 } else {
1244 rl->LoadHeader() ;
1245 man->SetRun(rl->GetHeader()->GetRun());
1246 }
1247 }
1248 }
2e331c8b 1249
92664bc8 1250 if (!fCycleSame)
4e25ac79 1251 if ( !InitQA(AliQAv1::kRAWS, fileName) )
9b4aee57 1252 return "" ;
2e331c8b 1253
92664bc8 1254 DoIt(AliQAv1::kRAWS) ;
1255 return fDetectorsW ;
2e331c8b 1256}
1257
1258//_____________________________________________________________________________
fec0891b 1259TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
2e331c8b 1260{
92664bc8 1261 // Runs all the QA data Maker for every detector
2e331c8b 1262
92664bc8 1263 fCycleSame = sameCycle ;
1264 fDetectors = detectors ;
1265 fDetectorsW = detectors ;
2e331c8b 1266
92664bc8 1267 AliCDBManager* man = AliCDBManager::Instance() ;
1268 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1269 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1270 if ( ! rl ) {
1271 AliFatal("galice.root file not found in current directory") ;
1272 } else {
1273 rl->CdGAFile() ;
1274 rl->LoadgAlice() ;
1275 if ( ! rl->GetAliRun() ) {
1276 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1277 } else {
1278 rl->LoadHeader() ;
1279 man->SetRun(rl->GetHeader()->GetRun()) ;
1280 }
1281 }
1282 }
fec0891b 1283 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
92664bc8 1284 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1285 if ( fTasks.Contains(Form("%d", task)) ) {
2e331c8b 1286 if (!fCycleSame)
4e25ac79 1287 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
9b4aee57 1288 return "" ;
4e25ac79 1289 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
92664bc8 1290 }
1291 }
1292 } else {
2e331c8b 1293 if (! fCycleSame )
1294 if ( !InitQA(taskIndex, fileName) )
9b4aee57 1295 return "" ;
92664bc8 1296 DoIt(taskIndex) ;
2e331c8b 1297 }
92664bc8 1298 return fDetectorsW ;
2e331c8b 1299}
1300
1301//_____________________________________________________________________________
1302void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1303{
c3c10397 1304 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1305
2e331c8b 1306 if ( ! rawReader )
1307 return ;
0d105c36 1308 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
c3c10397 1309 TString detList ;
1310 if ( GetEventInfo())
1311 detList = GetEventInfo()->GetTriggerCluster() ;
2e331c8b 1312 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
c3c10397 1313 if (!IsSelected(AliQAv1::GetDetName(iDet)) || (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(iDet))))
2e331c8b 1314 continue;
1315 AliQADataMaker *qadm = GetQADataMaker(iDet);
1316 if (!qadm)
1317 continue;
1318 if ( qadm->IsCycleDone() ) {
1319 qadm->EndOfCycle() ;
1320 }
5e232cd6 1321 qadm->SetEventSpecie(fEventSpecie) ;
13a2370e 1322 if ( qadm->GetRecoParam() )
c3c10397 1323 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
5e232cd6 1324 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
92664bc8 1325 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1326 }
2e331c8b 1327 }
1328}
1329
1330//_____________________________________________________________________________
aeb8fc30 1331void AliQAManager::RunOneEvent(AliESDEvent *& esd, AliESDEvent *& hltesd)
2e331c8b 1332{
c3c10397 1333 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
2e331c8b 1334
0d105c36 1335 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
c3c10397 1336 TString detList ;
1337 if ( GetEventInfo())
1338 detList = GetEventInfo()->GetTriggerCluster() ;
2e331c8b 1339 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
c3c10397 1340 if (!IsSelected(AliQAv1::GetDetName(iDet)) || (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(iDet))))
2e331c8b 1341 continue;
1342 AliQADataMaker *qadm = GetQADataMaker(iDet);
1343 if (!qadm)
1344 continue;
5e232cd6 1345 qadm->SetEventSpecie(fEventSpecie) ;
82a30871 1346 if ( qadm->GetRecoParam() )
c3c10397 1347 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
5e232cd6 1348 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
2e331c8b 1349 if ( qadm->IsCycleDone() ) {
1350 qadm->EndOfCycle() ;
1351 }
aeb8fc30 1352 if (iDet == AliQAv1::kHLT) {
1353 TObjArray esdarray;
1354 esdarray.Add(esd);
1355 esdarray.Add(hltesd);
1356 qadm->Exec(AliQAv1::kESDS, &esdarray);
1357 } else {
1358 qadm->Exec(AliQAv1::kESDS, esd) ;
1359 }
92664bc8 1360 }
1361 }
2e331c8b 1362}
1363
1364//_____________________________________________________________________________
1365void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1366{
c3c10397 1367 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
44ed7a66 1368
c3c10397 1369 TString detList ;
1370 if ( GetEventInfo())
1371 detList = GetEventInfo()->GetTriggerCluster() ;
1372 if (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(det)))
1373 return ;
1374
44ed7a66 1375 TString test(tree->GetName()) ;
0d105c36 1376 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
c3c10397 1377 if (IsSelected(AliQAv1::GetDetName(det))) {
2e331c8b 1378 AliQADataMaker *qadm = GetQADataMaker(det);
1379 if (qadm) {
5e232cd6 1380 qadm->SetEventSpecie(fEventSpecie) ;
31c31326 1381 if ( qadm->GetRecoParam() ) {
5e232cd6 1382 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
31c31326 1383 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1384 else
5c5ea798 1385 AliError(Form("%d defined by %s is not an event specie", qadm->GetRecoParam()->GetEventSpecie(), qadm->GetName())) ;
31c31326 1386 }
2e331c8b 1387 if ( qadm->IsCycleDone() ) {
1388 qadm->EndOfCycle() ;
1389 }
44ed7a66 1390 if (test.Contains("TreeD")) {
1391 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
44ed7a66 1392 } else if (test.Contains("TreeR")) {
1393 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
44ed7a66 1394 }
2e331c8b 1395 }
1396 }
1397 }
1398}
1399
1400//_____________________________________________________________________________
fec0891b 1401Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
2e331c8b 1402{
92664bc8 1403 // take the locasl QA data merge into a single file and save in OCDB
1404 Bool_t rv = kTRUE ;
1405 TString tmp(AliQAv1::GetQARefStorage()) ;
1406 if ( tmp.IsNull() ) {
1407 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1408 return kFALSE ;
1409 }
1410 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1411 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1412 return kFALSE ;
1413 }
1414 TString sdet(detectors) ;
1415 sdet.ToUpper() ;
1416 TFile * inputFile ;
1417 if ( sdet.Contains("ALL") ) {
1418 rv = Merge(runNumber) ;
1419 if ( ! rv )
1420 return kFALSE ;
1421 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1422 inputFile = TFile::Open(inputFileName.Data()) ;
1423 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1424 } else {
1425 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1426 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1427 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1428 inputFile = TFile::Open(inputFileName.Data()) ;
1429 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1430 }
1431 }
1432 }
1433 return rv ;
2e331c8b 1434}
1435
1436//_____________________________________________________________________________
fec0891b 1437Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
2e331c8b 1438{
92664bc8 1439 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1440 Bool_t rv = kTRUE ;
1441 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1442 if ( ! IsDefaultStorageSet() ) {
1443 TString tmp( AliQAv1::GetQARefStorage() ) ;
1444 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1445 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1446 else {
1447 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1448 tmp1.Append(year) ;
1449 tmp1.Append("?user=alidaq") ;
1450 Instance()->SetDefaultStorage(tmp1.Data()) ;
1451 }
1452 }
1453 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1454 if(GetRun() < 0)
1455 Instance()->SetRun(runNumber);
2e331c8b 1456
92664bc8 1457 AliCDBMetaData mdr ;
1458 mdr.SetResponsible("yves schutz");
2e331c8b 1459
92664bc8 1460 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1461 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1462 if ( detDir ) {
1463 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
4e25ac79 1464 AliQAv1::SetQARefDataDirName(es) ;
92664bc8 1465 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1466 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1467 TList * listDetQAD = new TList() ;
1468 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1469 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1470 listDetQAD->SetName(listName) ;
1471 TList * taskList = detDir->GetListOfKeys() ;
1472 TIter nextTask(taskList) ;
1473 TKey * taskKey ;
1474 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1475 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
2e331c8b 1476 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
92664bc8 1477 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1478 TObjArray * listTaskQAD = new TObjArray(100) ;
1479 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1480 listDetQAD->Add(listTaskQAD) ;
1481 TList * histList = esDir->GetListOfKeys() ;
1482 TIter nextHist(histList) ;
1483 TKey * histKey ;
1484 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1485 TObject * odata = esDir->Get(histKey->GetName()) ;
1486 if ( !odata ) {
1487 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1488 } else {
4e25ac79 1489 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
2e331c8b 1490 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1491 TList * expertHistList = expertDir->GetListOfKeys() ;
1492 TIter nextExpertHist(expertHistList) ;
1493 TKey * expertHistKey ;
eca4fa66 1494 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
2e331c8b 1495 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1496 if ( !expertOdata ) {
1497 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1498 } else {
5379c4a3 1499 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
2e331c8b 1500 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
5379c4a3 1501 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
2e331c8b 1502 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1503 listTaskQAD->Add(hExpertdata) ;
1504 }
1505 }
1506 }
1507 }
92664bc8 1508 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1509 if ( odata->IsA()->InheritsFrom("TH1") ) {
1510 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1511 TH1 * hdata = static_cast<TH1*>(odata) ;
1512 listTaskQAD->Add(hdata) ;
1513 }
1514 }
2e331c8b 1515 }
92664bc8 1516 }
1517 Instance()->Put(listDetQAD, idr, &mdr) ;
1518 }
1519 }
1520 return rv ;
2e331c8b 1521}
1522
1523//_____________________________________________________________________________
7c9ff472 1524
1525void AliQAManager::SetCheckerExternParam(AliQAv1::DETECTORINDEX_t detIndex, TList * parameterList)
1526{
1527 // set the external parameters list for the detector checkers
1528 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
1529 qac->SetExternParamlist(parameterList) ;
1530 qac->PrintExternParam() ;
1531}
1532
1533//_____________________________________________________________________________
2e331c8b 1534void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1535{
4e25ac79 1536 // set the current event specie and inform AliQAv1 that this event specie has been encountered
bc8761a0 1537 fEventSpecie = es ;
4e25ac79 1538 AliQAv1::Instance()->SetEventSpecie(es) ;
2e331c8b 1539}
1540
1541//_____________________________________________________________________________
1542void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1543{
1544 // Set custom reconstruction parameters for a given detector
1545 // Single set of parameters for all the events
1546 GetQADataMaker(det)->SetRecoParam(par) ;
1547}
1548
75373542 1549//_____________________________________________________________________________
1550void AliQAManager::SetWriteExpert()
1551{
1552 // enable the writing of QA expert data
1553 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
92664bc8 1554 if (IsSelected(AliQAv1::GetDetName(iDet)))
75373542 1555 fQAWriteExpert[iDet] = kTRUE ;
1556 }
1557}
7cade814 1558
1559//_____________________________________________________________________________
1560void AliQAManager::Destroy() {
bf76b847 1561 // delete AliQAManager instance and
1562 // all associated objects
7cade814 1563
1564 if (fgQAInstance) {
eca4fa66 1565 delete fgQAInstance ;
1566 fgQAInstance = NULL ;
7cade814 1567 }
1568}
1569
bf76b847 1570//_____________________________________________________________________________
1571void AliQAManager::ShowQA() {
1572 // Show the result of the QA checking
1573 // for all detectors
92664bc8 1574 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1575 if ( IsSelected(AliQAv1::GetDetName(detIndex)) )
1576 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;
bf76b847 1577}