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