Dixed a crash when no proper files/data to display (Mikolaj)
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 18 Aug 2008 15:30:33 +0000 (15:30 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 18 Aug 2008 15:30:33 +0000 (15:30 +0000)
MONITOR/AliQAHistNavigator.cxx
MONITOR/AliQAHistNavigator.h
MONITOR/AliQAHistViewer.cxx

index fc90b70..d209bd4 100644 (file)
@@ -37,33 +37,10 @@ AliQAHistNavigator::AliQAHistNavigator(Int_t run, Int_t rev):
     fPListOfFiles( new TList() ),
     fLoopAllFiles(kTRUE),
     fLoopAllDetectors(kTRUE),
-    fLoopAllLevels(kTRUE)
+    fLoopAllLevels(kTRUE),
+    fInitOK(kFALSE)
 {
-    if (CloneDirStructure())
-    {
-        fPCurrFile = (TList*)fPListOfFiles->First();
-        if (fPCurrFile)
-        {
-            fPCurrDetector = (TList*)fPCurrFile->First();
-            if (fPCurrDetector)
-            {
-                fPCurrLevel = (TList*) fPCurrDetector->First();
-                if (fPCurrLevel)
-                {
-                    fPCurrHistName = (TObjString*) fPCurrLevel->First();
-                    if (fPCurrHistName)
-                    {
-                        OpenCurrentFile();
-                        OpenCurrentDirectory();
-                    }
-                }
-            }
-        }
-    } else
-    {
-        printf("AliQAHistNavigator::AliQAHistNavigator(): error reading files\n");
-    }
-    
+    ReReadFiles();
 }
 
 //_________________________________________________________________________
@@ -87,7 +64,15 @@ Bool_t AliQAHistNavigator::GetNextHistogram(TH1*& hist)
 //_________________________________________________________________________
 Bool_t AliQAHistNavigator::GetHistogram(TH1*& hist)
 {
-    gDirectory->GetObject(GetFileName()+":"+GetDirName()+"/"+GetHistName(),hist);
+    TString file = GetFileName();
+    TString dir = GetDirName();
+    TString histname = GetHistName();
+    if (file==""||dir==""||histname=="") 
+    {
+        printf("GetHistogram: nothing to fetch...\n");
+        return kFALSE;
+    }
+    gDirectory->GetObject(file+":"+dir+"/"+histname,hist);
     if (!hist)
     {
         printf("GetHistogram: null pointer returned by gDirectory\n");
@@ -117,7 +102,7 @@ Bool_t AliQAHistNavigator::GetPrevHistogram(TH1*& hist)
 //_________________________________________________________________________
 Bool_t AliQAHistNavigator::Next()
 {
-    if (!fPCurrHistName) return kFALSE;
+    if (!fPCurrHistName||!fPCurrFile||!fPCurrDetector||!fPCurrLevel) return kFALSE;
     if (!(fPCurrHistName=(TObjString*)fPCurrLevel->After(fPCurrHistName)))
     {
         if (!(fPCurrLevel=(TList*)fPCurrDetector->After(fPCurrLevel)))
@@ -373,7 +358,10 @@ TString AliQAHistNavigator::GetFileName()
 //_________________________________________________________________________
 TString AliQAHistNavigator::GetDirName()
 {
-    TString dir = "/"+ GetDetectorName()+"/"+GetLevelName();
+    TString detector = GetDetectorName();
+    TString level = GetLevelName();
+    if (detector==""||level=="") return "";
+    TString dir = "/"+ detector +"/"+ level;
     return dir;
 }
 
@@ -591,3 +579,35 @@ Bool_t AliQAHistNavigator::Crawl(TList* dir)
     }
     return kTRUE;
 }
+
+Bool_t AliQAHistNavigator::ReReadFiles()
+{
+    if (CloneDirStructure())
+    {
+        fPCurrFile = (TList*)fPListOfFiles->First();
+        if (fPCurrFile)
+        {
+            fPCurrDetector = (TList*)fPCurrFile->First();
+            if (fPCurrDetector)
+            {
+                fPCurrLevel = (TList*) fPCurrDetector->First();
+                if (fPCurrLevel)
+                {
+                    fPCurrHistName = (TObjString*) fPCurrLevel->First();
+                    if (fPCurrHistName)
+                    {
+                        fInitOK = kTRUE;
+                        OpenCurrentFile();
+                        OpenCurrentDirectory();
+                    }
+                }
+            }
+        }
+    } else
+    {
+        printf("AliQAHistNavigator::AliQAHistNavigator(): error reading files\n");
+        return kFALSE;
+    }
+    return kTRUE;
+}
+
index 58b6847..226ac64 100644 (file)
@@ -66,6 +66,8 @@ public:
     TList* GetCurrDetector() {return fPCurrDetector;}
     TList* GetCurrLevel() {return fPCurrLevel;}
     TObjString* GetCurrHistName() {return fPCurrHistName;}
+    Bool_t InitOK() {return fInitOK;}
+    Bool_t ReReadFiles();
 
     Bool_t CloneDirStructure();
 
@@ -91,6 +93,8 @@ private:
     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
 
     ClassDef(AliQAHistNavigator,999)     //AliQAHistNavigator class
 };
index e07dc0b..f05ac70 100644 (file)
@@ -198,14 +198,15 @@ void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList*
 //_________________________________________________________________________
 void AliQAHistViewer::UpdateAllPathComboBoxes()
 {
-   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);
+    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);
 }
 
 //_________________________________________________________________________