Fixing bugs in Event Display
authorjniedzie <jeremi.niedziela@cern.ch>
Wed, 29 Oct 2014 08:42:50 +0000 (09:42 +0100)
committerjniedzie <jeremi.niedziela@cern.ch>
Wed, 29 Oct 2014 12:21:27 +0000 (13:21 +0100)
EVE/EveBase/AliEveConfigManager.cxx
EVE/EveBase/AliEveConfigManager.h
EVE/EveBase/AliEveEventManager.cxx
EVE/EveBase/AliEveEventManager.h
EVE/EveBase/AliEveEventManagerEditor.cxx
EVE/EveBase/AliEveEventManagerEditor.h
EVE/alieve_main/alieve_main.cxx
EVE/macros/alieve_online_new.C
MONITOR/alistoragemanager/setupStorageDatabase.sh [new file with mode: 0755]

index 2bae475..03e1d9e 100644 (file)
@@ -186,21 +186,13 @@ AliEveConfigManager::AliEveConfigManager() :
                         this, "AliEvePopupHandler(Int_t)");
 
   //Storage Manager:
-  fStoragePopup = new TGPopupMenu(gClient->GetRoot());
 #ifdef ZMQ
-//  fStoragePopup->AddEntry("&List events",kStorageListEvents);
-  fStoragePopup->AddEntry("&Mark event",kStorageMarkEvent);
-    
     gEve->GetBrowser()->StartEmbedding(0);
     AliStorageAdministratorPanelListEvents* fListEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
     gEve->GetBrowser()->StopEmbedding("List");
     
     fListEventsTab->Connect("SelectedEvent()","AliEveConfigManager",this,"SetEventInEventManager()");
-    
 #endif
-
-  fStoragePopup->Connect("Activated(Int_t)","AliEveConfigManager",
-                        this, "AliEvePopupHandler(Int_t)");
   
   fLoadCheck = kFALSE;
 
@@ -210,7 +202,6 @@ AliEveConfigManager::AliEveConfigManager() :
   ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
   mBar->AddPopup("&Tools", fAnalysisPopup, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
     ((TGCompositeFrame*)mBar->GetParent()->GetParent())->Layout();
-   mBar->AddPopup("&Storage Manager",fStoragePopup,new TGLayoutHints(kLHintsTop | kLHintsLeft,0,4,0,0));
   
   gEve->GetBrowser()->GetTopMenuFrame()->Layout();
 #else
@@ -1099,30 +1090,19 @@ void AliEveConfigManager::SetEventInEventManager()
 
 void AliEveConfigManager::StorageManagerChangedState(int state)
 {
-#ifdef ZMQ
-
-  AliEveEventManager *manager = AliEveEventManager::GetMaster();
-  AliStorageAdministratorPanelListEvents* fListEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
-
-  if (manager->IsOnlineMode()) {
-    if (state == 0)// storage manager is down
-      {
-        fStoragePopup->DisableEntry(kStorageMarkEvent);
-       fListEventsTab->SetOfflineMode(kTRUE);
-
-      }
-    else if(state == 1)// storage manager is alive
-      {
-        fStoragePopup->EnableEntry(kStorageMarkEvent);
-       fListEventsTab->SetOfflineMode(kFALSE);
-
-      }
-  }
-#endif
-}
-
-void AliEveConfigManager::DisableStoragePopup(){
-  fStoragePopup->DisableEntry(kStorageMarkEvent);
+    AliEveEventManager *manager = AliEveEventManager::GetMaster();
+    AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
+    
+    if (manager->IsOnlineMode()) {
+        if (state == 0)// storage manager is down
+        {
+            listEventsTab->SetOfflineMode(kTRUE);
+        }
+        else if(state == 1)// storage manager is alive
+        {
+            listEventsTab->SetOfflineMode(kFALSE);
+        }
+    }
 }
 
 
index 4300945..9ba97a3 100644 (file)
@@ -29,7 +29,6 @@ public:
     void AliEvePopupHandler(Int_t id);
     void SetEventInEventManager();
     void StorageManagerChangedState(int state);
-    void DisableStoragePopup();
 
     void ConnectEventManagerSignals();
     
index bed6b8b..844fbf9 100644 (file)
@@ -59,6 +59,7 @@
 #include <TEnv.h>
 #include <TString.h>
 #include <TMap.h>
+#include <TROOT.h>
 
 #ifdef ZMQ
 #include "AliStorageEventManager.h"
@@ -138,12 +139,13 @@ AliEveEventManager::AliEveEventManager(const TString& name, Int_t ev) :
     fPEventSelector(0),
     fSubManagers (0),
     fAutoLoadTimerRunning(kFALSE),
+    fMutex(new TMutex()),
     fgSubSock(EVENTS_SERVER_SUB),
     fEventInUse(1),
     fWritingToEventIndex(0),
     fIsNewEventAvaliable(false),
-    fStorageDown(false)
-
+    fStorageDown(false),
+    fFinished(false)
 {
     // Constructor with event-id.
                
@@ -178,15 +180,32 @@ AliEveEventManager::AliEveEventManager(const TString& name, Int_t ev) :
 AliEveEventManager::~AliEveEventManager()
 {
     // Destructor.
+    
+    fFinished = true;
+    
+    if(fEventListenerThread)
+    {
+        fEventListenerThread->Kill();
+        delete fEventListenerThread;
+    }
+    if(fStorageManagerWatcherThread)
+    {
+        fStorageManagerWatcherThread->Kill();
+        delete fStorageManagerWatcherThread;
+    }
+    
+    
     fAutoLoadTimer->Stop();
     fAutoLoadTimer->Disconnect("Timeout");
+    fAutoLoadTimer->Disconnect("AutoLoadNextEvent");
 
     AliEveEventManager *manager = AliEveEventManager::GetCurrent();
     manager->Disconnect("StorageManagerOk");
     manager->Disconnect("StorageManagerDown");
 
     if(fSubManagers){delete fSubManagers;}
-
+    if(fMutex){delete fMutex;}
+    
     if (fIsOpen)
     {
         Close();
@@ -214,30 +233,29 @@ void AliEveEventManager::GetNextEvent()
     fCurrentTree[1]=0;
     AliESDEvent *tmpEvent = NULL;
     
-    while(1)
+    while(!fFinished)
     {
         tmpEvent = eventManager->GetEvent(EVENTS_SERVER_SUB);
         if(tmpEvent)
-       {
+        {
             if(tmpEvent->GetRunNumber()>=0)
-           {
-                fMutex.Lock();
+            {
+                fMutex->Lock();
                 if(fEventInUse == 0){fWritingToEventIndex = 1;}
                 else if(fEventInUse == 1){fWritingToEventIndex = 0;}
                 cout<<"Received new event"<<endl;
                 if(fCurrentEvent[fWritingToEventIndex])
-               {
+                {
                     delete fCurrentEvent[fWritingToEventIndex];
                     fCurrentEvent[fWritingToEventIndex]=0;
-               }
+                }
                 fCurrentEvent[fWritingToEventIndex] = tmpEvent;
                 fIsNewEventAvaliable = true;
-               NewEventLoaded();
-                fMutex.UnLock();
-           }
-
-      }
-  }
+                NewEventLoaded();
+                fMutex->UnLock();
+            }
+        }
+    }
 #endif
 }
 
@@ -253,7 +271,7 @@ void AliEveEventManager::CheckStorageStatus()
     struct clientRequestStruct *request = new struct clientRequestStruct;
     request->messageType = REQUEST_CONNECTION;
     
-    while (1)
+    while (!fFinished)
     {
         if(eventManager->Send(request,CLIENT_COMMUNICATION_REQ,5000))
         {
@@ -265,8 +283,7 @@ void AliEveEventManager::CheckStorageStatus()
         {
             StorageManagerDown();
             cout<<"WARNING -- Storage Manager is DOWN!!"<<endl;
-           fStorageDown = kTRUE;
-
+            fStorageDown = kTRUE;
         }
         sleep(1);
     }
@@ -893,7 +910,7 @@ void AliEveEventManager::GotoEvent(Int_t event)
          AliESDEvent *resultEvent = NULL;
             
          eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
-         fMutex.Lock();
+         fMutex->Lock();
             
          // send request and receive event:
          eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
@@ -913,7 +930,7 @@ void AliEveEventManager::GotoEvent(Int_t event)
              if(event==2){cout<<"\n\nWARNING -- No next event is avaliable.\n\n"<<endl;}
           }
             
-         fMutex.UnLock();
+         fMutex->UnLock();
         }
       else
       {
@@ -926,7 +943,7 @@ void AliEveEventManager::GotoEvent(Int_t event)
          eventManager->CreateSocket(SERVER_COMMUNICATION_REQ);
          AliESDEvent *resultEvent = NULL;
             
-         fMutex.Lock();
+         fMutex->Lock();
          eventManager->Send(requestMessage,SERVER_COMMUNICATION_REQ);
          resultEvent = eventManager->GetEvent(SERVER_COMMUNICATION_REQ);
             
@@ -938,7 +955,7 @@ void AliEveEventManager::GotoEvent(Int_t event)
              SetEvent(0,0,resultEvent,0);
           }
          else{cout<<"\n\nWARNING -- The most recent event is not avaliable.\n\n"<<endl;}
-         fMutex.UnLock();
+         fMutex->UnLock();
       }
 #endif 
 
@@ -1128,7 +1145,7 @@ void AliEveEventManager::NextEvent()
 #ifdef ZMQ
         if(fIsNewEventAvaliable)
         {
-            fMutex.Lock();
+            fMutex->Lock();
             if(fWritingToEventIndex == 0) fEventInUse = 0;
             else if(fWritingToEventIndex == 1) fEventInUse = 1;
             
@@ -1141,17 +1158,17 @@ void AliEveEventManager::NextEvent()
                     DestroyElements();
                     InitOCDB(fCurrentEvent[fEventInUse]->GetRunNumber());
                     SetEvent(0,0,fCurrentEvent[fEventInUse],0);
-
+                    
                 }
             }
             fIsNewEventAvaliable = false;
-            fMutex.UnLock();
+            fMutex->UnLock();
         }
         else
-       {
-         cout<<"No new event is avaliable."<<endl;
-         NoEventLoaded();
-       }
+        {
+            cout<<"No new event is avaliable."<<endl;
+            NoEventLoaded();
+        }
 #endif
     }
     else if ((fESDTree!=0) || (fHLTESDTree!=0))
index a510d31..34cae3b 100644 (file)
@@ -229,13 +229,13 @@ private:
     static AliEveEventManager* fgMaster;
     static AliEveEventManager* fgCurrent;
 
-    static void* DispatchEventListener(void *arg){static_cast<AliEveEventManager*>(arg)->GetNextEvent();}
-    static void* DispatchStorageManagerWatcher(void *arg){static_cast<AliEveEventManager*>(arg)->CheckStorageStatus();}
+    static void* DispatchEventListener(void *arg){static_cast<AliEveEventManager*>(arg)->GetNextEvent();return nullptr;}
+    static void* DispatchStorageManagerWatcher(void *arg){static_cast<AliEveEventManager*>(arg)->CheckStorageStatus();return nullptr;}
     void GetNextEvent();
     void CheckStorageStatus();
     TThread *fEventListenerThread;
     TThread *fStorageManagerWatcherThread;
-    TMutex fMutex;
+    TMutex *fMutex;
     AliESDEvent *fCurrentEvent[2];
     TTree *fCurrentTree[2];
     int fEventInUse;
@@ -245,6 +245,7 @@ private:
 
     Bool_t fOnlineMode;
     Bool_t fStorageDown;
+    Bool_t fFinished;
 
     AliEveEventManager(const AliEveEventManager&);            // Not implemented
     AliEveEventManager& operator=(const AliEveEventManager&); // Not implemented
index afd682d..3f2bdbf 100644 (file)
@@ -155,7 +155,12 @@ AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
     b->Connect("Clicked()", cls, this, "DoLastEvent()");
     fMarkEvent = b = MkTxtButton(f, "Mark", width);
     b->Connect("Clicked()", cls, this, "DoMarkEvent()");
-
+      fRestartReco = b = MkTxtButton(f, "Restart reco", 2*width);
+      b->Connect("Clicked()", cls, this, "DoRestartReco()");
+      fRestartManager = b = MkTxtButton(f, "Restart manager", 2*width);
+      b->Connect("Clicked()", cls, this, "DoRestartManager()");
+      
+      
     MkLabel(f, "||", 0, 8, 8);
 
     fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
@@ -239,9 +244,11 @@ void AliEveEventManagerWindow::DoNextEvent()
   // Load next event
   // fM->NextEvent();
   if (fM->IsOnlineMode()) {
+      cout<<"next event, online node"<<endl;
     fM->GotoEvent(2);
   }
   else {
+      cout<<"next event, offline mode"<<endl;
     fM->GotoEvent((Int_t) fEventId->GetNumber()+1);
   }
 }
@@ -261,6 +268,19 @@ void AliEveEventManagerWindow::DoMarkEvent()
 }
 
 //______________________________________________________________________________
+void AliEveEventManagerWindow::DoRestartReco()
+{
+    // Kill reconstruction server
+    gSystem->Exec("ssh -n -f edis@pcald39fix \"killall alieventserver\"");
+}
+
+void AliEveEventManagerWindow::DoRestartManager()
+{
+    // Kill storage manager
+    gSystem->Exec("ssh -n -f edis@pcald39fix \"killall alistorage\"");
+}
+
+//______________________________________________________________________________
 void AliEveEventManagerWindow::DoSetEvent()
 {
   // Set current event
@@ -320,7 +340,6 @@ void AliEveEventManagerWindow::Update(int state)
   if (!fM->IsOnlineMode()) {
 
       listEventsTab->SetOfflineMode(kTRUE);
-      configManager->DisableStoragePopup();
 
       fFirstEvent->SetEnabled(!autoLoad);
       fPrevEvent ->SetEnabled(!autoLoad);
@@ -421,7 +440,6 @@ void AliEveEventManagerWindow::StorageManagerChangedState(int state)
         fPrevEvent->SetEnabled(kFALSE);
         fFirstEvent->SetEnabled(kFALSE);
        listEventsTab->SetOfflineMode(kTRUE);
-       configManager->DisableStoragePopup();
        fEventId->SetState(kFALSE);
       }
     else if(state == 1)
index 4c2bc5e..d5dd612 100644 (file)
@@ -74,6 +74,8 @@ public:
   void DoNextEvent();
   void DoLastEvent();
   void DoMarkEvent();
+    void DoRestartReco();
+    void DoRestartManager();
 
   void DoSetEvent();
 
@@ -87,13 +89,15 @@ public:
 
 protected:
   AliEveEventManager   *fM;            // Model object.
-
-  TGTextButton         *fFirstEvent;   // Go to first event
-  TGTextButton         *fPrevEvent;    // Go to prev event
-  TGTextButton         *fNextEvent;    // Go to next event
-  TGTextButton         *fLastEvent;    // Go to last event
-  TGTextButton         *fRefresh;      // Refresh event-file state
-  TGTextButton         *fMarkEvent;    // Mark current event
+    
+    TGTextButton         *fFirstEvent;   // Go to first event
+    TGTextButton         *fPrevEvent;    // Go to prev event
+    TGTextButton         *fNextEvent;    // Go to next event
+    TGTextButton         *fLastEvent;    // Go to last event
+    TGTextButton         *fRefresh;      // Refresh event-file state
+    TGTextButton         *fMarkEvent;    // Mark current event
+    TGTextButton         *fRestartReco;    // Restart reconstruction server
+    TGTextButton         *fRestartManager; // Restart storage manager
 
   TGNumberEntry        *fEventId;      // Display/edit current event id
   TGLabel              *fInfoLabel;    // Display last available event id
index 868e487..242d027 100644 (file)
 #include <EveBase/AliEveApplication.h>
 #include <EveBase/AliEveMainWindow.h>
 
+
+#include <iostream>
+using namespace std;
+
 int main(int argc, char **argv)
 {
     static const TEveException kEH("alieve::main");
@@ -108,17 +112,27 @@ int main(int argc, char **argv)
         AliErrorGeneral("alieve_main",exc.Data());
     }
 
-    app->Connect( "TEveBrowser", "CloseWindow()", "TRint", app, "Terminate(=0)");
-
+    app->Connect("TEveBrowser", "CloseWindow()", "TApplication", app, "Kill()");
+    
     app->Run(kTRUE);
 
+    cout<<"Terminate"<<endl;
+    
+    app->Terminate(0);
+    
+    cout<<"unmap"<<endl;
+    
     if (gEve && gEve->GetBrowser())    gEve->GetBrowser()->UnmapWindow();
 
+    cout<<"teve terminate"<<endl;
+    
     TEveManager::Terminate();
-    app->Terminate(0);
 
+    cout<<"delete"<<endl;
+    
     if(gEve) {delete gEve; gEve = 0;}
 
-
+    cout<<"return"<<endl;
+    
     return 0;
 }
index b9f7443..83eb3c2 100644 (file)
@@ -205,7 +205,9 @@ void alieve_online_on_new_event()
        if (gCenterProjectionsAtPrimaryVertex)
                mv->SetCenterMuon(x[0], x[1], x[2]);
        mv->ImportEventMuon(top);
- // Register image to amore.
+    /*
+    // Register image to amore.
   // const TString pichost("aldaqacrs3");
   const TString pichost(gEnv->GetValue("AliEve.imageDumpHost", "localhost"));
   TTimeStamp now;
@@ -243,8 +245,13 @@ void alieve_online_on_new_event()
     if (++g_pic_id >= g_pic_max)
       g_pic_id = 0;
     g_pic_prev.Set();
+<<<<<<< HEAD
   }
   AliSysInfo::AddStamp("on_new_event_end");
+=======
+  }*/
+       AliSysInfo::AddStamp("on_new_event_end");
+>>>>>>> Fixing bugs in Event Display
 }
 
 void alieve_init_import_macros()
diff --git a/MONITOR/alistoragemanager/setupStorageDatabase.sh b/MONITOR/alistoragemanager/setupStorageDatabase.sh
new file mode 100755 (executable)
index 0000000..2bf3a9b
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+HOST="localhost"   # IP of machine on which mysql database is located
+PORT="5055"
+DATABASE="storage"
+USER="storage"
+PASS="storage123"
+TABLE="events"
+STORAGE_PATH="/Users/Jerus/storedFiles"
+MAX_SIZE="30000000"
+MAX_OCCUPATION="80"
+REMOVE_PERCENT="60"
+EVENTS_IN_FILE="5"
+EVENT_SERVER="pcald39fix"   # IP of machine running alieventserver
+EVENT_SERVER_PORT="5024"
+STORAGE_SERVER="pcald39fix"      # IP of machine running alistorage
+STORAGE_SERVER_PORT="5066"      # server thread communication port
+STORAGE_CLIENT_PORT="5088"      # client thread communication port
+XML_SERVER_PORT="5099"          # server of xml files
+mysql -u root -pdaq -e "create database if not exists $DATABASE;"
+mysql -u root -pdaq -e "grant ALL PRIVILEGES on $DATABASE.* to '$USER'@'$HOST' identified by '$PASS';"
+mysql -u root -pdaq -e "use $DATABASE;"
+mysql -u root -pdaq -e "CREATE TABLE IF NOT EXISTS $DATABASE.$TABLE(\
+run_number int(6) NOT NULL,\
+event_number int(6) NOT NULL,\
+system text(7) DEFAULT NULL,\
+multiplicity int(5) DEFAULT NULL,\
+permanent tinyint(1) DEFAULT NULL,\
+file_path text(100) DEFAULT NULL,\
+PRIMARY KEY(run_number,event_number));"
+
+echo "-----------------------------"
+echo "Databases successfuly created"
+echo "-----------------------------"
\ No newline at end of file