]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/STEER/AliQAManager.cxx
Flag Secondaries from Weak decays and Material also for sub events
[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
fec0891b 381//_____________________________________________________________________________
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
2e331c8b 394//_____________________________________________________________________________
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)) {
eca4fa66 510 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
511 } else {
512 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
513 }
514 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
515 }
516 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
517 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
518 }
519 if (qadm) {
520 qadm->SetName(AliQAv1::GetDetName(iDet));
521 qadm->SetUniqueID(iDet);
522 fQADataMaker[iDet] = qadm ;
523 qadm->SetEventSpecie(fEventSpecie) ;
524 if ( qadm->GetRecoParam() )
525 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
526 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
527 }
528 }
2e331c8b 529 return qadm ;
530}
531
532//_____________________________________________________________________________
533void AliQAManager::EndOfCycle(TObjArray * detArray)
534{
92664bc8 535 // End of cycle QADataMakers
2e331c8b 536
8fa875cb 537 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
cd2a0b54 538 TCanvas fakeCanvas ;
1c00473b 539
92664bc8 540 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
541 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
542 if (IsSelected(AliQAv1::GetDetName(iDet))) {
543 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
544 if (!qadm)
545 continue ;
546 // skip non active detectors
547 if (detArray) {
548 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
549 if (!det || !det->IsActive())
550 continue ;
551 }
552 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
6090cc85 553 if (qac)
554 qac->SetPrintImage(fPrintImage) ;
d338b679 555 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
556 if ( fTasks.Contains(Form("%d", taskIndex)) )
557 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
50dee02c 558 }
92664bc8 559 qadm->Finish();
560 }
561 }
cd2a0b54 562 if (fPrintImage)
563 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps");
2e331c8b 564}
565
566//_____________________________________________________________________________
567void AliQAManager::EndOfCycle(TString detectors)
568{
92664bc8 569 // End of cycle QADataMakers
570
634696f5 571 AliQAChecker::Instance()->SetRunNumber(fRunNumber) ;
cd2a0b54 572 TCanvas fakeCanvas ;
573 if (fPrintImage)
1d46dcf4 574 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
fec0891b 575 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
92664bc8 576 if (IsSelected(AliQAv1::GetDetName(iDet))) {
577 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
578 if (!qadm)
579 continue ;
580 // skip non active detectors
4e25ac79 581 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
2e331c8b 582 continue ;
92664bc8 583 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(iDet) ;
6090cc85 584 if (qac)
585 qac->SetPrintImage(fPrintImage) ;
d338b679 586 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
587 if ( fTasks.Contains(Form("%d", taskIndex)) )
588 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
50dee02c 589 }
92664bc8 590 qadm->Finish();
591 }
592 }
cd2a0b54 593 if (fPrintImage)
594 fakeCanvas.Print(Form("%s%s%d.%s]", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps");
2e331c8b 595}
596
d34d00a9 597//_____________________________________________________________________________
598AliRecoParam::EventSpecie_t AliQAManager::GetEventSpecieFromESD()
599{
600 AliRecoParam::EventSpecie_t runtype = AliRecoParam::kDefault ;
601 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
602 TFile * esdFile = TFile::Open("AliESDs.root") ;
603 TTree * esdTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
604 if ( !esdTree ) {
605 AliError("esdTree not found") ;
606 } else {
607 AliESDEvent * esd = new AliESDEvent() ;
608 esd->ReadFromTree(esdTree) ;
609 esdTree->GetEntry(0) ;
bad8f87c 610 runtype = AliRecoParam::Convert(esd->GetEventType()) ;
d34d00a9 611 }
612 } else {
613 AliError("AliESDs.root not found") ;
614 }
615 return runtype ;
616}
617
2e331c8b 618//_____________________________________________________________________________
5e303886 619void AliQAManager::Increment(const AliQAv1::TASKINDEX_t taskIndex)
2e331c8b 620{
621 // Increments the cycle counter for all QA Data Makers
5e303886 622 static AliQAv1::TASKINDEX_t currentTask = AliQAv1::kNTASKINDEX ;
de402dc0 623 if ( (currentTask == taskIndex) && taskIndex != AliQAv1::kNULLTASKINDEX )
5e303886 624 return ;
625 else
626 currentTask = taskIndex ;
92664bc8 627 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
628 if (IsSelected(AliQAv1::GetDetName(iDet))) {
629 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
630 if (qadm)
2e331c8b 631 qadm->Increment() ;
632 }
633 }
634}
635
636//_____________________________________________________________________________
fec0891b 637Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t * input )
2e331c8b 638{
92664bc8 639 // Initialize the event source and QA data makers
2e331c8b 640
92664bc8 641 fTasks += Form("%d", taskIndex) ;
642
643 if (taskIndex == AliQAv1::kRAWS) {
644 if (!fRawReader) {
645 fRawReader = AliRawReader::Create(input);
646 }
647 if ( ! fRawReader )
648 return kFALSE ;
649 fRawReaderDelete = kTRUE ;
650 fRawReader->NextEvent() ;
651 fRunNumber = fRawReader->GetRunNumber() ;
652 SetRun(fRunNumber) ;
653 fRawReader->RewindEvents();
654 fNumberOfEvents = 999999 ;
655 if ( fMaxEvents < 0 )
656 fMaxEvents = fNumberOfEvents ;
657 } else if (taskIndex == AliQAv1::kESDS) {
658 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
659 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
660 TFile * esdFile = TFile::Open("AliESDs.root") ;
661 fESDTree = static_cast<TTree *> (esdFile->Get("esdTree")) ;
662 if ( !fESDTree ) {
663 AliError("esdTree not found") ;
664 return kFALSE ;
2e331c8b 665 } else {
92664bc8 666 fESD = new AliESDEvent() ;
667 fESD->ReadFromTree(fESDTree) ;
668 fESDTree->GetEntry(0) ;
669 fRunNumber = fESD->GetRunNumber() ;
670 fNumberOfEvents = fESDTree->GetEntries() ;
671 if ( fMaxEvents < 0 )
672 fMaxEvents = fNumberOfEvents ;
2e331c8b 673 }
92664bc8 674 } else {
675 AliError("AliESDs.root not found") ;
676 return kFALSE ;
677 }
678 } else {
679 if ( !InitRunLoader() ) {
680 AliWarning("No Run Loader not found") ;
681 } else {
682 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
683 if ( fMaxEvents < 0 )
684 fMaxEvents = fNumberOfEvents ;
2e331c8b 685 }
92664bc8 686 }
2e331c8b 687
688 // Get Detectors
689 TObjArray* detArray = NULL ;
92664bc8 690 if (fRunLoader) // check if RunLoader exists
691 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
692 detArray = fRunLoader->GetAliRun()->Detectors() ;
693 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
694 }
695
696 // Initialize all QA data makers for all detectors
697 fRunNumber = AliCDBManager::Instance()->GetRun() ;
698 if ( ! AliGeomManager::GetGeometry() )
699 AliGeomManager::LoadGeometry() ;
2e331c8b 700
92664bc8 701 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
fec0891b 702 if (fPrintImage) {
703 TCanvas fakeCanvas ;
7c9ff472 704 TStopwatch timer ;
705 timer.Start() ;
706 while (timer.CpuTime()<5) {
707 timer.Continue();
708 gSystem->ProcessEvents();
709 }
1d46dcf4 710 fakeCanvas.Print(Form("%s%s%d.%s[", AliQAv1::GetImageFileName(), GetMode(), fRunNumber, AliQAv1::GetImageFileFormat()), "ps") ;
fec0891b 711 }
92664bc8 712 return kTRUE ;
2e331c8b 713}
714
715//_____________________________________________________________________________
716void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
717{
92664bc8 718 // Initializes The QADataMaker for all active detectors and for all active tasks
fec0891b 719 fRunNumber = run ;
92664bc8 720 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
721 if (IsSelected(AliQAv1::GetDetName(iDet))) {
722 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
723 if (!qadm) {
724 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
725 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
726 } else {
2e331c8b 727 if (fQAWriteExpert[iDet])
728 qadm->SetWriteExpert() ;
92664bc8 729 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
730 // skip non active detectors
731 if (detArray) {
732 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
733 if (!det || !det->IsActive())
734 continue ;
735 }
736 // Set default reco params
2e331c8b 737 Bool_t sameCycle = kFALSE ;
92664bc8 738 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
739 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
740 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
4e25ac79 741 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
2e331c8b 742 sameCycle = kTRUE ;
92664bc8 743 }
2e331c8b 744 }
92664bc8 745 }
746 }
747 }
2e331c8b 748}
749
750
751//_____________________________________________________________________________
752Bool_t AliQAManager::InitRunLoader()
753{
92664bc8 754 // get or create the run loader
755 if (fRunLoader) {
756 fCycleSame = kTRUE ;
757 } else {
758 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
759 // load all base libraries to get the loader classes
760 TString libs = gSystem->GetLibraries() ;
761 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
762 if (!IsSelected(AliQAv1::GetDetName(iDet)))
763 continue ;
764 TString detName = AliQAv1::GetDetName(iDet) ;
765 if (detName == "HLT")
766 continue;
767 if (libs.Contains("lib" + detName + "base.so"))
768 continue;
769 gSystem->Load("lib" + detName + "base.so");
770 }
771 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
772 if (!fRunLoader) {
773 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
774 return kFALSE;
775 }
776 fRunLoader->CdGAFile();
777 if (fRunLoader->LoadgAlice() == 0) {
778 gAlice = fRunLoader->GetAliRun();
779 }
2e331c8b 780
92664bc8 781 if (!gAlice) {
782 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
783 return kFALSE;
784 }
785
786 } else { // galice.root does not exist
787 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
788 return kFALSE;
789 }
790 }
791
792 if (!fRunNumber) {
793 fRunLoader->LoadHeader();
794 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
795 }
796 return kTRUE;
2e331c8b 797}
798
799//_____________________________________________________________________________
fec0891b 800Bool_t AliQAManager::IsSelected(const Char_t * det)
2e331c8b 801{
802 // check whether detName is contained in detectors
92664bc8 803 // if yes, it is removed from detectors
2e331c8b 804
92664bc8 805 Bool_t rv = kFALSE;
806 const TString detName(det) ;
2e331c8b 807 // always activates Correlation
8fe40e49 808// if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR)) || detName.Contains(AliQAv1::GetDetName(AliQAv1::kGLOBAL))) {
809// rv = kTRUE ;
810// } else {
2e331c8b 811 // check if all detectors are selected
812 if (fDetectors.Contains("ALL")) {
813 fDetectors = "ALL";
814 rv = kTRUE;
815 } else if ((fDetectors.CompareTo(detName) == 0) ||
816 fDetectors.BeginsWith(detName+" ") ||
817 fDetectors.EndsWith(" "+detName) ||
818 fDetectors.Contains(" "+detName+" ")) {
819 rv = kTRUE;
820 }
8fe40e49 821// }
92664bc8 822 return rv ;
2e331c8b 823}
824
825//_____________________________________________________________________________
87da0921 826Bool_t AliQAManager::Merge(Int_t runNumber, const char *fileName) const
2e331c8b 827{
92664bc8 828 // Merge data from all detectors from a given run in one single file
829 // Merge the QA results from all the data chunks in one run
87da0921 830 // The 'fileName' is name of the output file with merged QA data
92664bc8 831 if ( runNumber == -1)
832 runNumber = fRunNumber ;
833 Bool_t rv = MergeData(runNumber,fileName) ;
834 //rv *= MergeResults(runNumber) ; // not needed for the time being
835 return rv ;
2e331c8b 836}
837
149a2367 838//______________________________________________________________________
fec0891b 839Bool_t AliQAManager::MergeXML(const Char_t * collectionFile, const Char_t * subFile, const Char_t * outFile)
149a2367 840{
841 // merges files listed in a xml collection
842 // usage Merge(collection, outputFile))
843 // collection: is a xml collection
844
845 Bool_t rv = kFALSE ;
846
847 if ( strstr(collectionFile, ".xml") == 0 ) {
848 AliError("Input collection file must be an \".xml\" file\n") ;
849 return kFALSE ;
850 }
851
92664bc8 852 if ( !gGrid )
853 TGrid::Connect("alien://");
854 if ( !gGrid )
855 return kFALSE ;
149a2367 856
857 // Open the file collection
5e232cd6 858 AliInfoClass(Form("*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
149a2367 859
bededc30 860 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
149a2367 861 TGridResult* result = collection->GetGridResult("", 0, 0);
862
863 Int_t index = 0 ;
fec0891b 864 const Char_t * turl ;
adae62c9 865 TFileMerger merger(kFALSE) ;
149a2367 866 if (!outFile) {
867 TString tempo(collectionFile) ;
868 if ( subFile)
869 tempo.ReplaceAll(".xml", subFile) ;
870 else
871 tempo.ReplaceAll(".xml", "_Merged.root") ;
872 outFile = tempo.Data() ;
873 }
874 merger.OutputFile(outFile) ;
875
876 while ( (turl = result->GetKey(index, "turl")) ) {
fec0891b 877 Char_t * file ;
149a2367 878 if ( subFile )
879 file = Form("%s#%s", turl, subFile) ;
880 else
881 file = Form("%s", turl) ;
882
5379c4a3 883 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
149a2367 884 merger.AddFile(file) ;
885 index++ ;
886 }
887
888 if (index)
889 merger.Merge() ;
890
5379c4a3 891 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
149a2367 892
893 rv = kFALSE;
894 return rv ;
895}
896
69a898e3 897//_____________________________________________________________________________
898void AliQAManager::MergeCustom() const
899{
92664bc8 900 // Custom Merge of QA data from all detectors for all runs in one single file
69a898e3 901 // search all the run numbers
902 // search all the run numbers
903 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
9025307b 904 TString theQAfile ;
905 FILE * theQAfiles = fopen("QAtempo.txt", "r") ;
69a898e3 906 Int_t index = 0 ;
907 TList srunList ;
908 TIter nextRun(&srunList) ;
909 TObjString * srun = NULL ;
910 Int_t loRun = 999999999 ;
911 Int_t hiRun = 0 ;
9025307b 912 while ( theQAfile.Gets(theQAfiles) ) {
69a898e3 913 Bool_t runExist = kFALSE ;
9025307b 914 TString srunNew(theQAfile(theQAfile.Index("QA.")+3, theQAfile.Index(".root")-(theQAfile.Index("QA.")+3))) ;
69a898e3 915 Int_t cuRun = srunNew.Atoi() ;
916 if (cuRun < loRun)
917 loRun = cuRun ;
918 if (cuRun > hiRun)
919 hiRun = cuRun ;
eca4fa66 920 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
69a898e3 921 if ( cuRun == (srun->String()).Atoi() ) {
922 runExist = kTRUE ;
923 break ;
924 }
925 }
926 nextRun.Reset() ;
927 if ( ! runExist )
928 srunList.Add(new TObjString(srunNew.Data()));
929 }
930 nextRun.Reset() ;
931 Int_t runNumber = 0 ;
4e25ac79 932 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
69a898e3 933 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
934 // create the structure into the merged file
4e25ac79 935 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
936 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
937 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
69a898e3 938 detDir->cd() ;
4e25ac79 939 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
69a898e3 940 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
941 taskDir->cd() ;
942 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
943 esDir->cd() ;
4e25ac79 944 gDirectory->mkdir(AliQAv1::GetExpert()) ;
69a898e3 945 }
946 }
947 }
eca4fa66 948 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
69a898e3 949 runNumber = (srun->String()).Atoi() ;
950 hisRun->Fill(runNumber) ;
5379c4a3 951 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
69a898e3 952 // search all QA files for runNumber in the current directory
fec0891b 953 Char_t * fileList[AliQAv1::kNDET] ;
69a898e3 954 index = 0 ;
4e25ac79 955 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
fec0891b 956 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
69a898e3 957 if (file)
958 fileList[index++] = file ;
959 }
960 if ( index == 0 ) {
961 AliError("No QA data file found\n") ;
962 return ;
963 }
964 for ( Int_t i = 0 ; i < index ; i++) {
965 TFile * inFile = TFile::Open(fileList[i]) ;
966 TList * listOfKeys =inFile->GetListOfKeys() ;
967 TIter nextkey(listOfKeys) ;
968 TObject * obj1 ;
969 TString dirName("") ;
970 while ( (obj1 = nextkey()) ) {
971 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
972 if ( directoryDet ) {
5379c4a3 973 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
69a898e3 974 dirName += Form("%s/", directoryDet->GetName() ) ;
975 directoryDet->cd() ;
976 TList * listOfTasks = directoryDet->GetListOfKeys() ;
977 TIter nextTask(listOfTasks) ;
978 TObject * obj2 ;
979 while ( (obj2 = nextTask()) ) {
980 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
981 if ( directoryTask ) {
982 dirName += Form("%s", obj2->GetName()) ;
5379c4a3 983 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
69a898e3 984 directoryTask->cd() ;
985 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
986 TIter nextEventSpecie(listOfEventSpecie) ;
987 TObject * obj3 ;
988 while ( (obj3 = nextEventSpecie()) ) {
989 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
990 if ( directoryEventSpecie ) {
991 dirName += Form("/%s/", obj3->GetName()) ;
5379c4a3 992 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
69a898e3 993 directoryEventSpecie->cd() ;
994 // histograms are here
995 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
996 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
997 TIter nextData(listOfData) ;
998 TKey * key ;
eca4fa66 999 while ( (key = static_cast<TKey *>(nextData())) ) {
69a898e3 1000 TString className(key->GetClassName()) ;
1001 if ( className.Contains("TH") || className.Contains("TProfile") ) {
eca4fa66 1002 TH1 * histIn = static_cast<TH1*> (key->ReadObj()) ;
1003 TH1 * histOu = static_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
65b25288 1004 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %p %p\n", key->GetName(), histIn, histOu)) ;
69a898e3 1005 mergedDirectory->cd() ;
1006 if ( ! histOu ) {
1007 histIn->Write() ;
1008 } else {
1009 histOu->Add(histIn) ;
1010 histOu->Write(histOu->GetName(), kOverwrite) ;
1011 }
1012 }
1013 else if ( className.Contains("TDirectoryFile") ) {
1014 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
1015 dirExpert->cd() ;
1016 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
1017 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
1018 TIter nextExpertData(listOfExpertData) ;
1019 TKey * keykey ;
eca4fa66 1020 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
69a898e3 1021 TString classNameExpert(keykey->GetClassName()) ;
1022 if (classNameExpert.Contains("TH")) {
eca4fa66 1023 TH1 * histInExpert = static_cast<TH1*> (keykey->ReadObj()) ;
1024 TH1 * histOuExpert = static_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
69a898e3 1025 mergedDirectoryExpert->cd() ;
1026 if ( ! histOuExpert ) {
1027 histInExpert->Write() ;
1028 } else {
1029 histOuExpert->Add(histInExpert) ;
1030 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
1031 }
1032 }
1033 }
1034 } else {
1035 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
1036 }
1037 }
1038 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
1039 }
1040 }
1041 dirName.ReplaceAll(obj2->GetName(), "") ;
1042 }
1043 }
1044 }
1045 }
1046 inFile->Close() ;
1047 }
1048 }
1049 mergedFile.cd() ;
1050 hisRun->Write() ;
1051 mergedFile.Close() ;
1052 srunList.Delete() ;
1053}
1054
2e331c8b 1055//_____________________________________________________________________________
87da0921 1056Bool_t AliQAManager::MergeData(const Int_t runNumber, const char *fileName) const
2e331c8b 1057{
92664bc8 1058 // Merge QA data from all detectors for a given run in one single file
bededc30 1059
87da0921 1060 TFileMerger merger(kFALSE) ;
1061 TString outFileName = fileName;
1062 if (outFileName.IsNull()) outFileName.Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName());
2e331c8b 1063 merger.OutputFile(outFileName.Data()) ;
bededc30 1064 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
fec0891b 1065 Char_t * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
bededc30 1066 if (file)
3136db6f 1067 merger.AddFile(file);
1068 delete[] file;
bededc30 1069 }
2e331c8b 1070 merger.Merge() ;
92664bc8 1071 return kTRUE ;
2e331c8b 1072}
1073
1074//_____________________________________________________________________________
1075Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
1076{
92664bc8 1077 // Merge the QA result from all the data chunks in a run
bededc30 1078 // to be revised whwn it will be used (see MergeData)
92664bc8 1079 TString cmd ;
1080 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
1081 gROOT->ProcessLine(cmd.Data()) ;
1082 ifstream in("tempo.txt") ;
1083 const Int_t chunkMax = 100 ;
1084 TString fileList[chunkMax] ;
2e331c8b 1085
92664bc8 1086 Int_t index = 0 ;
1087 while ( 1 ) {
1088 TString file ;
1089 in >> fileList[index] ;
1090 if ( !in.good() )
1091 break ;
1092 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
1093 index++ ;
1094 }
2e331c8b 1095
92664bc8 1096 if ( index == 0 ) {
1097 AliError("No QA Result File found") ;
1098 return kFALSE ;
1099 }
2e331c8b 1100
92664bc8 1101 TFileMerger merger ;
fc07289e 1102 TString outFileName ;
1103 if (runNumber != -1)
4e25ac79 1104 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
fc07289e 1105 else
4e25ac79 1106 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
92664bc8 1107 merger.OutputFile(outFileName.Data()) ;
1108 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1109 TString file = fileList[ifile] ;
1110 merger.AddFile(file) ;
1111 }
1112 merger.Merge() ;
2e331c8b 1113
92664bc8 1114 return kTRUE ;
2e331c8b 1115}
1116
1117//_____________________________________________________________________________
1118void AliQAManager::Reset(const Bool_t sameCycle)
1119{
92664bc8 1120 // Reset the default data members
2e331c8b 1121
92664bc8 1122 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1123 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1124 AliQADataMaker * qadm = GetQADataMaker(iDet);
1125 if (qadm)
5aae1dab 1126 qadm->Reset();
92664bc8 1127 }
1128 }
1129 if (fRawReaderDelete) {
1130 delete fRawReader ;
1131 fRawReader = NULL ;
1132 }
2e331c8b 1133
92664bc8 1134 fCycleSame = sameCycle ;
1135 fESD = NULL ;
1136 fESDTree = NULL ;
1137 //fFirst = kTRUE ;
1138 fNumberOfEvents = 999999 ;
2e331c8b 1139}
1140
9ac91920 1141//_____________________________________________________________________________
1142void AliQAManager::ResetDetectors(AliQAv1::TASKINDEX_t task, AliQAv1::DETECTORINDEX_t det)
1143{
92664bc8 1144 //calls ResetDetector of specified or all detectors
9ac91920 1145 UInt_t iDet = 0 ;
1146 UInt_t iDetMax = fgkNDetectors ;
1147 if ( det != AliQAv1::kNULLDET ) {
1148 iDet = det ;
1149 iDetMax = det+1 ;
1150 }
1151
92664bc8 1152 for (iDet = 0; iDet < iDetMax ; iDet++) {
1153 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1154 AliQADataMaker * qadm = GetQADataMaker(iDet);
1155 qadm->ResetDetector(task);
1156 }
1157 }
9ac91920 1158}
1159
2e331c8b 1160//_____________________________________________________________________________
634696f5 1161AliQAManager * AliQAManager::QAManager(AliQAv1::MODE_t mode, TMap *entryCache, Int_t run)
2e331c8b 1162{
1163 // returns AliQAManager instance (singleton)
1164
92664bc8 1165 if (!fgQAInstance) {
5aae1dab 1166 if ( (mode != AliQAv1::kSIMMODE) && (mode != AliQAv1::kRECMODE) && (mode != AliQAv1::kQAMODE) ) {
1167 AliWarningClass("You must specify kSIMMODE or kRECMODE or kQAMODE") ;
bf76b847 1168 return NULL ;
1169 }
2e331c8b 1170 fgQAInstance = new AliQAManager(mode) ;
1171 if (!entryCache)
92664bc8 1172 fgQAInstance->Init();
1173 else
1174 fgQAInstance->InitFromCache(entryCache,run);
2e331c8b 1175 }
92664bc8 1176 return fgQAInstance;
2e331c8b 1177}
1178
5e303886 1179//_____________________________________________________________________________
1180AliQAManager * AliQAManager::QAManager(AliQAv1::TASKINDEX_t task)
1181{
1182 // returns AliQAManager instance (singleton)
634696f5 1183 return QAManager(AliQAv1::Mode(task)) ;
5e303886 1184}
1185
2e331c8b 1186//_____________________________________________________________________________
fec0891b 1187TString AliQAManager::Run(const Char_t * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
2e331c8b 1188{
92664bc8 1189 //Runs all the QA data Maker for Raws only
2e331c8b 1190
92664bc8 1191 fCycleSame = sameCycle ;
1192 fRawReader = rawReader ;
1193 fDetectors = detectors ;
1194 fDetectorsW = detectors ;
2e331c8b 1195
92664bc8 1196 AliCDBManager* man = AliCDBManager::Instance() ;
2e331c8b 1197
92664bc8 1198 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1199 rawReader->NextEvent() ;
1200 man->SetRun(fRawReader->GetRunNumber()) ;
1201 rawReader->RewindEvents() ;
1202 }
2e331c8b 1203
92664bc8 1204 if (!fCycleSame)
4e25ac79 1205 if ( !InitQA(AliQAv1::kRAWS) )
9b4aee57 1206 return "" ;
2e331c8b 1207 fRawReaderDelete = kFALSE ;
1208
92664bc8 1209 DoIt(AliQAv1::kRAWS) ;
1210 return fDetectorsW ;
2e331c8b 1211}
1212
1213//_____________________________________________________________________________
fec0891b 1214TString AliQAManager::Run(const Char_t * detectors, const Char_t * fileName, const Bool_t sameCycle)
2e331c8b 1215{
92664bc8 1216 //Runs all the QA data Maker for Raws only
2e331c8b 1217
92664bc8 1218 fCycleSame = sameCycle ;
1219 fDetectors = detectors ;
1220 fDetectorsW = detectors ;
2e331c8b 1221
92664bc8 1222 AliCDBManager* man = AliCDBManager::Instance() ;
1223 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1224 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1225 if ( ! rl ) {
1226 AliFatal("galice.root file not found in current directory") ;
1227 } else {
1228 rl->CdGAFile() ;
1229 rl->LoadgAlice() ;
1230 if ( ! rl->GetAliRun() ) {
1231 AliFatal("AliRun not found in galice.root") ;
1232 } else {
1233 rl->LoadHeader() ;
1234 man->SetRun(rl->GetHeader()->GetRun());
1235 }
1236 }
1237 }
2e331c8b 1238
92664bc8 1239 if (!fCycleSame)
4e25ac79 1240 if ( !InitQA(AliQAv1::kRAWS, fileName) )
9b4aee57 1241 return "" ;
2e331c8b 1242
92664bc8 1243 DoIt(AliQAv1::kRAWS) ;
1244 return fDetectorsW ;
2e331c8b 1245}
1246
1247//_____________________________________________________________________________
fec0891b 1248TString AliQAManager::Run(const Char_t * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const Char_t * fileName )
2e331c8b 1249{
92664bc8 1250 // Runs all the QA data Maker for every detector
2e331c8b 1251
92664bc8 1252 fCycleSame = sameCycle ;
1253 fDetectors = detectors ;
1254 fDetectorsW = detectors ;
2e331c8b 1255
92664bc8 1256 AliCDBManager* man = AliCDBManager::Instance() ;
1257 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1258 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1259 if ( ! rl ) {
1260 AliFatal("galice.root file not found in current directory") ;
1261 } else {
1262 rl->CdGAFile() ;
1263 rl->LoadgAlice() ;
1264 if ( ! rl->GetAliRun() ) {
1265 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1266 } else {
1267 rl->LoadHeader() ;
1268 man->SetRun(rl->GetHeader()->GetRun()) ;
1269 }
1270 }
1271 }
fec0891b 1272 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
92664bc8 1273 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1274 if ( fTasks.Contains(Form("%d", task)) ) {
2e331c8b 1275 if (!fCycleSame)
4e25ac79 1276 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
9b4aee57 1277 return "" ;
4e25ac79 1278 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
92664bc8 1279 }
1280 }
1281 } else {
2e331c8b 1282 if (! fCycleSame )
1283 if ( !InitQA(taskIndex, fileName) )
9b4aee57 1284 return "" ;
92664bc8 1285 DoIt(taskIndex) ;
2e331c8b 1286 }
92664bc8 1287 return fDetectorsW ;
2e331c8b 1288}
1289
1290//_____________________________________________________________________________
1291void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1292{
c3c10397 1293 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1294
2e331c8b 1295 if ( ! rawReader )
1296 return ;
0d105c36 1297 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
c3c10397 1298 TString detList ;
1299 if ( GetEventInfo())
1300 detList = GetEventInfo()->GetTriggerCluster() ;
2e331c8b 1301 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
c3c10397 1302 if (!IsSelected(AliQAv1::GetDetName(iDet)) || (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(iDet))))
2e331c8b 1303 continue;
1304 AliQADataMaker *qadm = GetQADataMaker(iDet);
1305 if (!qadm)
1306 continue;
1307 if ( qadm->IsCycleDone() ) {
1308 qadm->EndOfCycle() ;
1309 }
5e232cd6 1310 qadm->SetEventSpecie(fEventSpecie) ;
13a2370e 1311 if ( qadm->GetRecoParam() )
c3c10397 1312 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
5e232cd6 1313 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
92664bc8 1314 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1315 }
2e331c8b 1316 }
1317}
1318
1319//_____________________________________________________________________________
aeb8fc30 1320void AliQAManager::RunOneEvent(AliESDEvent *& esd, AliESDEvent *& hltesd)
2e331c8b 1321{
c3c10397 1322 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
2e331c8b 1323
0d105c36 1324 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
c3c10397 1325 TString detList ;
1326 if ( GetEventInfo())
1327 detList = GetEventInfo()->GetTriggerCluster() ;
2e331c8b 1328 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
c3c10397 1329 if (!IsSelected(AliQAv1::GetDetName(iDet)) || (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(iDet))))
2e331c8b 1330 continue;
1331 AliQADataMaker *qadm = GetQADataMaker(iDet);
1332 if (!qadm)
1333 continue;
5e232cd6 1334 qadm->SetEventSpecie(fEventSpecie) ;
82a30871 1335 if ( qadm->GetRecoParam() )
c3c10397 1336 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
5e232cd6 1337 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
2e331c8b 1338 if ( qadm->IsCycleDone() ) {
1339 qadm->EndOfCycle() ;
1340 }
aeb8fc30 1341 if (iDet == AliQAv1::kHLT) {
1342 TObjArray esdarray;
1343 esdarray.Add(esd);
1344 esdarray.Add(hltesd);
1345 qadm->Exec(AliQAv1::kESDS, &esdarray);
1346 } else {
1347 qadm->Exec(AliQAv1::kESDS, esd) ;
1348 }
92664bc8 1349 }
1350 }
2e331c8b 1351}
1352
1353//_____________________________________________________________________________
1354void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1355{
c3c10397 1356 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
44ed7a66 1357
c3c10397 1358 TString detList ;
1359 if ( GetEventInfo())
1360 detList = GetEventInfo()->GetTriggerCluster() ;
1361 if (!detList.IsNull() && !detList.Contains(AliQAv1::GetDetName(det)))
1362 return ;
1363
44ed7a66 1364 TString test(tree->GetName()) ;
0d105c36 1365 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
c3c10397 1366 if (IsSelected(AliQAv1::GetDetName(det))) {
2e331c8b 1367 AliQADataMaker *qadm = GetQADataMaker(det);
1368 if (qadm) {
5e232cd6 1369 qadm->SetEventSpecie(fEventSpecie) ;
31c31326 1370 if ( qadm->GetRecoParam() ) {
5e232cd6 1371 if ( AliRecoParam::Convert(qadm->GetRecoParam()->GetEventSpecie()) != AliRecoParam::kDefault)
31c31326 1372 qadm->SetEventSpecie(qadm->GetRecoParam()->GetEventSpecie()) ;
1373 else
5c5ea798 1374 AliError(Form("%d defined by %s is not an event specie", qadm->GetRecoParam()->GetEventSpecie(), qadm->GetName())) ;
31c31326 1375 }
2e331c8b 1376 if ( qadm->IsCycleDone() ) {
1377 qadm->EndOfCycle() ;
1378 }
44ed7a66 1379 if (test.Contains("TreeD")) {
1380 qadm->Exec(AliQAv1::kDIGITSR, tree) ;
44ed7a66 1381 } else if (test.Contains("TreeR")) {
1382 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
44ed7a66 1383 }
2e331c8b 1384 }
1385 }
1386 }
1387}
1388
1389//_____________________________________________________________________________
fec0891b 1390Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t * year, const Char_t * detectors) const
2e331c8b 1391{
92664bc8 1392 // take the locasl QA data merge into a single file and save in OCDB
1393 Bool_t rv = kTRUE ;
1394 TString tmp(AliQAv1::GetQARefStorage()) ;
1395 if ( tmp.IsNull() ) {
1396 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1397 return kFALSE ;
1398 }
1399 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1400 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1401 return kFALSE ;
1402 }
1403 TString sdet(detectors) ;
1404 sdet.ToUpper() ;
1405 TFile * inputFile ;
1406 if ( sdet.Contains("ALL") ) {
1407 rv = Merge(runNumber) ;
1408 if ( ! rv )
1409 return kFALSE ;
1410 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1411 inputFile = TFile::Open(inputFileName.Data()) ;
1412 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1413 } else {
1414 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1415 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1416 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1417 inputFile = TFile::Open(inputFileName.Data()) ;
1418 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1419 }
1420 }
1421 }
1422 return rv ;
2e331c8b 1423}
1424
1425//_____________________________________________________________________________
fec0891b 1426Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const Char_t * year, AliRecoParam::EventSpecie_t es) const
2e331c8b 1427{
92664bc8 1428 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1429 Bool_t rv = kTRUE ;
1430 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1431 if ( ! IsDefaultStorageSet() ) {
1432 TString tmp( AliQAv1::GetQARefStorage() ) ;
1433 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1434 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1435 else {
1436 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1437 tmp1.Append(year) ;
1438 tmp1.Append("?user=alidaq") ;
1439 Instance()->SetDefaultStorage(tmp1.Data()) ;
1440 }
1441 }
1442 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1443 if(GetRun() < 0)
1444 Instance()->SetRun(runNumber);
2e331c8b 1445
92664bc8 1446 AliCDBMetaData mdr ;
1447 mdr.SetResponsible("yves schutz");
2e331c8b 1448
92664bc8 1449 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1450 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1451 if ( detDir ) {
1452 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
4e25ac79 1453 AliQAv1::SetQARefDataDirName(es) ;
92664bc8 1454 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1455 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1456 TList * listDetQAD = new TList() ;
1457 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1458 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1459 listDetQAD->SetName(listName) ;
1460 TList * taskList = detDir->GetListOfKeys() ;
1461 TIter nextTask(taskList) ;
1462 TKey * taskKey ;
1463 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1464 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
2e331c8b 1465 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
92664bc8 1466 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1467 TObjArray * listTaskQAD = new TObjArray(100) ;
1468 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1469 listDetQAD->Add(listTaskQAD) ;
1470 TList * histList = esDir->GetListOfKeys() ;
1471 TIter nextHist(histList) ;
1472 TKey * histKey ;
1473 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1474 TObject * odata = esDir->Get(histKey->GetName()) ;
1475 if ( !odata ) {
1476 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1477 } else {
4e25ac79 1478 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
2e331c8b 1479 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1480 TList * expertHistList = expertDir->GetListOfKeys() ;
1481 TIter nextExpertHist(expertHistList) ;
1482 TKey * expertHistKey ;
eca4fa66 1483 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
2e331c8b 1484 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1485 if ( !expertOdata ) {
1486 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1487 } else {
5379c4a3 1488 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
2e331c8b 1489 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
5379c4a3 1490 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
2e331c8b 1491 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1492 listTaskQAD->Add(hExpertdata) ;
1493 }
1494 }
1495 }
1496 }
92664bc8 1497 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1498 if ( odata->IsA()->InheritsFrom("TH1") ) {
1499 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1500 TH1 * hdata = static_cast<TH1*>(odata) ;
1501 listTaskQAD->Add(hdata) ;
1502 }
1503 }
2e331c8b 1504 }
92664bc8 1505 }
1506 Instance()->Put(listDetQAD, idr, &mdr) ;
1507 }
1508 }
1509 return rv ;
2e331c8b 1510}
1511
7c9ff472 1512//_____________________________________________________________________________
1513
1514void AliQAManager::SetCheckerExternParam(AliQAv1::DETECTORINDEX_t detIndex, TList * parameterList)
1515{
1516 // set the external parameters list for the detector checkers
1517 AliQACheckerBase * qac = AliQAChecker::Instance()->GetDetQAChecker(detIndex) ;
1518 qac->SetExternParamlist(parameterList) ;
1519 qac->PrintExternParam() ;
1520}
1521
2e331c8b 1522//_____________________________________________________________________________
1523void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1524{
4e25ac79 1525 // set the current event specie and inform AliQAv1 that this event specie has been encountered
bc8761a0 1526 fEventSpecie = es ;
4e25ac79 1527 AliQAv1::Instance()->SetEventSpecie(es) ;
2e331c8b 1528}
1529
1530//_____________________________________________________________________________
1531void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1532{
1533 // Set custom reconstruction parameters for a given detector
1534 // Single set of parameters for all the events
1535 GetQADataMaker(det)->SetRecoParam(par) ;
1536}
1537
75373542 1538//_____________________________________________________________________________
1539void AliQAManager::SetWriteExpert()
1540{
1541 // enable the writing of QA expert data
1542 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
92664bc8 1543 if (IsSelected(AliQAv1::GetDetName(iDet)))
75373542 1544 fQAWriteExpert[iDet] = kTRUE ;
1545 }
1546}
7cade814 1547
1548//_____________________________________________________________________________
1549void AliQAManager::Destroy() {
bf76b847 1550 // delete AliQAManager instance and
1551 // all associated objects
7cade814 1552
1553 if (fgQAInstance) {
eca4fa66 1554 delete fgQAInstance ;
1555 fgQAInstance = NULL ;
7cade814 1556 }
1557}
1558
bf76b847 1559//_____________________________________________________________________________
1560void AliQAManager::ShowQA() {
1561 // Show the result of the QA checking
1562 // for all detectors
92664bc8 1563 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++)
1564 if ( IsSelected(AliQAv1::GetDetName(detIndex)) )
1565 AliQAv1::Instance(AliQAv1::GetDetIndex(AliQAv1::GetDetName(detIndex)))->Show() ;
bf76b847 1566}