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