34 #include <TFileMerger.h> 36 #include <TGridCollection.h> 37 #include <TGridResult.h> 38 #include <TPluginManager.h> 42 #include <TStopwatch.h> 63 #include "AliRawReaderDate.h" 64 #include "AliRawReaderFile.h" 65 #include "AliRawReaderRoot.h" 89 fNumberOfEvents(999999),
93 fRawReaderDelete(kTRUE),
101 fMaxEvents = fNumberOfEvents ;
102 for (UInt_t iDet = 0; iDet < fgkNDetectors; iDet++) {
104 fLoader[iDet] = NULL ;
105 fQADataMaker[iDet] = NULL ;
106 fQACycles[iDet] = 999999 ;
122 fGAliceFileName(gAliceFilename),
125 fMode(
AliQAv1::GetModeName(mode)),
126 fNumberOfEvents(999999),
130 fRawReaderDelete(kTRUE),
222 if ( iEvent%10 == 0 )
228 if (
fESDTree->GetEntry(iEvent) == 0 )
247 TTree * data = NULL ;
258 data = loader->
TreeH() ;
263 qadm->
Exec(taskIndex, data) ;
270 if (gSystem->FindFile(
"./", fileName)) {
273 data = loader->
TreeS() ;
278 qadm->
Exec(taskIndex, data) ;
286 data = loader->
TreeD() ;
291 qadm->
Exec(taskIndex, data) ;
297 data = loader->
TreeD() ;
302 qadm->
Exec(taskIndex, data) ;
308 data = loader->
TreeR() ;
313 qadm->
Exec(taskIndex, data) ;
363 AliError(
"No storage defined, use AliQAv1::SetQARefStorage") ;
376 TList * listDetQAD =
static_cast<TList *
>(entry->
GetObject()) ;
386 TCanvas ** rv = NULL ;
409 TPluginManager* pluginManager =
gROOT->GetPluginManager() ;
410 TString loaderName =
"Ali" + detName +
"Loader" ;
414 TPluginHandler* pluginHandler = pluginManager->FindHandler(
"AliLoader", detName) ;
416 if (!pluginHandler) {
418 TString libs = gSystem->GetLibraries() ;
419 if (libs.Contains(
"lib" + detName +
"base") || (gSystem->Load(
"lib" + detName +
"base") >= 0)) {
420 pluginManager->AddHandler(
"AliQADataMaker", detName, loaderName, detName +
"loader", loaderName +
"()") ;
422 pluginManager->AddHandler(
"AliLoader", detName, loaderName, detName, loaderName +
"()") ;
424 pluginHandler = pluginManager->FindHandler(
"AliLoader", detName) ;
426 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
427 loader = (
AliLoader *) pluginHandler->ExecPlugin(0) ;
438 Char_t *
fileName = Form(
"Run%d.Event%d_1.ESD.tag.root", run, evt) ;
441 AliError(Form(
"File %s not found", fileName)) ;
444 TTree * tagTree =
static_cast<TTree *
>(tagFile->Get(
"T")) ;
446 AliError(Form(
"Tree T not found in %s", fileName)) ;
451 tagTree->SetBranchAddress(
"AliTAG", &tag) ;
452 tagTree->GetEntry(evt) ;
476 qadm->SetUniqueID(iDet);
486 qadm->SetUniqueID(iDet);
498 TPluginManager* pluginManager =
gROOT->GetPluginManager() ;
500 TString qadmName =
"Ali" + detName +
"QADataMaker" + smode ;
503 TPluginHandler* pluginHandler = pluginManager->FindHandler(
"AliQADataMaker", detName) ;
505 if (!pluginHandler) {
507 TString libs = gSystem->GetLibraries() ;
508 TString temp(smode) ;
510 if (libs.Contains(
"lib" + detName + smode +
".so") || (gSystem->Load(
"lib" + detName + temp.Data()) >= 0)) {
512 pluginManager->AddHandler(
"AliQADataMaker", detName, qadmName, detName +
"qadm", qadmName +
"(Bool_t,Bool_t)");
514 pluginManager->AddHandler(
"AliQADataMaker", detName, qadmName, detName +
"qadm", qadmName +
"()");
517 pluginManager->AddHandler(
"AliQADataMaker", detName, qadmName, detName, qadmName +
"()");
519 pluginHandler = pluginManager->FindHandler(
"AliQADataMaker", detName) ;
521 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
533 qadm->SetUniqueID(iDet);
568 if (
fTasks.Contains(Form(
"%d", taskIndex)) )
599 if (
fTasks.Contains(Form(
"%d", taskIndex)) )
613 if (!gSystem->AccessPathName(
"AliESDs.root")) {
615 TTree * esdTree =
static_cast<TTree *
> (esdFile->Get(
"esdTree")) ;
621 esdTree->GetEntry(0) ;
625 AliError(
"AliESDs.root not found") ;
638 currentTask = taskIndex ;
653 fTasks += Form(
"%d", taskIndex) ;
671 if (!gSystem->AccessPathName(
"AliESDs.root")) {
673 fESDTree =
static_cast<TTree *
> (esdFile->Get(
"esdTree")) ;
687 AliError(
"AliESDs.root not found") ;
718 while (timer.CpuTime()<5) {
720 gSystem->ProcessEvents();
749 Bool_t sameCycle = kFALSE ;
751 if (
fTasks.Contains(Form(
"%d", taskIndex)) ) {
772 TString libs = gSystem->GetLibraries() ;
777 if (detName ==
"HLT")
779 if (libs.Contains(
"lib" + detName +
"base.so"))
781 gSystem->Load(
"lib" + detName +
"base");
818 const TString detName(det) ;
827 }
else if ((
fDetectors.CompareTo(detName) == 0) ||
843 if ( runNumber == -1)
845 Bool_t rv =
MergeData(runNumber,fileName) ;
859 if ( strstr(collectionFile,
".xml") == 0 ) {
860 AliError(
"Input collection file must be an \".xml\" file\n") ;
865 TGrid::Connect(
"alien://");
870 AliInfoClass(Form(
"*** Create Collection ***\n*** Wk-Dir = |%s| \n*** Coll = |%s| \n",gSystem->WorkingDirectory(), collectionFile));
872 TGridCollection * collection = (TGridCollection*)
gROOT->ProcessLine(Form(
"TAlienCollection::Open(\"%s\")",collectionFile));
873 TGridResult* result = collection->GetGridResult(
"", 0, 0);
876 const Char_t * turl ;
877 TFileMerger merger(kFALSE) ;
879 TString tempo(collectionFile) ;
881 tempo.ReplaceAll(
".xml", subFile) ;
883 tempo.ReplaceAll(
".xml",
"_Merged.root") ;
884 outFile = tempo.Data() ;
886 merger.OutputFile(outFile) ;
888 while ( (turl = result->GetKey(index,
"turl")) ) {
891 file = Form(
"%s#%s", turl, subFile) ;
893 file = Form(
"%s", turl) ;
896 merger.AddFile(file) ;
915 gROOT->ProcessLine(
".! ls *QA*.root > QAtempo.txt") ;
917 FILE * theQAfiles = fopen(
"QAtempo.txt",
"r") ;
920 TIter nextRun(&srunList) ;
921 TObjString *
srun = NULL ;
922 Int_t loRun = 999999999 ;
924 while ( theQAfile.Gets(theQAfiles) ) {
925 Bool_t runExist = kFALSE ;
926 TString srunNew(theQAfile(theQAfile.Index(
"QA.")+3, theQAfile.Index(
".root")-(theQAfile.Index(
"QA.")+3))) ;
927 Int_t cuRun = srunNew.Atoi() ;
932 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
933 if ( cuRun == (srun->String()).Atoi() ) {
940 srunList.Add(
new TObjString(srunNew.Data()));
945 TH1I * hisRun =
new TH1I(
"hLMR",
"List of merged runs", hiRun-loRun+10, loRun, hiRun+10) ;
960 while ( (srun = static_cast<TObjString *> (nextRun())) ) {
961 runNumber = (srun->String()).Atoi() ;
962 hisRun->Fill(runNumber) ;
970 fileList[index++] = file ;
973 AliError(
"No QA data file found\n") ;
976 for ( Int_t i = 0 ; i < index ; i++) {
978 TList * listOfKeys =inFile->GetListOfKeys() ;
979 TIter nextkey(listOfKeys) ;
981 TString dirName(
"") ;
982 while ( (obj1 = nextkey()) ) {
983 TDirectory * directoryDet = inFile->GetDirectory(obj1->GetName()) ;
984 if ( directoryDet ) {
986 dirName += Form(
"%s/", directoryDet->GetName() ) ;
988 TList * listOfTasks = directoryDet->GetListOfKeys() ;
989 TIter nextTask(listOfTasks) ;
991 while ( (obj2 = nextTask()) ) {
992 TDirectory * directoryTask = directoryDet->GetDirectory(obj2->GetName()) ;
993 if ( directoryTask ) {
994 dirName += Form(
"%s", obj2->GetName()) ;
996 directoryTask->cd() ;
997 TList * listOfEventSpecie = directoryTask->GetListOfKeys() ;
998 TIter nextEventSpecie(listOfEventSpecie) ;
1000 while ( (obj3 = nextEventSpecie()) ) {
1001 TDirectory * directoryEventSpecie = directoryTask->GetDirectory(obj3->GetName()) ;
1002 if ( directoryEventSpecie ) {
1003 dirName += Form(
"/%s/", obj3->GetName()) ;
1005 directoryEventSpecie->cd() ;
1007 TDirectory * mergedDirectory = mergedFile.GetDirectory(dirName.Data()) ;
1008 TList * listOfData = directoryEventSpecie->GetListOfKeys() ;
1009 TIter nextData(listOfData) ;
1011 while ( (key = static_cast<TKey *>(nextData())) ) {
1012 TString className(key->GetClassName()) ;
1013 if ( className.Contains(
"TH") || className.Contains(
"TProfile") ) {
1014 TH1 * histIn =
static_cast<TH1*
> (key->ReadObj()) ;
1015 TH1 * histOu =
static_cast<TH1*
> (mergedDirectory->FindObjectAny(histIn->GetName())) ;
1017 mergedDirectory->cd() ;
1021 histOu->Add(histIn) ;
1022 histOu->Write(histOu->GetName(), kOverwrite) ;
1025 else if ( className.Contains(
"TDirectoryFile") ) {
1026 TDirectory * dirExpert = directoryEventSpecie->GetDirectory(key->GetName()) ;
1028 TDirectory * mergedDirectoryExpert = mergedDirectory->GetDirectory(dirExpert->GetName()) ;
1029 TList * listOfExpertData = dirExpert->GetListOfKeys() ;
1030 TIter nextExpertData(listOfExpertData) ;
1032 while ( (keykey = static_cast<TKey *>(nextExpertData())) ) {
1033 TString classNameExpert(keykey->GetClassName()) ;
1034 if (classNameExpert.Contains(
"TH")) {
1035 TH1 * histInExpert =
static_cast<TH1*
> (keykey->ReadObj()) ;
1036 TH1 * histOuExpert =
static_cast<TH1*
> (mergedDirectory->FindObjectAny(histInExpert->GetName())) ;
1037 mergedDirectoryExpert->cd() ;
1038 if ( ! histOuExpert ) {
1039 histInExpert->Write() ;
1041 histOuExpert->Add(histInExpert) ;
1042 histOuExpert->Write(histOuExpert->GetName(), kOverwrite) ;
1047 AliError(Form(
"No merge done for this object %s in %s", key->GetName(), dirName.Data())) ;
1050 dirName.ReplaceAll(Form(
"/%s/",obj3->GetName()),
"") ;
1053 dirName.ReplaceAll(obj2->GetName(),
"") ;
1063 mergedFile.Close() ;
1072 TFileMerger merger(kFALSE) ;
1075 merger.OutputFile(outFileName.Data()) ;
1079 merger.AddFile(file);
1093 gROOT->ProcessLine(cmd.Data()) ;
1094 ifstream in(
"tempo.txt") ;
1095 const Int_t chunkMax = 100 ;
1096 TString fileList[chunkMax] ;
1101 in >> fileList[index] ;
1109 AliError(
"No QA Result File found") ;
1113 TFileMerger merger ;
1114 TString outFileName ;
1115 if (runNumber != -1)
1119 merger.OutputFile(outFileName.Data()) ;
1120 for (Int_t ifile = 0 ; ifile < index ; ifile++) {
1121 TString file = fileList[ifile] ;
1122 merger.AddFile(file) ;
1164 for (iDet = 0; iDet < iDetMax ; iDet++) {
1199 TString
AliQAManager::Run(
const Char_t * detectors, AliRawReader * rawReader,
const Bool_t sameCycle)
1210 if ( man->
GetRun() == -1 ) {
1211 rawReader->NextEvent() ;
1213 rawReader->RewindEvents() ;
1235 if ( man->
GetRun() == -1 ) {
1238 AliFatal(
"galice.root file not found in current directory") ;
1243 AliFatal(
"AliRun not found in galice.root") ;
1269 if ( man->
GetRun() == -1 ) {
1272 AliFatal(
"galice.root file not found in current directory") ;
1286 if (
fTasks.Contains(Form(
"%d", task)) ) {
1295 if ( !
InitQA(taskIndex, fileName) )
1356 if (hltesd) esdarray.Add(hltesd);
1376 TString
test(tree->GetName()) ;
1391 if (
test.Contains(
"TreeD")) {
1393 }
else if (
test.Contains(
"TreeR")) {
1407 if ( tmp.IsNull() ) {
1408 AliError(
"No storage defined, use AliQAv1::SetQARefStorage") ;
1415 TString sdet(detectors) ;
1418 if ( sdet.Contains(
"ALL") ) {
1419 rv =
Merge(runNumber) ;
1424 rv =
SaveIt2OCDB(runNumber, inputFile, year, es) ;
1430 rv *=
SaveIt2OCDB(runNumber, inputFile, year, es) ;
1450 tmp1.Append(
"?user=alidaq") ;
1461 for ( Int_t detIndex = 0 ; detIndex <
AliQAv1::kNDET ; detIndex++) {
1468 TList * listDetQAD =
new TList() ;
1471 listDetQAD->SetName(listName) ;
1472 TList * taskList = detDir->GetListOfKeys() ;
1473 TIter nextTask(taskList) ;
1475 while ( (taskKey = static_cast<TKey*>(nextTask())) ) {
1476 TDirectory * taskDir = detDir->GetDirectory(taskKey->GetName()) ;
1481 listDetQAD->Add(listTaskQAD) ;
1482 TList * histList = esDir->GetListOfKeys() ;
1483 TIter nextHist(histList) ;
1485 while ( (histKey = static_cast<TKey*>(nextHist())) ) {
1486 TObject * odata = esDir->Get(histKey->GetName()) ;
1488 AliError(Form(
"%s in %s/%s returns a NULL pointer !!", histKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1491 TDirectory * expertDir = esDir->GetDirectory(histKey->GetName()) ;
1492 TList * expertHistList = expertDir->GetListOfKeys() ;
1493 TIter nextExpertHist(expertHistList) ;
1494 TKey * expertHistKey ;
1495 while ( (expertHistKey = static_cast<TKey*>(nextExpertHist())) ) {
1496 TObject * expertOdata = expertDir->Get(expertHistKey->GetName()) ;
1497 if ( !expertOdata ) {
1498 AliError(Form(
"%s in %s/%s/Expert returns a NULL pointer !!", expertHistKey->GetName(), detDir->GetName(), taskDir->GetName())) ;
1501 if ( expertOdata->IsA()->InheritsFrom(
"TH1") ) {
1503 TH1 * hExpertdata =
static_cast<TH1*
>(expertOdata) ;
1504 listTaskQAD->Add(hExpertdata) ;
1510 if ( odata->IsA()->InheritsFrom(
"TH1") ) {
1512 TH1 * hdata =
static_cast<TH1*
>(odata) ;
1513 listTaskQAD->Add(hdata) ;
1575 for ( Int_t detIndex = 0 ; detIndex <
AliQAv1::kNDET ; detIndex++)
static const char * GetEventSpecieName(EventSpecie_t es)
static AliQAManager * fgQAInstance
AliQAv1 * GetQA(UInt_t run, UInt_t evt)
TString fDetectorsW
list of active detectors
Bool_t fRawReaderDelete
current raw reader object
TFile * Open(const char *filename, Long64_t &nevents)
AliQAManager & operator=(const AliQAManager &qas)
TString fGAliceFileName
info on the current event
static AliQAManager * QAManager(AliQAv1::MODE_t=AliQAv1::kNULLMODE, TMap *entryCache=NULL, Int_t run=-1)
Int_t fQACycles[fgkNDetectors]
array of QA data maker objects
void Increment(const AliQAv1::TASKINDEX_t taskIndex=AliQAv1::kNULLTASKINDEX)
Long64_t fMaxEvents
first event to process
Int_t year
year for detector configuration
Long64_t fNumberOfEvents
sim or rec
Int_t GetQALength() const
void SetCheckerExternParam(AliQAv1::DETECTORINDEX_t det, TList *parameterList)
Bool_t Save2OCDB(const Int_t runNumber, AliRecoParam::EventSpecie_t es, const Char_t *year="08", const Char_t *detectors="ALL") const
Bool_t MergeData(const Int_t runNumber, const char *fileName=NULL) const
virtual const AliDetectorRecoParam * GetRecoParam()
void SetEventSpecie(AliRecoParam::EventSpecie_t es)
UInt_t fRunNumber
container for the reco-param objects for detectors
void SetExternParamlist(TList *list)
Int_t GetESLength() const
void InitQADataMaker(UInt_t run, TObjArray *detArray=0x0)
Bool_t MergeResults(const Int_t runNumber) const
void SetEventSpecie(AliRecoParam::EventSpecie_t es)
void RunOneEventInOneDetector(Int_t det, TTree *tree)
TCanvas ** GetImage(Char_t *detName)
AliLoader * GetLoader(Int_t iDet)
Bool_t IsCycleDone() const
static const char * GetRefOCDBDirName()
AliLoader * GetLoader(const char *detname) const
static const char * GetImageFileFormat()
static const char * GetImageFileName()
AliQADataMaker * GetQADataMaker(const Int_t iDet)
Bool_t Merge(Int_t runNumber=-1, const char *fileName=NULL) const
static const char * GetQARefStorage()
Bool_t DoIt(const AliQAv1::TASKINDEX_t taskIndex)
Int_t LoadRecPoints(Option_t *opt="")
void InitFromCache(TMap *entryCache, Int_t run)
Bool_t fSaveData
flag to print the images or not
Bool_t fCycleSame
event counter
AliRawReader * fRawReader
current run number
#define AliInfoClass(message)
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
virtual void Exec(AliQAv1::TASKINDEX_t, TObject *data)=0
#define AliWarning(message)
ULong_t * GetQAArray() const
AliCDBEntry * Get(const AliCDBId &query, Bool_t forceCaching=kFALSE)
static AliRunLoader * Open(const char *filename="galice.root", const char *eventfoldername=AliConfig::GetDefaultEventFolderName(), Option_t *option="READ")
Bool_t SaveIt2OCDB(const Int_t runNumber, TFile *inputFile, const Char_t *year, AliRecoParam::EventSpecie_t es) const
virtual void ResetDetector(AliQAv1::TASKINDEX_t task)=0
Bool_t MergeXML(const Char_t *collection, const Char_t *subFile=0, const Char_t *outFile=0)
Int_t LoadSDigits(Option_t *opt="")
Bool_t * GetEventSpecies() const
static DETECTORINDEX_t GetDetIndex(const char *name)
void Reset(const Bool_t sameCycle=kFALSE)
Bool_t InitQA(const AliQAv1::TASKINDEX_t taskIndex, const Char_t *fileName=NULL)
void SetSpecificStorage(const char *calibType, const char *dbString, Int_t version=-1, Int_t subVersion=-1)
UInt_t GetEventType() const
void SetRunNumber(Int_t run)
void Show(DETECTORINDEX_t det=kNULLDET) const
AliHeader * GetHeader() const
Int_t GetRunNumber() const
static const TString GetExpert()
void SetPrintImage(Bool_t opt=kTRUE)
#define AliWarningClass(message)
Bool_t IsSelected(const Char_t *detName)
Bool_t Put(TObject *object, const AliCDBId &id, AliCDBMetaData *metaData, const char *mirrors="", DataType type=kPrivate)
AliRunLoader * fRunLoader
tells if the rawReader has been created by this
Int_t GetNumberOfEvents()
TString Run(const Char_t *detectors, const AliQAv1::TASKINDEX_t taskIndex=AliQAv1::kNULLTASKINDEX, Bool_t const sameCycle=kFALSE, const Char_t *fileName=NULL)
TString fActiveOnlineDetectors
flag to sve the QA data or not
AliLoader * fLoader[fgkNDetectors]
number of detectors
static const TString GetDetName(DETECTORINDEX_t det)
TTree * fESDTree
current ESD
#define AliFatal(message)
Bool_t fQAWriteExpert[fgkNDetectors]
array of QA cycle length
Int_t LoadHits(Option_t *opt="")
void SetDefaultStorage(const char *dbString)
AliESDEvent * fESD
list of active detectors with QA implemented
const char * GetTriggerCluster() const
virtual TObjArray ** Init(AliQAv1::TASKINDEX_t, Int_t cycles=-1)=0
AliRecoParam::EventSpecie_t fEventSpecie
array of QA cycle length
Int_t GetEvent(Int_t evno)
virtual void StartOfCycle(Int_t run=-1)=0
TString fTasks
current run loader object
static const char * GetRefDataDirName()
#define AliDebug(logLevel, message)
AliRecoParam::EventSpecie_t GetEventSpecieFromESD()
Int_t GetQACycles(const Int_t iDet) const
static void SetQARefDataDirName(AliRecoParam::EventSpecie_t es)
static const char * GetModeName(MODE_t mode)
void ReadFromTree(TTree *tree, Option_t *opt="")
void SetEventSpecie(AliRecoParam::EventSpecie_t es)
virtual void EndOfCycle()=0
static MODE_t Mode(TASKINDEX_t task)
static const TString GetLabLocalOCDB()
TString fMode
number of events to process
UInt_t fFirstEvent
name of the galice file
Bool_t Finish(const AliQAv1::TASKINDEX_t taskIndex)
void SetRecoParam(const Int_t det, const AliDetectorRecoParam *par)
static const UInt_t fgkNDetectors
list of QA tasks to be performed
AliQACheckerBase * GetDetQAChecker(Int_t det)
Bool_t fPrintImage
type of event
TObjArray * GetFromOCDB(AliQAv1::DETECTORINDEX_t det, AliQAv1::TASKINDEX_t task, const Char_t *year) const
static EventSpecie_t Convert(Int_t ies)
void RunOneEvent(AliRawReader *rawReader)
AliEventInfo * fEventInfo
current ESD Tree
TString fDetectors
true if 2 consecutive data making for a same detector
void ResetDetectors(AliQAv1::TASKINDEX_t task, AliQAv1::DETECTORINDEX_t det=AliQAv1::kNULLDET)
virtual void SetRecoParam(const AliDetectorRecoParam *)
#define AliError(message)
AliRecoParam fRecoParam
number of events in the run
static const TString GetLabAliEnOCDB()
static const char * GetQAName()
Int_t LoadDigits(Option_t *opt="")
static AliCDBManager * Instance(TMap *entryCache=NULL, Int_t run=-1)
const AliEventInfo * GetEventInfo() const
virtual Bool_t IsActive() const
static Int_t GetQADebugLevel()
Bool_t IsDefaultStorageSet() const
static const char * GetQADataFileName()
static const char * GetQARefDefaultStorage()
static TGeoManager * GetGeometry()
void EndOfCycle(TObjArray *detArray=0x0)
static AliQAChecker * Instance()
static void LoadGeometry(const char *geomFileName=NULL)
static TString GetTaskName(UInt_t tsk)
AliQADataMaker * fQADataMaker[fgkNDetectors]
array of detectors loader
static AliQAv1 * Instance()
AliRun * GetAliRun() const
static TASKINDEX_t GetTaskIndex(const char *name)
Int_t GetEventSpecie() const
TObjArray * Detectors() const