1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliQAManager.cxx 30894 2009-02-05 13:46:48Z schutz $ */
17 ///////////////////////////////////////////////////////////////////////////////
19 // class for running the QA makers //
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); //
29 ///////////////////////////////////////////////////////////////////////////////
33 #include <TFileMerger.h>
35 #include <TGridCollection.h>
36 #include <TGridResult.h>
37 #include <TPluginManager.h>
42 #include "AliCDBManager.h"
43 #include "AliCDBEntry.h"
45 #include "AliCDBMetaData.h"
46 #include "AliCodeTimer.h"
47 #include "AliCorrQADataMakerRec.h"
48 #include "AliDetectorRecoParam.h"
49 #include "AliESDEvent.h"
50 #include "AliGeomManager.h"
51 #include "AliGlobalQADataMaker.h"
52 #include "AliHeader.h"
54 #include "AliModule.h"
56 #include "AliQADataMakerRec.h"
57 #include "AliQADataMakerSim.h"
58 #include "AliQAManager.h"
59 #include "AliRawReaderDate.h"
60 #include "AliRawReaderFile.h"
61 #include "AliRawReaderRoot.h"
63 #include "AliRunLoader.h"
64 #include "AliRunTag.h"
66 ClassImp(AliQAManager)
67 AliQAManager* AliQAManager::fgQAInstance = 0x0;
69 //_____________________________________________________________________________
70 AliQAManager::AliQAManager() :
82 fNumberOfEvents(999999),
86 fRawReaderDelete(kTRUE),
89 fEventSpecie(AliRecoParam::kDefault)
92 fMaxEvents = fNumberOfEvents ;
93 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
94 if (IsSelected(AliQAv1::GetDetName(iDet))) {
95 fLoader[iDet] = NULL ;
96 fQADataMaker[iDet] = NULL ;
97 fQACycles[iDet] = 999999 ;
103 //_____________________________________________________________________________
104 AliQAManager::AliQAManager(const Char_t * mode, const Char_t* gAliceFilename) :
112 fGAliceFileName(gAliceFilename),
116 fNumberOfEvents(999999),
120 fRawReaderDelete(kTRUE),
123 fEventSpecie(AliRecoParam::kDefault)
126 fMaxEvents = fNumberOfEvents ;
127 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
128 if (IsSelected(AliQAv1::GetDetName(iDet))) {
129 fLoader[iDet] = NULL ;
130 fQADataMaker[iDet] = NULL ;
131 fQACycles[iDet] = 999999 ;
137 //_____________________________________________________________________________
138 AliQAManager::AliQAManager(const AliQAManager & qas) :
140 fCurrentEvent(qas.fCurrentEvent),
142 fDetectors(qas.fDetectors),
143 fDetectorsW(qas.fDetectorsW),
146 fGAliceFileName(qas.fGAliceFileName),
147 fFirstEvent(qas.fFirstEvent),
148 fMaxEvents(qas.fMaxEvents),
150 fNumberOfEvents(qas.fNumberOfEvents),
152 fRunNumber(qas.fRunNumber),
154 fRawReaderDelete(kTRUE),
157 fEventSpecie(qas.fEventSpecie)
160 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
161 fLoader[iDet] = qas.fLoader[iDet] ;
162 fQADataMaker[iDet] = qas.fQADataMaker[iDet] ;
163 fQACycles[iDet] = qas.fQACycles[iDet] ;
164 fQAWriteExpert[iDet] = qas.fQAWriteExpert[iDet] ;
168 //_____________________________________________________________________________
169 AliQAManager & AliQAManager::operator = (const AliQAManager & qas)
171 // assignment operator
172 this->~AliQAManager() ;
173 new(this) AliQAManager(qas) ;
177 //_____________________________________________________________________________
178 AliQAManager::~AliQAManager()
181 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
182 if (IsSelected(AliQAv1::GetDetName(iDet))) {
183 fLoader[iDet] = NULL;
184 if (fQADataMaker[iDet]) {
185 (fQADataMaker[iDet])->Finish() ;
186 delete fQADataMaker[iDet] ;
190 if (fRawReaderDelete) {
197 //_____________________________________________________________________________
198 Bool_t AliQAManager::DoIt(const AliQAv1::TASKINDEX_t taskIndex)
200 // Runs all the QA data Maker for every detector
203 // Fill QA data in event loop
204 for (UInt_t iEvent = fFirstEvent ; iEvent < (UInt_t)fMaxEvents ; iEvent++) {
207 if ( iEvent%10 == 0 )
208 AliDebug(AliQAv1::GetQADebugLevel(), Form("processing event %d", iEvent));
209 if ( taskIndex == AliQAv1::kRAWS ) {
210 if ( !fRawReader->NextEvent() )
212 } else if ( taskIndex == AliQAv1::kESDS ) {
213 if ( fESDTree->GetEntry(iEvent) == 0 )
216 if ( fRunLoader->GetEvent(iEvent) != 0 )
219 // loop over active loaders
220 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
221 if (IsSelected(AliQAv1::GetDetName(iDet))) {
222 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
223 if (!qadm) continue; // This detector doesn't have any QA (for example, HLT)
224 if ( qadm->IsCycleDone() ) {
225 qadm->EndOfCycle(taskIndex) ;
227 TTree * data = NULL ;
228 AliLoader* loader = GetLoader(qadm->GetUniqueID());
230 case AliQAv1::kNULLTASKINDEX :
232 case AliQAv1::kRAWS :
233 qadm->Exec(taskIndex, fRawReader) ;
235 case AliQAv1::kHITS :
238 data = loader->TreeH() ;
240 AliWarning(Form(" Hit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
244 qadm->Exec(taskIndex, data) ;
246 case AliQAv1::kSDIGITS :
248 loader->LoadSDigits() ;
249 data = loader->TreeS() ;
251 AliWarning(Form(" SDigit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
255 qadm->Exec(taskIndex, data) ;
257 case AliQAv1::kDIGITS :
259 loader->LoadDigits() ;
260 data = loader->TreeD() ;
262 AliWarning(Form(" Digit Tree not found for %s", AliQAv1::GetDetName(iDet))) ;
266 qadm->Exec(taskIndex, data) ;
268 case AliQAv1::kRECPOINTS :
270 loader->LoadRecPoints() ;
271 data = loader->TreeR() ;
273 AliWarning(Form("RecPoints not found for %s", AliQAv1::GetDetName(iDet))) ;
277 qadm->Exec(taskIndex, data) ;
279 case AliQAv1::kTRACKSEGMENTS :
281 case AliQAv1::kRECPARTICLES :
283 case AliQAv1::kESDS :
284 qadm->Exec(taskIndex, fESD) ;
286 case AliQAv1::kNTASKINDEX :
293 // Save QA data for all detectors
294 rv = Finish(taskIndex) ;
296 if ( taskIndex == AliQAv1::kRAWS )
297 fRawReader->RewindEvents() ;
302 //_____________________________________________________________________________
303 Bool_t AliQAManager::Finish(const AliQAv1::TASKINDEX_t taskIndex)
305 // write output to file for all detectors
306 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
307 if (IsSelected(AliQAv1::GetDetName(iDet))) {
308 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
310 qadm->EndOfCycle(taskIndex) ;
316 //_____________________________________________________________________________
317 TObjArray * AliQAManager::GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const char * year) const
319 // Retrieve the list of QA data for a given detector and a given task
320 TObjArray * rv = NULL ;
321 if ( !strlen(AliQAv1::GetQARefStorage()) ) {
322 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
325 if ( ! IsDefaultStorageSet() ) {
326 TString tmp(AliQAv1::GetQARefDefaultStorage()) ;
329 Instance()->SetDefaultStorage(tmp.Data()) ;
330 Instance()->SetSpecificStorage(Form("%s/*", AliQAv1::GetQAName()), AliQAv1::GetQARefStorage()) ;
332 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetQAName(), AliQAv1::GetDetName((Int_t)det), AliQAv1::GetRefOCDBDirName())) ;
333 AliDebug(AliQAv1::GetQADebugLevel(), Form("Retrieving reference data from %s/%s for %s", AliQAv1::GetQARefStorage(), detOCDBDir.Data(), AliQAv1::GetTaskName(task).Data())) ;
334 AliCDBEntry* entry = QAManager()->Get(detOCDBDir.Data(), 0) ; //FIXME 0 --> Run Number
335 TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
337 rv = dynamic_cast<TObjArray *>(listDetQAD->FindObject(AliQAv1::GetTaskName(task))) ;
341 //_____________________________________________________________________________
342 AliLoader * AliQAManager::GetLoader(Int_t iDet)
344 // get the loader for a detector
346 if ( !fRunLoader || iDet == AliQAv1::kCORR)
349 TString detName = AliQAv1::GetDetName(iDet) ;
350 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
352 return fLoader[iDet] ;
354 // load the QA data maker object
355 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
356 TString loaderName = "Ali" + detName + "Loader" ;
358 AliLoader * loader = NULL ;
359 // first check if a plugin is defined for the quality assurance data maker
360 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
361 // if not, add a plugin for it
362 if (!pluginHandler) {
363 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", loaderName.Data())) ;
364 TString libs = gSystem->GetLibraries() ;
365 if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) {
366 pluginManager->AddHandler("AliQADataMaker", detName, loaderName, detName + "loader", loaderName + "()") ;
368 pluginManager->AddHandler("AliLoader", detName, loaderName, detName, loaderName + "()") ;
370 pluginHandler = pluginManager->FindHandler("AliLoader", detName) ;
372 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
373 loader = (AliLoader *) pluginHandler->ExecPlugin(0) ;
376 fLoader[iDet] = loader ;
380 //_____________________________________________________________________________
381 AliQAv1 * AliQAManager::GetQA(UInt_t run, UInt_t evt)
383 // retrieves the QA object stored in a file named "Run{run}.Event{evt}_1.ESD.tag.root"
384 char * fileName = Form("Run%d.Event%d_1.ESD.tag.root", run, evt) ;
385 TFile * tagFile = TFile::Open(fileName) ;
387 AliError(Form("File %s not found", fileName)) ;
390 TTree * tagTree = dynamic_cast<TTree *>(tagFile->Get("T")) ;
392 AliError(Form("Tree T not found in %s", fileName)) ;
396 AliRunTag * tag = new AliRunTag ;
397 tagTree->SetBranchAddress("AliTAG", &tag) ;
398 tagTree->GetEntry(evt) ;
399 AliQAv1 * qa = AliQAv1::Instance(tag->GetQALength(), tag->GetQAArray(), tag->GetESLength(), tag->GetEventSpecies()) ;
404 //_____________________________________________________________________________
405 AliQADataMaker * AliQAManager::GetQADataMaker(const Int_t iDet)
407 // get the quality assurance data maker for a detector
409 if (fQADataMaker[iDet]) {
410 fQADataMaker[iDet]->SetEventSpecie(fEventSpecie) ;
411 return fQADataMaker[iDet] ;
414 AliQADataMaker * qadm = NULL ;
416 if (iDet == AliQAv1::kGLOBAL) { //Global QA
417 qadm = new AliGlobalQADataMaker();
418 qadm->SetName(AliQAv1::GetDetName(iDet));
419 qadm->SetUniqueID(iDet);
420 fQADataMaker[iDet] = qadm;
421 qadm->SetEventSpecie(fEventSpecie) ;
425 if (iDet == AliQAv1::kCORR) { //the data maker for correlations among detectors
426 qadm = new AliCorrQADataMakerRec(fQADataMaker) ;
427 qadm->SetName(AliQAv1::GetDetName(iDet));
428 qadm->SetUniqueID(iDet);
429 fQADataMaker[iDet] = qadm;
430 qadm->SetEventSpecie(fEventSpecie) ;
434 // load the QA data maker object
435 TPluginManager* pluginManager = gROOT->GetPluginManager() ;
436 TString detName = AliQAv1::GetDetName(iDet) ;
438 if (tmp.Contains("sim"))
439 tmp.ReplaceAll("s", "S") ;
440 else if (tmp.Contains("rec"))
441 tmp.ReplaceAll("r", "R") ;
443 TString qadmName = "Ali" + detName + "QADataMaker" + tmp ;
445 // first check if a plugin is defined for the quality assurance data maker
446 TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
447 // if not, add a plugin for it
448 if (!pluginHandler) {
449 AliDebug(AliQAv1::GetQADebugLevel(), Form("defining plugin for %s", qadmName.Data())) ;
450 TString libs = gSystem->GetLibraries() ;
451 if (libs.Contains("lib" + detName + fMode + ".so") || (gSystem->Load("lib" + detName + fMode + ".so") >= 0)) {
452 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName + "qadm", qadmName + "()") ;
454 pluginManager->AddHandler("AliQADataMaker", detName, qadmName, detName, qadmName + "()") ;
456 pluginHandler = pluginManager->FindHandler("AliQADataMaker", detName) ;
458 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
459 qadm = (AliQADataMaker *) pluginHandler->ExecPlugin(0) ;
462 qadm->SetName(AliQAv1::GetDetName(iDet));
463 qadm->SetUniqueID(iDet);
464 fQADataMaker[iDet] = qadm ;
465 qadm->SetEventSpecie(fEventSpecie) ;
471 //_____________________________________________________________________________
472 void AliQAManager::EndOfCycle(TObjArray * detArray)
474 // End of cycle QADataMakers
476 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
477 if (IsSelected(AliQAv1::GetDetName(iDet))) {
478 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
481 // skip non active detectors
483 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
484 if (!det || !det->IsActive())
487 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
488 if ( fTasks.Contains(Form("%d", taskIndex)) )
489 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
496 //_____________________________________________________________________________
497 void AliQAManager::EndOfCycle(TString detectors)
499 // End of cycle QADataMakers
501 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
502 if (IsSelected(AliQAv1::GetDetName(iDet))) {
503 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
506 // skip non active detectors
507 if (!detectors.Contains(AliQAv1::GetDetName(iDet)))
509 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
510 if ( fTasks.Contains(Form("%d", taskIndex)) )
511 qadm->EndOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex))) ;
518 //_____________________________________________________________________________
519 void AliQAManager::Increment()
521 // Increments the cycle counter for all QA Data Makers
522 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
523 if (IsSelected(AliQAv1::GetDetName(iDet))) {
524 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
531 //_____________________________________________________________________________
532 Bool_t AliQAManager::InitQA(const AliQAv1::TASKINDEX_t taskIndex, const char * input )
534 // Initialize the event source and QA data makers
536 fTasks += Form("%d", taskIndex) ;
538 if (taskIndex == AliQAv1::kRAWS) {
540 fRawReader = AliRawReader::Create(input);
544 fRawReaderDelete = kTRUE ;
545 fRawReader->NextEvent() ;
546 fRunNumber = fRawReader->GetRunNumber() ;
548 fRawReader->RewindEvents();
549 fNumberOfEvents = 999999 ;
550 if ( fMaxEvents < 0 )
551 fMaxEvents = fNumberOfEvents ;
552 } else if (taskIndex == AliQAv1::kESDS) {
553 fTasks = AliQAv1::GetTaskName(AliQAv1::kESDS) ;
554 if (!gSystem->AccessPathName("AliESDs.root")) { // AliESDs.root exists
555 TFile * esdFile = TFile::Open("AliESDs.root") ;
556 fESDTree = dynamic_cast<TTree *> (esdFile->Get("esdTree")) ;
558 AliError("esdTree not found") ;
561 fESD = new AliESDEvent() ;
562 fESD->ReadFromTree(fESDTree) ;
563 fESDTree->GetEntry(0) ;
564 fRunNumber = fESD->GetRunNumber() ;
565 fNumberOfEvents = fESDTree->GetEntries() ;
566 if ( fMaxEvents < 0 )
567 fMaxEvents = fNumberOfEvents ;
570 AliError("AliESDs.root not found") ;
574 if ( !InitRunLoader() ) {
575 AliWarning("No Run Loader not found") ;
577 fNumberOfEvents = fRunLoader->GetNumberOfEvents() ;
578 if ( fMaxEvents < 0 )
579 fMaxEvents = fNumberOfEvents ;
584 TObjArray* detArray = NULL ;
585 if (fRunLoader) // check if RunLoader exists
586 if ( fRunLoader->GetAliRun() ) { // check if AliRun exists in gAlice.root
587 detArray = fRunLoader->GetAliRun()->Detectors() ;
588 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
591 // Initialize all QA data makers for all detectors
592 fRunNumber = AliCDBManager::Instance()->GetRun() ;
593 if ( ! AliGeomManager::GetGeometry() )
594 AliGeomManager::LoadGeometry() ;
596 InitQADataMaker(fRunNumber, detArray) ; //, fCycleSame, kTRUE, detArray) ;
600 //_____________________________________________________________________________
601 void AliQAManager::InitQADataMaker(UInt_t run, TObjArray * detArray)
603 // Initializes The QADataMaker for all active detectors and for all active tasks
604 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
605 if (IsSelected(AliQAv1::GetDetName(iDet))) {
606 AliQADataMaker * qadm = GetQADataMaker(iDet) ;
608 AliError(Form("AliQADataMaker not found for %s", AliQAv1::GetDetName(iDet))) ;
609 fDetectorsW.ReplaceAll(AliQAv1::GetDetName(iDet), "") ;
611 if (fQAWriteExpert[iDet])
612 qadm->SetWriteExpert() ;
613 AliDebug(AliQAv1::GetQADebugLevel(), Form("Data Maker found for %s %d", qadm->GetName(), qadm->WriteExpert())) ;
614 // skip non active detectors
616 AliModule* det = static_cast<AliModule*>(detArray->FindObject(AliQAv1::GetDetName(iDet))) ;
617 if (!det || !det->IsActive())
620 // Set default reco params
621 Bool_t sameCycle = kFALSE ;
622 for (UInt_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
623 if ( fTasks.Contains(Form("%d", taskIndex)) ) {
624 qadm->Init(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), GetQACycles(qadm->GetUniqueID())) ;
625 qadm->StartOfCycle(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(taskIndex)), run, sameCycle) ;
635 //_____________________________________________________________________________
636 Bool_t AliQAManager::InitRunLoader()
638 // get or create the run loader
642 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
643 // load all base libraries to get the loader classes
644 TString libs = gSystem->GetLibraries() ;
645 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
646 if (!IsSelected(AliQAv1::GetDetName(iDet)))
648 TString detName = AliQAv1::GetDetName(iDet) ;
649 if (detName == "HLT")
651 if (libs.Contains("lib" + detName + "base.so"))
653 gSystem->Load("lib" + detName + "base.so");
655 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
657 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
660 fRunLoader->CdGAFile();
661 if (fRunLoader->LoadgAlice() == 0) {
662 gAlice = fRunLoader->GetAliRun();
666 AliError(Form("no gAlice object found in file %s", fGAliceFileName.Data()));
670 } else { // galice.root does not exist
671 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
677 fRunLoader->LoadHeader();
678 fRunNumber = fRunLoader->GetHeader()->GetRun() ;
683 //_____________________________________________________________________________
684 Bool_t AliQAManager::IsSelected(const char * det)
686 // check whether detName is contained in detectors
687 // if yes, it is removed from detectors
690 const TString detName(det) ;
691 // always activates Correlation
692 if ( detName.Contains(AliQAv1::GetDetName(AliQAv1::kCORR))) {
695 // check if all detectors are selected
696 if (fDetectors.Contains("ALL")) {
699 } else if ((fDetectors.CompareTo(detName) == 0) ||
700 fDetectors.BeginsWith(detName+" ") ||
701 fDetectors.EndsWith(" "+detName) ||
702 fDetectors.Contains(" "+detName+" ")) {
709 //_____________________________________________________________________________
710 Bool_t AliQAManager::Merge(Int_t runNumber) const
712 // Merge data from all detectors from a given run in one single file
713 // Merge the QA results from all the data chunks in one run
714 if ( runNumber == -1)
715 runNumber = fRunNumber ;
716 Bool_t rv = MergeData(runNumber) ;
717 //rv *= MergeResults(runNumber) ; // not needed for the time being
721 //______________________________________________________________________
722 Bool_t AliQAManager::MergeXML(const char * collectionFile, const char * subFile, const char * outFile)
724 // merges files listed in a xml collection
725 // usage Merge(collection, outputFile))
726 // collection: is a xml collection
730 if ( strstr(collectionFile, ".xml") == 0 ) {
731 AliError("Input collection file must be an \".xml\" file\n") ;
736 TGrid::Connect("alien://");
740 // Open the file collection
741 printf("*** Create Collection ***\n");
742 printf("*** Wk-Dir = |%s| \n",gSystem->WorkingDirectory());
743 printf("*** Coll = |%s| \n",collectionFile);
745 TGridCollection * collection = (TGridCollection*)gROOT->ProcessLine(Form("TAlienCollection::Open(\"%s\")",collectionFile));
746 TGridResult* result = collection->GetGridResult("", 0, 0);
750 TFileMerger merger(kFALSE) ;
752 TString tempo(collectionFile) ;
754 tempo.ReplaceAll(".xml", subFile) ;
756 tempo.ReplaceAll(".xml", "_Merged.root") ;
757 outFile = tempo.Data() ;
759 merger.OutputFile(outFile) ;
761 while ( (turl = result->GetKey(index, "turl")) ) {
764 file = Form("%s#%s", turl, subFile) ;
766 file = Form("%s", turl) ;
768 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", file)) ;
769 merger.AddFile(file) ;
776 AliDebug(AliQAv1::GetQADebugLevel(), Form("Files merged into %s\n", outFile)) ;
782 //_____________________________________________________________________________
783 void AliQAManager::MergeCustom() const
785 // Custom Merge of QA data from all detectors for all runs in one single file
786 // search all the run numbers
787 // search all the run numbers
788 gROOT->ProcessLine(".! ls *QA*.root > QAtempo.txt") ;
790 FILE * QAfiles = fopen("QAtempo.txt", "r") ;
793 TIter nextRun(&srunList) ;
794 TObjString * srun = NULL ;
795 Int_t loRun = 999999999 ;
797 while ( QAfile.Gets(QAfiles) ) {
798 Bool_t runExist = kFALSE ;
799 TString srunNew(QAfile(QAfile.Index("QA.")+3, QAfile.Index(".root")-(QAfile.Index("QA.")+3))) ;
800 Int_t cuRun = srunNew.Atoi() ;
805 while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
806 if ( cuRun == (srun->String()).Atoi() ) {
813 srunList.Add(new TObjString(srunNew.Data()));
816 Int_t runNumber = 0 ;
817 TFile mergedFile(Form("Merged.%s.Data.root", AliQAv1::GetQADataFileName()), "RECREATE") ;
818 TH1I * hisRun = new TH1I("hLMR", "List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
819 // create the structure into the merged file
820 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
821 TDirectory * detDir = mergedFile.mkdir(AliQAv1::GetDetName(iDet)) ;
822 for (Int_t taskIndex = 0; taskIndex < AliQAv1::kNTASKINDEX; taskIndex++) {
824 TDirectory * taskDir = gDirectory->mkdir(AliQAv1::GetTaskName(taskIndex)) ;
825 for (Int_t es = 0 ; es < AliRecoParam::kNSpecies ; es++) {
827 TDirectory * esDir = gDirectory->mkdir(AliRecoParam::GetEventSpecieName(es)) ;
829 gDirectory->mkdir(AliQAv1::GetExpert()) ;
833 while ( (srun = dynamic_cast<TObjString *> (nextRun())) ) {
834 runNumber = (srun->String()).Atoi() ;
835 hisRun->Fill(runNumber) ;
836 AliDebug(AliQAv1::GetQADebugLevel(), Form("Merging run number %d", runNumber)) ;
837 // search all QA files for runNumber in the current directory
838 char * fileList[AliQAv1::kNDET] ;
840 for (Int_t iDet = 0; iDet < AliQAv1::kNDET ; iDet++) {
841 char * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
843 fileList[index++] = file ;
846 AliError("No QA data file found\n") ;
849 for ( Int_t i = 0 ; i < index ; i++) {
850 TFile * inFile = TFile::Open(fileList[i]) ;
851 TList * listOfKeys =inFile->GetListOfKeys() ;
852 TIter nextkey(listOfKeys) ;
854 TString dirName("") ;
855 while ( (obj1 = nextkey()) ) {
856 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
857 if ( directoryDet ) {
858 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s dir = %s", inFile->GetName(), directoryDet->GetName())) ;
859 dirName += Form("%s/", directoryDet->GetName() ) ;
861 TList * listOfTasks = directoryDet->GetListOfKeys() ;
862 TIter nextTask(listOfTasks) ;
864 while ( (obj2 = nextTask()) ) {
865 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
866 if ( directoryTask ) {
867 dirName += Form("%s", obj2->GetName()) ;
868 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s", dirName.Data())) ;
869 directoryTask->cd() ;
870 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
871 TIter nextEventSpecie(listOfEventSpecie) ;
873 while ( (obj3 = nextEventSpecie()) ) {
874 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
875 if ( directoryEventSpecie ) {
876 dirName += Form("/%s/", obj3->GetName()) ;
877 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s\n", dirName.Data())) ;
878 directoryEventSpecie->cd() ;
879 // histograms are here
880 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
881 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
882 TIter nextData(listOfData) ;
884 while ( (key = dynamic_cast<TKey *>(nextData())) ) {
885 TString className(key->GetClassName()) ;
886 if ( className.Contains("TH") || className.Contains("TProfile") ) {
887 TH1 * histIn = dynamic_cast<TH1*> (key->ReadObj()) ;
888 TH1 * histOu = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
889 AliDebug(AliQAv1::GetQADebugLevel(), Form("%s %x %x\n", key->GetName(), histIn, histOu)) ;
890 mergedDirectory->cd() ;
894 histOu->Add(histIn) ;
895 histOu->Write(histOu->GetName(), kOverwrite) ;
898 else if ( className.Contains("TDirectoryFile") ) {
899 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
901 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
902 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
903 TIter nextExpertData(listOfExpertData) ;
905 while ( (keykey = dynamic_cast<TKey *>(nextExpertData())) ) {
906 TString classNameExpert(keykey->GetClassName()) ;
907 if (classNameExpert.Contains("TH")) {
908 TH1 * histInExpert = dynamic_cast<TH1*> (keykey->ReadObj()) ;
909 TH1 * histOuExpert = dynamic_cast<TH1*> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
910 mergedDirectoryExpert->cd() ;
911 if ( ! histOuExpert ) {
912 histInExpert->Write() ;
914 histOuExpert->Add(histInExpert) ;
915 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
920 AliError(Form("No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
923 dirName.ReplaceAll(Form("/%s/",obj3->GetName()), "") ;
926 dirName.ReplaceAll(obj2->GetName(), "") ;
940 //_____________________________________________________________________________
941 Bool_t AliQAManager::MergeData(const Int_t runNumber) const
943 // Merge QA data from all detectors for a given run in one single file
946 TString outFileName = Form("Merged.%s.Data.root",AliQAv1::GetQADataFileName()) ;
947 merger.OutputFile(outFileName.Data()) ;
948 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
949 char * file = gSystem->Which(gSystem->WorkingDirectory(), Form("%s.%s.%d.root", AliQAv1::GetDetName(iDet), AliQAv1::GetQADataFileName(), runNumber));
951 merger.AddFile(file) ;
957 //_____________________________________________________________________________
958 Bool_t AliQAManager::MergeResults(const Int_t runNumber) const
960 // Merge the QA result from all the data chunks in a run
961 // to be revised whwn it will be used (see MergeData)
963 cmd = Form(".! ls %s*.root > tempo.txt", AliQAv1::GetQADataFileName()) ;
964 gROOT->ProcessLine(cmd.Data()) ;
965 ifstream in("tempo.txt") ;
966 const Int_t chunkMax = 100 ;
967 TString fileList[chunkMax] ;
972 in >> fileList[index] ;
975 AliDebug(AliQAv1::GetQADebugLevel(), Form("index = %d file = %s", index, (fileList[index].Data()))) ;
980 AliError("No QA Result File found") ;
985 TString outFileName ;
987 outFileName = Form("Merged.%s.Result.%d.root",AliQAv1::GetQADataFileName(),runNumber);
989 outFileName = Form("Merged.%s.Result.root",AliQAv1::GetQADataFileName());
990 merger.OutputFile(outFileName.Data()) ;
991 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
992 TString file = fileList[ifile] ;
993 merger.AddFile(file) ;
1000 //_____________________________________________________________________________
1001 void AliQAManager::Reset(const Bool_t sameCycle)
1003 // Reset the default data members
1005 for (UInt_t iDet = 0; iDet < fgkNDetectors ; iDet++) {
1006 if (IsSelected(AliQAv1::GetDetName(iDet))) {
1007 AliQADataMaker * qadm = GetQADataMaker(iDet);
1011 if (fRawReaderDelete) {
1016 fCycleSame = sameCycle ;
1020 fNumberOfEvents = 999999 ;
1023 //_____________________________________________________________________________
1024 AliQAManager * AliQAManager::QAManager(const Char_t * mode, TMap *entryCache, Int_t run)
1026 // returns AliQAManager instance (singleton)
1028 if (!fgQAInstance) {
1029 fgQAInstance = new AliQAManager(mode) ;
1031 fgQAInstance->Init();
1033 fgQAInstance->InitFromCache(entryCache,run);
1035 return fgQAInstance;
1038 //_____________________________________________________________________________
1039 TString AliQAManager::Run(const char * detectors, AliRawReader * rawReader, const Bool_t sameCycle)
1041 //Runs all the QA data Maker for Raws only
1043 fCycleSame = sameCycle ;
1044 fRawReader = rawReader ;
1045 fDetectors = detectors ;
1046 fDetectorsW = detectors ;
1048 AliCDBManager* man = AliCDBManager::Instance() ;
1050 if ( man->GetRun() == -1 ) {// check if run number not set previously and set it from raw data
1051 rawReader->NextEvent() ;
1052 man->SetRun(fRawReader->GetRunNumber()) ;
1053 rawReader->RewindEvents() ;
1057 if ( !InitQA(AliQAv1::kRAWS) )
1059 fRawReaderDelete = kFALSE ;
1061 DoIt(AliQAv1::kRAWS) ;
1062 return fDetectorsW ;
1065 //_____________________________________________________________________________
1066 TString AliQAManager::Run(const char * detectors, const char * fileName, const Bool_t sameCycle)
1068 //Runs all the QA data Maker for Raws only
1070 fCycleSame = sameCycle ;
1071 fDetectors = detectors ;
1072 fDetectorsW = detectors ;
1074 AliCDBManager* man = AliCDBManager::Instance() ;
1075 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1076 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1078 AliFatal("galice.root file not found in current directory") ;
1082 if ( ! rl->GetAliRun() ) {
1083 AliFatal("AliRun not found in galice.root") ;
1086 man->SetRun(rl->GetHeader()->GetRun());
1092 if ( !InitQA(AliQAv1::kRAWS, fileName) )
1095 DoIt(AliQAv1::kRAWS) ;
1096 return fDetectorsW ;
1099 //_____________________________________________________________________________
1100 TString AliQAManager::Run(const char * detectors, const AliQAv1::TASKINDEX_t taskIndex, Bool_t const sameCycle, const char * fileName )
1102 // Runs all the QA data Maker for every detector
1104 fCycleSame = sameCycle ;
1105 fDetectors = detectors ;
1106 fDetectorsW = detectors ;
1108 AliCDBManager* man = AliCDBManager::Instance() ;
1109 if ( man->GetRun() == -1 ) { // check if run number not set previously and set it from AliRun
1110 AliRunLoader * rl = AliRunLoader::Open("galice.root") ;
1112 AliFatal("galice.root file not found in current directory") ;
1116 if ( ! rl->GetAliRun() ) {
1117 AliDebug(AliQAv1::GetQADebugLevel(), "AliRun not found in galice.root") ;
1120 man->SetRun(rl->GetHeader()->GetRun()) ;
1126 if ( taskIndex == AliQAv1::kNULLTASKINDEX) {
1127 for (UInt_t task = 0; task < AliQAv1::kNTASKINDEX; task++) {
1128 if ( fTasks.Contains(Form("%d", task)) ) {
1130 if ( !InitQA(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task)), fileName) )
1132 DoIt(AliQAv1::GetTaskIndex(AliQAv1::GetTaskName(task))) ;
1137 if ( !InitQA(taskIndex, fileName) )
1142 return fDetectorsW ;
1146 //_____________________________________________________________________________
1147 void AliQAManager::RunOneEvent(AliRawReader * rawReader)
1149 //Runs all the QA data Maker for Raws only and on one event only (event loop done by calling method)
1152 AliCodeTimerAuto("") ;
1153 if (fTasks.Contains(Form("%d", AliQAv1::kRAWS))){
1154 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1155 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1157 AliQADataMaker *qadm = GetQADataMaker(iDet);
1160 if ( qadm->IsCycleDone() ) {
1161 qadm->EndOfCycle() ;
1163 AliCodeTimerStart(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1164 qadm->SetEventSpecie(fEventSpecie) ;
1165 qadm->Exec(AliQAv1::kRAWS, rawReader) ;
1166 AliCodeTimerStop(Form("running RAW quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1171 //_____________________________________________________________________________
1172 void AliQAManager::RunOneEvent(AliESDEvent *& esd)
1174 //Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1176 AliCodeTimerAuto("") ;
1177 if (fTasks.Contains(Form("%d", AliQAv1::kESDS))) {
1178 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1179 if (!IsSelected(AliQAv1::GetDetName(iDet)))
1181 AliQADataMaker *qadm = GetQADataMaker(iDet);
1184 if ( qadm->IsCycleDone() ) {
1185 qadm->EndOfCycle() ;
1187 AliCodeTimerStart(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1188 qadm->Exec(AliQAv1::kESDS, esd) ;
1189 AliCodeTimerStop(Form("running ESD quality assurance data maker for %s", AliQAv1::GetDetName(iDet)));
1194 //_____________________________________________________________________________
1195 void AliQAManager::RunOneEventInOneDetector(Int_t det, TTree * tree)
1197 // Runs all the QA data Maker for ESDs only and on one event only (event loop done by calling method)
1198 AliCodeTimerAuto("") ;
1199 if (fTasks.Contains(Form("%d", AliQAv1::kRECPOINTS))) {
1200 if (IsSelected(AliQAv1::GetDetName(det))) {
1201 AliQADataMaker *qadm = GetQADataMaker(det);
1203 if ( qadm->IsCycleDone() ) {
1204 qadm->EndOfCycle() ;
1206 AliCodeTimerStart(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1207 qadm->Exec(AliQAv1::kRECPOINTS, tree) ;
1208 AliCodeTimerStop(Form("running RecPoints quality assurance data maker for %s", AliQAv1::GetDetName(det)));
1214 //_____________________________________________________________________________
1215 Bool_t AliQAManager::Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const char * year, const char * detectors) const
1217 // take the locasl QA data merge into a single file and save in OCDB
1219 TString tmp(AliQAv1::GetQARefStorage()) ;
1220 if ( tmp.IsNull() ) {
1221 AliError("No storage defined, use AliQAv1::SetQARefStorage") ;
1224 if ( !(tmp.Contains(AliQAv1::GetLabLocalOCDB()) || tmp.Contains(AliQAv1::GetLabAliEnOCDB())) ) {
1225 AliError(Form("%s is a wrong storage, use %s or %s", AliQAv1::GetQARefStorage(), AliQAv1::GetLabLocalOCDB().Data(), AliQAv1::GetLabAliEnOCDB().Data())) ;
1228 TString sdet(detectors) ;
1231 if ( sdet.Contains("ALL") ) {
1232 rv = Merge(runNumber) ;
1235 TString inputFileName(Form("Merged.%s.Data.%d.root", AliQAv1::GetQADataFileName(), runNumber)) ;
1236 inputFile = TFile::Open(inputFileName.Data()) ;
1237 rv = SaveIt2OCDB(runNumber, inputFile, year, es) ;
1239 for (Int_t index = 0; index < AliQAv1::kNDET; index++) {
1240 if (sdet.Contains(AliQAv1::GetDetName(index))) {
1241 TString inputFileName(Form("%s.%s.%d.root", AliQAv1::GetDetName(index), AliQAv1::GetQADataFileName(), runNumber)) ;
1242 inputFile = TFile::Open(inputFileName.Data()) ;
1243 rv *= SaveIt2OCDB(runNumber, inputFile, year, es) ;
1250 //_____________________________________________________________________________
1251 Bool_t AliQAManager::SaveIt2OCDB(const Int_t runNumber, TFile * inputFile, const char * year, AliRecoParam::EventSpecie_t es) const
1253 // reads the TH1 from file and adds it to appropriate list before saving to OCDB
1255 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving TH1s in %s to %s", inputFile->GetName(), AliQAv1::GetQARefStorage())) ;
1256 if ( ! IsDefaultStorageSet() ) {
1257 TString tmp( AliQAv1::GetQARefStorage() ) ;
1258 if ( tmp.Contains(AliQAv1::GetLabLocalOCDB()) )
1259 Instance()->SetDefaultStorage(AliQAv1::GetQARefStorage()) ;
1261 TString tmp1(AliQAv1::GetQARefDefaultStorage()) ;
1263 tmp1.Append("?user=alidaq") ;
1264 Instance()->SetDefaultStorage(tmp1.Data()) ;
1267 Instance()->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
1269 Instance()->SetRun(runNumber);
1271 AliCDBMetaData mdr ;
1272 mdr.SetResponsible("yves schutz");
1274 for ( Int_t detIndex = 0 ; detIndex < AliQAv1::kNDET ; detIndex++) {
1275 TDirectory * detDir = inputFile->GetDirectory(AliQAv1::GetDetName(detIndex)) ;
1277 AliDebug(AliQAv1::GetQADebugLevel(), Form("Entering %s", detDir->GetName())) ;
1278 AliQAv1::SetQARefDataDirName(es) ;
1279 TString detOCDBDir(Form("%s/%s/%s", AliQAv1::GetDetName(detIndex), AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName())) ;
1280 AliCDBId idr(detOCDBDir.Data(), runNumber, AliCDBRunRange::Infinity()) ;
1281 TList * listDetQAD = new TList() ;
1282 TString listName(Form("%s QA data Reference", AliQAv1::GetDetName(detIndex))) ;
1283 mdr.SetComment(Form("%s QA stuff", AliQAv1::GetDetName(detIndex)));
1284 listDetQAD->SetName(listName) ;
1285 TList * taskList = detDir->GetListOfKeys() ;
1286 TIter nextTask(taskList) ;
1288 while ( (taskKey = dynamic_cast<TKey*>(nextTask())) ) {
1289 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1290 TDirectory * esDir = taskDir->GetDirectory(AliRecoParam::GetEventSpecieName(es)) ;
1291 AliDebug(AliQAv1::GetQADebugLevel(), Form("Saving %s", esDir->GetName())) ;
1292 TObjArray * listTaskQAD = new TObjArray(100) ;
1293 listTaskQAD->SetName(Form("%s/%s", taskKey->GetName(), AliRecoParam::GetEventSpecieName(es))) ;
1294 listDetQAD->Add(listTaskQAD) ;
1295 TList * histList = esDir->GetListOfKeys() ;
1296 TIter nextHist(histList) ;
1298 while ( (histKey = dynamic_cast<TKey*>(nextHist())) ) {
1299 TObject * odata = esDir->Get(histKey->GetName()) ;
1301 AliError(Form("%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1303 if ( AliQAv1::GetExpert() == histKey->GetName() ) {
1304 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1305 TList * expertHistList = expertDir->GetListOfKeys() ;
1306 TIter nextExpertHist(expertHistList) ;
1307 TKey * expertHistKey ;
1308 while ( (expertHistKey = dynamic_cast<TKey*>(nextExpertHist())) ) {
1309 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1310 if ( !expertOdata ) {
1311 AliError(Form("%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1313 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1314 if ( expertOdata->IsA()->InheritsFrom("TH1") ) {
1315 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", expertHistKey->GetName())) ;
1316 TH1 * hExpertdata = static_cast<TH1*>(expertOdata) ;
1317 listTaskQAD->Add(hExpertdata) ;
1322 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1323 if ( odata->IsA()->InheritsFrom("TH1") ) {
1324 AliDebug(AliQAv1::GetQADebugLevel(), Form("Adding %s", histKey->GetName())) ;
1325 TH1 * hdata = static_cast<TH1*>(odata) ;
1326 listTaskQAD->Add(hdata) ;
1331 Instance()->Put(listDetQAD, idr, &mdr) ;
1337 //_____________________________________________________________________________
1338 void AliQAManager::SetEventSpecie(AliRecoParam::EventSpecie_t es)
1340 // set the current event specie and inform AliQAv1 that this event specie has been encountered
1342 AliQAv1::Instance()->SetEventSpecie(es) ;
1345 //_____________________________________________________________________________
1346 void AliQAManager::SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
1348 // Set custom reconstruction parameters for a given detector
1349 // Single set of parameters for all the events
1350 GetQADataMaker(det)->SetRecoParam(par) ;
1353 //_____________________________________________________________________________
1354 void AliQAManager::SetWriteExpert()
1356 // enable the writing of QA expert data
1357 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1358 if (IsSelected(AliQAv1::GetDetName(iDet)))
1359 fQAWriteExpert[iDet] = kTRUE ;