From d3a269fff1bc3d672a65b44d9f2fd01a084428a9 Mon Sep 17 00:00:00 2001 From: cvetan Date: Wed, 1 Oct 2008 14:27:28 +0000 Subject: [PATCH 1/1] Update of the QA histo viewer. 2 new helper classes (Mikolaj) --- MONITOR/AliQAHistNavigator.cxx | 494 ++++++++++++++++----------------- MONITOR/AliQAHistNavigator.h | 97 +++++-- MONITOR/AliQAHistViewer.cxx | 74 +++-- MONITOR/AliQAHistViewer.h | 4 + MONITOR/MONITORLinkDef.h | 2 + 5 files changed, 366 insertions(+), 305 deletions(-) diff --git a/MONITOR/AliQAHistNavigator.cxx b/MONITOR/AliQAHistNavigator.cxx index d209bd4a510..ad652767bd2 100644 --- a/MONITOR/AliQAHistNavigator.cxx +++ b/MONITOR/AliQAHistNavigator.cxx @@ -26,39 +26,31 @@ ClassImp(AliQAHistNavigator) //_________________________________________________________________________ -AliQAHistNavigator::AliQAHistNavigator(Int_t run, Int_t rev): +AliQAHistNavigator::AliQAHistNavigator(Int_t run): fPFile( NULL ), + fPCORRFile( NULL ), + fPQAResultFile( NULL ), fRun( run ), - fCyc( rev ), fPCurrFile( NULL ), fPCurrDetector( NULL ), fPCurrLevel( NULL ), - fPCurrHistName( NULL ), - fPListOfFiles( new TList() ), + fPCurrItem( NULL ), + fPListOfFiles( new AliQADirList() ), fLoopAllFiles(kTRUE), fLoopAllDetectors(kTRUE), fLoopAllLevels(kTRUE), - fInitOK(kFALSE) + fInitOK(kFALSE), + fExpertMode(kFALSE), + fExpertDirName("Expert"), + fPEmptyList(new TList()) { + fPEmptyList->AddLast(new AliQADirListItem("")); ReReadFiles(); } //_________________________________________________________________________ -Bool_t AliQAHistNavigator::GetNextHistogram(TH1*& hist) +AliQAHistNavigator::~AliQAHistNavigator() { - //moves to the next histogram from the list and tries to get it. - if (!Next()) - { - hist = NULL; - return kFALSE; - } - if (GetHistName()=="") - if (!Next()) - { - hist = NULL; - return kTRUE; - } - return GetHistogram(hist); } //_________________________________________________________________________ @@ -66,89 +58,68 @@ Bool_t AliQAHistNavigator::GetHistogram(TH1*& hist) { TString file = GetFileName(); TString dir = GetDirName(); - TString histname = GetHistName(); + TString histname = GetItemName(); + cout<<"GetHistogram: "<GetObject(file+":"+dir+"/"+histname,hist); + if (!OpenCurrentDirectory()) return kFALSE; + hist = dynamic_cast( gDirectory->FindKey(histname)->ReadObj() ); if (!hist) { - printf("GetHistogram: null pointer returned by gDirectory\n"); + printf("GetItem: null pointer returned by gDirectory\n"); return kFALSE; } return kTRUE; } -//_________________________________________________________________________ -Bool_t AliQAHistNavigator::GetPrevHistogram(TH1*& hist) -{ - //moves to the prev histogram from the list and tries to get it. - if (!Prev()) - { - hist = NULL; - return kFALSE; - } - if (GetHistName()=="") - if (!Prev()) - { - hist = NULL; - return kTRUE; - } - return GetHistogram(hist); -} - //_________________________________________________________________________ Bool_t AliQAHistNavigator::Next() { - if (!fPCurrHistName||!fPCurrFile||!fPCurrDetector||!fPCurrLevel) return kFALSE; - if (!(fPCurrHistName=(TObjString*)fPCurrLevel->After(fPCurrHistName))) + if (!fPCurrFile||!fPCurrDetector||!fPCurrLevel) return kFALSE; + if (!(fPCurrItem=(AliQADirListItem*)GetItemList()->After(fPCurrItem))) { - if (!(fPCurrLevel=(TList*)fPCurrDetector->After(fPCurrLevel))) + if (!(fPCurrLevel=(AliQADirList*)fPCurrDetector->GetDirs()->After(fPCurrLevel))) { - if (!(fPCurrDetector=(TList*)fPCurrFile->After(fPCurrDetector))) + if (!(fPCurrDetector=(AliQADirList*)fPCurrFile->GetDirs()->After(fPCurrDetector))) { - if (!(fPCurrFile=(TList*)fPListOfFiles->After(fPCurrFile))) + if (!(fPCurrFile=(AliQADirList*)fPListOfFiles->GetDirs()->After(fPCurrFile))) { //we're at the end of everything if (fLoopAllFiles) { //rewind to the beginning - fPCurrFile = (TList*)fPListOfFiles->First(); - fPCurrDetector = (TList*)fPCurrFile->First(); - fPCurrLevel = (TList*) fPCurrDetector->First(); - fPCurrHistName = (TObjString*) fPCurrLevel->First(); + fPCurrFile = (AliQADirList*)fPListOfFiles->GetDirs()->First(); + fPCurrDetector = (AliQADirList*)fPCurrFile->GetDirs()->First(); + fPCurrLevel = (AliQADirList*) fPCurrDetector->GetDirs()->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); OpenCurrentFile(); OpenCurrentDirectory(); printf("----------------back at the beginning!\n"); } else return kFALSE; //no rewind, we finish } else //if there is a next file { - fPCurrDetector = (TList*)fPCurrFile->First(); - fPCurrLevel=(TList*)fPCurrDetector->First(); - fPCurrHistName=(TObjString*)fPCurrLevel->First(); - cout<GetDirs()->First(); + fPCurrLevel=(AliQADirList*)fPCurrDetector->GetDirs()->First(); + fPCurrItem=(AliQADirListItem*)GetItemList()->First(); OpenCurrentFile(); OpenCurrentDirectory(); } } else //if there is a next detector { - fPCurrLevel=(TList*)fPCurrDetector->First(); - fPCurrHistName=(TObjString*)fPCurrLevel->First(); - cout<GetDirs()->First(); + fPCurrItem=(AliQADirListItem*)GetItemList()->First(); OpenCurrentDirectory(); } } else //if there is a next level { - fPCurrHistName=(TObjString*)fPCurrLevel->First(); - cout<First(); OpenCurrentDirectory(); - cout<Before(fPCurrHistName))) + if (!fPCurrLevel||!fPCurrDetector||!fPCurrFile) return kFALSE; + if (!(fPCurrItem=(AliQADirListItem*)GetItemList()->Before(fPCurrItem))) { - if (!(fPCurrLevel=(TList*)fPCurrDetector->Before(fPCurrLevel))) + if (!(fPCurrLevel=(AliQADirList*)fPCurrDetector->GetDirs()->Before(fPCurrLevel))) { - if (!(fPCurrDetector=(TList*)fPCurrFile->Before(fPCurrDetector))) + if (!(fPCurrDetector=(AliQADirList*)fPCurrFile->GetDirs()->Before(fPCurrDetector))) { - if (!(fPCurrFile=(TList*)fPListOfFiles->Before(fPCurrFile))) + if (!(fPCurrFile=(AliQADirList*)fPListOfFiles->GetDirs()->Before(fPCurrFile))) { //we're at the end of everything if (fLoopAllFiles) { //rewind to the beginning - fPCurrFile = (TList*)fPListOfFiles->Last(); - fPCurrDetector = (TList*)fPCurrFile->Last(); - fPCurrLevel = (TList*) fPCurrDetector->Last(); - fPCurrHistName = (TObjString*) fPCurrLevel->Last(); + fPCurrFile = (AliQADirList*)fPListOfFiles->GetDirs()->Last(); + fPCurrDetector = (AliQADirList*)fPCurrFile->GetDirs()->Last(); + fPCurrLevel = (AliQADirList*) fPCurrDetector->GetDirs()->Last(); + fPCurrItem = (AliQADirListItem*)GetItemList()->Last(); OpenCurrentFile(); OpenCurrentDirectory(); printf("----------------back at the end!\n"); } else return kFALSE; //no rewind, we finish } else //if there is a next file { - fPCurrDetector = (TList*)fPCurrFile->Last(); - fPCurrLevel=(TList*)fPCurrDetector->Last(); - fPCurrHistName=(TObjString*)fPCurrLevel->Last(); - cout<GetDirs()->Last(); + fPCurrLevel=(AliQADirList*)fPCurrDetector->GetDirs()->Last(); + fPCurrItem=(AliQADirListItem*)GetItemList()->Last(); OpenCurrentFile(); OpenCurrentDirectory(); } } else //if there is a next detector { - fPCurrLevel=(TList*)fPCurrDetector->Last(); - fPCurrHistName=(TObjString*)fPCurrLevel->Last(); - cout<GetDirs()->Last(); + fPCurrItem=(AliQADirListItem*)GetItemList()->Last(); OpenCurrentDirectory(); } } else //if there is a next level { - fPCurrHistName=(TObjString*)fPCurrLevel->Last(); - cout<Last(); OpenCurrentDirectory(); - cout<First(); + +} + //_________________________________________________________________________ Bool_t AliQAHistNavigator::OpenCurrentFile() { + //open current file if (fPFile) fPFile->Close(); if (!(fPFile->Open(GetFileName(),"READ"))) { @@ -222,6 +199,7 @@ Bool_t AliQAHistNavigator::OpenCurrentFile() //_________________________________________________________________________ Bool_t AliQAHistNavigator::OpenCurrentDirectory() { + //Open current directory if (!gDirectory->cd(GetDirName())) return kFALSE; return kTRUE; } @@ -229,27 +207,29 @@ Bool_t AliQAHistNavigator::OpenCurrentDirectory() //_________________________________________________________________________ Bool_t AliQAHistNavigator::SetFile( TString file ) { - TList* tmp = (TList*)fPListOfFiles->FindObject ( file.Data() ); + //Set a new file to read from + AliQADirList* tmp = (AliQADirList*)fPListOfFiles->GetDirs()->FindObject ( file.Data() ); if (!tmp) return kFALSE; fPCurrFile = tmp; OpenCurrentFile(); - fPCurrDetector = (TList*)fPCurrFile->First(); - fPCurrLevel = (TList*)fPCurrDetector->First(); - fPCurrHistName = (TObjString*)fPCurrLevel->First(); + fPCurrDetector = (AliQADirList*)fPCurrFile->GetDirs()->First(); + fPCurrLevel = (AliQADirList*)fPCurrDetector->GetDirs()->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); return kTRUE; } //_________________________________________________________________________ Bool_t AliQAHistNavigator::SetFile( Int_t file ) { + //Set a new file to read from printf("AliQAHistNavigator::SetFile(%i)\n",file); - TList* tmp = (TList*)fPListOfFiles->At(file); + AliQADirList* tmp = (AliQADirList*)fPListOfFiles->GetDirs()->At(file); if (!tmp) return kFALSE; fPCurrFile = tmp; OpenCurrentFile(); - fPCurrDetector = (TList*)fPCurrFile->First(); - fPCurrLevel = (TList*)fPCurrDetector->First(); - fPCurrHistName = (TObjString*)fPCurrLevel->First(); + fPCurrDetector = (AliQADirList*)fPCurrFile->GetDirs()->First(); + fPCurrLevel = (AliQADirList*)fPCurrDetector->GetDirs()->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); OpenCurrentDirectory(); return kTRUE; } @@ -257,11 +237,12 @@ Bool_t AliQAHistNavigator::SetFile( Int_t file ) //_________________________________________________________________________ Bool_t AliQAHistNavigator::SetDetector( TString det ) { - TList* tmp = (TList*)fPCurrFile->FindObject( det.Data() ); + //Set a new detector + AliQADirList* tmp = (AliQADirList*)fPCurrFile->GetDirs()->FindObject( det.Data() ); if (!tmp) return kFALSE; fPCurrDetector = tmp; - fPCurrLevel = (TList*)fPCurrDetector->First(); - fPCurrHistName = (TObjString*)fPCurrLevel->First(); + fPCurrLevel = (AliQADirList*)fPCurrDetector->GetDirs()->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); OpenCurrentDirectory(); return kTRUE; } @@ -269,12 +250,13 @@ Bool_t AliQAHistNavigator::SetDetector( TString det ) //_________________________________________________________________________ Bool_t AliQAHistNavigator::SetDetector( Int_t det ) { + //Set a new detector printf("AliQAHistNavigator::SetDetector(%i)\n",det); - TList* tmp = (TList*)fPCurrFile->At( det ); + AliQADirList* tmp = (AliQADirList*)fPCurrFile->GetDirs()->At( det ); if (!tmp) return kFALSE; fPCurrDetector = tmp; - fPCurrLevel = (TList*)fPCurrDetector->First(); - fPCurrHistName = (TObjString*)fPCurrLevel->First(); + fPCurrLevel = (AliQADirList*)fPCurrDetector->GetDirs()->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); OpenCurrentDirectory(); return kTRUE; } @@ -282,10 +264,11 @@ Bool_t AliQAHistNavigator::SetDetector( Int_t det ) //_________________________________________________________________________ Bool_t AliQAHistNavigator::SetLevel( TString level ) { - TList* tmp = (TList*)fPCurrDetector->FindObject( level.Data() ); + //Set a new level + AliQADirList* tmp = (AliQADirList*)fPCurrDetector->GetDirs()->FindObject( level.Data() ); if (!tmp) return kFALSE; fPCurrLevel = tmp; - fPCurrHistName = (TObjString*)fPCurrLevel->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); OpenCurrentDirectory(); return kTRUE; } @@ -293,47 +276,62 @@ Bool_t AliQAHistNavigator::SetLevel( TString level ) //_________________________________________________________________________ Bool_t AliQAHistNavigator::SetLevel( Int_t level ) { - TList* tmp = (TList*)fPCurrDetector->At( level ); + //Set a new level + AliQADirList* tmp = (AliQADirList*)fPCurrDetector->GetDirs()->At( level ); if (!tmp) return kFALSE; fPCurrLevel = tmp; - fPCurrHistName = (TObjString*)fPCurrLevel->First(); + fPCurrItem = (AliQADirListItem*)GetItemList()->First(); OpenCurrentDirectory(); return kTRUE; } //_________________________________________________________________________ -Bool_t AliQAHistNavigator::SetHist( TString hist ) +Bool_t AliQAHistNavigator::SetItem( TString hist ) { - TObjString* tmp = (TObjString*)fPCurrLevel->FindObject( hist.Data() ); + //set the new item + AliQADirListItem* tmp = (AliQADirListItem*)GetItemList()->FindObject( hist.Data() ); if (!tmp) return kFALSE; - fPCurrHistName = tmp; + fPCurrItem = tmp; return kTRUE; } //_________________________________________________________________________ -Bool_t AliQAHistNavigator::SetHist( Int_t hist ) +Bool_t AliQAHistNavigator::SetItem( Int_t hist ) { - TObjString* tmp = (TObjString*)fPCurrLevel->At( hist ); + //set the new item + AliQADirListItem* tmp = (AliQADirListItem*)GetItemList()->At( hist ); if (!tmp) return kFALSE; - fPCurrHistName = tmp; + fPCurrItem = tmp; return kTRUE; } //_________________________________________________________________________ -void AliQAHistNavigator::PrintDebugInfo() +TList* AliQAHistNavigator::GetItemList() { - if (!fPCurrHistName) {cout<<"no more histograms"<pwd();cout<GetDirs()->FindObject(fExpertDirName); + if (expertlist) itemlist = expertlist->GetItems(); + else + { + //this is a bit of a hack, but it will always return something sensible + AliQADirListItem* it = (AliQADirListItem*)fPEmptyList->First(); + it->SetParent(fPCurrLevel); + itemlist = fPEmptyList; + } + } else + { + itemlist = fPCurrLevel->GetItems(); + } + return itemlist; } //_________________________________________________________________________ TString AliQAHistNavigator::GetDetectorName() { + //Get name of current detector if (!fPCurrDetector) return ""; TString name = fPCurrDetector->GetName(); return name; @@ -342,6 +340,7 @@ TString AliQAHistNavigator::GetDetectorName() //_________________________________________________________________________ TString AliQAHistNavigator::GetLevelName() { + //Get name of current leve if (!fPCurrLevel) return ""; TString name = fPCurrLevel->GetName(); return name; @@ -350,6 +349,7 @@ TString AliQAHistNavigator::GetLevelName() //_________________________________________________________________________ TString AliQAHistNavigator::GetFileName() { + //Get name of current file if (!fPCurrFile) return ""; TString file = fPCurrFile->GetName(); return file; @@ -358,122 +358,52 @@ TString AliQAHistNavigator::GetFileName() //_________________________________________________________________________ TString AliQAHistNavigator::GetDirName() { - TString detector = GetDetectorName(); - TString level = GetLevelName(); - if (detector==""||level=="") return ""; - TString dir = "/"+ detector +"/"+ level; - return dir; -} - -//_________________________________________________________________________ -TString AliQAHistNavigator::GetHistName() -{ - if (!fPCurrHistName) return ""; - return fPCurrHistName->GetString(); + //get the name of dir containing current item + if (!fPCurrItem) return ""; + AliQADirList* d=(AliQADirList*)fPCurrItem->GetParent(); + TString path; + do + { + path = d->GetName() + path; + path = "/" + path; + d=d->GetParent(); + } + while (d->GetParent()); + return path; } //_________________________________________________________________________ -Bool_t AliQAHistNavigator::DumpList( TString filename ) +TString AliQAHistNavigator::GetPath(AliQADirListItem* item) { - ofstream fout(filename); - if (fout.bad()) return kFALSE; - TString lastlevel=""; - TString lastdet=""; - if (!Next()) return kTRUE; + //Get the full path to teh directory containing item + AliQADirList* d=item->GetParent(); + TString path = "";//item->GetString(); do { - if (GetLevelName()!=lastlevel) - { - fout<GetParent()) ? "/" : ":/" ; + path = d->GetName() + sep + path; + } + while (d=d->GetParent()); + return path; } //_________________________________________________________________________ -Bool_t AliQAHistNavigator::ReadList( TString filename ) +TString AliQAHistNavigator::GetItemName() { - TString line = filename; - //TString level=""; - //TString lastlevel=""; - //TString det=""; - //TString lastdet=""; - //TRegexp detRegexp("^[a-zA-Z0-9]*"); - //TRegexp typRegexp("[a-zA-Z0-9]*"); - - //ifstream fin(filename); - //if (fin.bad()) return kFALSE; - //delete fPListOfFiles; - //fPListOfFiles = new TList(); - //TList* pDetector=new TList(); - //TList* pLevel=new TList(); - // - //line.ReadLine(fin,kFALSE); - //if (line=="") return kFALSE; - //cout<<"read line: "<SetName(det); - //lastdet = det; - //pLevel->SetName(level); - //lastlevel = level; - //pLevel->AddLast(new TObjString("DO NOT REMOVE THIS LINE")); - // - //while (!fin.eof()) - //{ - // line.ReadLine(fin,kFALSE); - // cout<<"read line: "<AddLast(pLevel); - // fPListOfFiles->AddLast(pDetector); - // pDetector = new TList(); - // pDetector->SetName(det); - // cout<<"new detector: "<SetName(level); - // cout<<"new level: "<AddLast(pLevel); - // pLevel = new TList(); - // pLevel->SetName(level); - // cout<<"new level: "<AddLast(new TObjString(line)); - // cout<<"added line: "<First(); - //fPCurrLevel = (TList*) fPCurrDetector->First(); - //fPCurrHistName = (TObjString*) fPCurrLevel->First(); - //OpenCurrentFile(); - //OpenCurrentDirectory(); - //fPListOfFiles->Print(); - return kFALSE; + //Get name of current item + if (!fPCurrItem) return ""; + return fPCurrItem->GetString(); } //_________________________________________________________________________ Bool_t AliQAHistNavigator::GetListOfFiles() { + //scan directory for QA files delete fPListOfFiles; - fPListOfFiles = new TList(); + fPListOfFiles = new AliQADirList(); + + TString CORRFileName; + TString QAResultFileName; TString macdir("."); gSystem->ExpandPathName(macdir); @@ -485,23 +415,40 @@ Bool_t AliQAHistNavigator::GetListOfFiles() TString runstr = ""; TString revstr = ""; runstr += fRun; - revstr += fCyc; TString reg; reg+= ".*QA\\."; - reg+= (fRun==0) ? "[0-9].*" : runstr.Data(); - reg+= "\\."; reg+= (fRun==0) ? "[0-9].*" : revstr.Data(); reg+= "\\.root$"; - cout< names; while((filename = gSystem->GetDirEntry(dirhandle)) != 0) { - if(re.Match(filename)) + if (reCORR.Match(filename)) + { + CORRFileName = filename; + continue; + } + if (reQA.Match(filename)) + { + QAResultFileName = filename; + continue; + } + if (reMerged.Match(filename)) + { + names.clear(); + names.push_back(filename); + break; + } + if (reHist.Match(filename)) { names.push_back(filename); } } + if (!fPCORRFile) fPCORRFile = new TFile(CORRFileName,"READ"); + if (!fPQAResultFile) fPQAResultFile = new TFile(QAResultFileName,"READ"); if (names.empty()) { printf("GetListOfFiles: no files matching...\n"); @@ -512,9 +459,9 @@ Bool_t AliQAHistNavigator::GetListOfFiles() for (std::list::iterator si=names.begin(); si!=names.end(); ++si) { sprintf(fullName,"%s", si->c_str()); - TList* f = new TList(); + AliQADirList* f = new AliQADirList(); f->SetName(fullName); - fPListOfFiles->AddLast(f); + fPListOfFiles->GetDirs()->AddLast(f); } } else @@ -528,14 +475,14 @@ Bool_t AliQAHistNavigator::GetListOfFiles() //_________________________________________________________________________ Bool_t AliQAHistNavigator::CloneDirStructure() { + //scan all files if (!GetListOfFiles()) return kFALSE; - if (fPListOfFiles->GetEntries()==0) return kFALSE; - TIter fileiter(fPListOfFiles); - TList* f; - while ((f = (TList*)fileiter.Next())) + if (fPListOfFiles->GetDirs()->GetEntries()==0) return kFALSE; + TIter fileiter(fPListOfFiles->GetDirs()); + AliQADirList* f; + while ((f = (AliQADirList*)fileiter.Next())) { TString filename = f->GetName(); - cout<GetPath(); //returns false if dir in file empty TList* keys = gDirectory->GetListOfKeys(); @@ -554,13 +504,15 @@ Bool_t AliQAHistNavigator::Crawl(TList* dir) TKey* key; while ((key = dynamic_cast (keyiter.Next()) )) { + keyname = key->GetName(); + if (keyname==oldkeyname) continue; //do not copy cycles + oldkeyname = keyname; TString classname=key->GetClassName(); if (!classname) return kFALSE; if (classname=="TDirectoryFile") { gDirectory->cd(key->GetName()); - gDirectory->pwd(); - TList* newdir = new TList(); + AliQADirList* newdir = new AliQADirList(); if (!Crawl(newdir)) { gDirectory->cd(pwd); @@ -568,46 +520,86 @@ Bool_t AliQAHistNavigator::Crawl(TList* dir) } gDirectory->cd(pwd); - newdir->SetName(key->GetName()); - dir->AddLast(newdir); + newdir->SetName(keyname); + newdir->SetParent(dir); + dir->GetDirs()->AddLast(newdir); } else { - cout<GetName()<AddLast(new TObjString(key->GetName())); + AliQADirListItem* item = new AliQADirListItem(keyname); + item->SetParent(dir); + dir->GetItems()->AddLast(item); } } return kTRUE; } +//_________________________________________________________________________ Bool_t AliQAHistNavigator::ReReadFiles() { - if (CloneDirStructure()) + //close, open and rescan the files + if (!CloneDirStructure()) + { + printf("AliQAHistNavigator::AliQAHistNavigator(): error reading files\n"); + return kFALSE; + } + fPCurrFile = (AliQADirList*)fPListOfFiles->GetDirs()->First(); + if (fPCurrFile) { - fPCurrFile = (TList*)fPListOfFiles->First(); - if (fPCurrFile) + fPCurrDetector = (AliQADirList*)fPCurrFile->GetDirs()->First(); + if (fPCurrDetector) { - fPCurrDetector = (TList*)fPCurrFile->First(); - if (fPCurrDetector) + fPCurrLevel = (AliQADirList*) fPCurrDetector->GetDirs()->First(); + if (fPCurrLevel) { - fPCurrLevel = (TList*) fPCurrDetector->First(); - if (fPCurrLevel) + fPCurrItem = (AliQADirListItem*) GetItemList()->First(); + if (fPCurrItem) { - fPCurrHistName = (TObjString*) fPCurrLevel->First(); - if (fPCurrHistName) - { - fInitOK = kTRUE; - OpenCurrentFile(); - OpenCurrentDirectory(); - } + fInitOK = kTRUE; + OpenCurrentFile(); + OpenCurrentDirectory(); } } } - } else - { - printf("AliQAHistNavigator::AliQAHistNavigator(): error reading files\n"); - return kFALSE; } return kTRUE; } +//_________________________________________________________________________ +ClassImp(AliQADirList) +//_________________________________________________________________________ +AliQADirList::AliQADirList(): + TNamed(), + fPParent(NULL), + fPItems(new TList()), + fPDirs(new TList()) +{ + //ctor +} + +//_________________________________________________________________________ +AliQADirList::~AliQADirList() +{ + //dtor + if (fPParent) delete fPParent; + delete fPItems; + delete fPDirs; +} + +//_________________________________________________________________________ +ClassImp(AliQADirListItem) +//_________________________________________________________________________ +AliQADirListItem::AliQADirListItem(const char* s): + TObjString(s), + fPParent(NULL) +{ + //ctor +} + +//_________________________________________________________________________ +AliQADirListItem::~AliQADirListItem() +{ + //dtor + if (fPParent) delete fPParent; +} + diff --git a/MONITOR/AliQAHistNavigator.h b/MONITOR/AliQAHistNavigator.h index 226ac648677..43a7480ff04 100644 --- a/MONITOR/AliQAHistNavigator.h +++ b/MONITOR/AliQAHistNavigator.h @@ -27,19 +27,53 @@ #include #include +class AliQADirList; +class AliQADirListItem; +class AliQAHistNavigator; + +class AliQADirList : public TNamed{ +public: + AliQADirList(); + virtual ~AliQADirList(); + TList* GetItems() {return fPItems;} + TList* GetDirs() {return fPDirs;} + AliQADirList* GetParent() {return fPParent;} + void SetParent(AliQADirList* l) {fPParent = l;} + +private: + AliQADirList* fPParent; //pointer to parent folder + TList* fPItems; //List of items contained in the list + TList* fPDirs; //List of dirs + AliQADirList(const AliQADirList&); // Not implemented + AliQADirList& operator=(const AliQADirList&); // Not implemented + + ClassDef(AliQADirList,999) //AliQADirListDir +}; + +class AliQADirListItem : public TObjString { +public: + AliQADirListItem(const char* s=""); + virtual ~AliQADirListItem(); + AliQADirList* GetParent() {return fPParent;} + void SetParent(AliQADirList* parent) {fPParent=parent;} + +private: + AliQADirList* fPParent; + AliQADirListItem(const AliQADirListItem&); // Not implemented + AliQADirListItem& operator=(const AliQADirListItem&); // Not implemented + + ClassDef(AliQADirListItem,999) +}; + class AliQAHistNavigator { public: - AliQAHistNavigator( Int_t run=0, Int_t rev=0 ); + AliQAHistNavigator( Int_t run=0 ); + virtual ~AliQAHistNavigator(); Bool_t GetHistogram(TH1*& hist); - Bool_t GetNextHistogram(TH1*& hist); - Bool_t GetPrevHistogram(TH1*& hist); Bool_t Next(); Bool_t Prev(); - void PrintDebugInfo(); - Bool_t DumpList(TString file="AliQAHistNavigator.conf"); - Bool_t ReadList(TString file="AliQAHistNavigator.conf"); Bool_t SetFile (TString file ); Bool_t SetFile (Int_t file ); @@ -47,27 +81,33 @@ public: Bool_t SetDetector( Int_t detector ); Bool_t SetLevel( TString type ); Bool_t SetLevel( Int_t type ); - Bool_t SetHist( TString histo ); - Bool_t SetHist( Int_t histo ); + Bool_t SetItem( TString histo ); + Bool_t SetItem( Int_t histo ); + void SetLoopAllFiles( const Bool_t s=kTRUE ) {fLoopAllFiles=s;} void SetLoopAllDetectors( const Bool_t s=kTRUE ) {fLoopAllDetectors=s;} void SetLoopAllLevels( const Bool_t s=kTRUE ) {fLoopAllLevels=s;} + TString GetDetectorName(); TString GetLevelName(); - TString GetHistName(); + TString GetItemName(); TString GetFileName(); TString GetDirName(); - TList* GetFileList() {return fPListOfFiles;} - TList* GetDetectorList() {return fPCurrFile;} - TList* GetLevelList() {return fPCurrDetector;} - TList* GetHistList() {return fPCurrLevel;} - TList* GetCurrListOfFiles() {return fPListOfFiles;} - TList* GetCurrFile() {return fPCurrFile;} - TList* GetCurrDetector() {return fPCurrDetector;} - TList* GetCurrLevel() {return fPCurrLevel;} - TObjString* GetCurrHistName() {return fPCurrHistName;} + TString GetPath(AliQADirListItem* item); + + AliQADirList* GetFileList() {return fPListOfFiles;} + AliQADirList* GetDetectorList() {return fPCurrFile;} + AliQADirList* GetLevelList() {return fPCurrDetector;} + TList* GetItemList(); + AliQADirList* GetCurrListOfFiles() {return fPListOfFiles;} + AliQADirList* GetCurrFile() {return fPCurrFile;} + AliQADirList* GetCurrDetector() {return fPCurrDetector;} + AliQADirList* GetCurrLevel() {return fPCurrLevel;} + AliQADirListItem* GetCurrItem() {return fPCurrItem;} + Bool_t InitOK() {return fInitOK;} Bool_t ReReadFiles(); + void SetExpertMode(Bool_t mode); Bool_t CloneDirStructure(); @@ -76,25 +116,32 @@ private: Bool_t OpenCurrentFile(); Bool_t OpenCurrentDirectory(); Bool_t GetListOfFiles(); - Bool_t Crawl(TList* parent); + Bool_t Crawl(AliQADirList* parent); TFile* fPFile; //pointer to current open file + TFile* fPCORRFile; //pointer to file with ntuple + TFile* fPQAResultFile; //pointer to file with AliQA object Int_t fRun; //runnumber - Int_t fCyc; //Cycle number //The state of the navigator, these help navigate the "tree" - TList* fPCurrFile; //current list holding detectors - TList* fPCurrDetector; //current list holding levels - TList* fPCurrLevel; //current list holding histograms - TObjString* fPCurrHistName; //current histogram name + AliQADirList* fPCurrFile; //current list holding detectors + AliQADirList* fPCurrDetector; //current list holding levels + AliQADirList* fPCurrLevel; //current list holding histograms + AliQADirListItem* fPCurrItem; //current histogram name - TList* fPListOfFiles; //Tree-like structure of lists within lists mirroring the layout of histogtams in files + AliQADirList* fPListOfFiles; //Tree-like structure of lists within lists mirroring the layout of histogtams in files Bool_t fLoopAllFiles; //whether to loop over all files Bool_t fLoopAllDetectors; //whether to loop over all detectors Bool_t fLoopAllLevels; //whether to loop over all levels Bool_t fInitOK; //whether there is data to navigate + Bool_t fExpertMode; //expert histogram mode + TString fExpertDirName; //expert dir name + TList* fPEmptyList; + + AliQAHistNavigator(const AliQAHistNavigator&); // Not implemented + AliQAHistNavigator& operator=(const AliQAHistNavigator&); // Not implemented ClassDef(AliQAHistNavigator,999) //AliQAHistNavigator class }; diff --git a/MONITOR/AliQAHistViewer.cxx b/MONITOR/AliQAHistViewer.cxx index f05ac70d675..203ab6c415f 100644 --- a/MONITOR/AliQAHistViewer.cxx +++ b/MONITOR/AliQAHistViewer.cxx @@ -49,9 +49,10 @@ void AliQAHistViewer::DoDrawNext() } c1->cd(i); TH1* hist; - if (!fQANavigator->GetHistogram(hist)) break; - if (hist) hist->Draw(); - else continue; + if (fQANavigator->GetHistogram(hist)) + { + if (hist) hist->Draw(); + } if (!fQANavigator->Next()) { break; @@ -84,9 +85,10 @@ void AliQAHistViewer::DoDrawPrev() } c1->cd(i); TH1* hist; - if (!fQANavigator->GetHistogram(hist)) break; - if (hist) hist->Draw(); - else continue; + if (fQANavigator->GetHistogram(hist)) + { + if (hist) hist->Draw(); + } if (!fQANavigator->Prev()) { break; @@ -104,26 +106,17 @@ void AliQAHistViewer::DoExit() //_________________________________________________________________________ AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) : + fEcan(NULL), + fQANavigator(new AliQAHistNavigator()), TGMainFrame(p, w, h), fFileListBox(NULL), fDetectorListBox(NULL), fLevelListBox(NULL), fHistListBox(NULL), + fExpertMode(NULL), fIsEmbedded(embed) { //initialize the QA navigator - fQANavigator = new AliQAHistNavigator(); - // Create the embedded canvas - fEcan = new TRootEmbeddedCanvas(0,this,800,600); - Int_t wid = fEcan->GetCanvasWindowId(); - TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid); - fEcan->AdoptCanvas(myc); - //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this, - // "EventInfo(Int_t,Int_t,Int_t,TObject*)"); - - AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft | - kLHintsExpandX | kLHintsExpandY,0,0,1,1)); - // horizontal frame with comboboxes for navigation TGHorizontalFrame *hframenav = new TGHorizontalFrame(this, 200,40); fFileListBox = new TGComboBox(hframenav); @@ -144,7 +137,22 @@ AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t e hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft)); AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5)); UpdateAllPathComboBoxes(); - // Create a horizontal frame containing two buttons + fExpertMode = new TGCheckButton(hframenav,"Expert"); + hframenav->AddFrame(fExpertMode,new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0)); + fExpertMode->SetToolTipText("Show expert histograms"); + fExpertMode->Connect("Toggled(Bool_t)", "AliQAHistViewer", this, "DoSetExpertMode(Bool_t)"); + // Create the embedded canvas + fEcan = new TRootEmbeddedCanvas(0,this,800,600); + Int_t wid = fEcan->GetCanvasWindowId(); + TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid); + fEcan->AdoptCanvas(myc); + //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this, + // "EventInfo(Int_t,Int_t,Int_t,TObject*)"); + + AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft | + kLHintsExpandX | kLHintsExpandY,0,0,1,1)); + + // Create a horizontal frame containing the buttons TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40); TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev"); prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()"); @@ -152,13 +160,14 @@ AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t e TGTextButton *next = new TGTextButton(hframebuttons, "&Next"); next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()"); hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); + AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); + if ((!fIsEmbedded)) { TGTextButton *exit = new TGTextButton(hframebuttons, "&Exit "); exit->Connect("Pressed()", "AliQAHistViewer", this, "DoExit()"); hframebuttons->AddFrame(exit, new TGLayoutHints(kLHintsRight, 5, 5, 3, 4)); } - AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); // Set a name to the main frame SetWindowName("Quality Assurance Monitoring"); @@ -199,14 +208,14 @@ void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* void AliQAHistViewer::UpdateAllPathComboBoxes() { if (!fQANavigator->InitOK()) return; - FillComboBoxWithListEntries( fFileListBox, fQANavigator->GetFileList() ); - FillComboBoxWithListEntries( fDetectorListBox, fQANavigator->GetDetectorList() ); - FillComboBoxWithListEntries( fLevelListBox, fQANavigator->GetLevelList() ); - FillComboBoxWithListEntries( fHistListBox, fQANavigator->GetHistList() ); - fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->IndexOf(fQANavigator->GetCurrFile()),kFALSE); - fDetectorListBox->Select(fQANavigator->GetCurrFile()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE); - fLevelListBox->Select(fQANavigator->GetCurrDetector()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE); - fHistListBox->Select(fQANavigator->GetCurrLevel()->IndexOf(fQANavigator->GetCurrHistName()),kFALSE); + FillComboBoxWithListEntries( fFileListBox, (TList*)fQANavigator->GetFileList()->GetDirs() ); + FillComboBoxWithListEntries( fDetectorListBox, (TList*)fQANavigator->GetDetectorList()->GetDirs() ); + FillComboBoxWithListEntries( fLevelListBox, (TList*)fQANavigator->GetLevelList()->GetDirs() ); + FillComboBoxWithListEntries( fHistListBox, (TList*)fQANavigator->GetItemList() ); + fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->GetDirs()->IndexOf(fQANavigator->GetCurrFile()),kFALSE); + fDetectorListBox->Select(fQANavigator->GetCurrFile()->GetDirs()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE); + fLevelListBox->Select(fQANavigator->GetCurrDetector()->GetDirs()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE); + fHistListBox->Select(fQANavigator->GetItemList()->IndexOf(fQANavigator->GetCurrItem()),kFALSE); } //_________________________________________________________________________ @@ -233,6 +242,13 @@ void AliQAHistViewer::DoSetLevel( Int_t s ) //_________________________________________________________________________ void AliQAHistViewer::DoSetHistogram( Int_t s ) { - fQANavigator->SetHist(s); + fQANavigator->SetItem(s); + DoDrawNext(); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoSetExpertMode(Bool_t mode) +{ + fQANavigator->SetExpertMode(mode); DoDrawNext(); } diff --git a/MONITOR/AliQAHistViewer.h b/MONITOR/AliQAHistViewer.h index 37cfd8f0a66..4f060930c7b 100644 --- a/MONITOR/AliQAHistViewer.h +++ b/MONITOR/AliQAHistViewer.h @@ -37,7 +37,10 @@ private: TGComboBox *fDetectorListBox; //drop down menun TGComboBox *fLevelListBox; //drop down menu TGComboBox *fHistListBox; //drop down menu + TGCheckButton *fExpertMode;// expertmode Bool_t fIsEmbedded; //whether the window is embedded somewhere + AliQAHistViewer(const AliQAHistViewer&); // Not implemented + AliQAHistViewer& operator=(const AliQAHistViewer&); // Not implemented public: AliQAHistViewer(const TGWindow *p, UInt_t w=500, UInt_t h=500, Bool_t embed=kFALSE); @@ -49,6 +52,7 @@ public: void DoSetDetector(Int_t s); void DoSetLevel(Int_t s); void DoSetHistogram(Int_t s); + void DoSetExpertMode(Bool_t mode=kTRUE); void FillComboBoxWithListEntries( TGComboBox* box, const TList* list ); void UpdateAllPathComboBoxes(); diff --git a/MONITOR/MONITORLinkDef.h b/MONITOR/MONITORLinkDef.h index 550461b1acc..bc189392f99 100644 --- a/MONITOR/MONITORLinkDef.h +++ b/MONITOR/MONITORLinkDef.h @@ -27,5 +27,7 @@ #pragma link C++ class AliQAHistNavigator+; #pragma link C++ class AliQAHistViewer+; +#pragma link C++ class AliQADirList+; +#pragma link C++ class AliQADirListItem+; #endif -- 2.39.3