Event Server can now run without GUI.
authorjniedzie <jeremi.niedziela@cern.ch>
Wed, 24 Sep 2014 12:59:31 +0000 (14:59 +0200)
committerjniedzie <jeremi.niedziela@cern.ch>
Wed, 24 Sep 2014 13:03:01 +0000 (15:03 +0200)
EVE/alieve_main/alieve_main.cxx
MONITOR/CMakelibMONITORzmq.pkg
MONITOR/MONITORzmqLinkDef.h
MONITOR/alieventserver/AliEventServerReconstruction.cxx
MONITOR/alieventserver/AliEventServerReconstruction.h
MONITOR/alieventserver/AliEventServerUtil.h
MONITOR/alieventserver/AliEventServerWindow.cxx
MONITOR/alieventserver/alieventserver.cxx
MONITOR/alistoragemanager/AliStorageEventManager.cxx

index 6b7a668..868e487 100644 (file)
@@ -88,7 +88,7 @@ int main(int argc, char **argv)
 
     // make sure logger is instantiated
     AliLog::GetRootLogger();
-    TRint  *app = new TRint("App", &argc, argv);
+    TApplication  *app = new TRint("App", &argc, argv);
 
 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,25,4) || defined XXX_LATEST_ROOT
     // Waiting for update by Pawel. Now GED in ROOT is better again :)
index 4ca5d74..f848a0c 100644 (file)
@@ -10,7 +10,7 @@ set ( SRCS
     alistoragemanager/AliStorageDatabase.cxx
     alieventserver/AliEventServerReconstruction.cxx
     alieventserver/AliEventServerWindow.cxx
-
+    alieventserver/AliEventServer.cxx
 )
 
 string ( REPLACE ".cxx" ".h" CINTHDRS "${SRCS}" )
index 2eab316..a4479d5 100644 (file)
@@ -20,5 +20,6 @@
 #pragma link C++ class AliStorageAdministratorPanelSetStorageParams+;
 #pragma link C++ class AliEventServerReconstruction+;
 #pragma link C++ class AliEventServerWindow+;
+#pragma link C++ class AliEventServer+;
 
 #endif
index 60199a0..ed93a2e 100644 (file)
@@ -44,13 +44,15 @@ AliEventServerReconstruction::AliEventServerReconstruction()
          fIsListenning(kFALSE),
          fSettings(0),
          fHost(0),
-         fRecoThread(0)
+         fRecoThread(0),
+         fRecoIsRunning(false)
 {}
 
 AliEventServerReconstruction::~AliEventServerReconstruction()
 {
        Close();
        if(fSettings){delete fSettings;fSettings=0;}
+       if(fAliReco){delete fAliReco;fAliReco=0;}
 }
 
 void AliEventServerReconstruction::Close()
@@ -67,27 +69,20 @@ Bool_t AliEventServerReconstruction::StartReconstruction(Int_t run, const char*
 {
        fCurrentRunId = run;
 
-       StopReconstruction();
-
        // re-read settings
-       if(fSettings){delete fSettings;}
+       if(fSettings){delete fSettings;fSettings=0;}
        fSettings = new TEnv(AliEventServerUtil::GetPathToServerConf());
        
-       TString recoBaseDir = fSettings->GetValue("server.saveRecoDir",
-                                                 DEFAULT_SERVER_SAVE_RECO_DIR);
+       TString recoBaseDir = fSettings->GetValue("server.saveRecoDir",DEFAULT_SERVER_SAVE_RECO_DIR);
        
        // Create directories and logfile
-       TString logFile = Form("%s/log/run%d.log",
-                              recoBaseDir.Data(),
-                              run);
-       
+       TString logFile = Form("%s/log/run%d.log",recoBaseDir.Data(),run);
        Info("DoStart","Reconstruction log will be written to %s",logFile.Data());
        if( gSystem->RedirectOutput(logFile.Data())!=0)
        {
                printf(Form("AliRecoServer::StartReconstruction [] Error while trying to redirect output to [%s]. Exiting...", logFile.Data()) );
                return kFALSE;
        }
-
        gSystem->cd(recoBaseDir.Data());
 
        TString gdcs;
@@ -98,8 +93,7 @@ Bool_t AliEventServerReconstruction::StartReconstruction(Int_t run, const char*
 
        // Create Reco and Reco Thread
        SetupReco(input);
-       fAliReco->InitRun(input);
-
+       
        fHost = (const char*)Form("%s:%d", fSettings->GetValue("server.host", DEFAULT_SERVER_HOST), fSettings->GetValue("server.port", DEFAULT_SERVER_PORT));
        
        fRecoThread = new TThread("AliEventServerReconstruction",
@@ -107,19 +101,43 @@ Bool_t AliEventServerReconstruction::StartReconstruction(Int_t run, const char*
                               (void*)this);
        fRecoThread->Run();
        fIsListenning = kTRUE;
+       fRecoIsRunning=true;
 
        return true;
 }
 
 void AliEventServerReconstruction::StopReconstruction()
 {
-       if(!fRecoThread) return;
-       delete fRecoThread;
-       fRecoThread=0;
-       Emit("Stopped()");
-  
-       if(fAliReco){delete fAliReco;fAliReco=0;}
-       if(fCDBmanager){delete fCDBmanager;fCDBmanager=0;}
+  cout<<"Reco server -- StopPeconstruction() called"<<endl;
+  if(!fRecoIsRunning)
+    {
+      cout<<"Reco is not running. Returning"<<endl;
+      return;
+    }
+  if(!fRecoThread) 
+    {
+      cout<<"Reco server -- no thread. Returning"<<endl;
+      return;
+    }
+  cout<<"killing thread"<<endl;
+  fRecoThread->Kill();
+  cout<<"thread killed"<<endl;
+  delete fRecoThread;
+  fRecoThread=0;
+  cout<<"Reco server -- thread removed"<<endl;
+  // Emit("Stopped()");
+
+  cout<<"Reco server -- terminating reconstruction"<<endl;     
+  fAliReco->SlaveTerminate();
+  if (fAliReco->GetAbort() != TSelector::kContinue) return;
+  fAliReco->Terminate();
+  if (fAliReco->GetAbort() != TSelector::kContinue) return; 
+       
+  if(fAliReco){delete fAliReco;fAliReco=0;}
+  cout<<"Reco server -- deleting CDBManager"<<endl;
+  if(fCDBmanager){delete fCDBmanager;fCDBmanager=0;}
+  cout<<"Reco server -- recontruction stopped"<<endl;
+  fRecoIsRunning=false;
 }
 
 void AliEventServerReconstruction::ReconstructionHandle()
@@ -165,7 +183,9 @@ void AliEventServerReconstruction::ReconstructionHandle()
        fAliReco->SlaveTerminate();
        if (fAliReco->GetAbort() != TSelector::kContinue) return;
        fAliReco->Terminate();
-       if (fAliReco->GetAbort() != TSelector::kContinue) return;  
+       if (fAliReco->GetAbort() != TSelector::kContinue) return;
+       StopReconstruction();
+       fRecoIsRunning=false;
 }
 
 Int_t AliEventServerReconstruction::RetrieveGRP(UInt_t run, TString &gdc)
@@ -212,26 +232,29 @@ void AliEventServerReconstruction::SetupReco(const char* input)
        fCDBmanager->SetSpecificStorage(fSettings->GetValue( "cdb.specificStoragePath3", DEFAULT_CDB_SPEC_STORAGE_PATH3),  
                                    fSettings->GetValue( "cdb.specificStorageValue3", DEFAULT_CDB_SPEC_STORAGE_VALUE3));
   
-       /* Reconstruction settings */
-       if(fAliReco) delete fAliReco;
-  
-       AliReconstruction* rec = new AliReconstruction;
-       
+       /* Reconstruction settings */  
+       if(!fAliReco)fAliReco = new AliReconstruction();
+
        // QA options
-       rec->SetRunQA(fSettings->GetValue( "qa.runDetectors", DEFAULT_QA_RUN));
-       rec->SetRunGlobalQA(fSettings->GetValue( "qa.runGlobal", DEFAULT_QA_RUN_GLOBAL));
-       rec->SetQARefDefaultStorage(fSettings->GetValue( "qa.defaultStorage",DEFAULT_QAREF_STORAGE)) ;
-       rec->SetRunPlaneEff(fSettings->GetValue( "reco.runPlaneEff", DEFAULT_RECO_RUN_PLANE_EFF));
+       //rec->SetRunQA(fSettings->GetValue( "qa.runDetectors", DEFAULT_QA_RUN));
+       //rec->SetRunGlobalQA(fSettings->GetValue( "qa.runGlobal", DEFAULT_QA_RUN_GLOBAL));
+       fAliReco->SetQARefDefaultStorage(fSettings->GetValue( "qa.defaultStorage",DEFAULT_QAREF_STORAGE)) ;
+       //rec->SetRunPlaneEff(fSettings->GetValue( "reco.runPlaneEff", DEFAULT_RECO_RUN_PLANE_EFF));
+
+       fAliReco->SetRunQA(":");
+       fAliReco->SetRunGlobalQA(false);
+       fAliReco->SetRunPlaneEff(false);
 
        // AliReconstruction settings
-       rec->SetWriteESDfriend(fSettings->GetValue( "reco.writeESDfriend", DEFAULT_RECO_WRITE_ESDF));
-       rec->SetWriteAlignmentData(fSettings->GetValue( "reco.writeAlignment",DEFAULT_RECO_WRITE_ALIGN));
-       rec->SetInput(input); // reconstruct data from this input
-       rec->SetRunReconstruction(fSettings->GetValue( "reco.detectors", DEFAULT_RECO_DETECTORS));
-       rec->SetUseTrackingErrorsForAlignment("ITS"); //-- !should be set from conf file!
+       fAliReco->SetWriteESDfriend(fSettings->GetValue( "reco.writeESDfriend", DEFAULT_RECO_WRITE_ESDF));
+       fAliReco->SetWriteAlignmentData(fSettings->GetValue( "reco.writeAlignment",DEFAULT_RECO_WRITE_ALIGN));
+       fAliReco->SetInput(input); // reconstruct data from this input
+       fAliReco->SetRunReconstruction(fSettings->GetValue( "reco.detectors", DEFAULT_RECO_DETECTORS));
+       fAliReco->SetUseTrackingErrorsForAlignment("ITS"); //-- !should be set from conf file!
 
        // switch off cleanESD
-       rec->SetCleanESD(fSettings->GetValue( "reco.cleanESD",DEFAULT_RECO_CLEAN_ESD));
+       fAliReco->SetCleanESD(fSettings->GetValue( "reco.cleanESD",DEFAULT_RECO_CLEAN_ESD));
 
-       fAliReco = rec;
+       // init reco for given run
+       fAliReco->InitRun(input);
 }
index 1feee67..1c78aa1 100644 (file)
@@ -48,6 +48,7 @@ private:
        TEnv *fSettings;
        TString fHost;
        TThread *fRecoThread;
+       bool fRecoIsRunning;
 
        AliEventServerReconstruction(const AliEventServerReconstruction&);
        AliEventServerReconstruction& operator=(const AliEventServerReconstruction&);
index 96b5303..3f828c1 100644 (file)
@@ -8,7 +8,7 @@
 #define DEFAULT_SERVER_HOST "tcp://*"
 #define DEFAULT_SERVER_PORT 5024
 #define DEFAULT_SERVER_SAVE_RECO_DIR "/local/reco"
-#define DEFAULT_CDB_STORAGE "local:///local/OCDB/2013"
+#define DEFAULT_CDB_STORAGE "local:///local/cdb"
 #define DEFAULT_CDB_SPEC_STORAGE_PATH1 "/local/reco/GRP/GRP/Data"
 #define DEFAULT_CDB_SPEC_STORAGE_VALUE1 ""
 #define DEFAULT_CDB_SPEC_STORAGE_PATH2 "/local/reco/GRP/CTP/Config"
 #define DEFAULT_RECO_WRITE_ALIGN 1
 #define DEFAULT_RECO_CLEAN_ESD 0
 #define DEFAULT_RECO_DETECTORS "ALL -PHOS -EMCAL"
-#define DEFAULT_LOGBOOK_HOST "localhost"
+#define DEFAULT_LOGBOOK_HOST "aldaqdb"
 #define DEFAULT_LOGBOOK_PORT 3306
-#define DEFAULT_LOGBOOK_DB "logbook"
-#define DEFAULT_LOGBOOK_USER "dqm"
-#define DEFAULT_LOGBOOK_PASS "dqm123"
+#define DEFAULT_LOGBOOK_DB "LOGBOOK"
+#define DEFAULT_LOGBOOK_USER "logbookdqm"
+#define DEFAULT_LOGBOOK_PASS "SivaGJqi"
 #define DEFAULT_DATA_SOURCE "local"
 
 #include <TSystem.h>
index d9b822c..f2938a6 100644 (file)
@@ -196,39 +196,39 @@ void AliEventServerWindow::HandleToolBarAction(Int_t id)
 }
 
 /*
-  void AliEventServerWindow::FinishedReconstruction(Int_t status)
-  {
-// Slot called on termination of child process.
-Int_t run = fServer->GetRunId();
+void AliEventServerWindow::FinishedReconstruction(Int_t status)
+{
+  // Slot called on termination of child process.
+  Int_t run = fServer->GetRunId();
        
-Info("FinishedReconstruction", "Reconstruction Thread finished \tRunId:%d \tstatus=%d", run, status);
+  Info("FinishedReconstruction", "Reconstruction Thread finished \tRunId:%d \tstatus=%d", run, status);
 
-mIntInt_i i =fRun2PidMap.find(run);
-if (i != fRun2PidMap.end())
-{
-fRunList->RemoveEntry(run);
+  mIntInt_i i =fRun2PidMap.find(run);
+  if (i != fRun2PidMap.end())
+    {
+      fRunList->RemoveEntry(run);
     
-// clean (remove) run's reconstructed directory
-//gSystem->Exec(Form("rm -rf %s/reco/run%d_%d",gSystem->Getenv("ONLINERECO_BASE_DIR"),run,pid));
+      // clean (remove) run's reconstructed directory
+      //gSystem->Exec(Form("rm -rf %s/reco/run%d_%d",gSystem->Getenv("ONLINERECO_BASE_DIR"),run,pid));
       
-if (status == 0)
-{
-fRunList->AddEntrySort(TString::Format("%-20d -- PROCESSED", run), run);
-}
-else
-{
-fRunList->AddEntrySort(TString::Format("%-20d -- PROCESSED [%d]", run, status), run);
-}
-fRunList->Layout();
+      if (status == 0)
+       {
+         fRunList->AddEntrySort(TString::Format("%-20d -- PROCESSED", run), run);
+       }
+      else
+       {
+         fRunList->AddEntrySort(TString::Format("%-20d -- PROCESSED [%d]", run, status), run);
+       }
+      fRunList->Layout();
     
-}
-else
-{
-Warning("FinishedReconstruction", "Run number %d not registered.", run);
-}
+    }
+  else
+    {
+      Warning("FinishedReconstruction", "Run number %d not registered.", run);
+    }
+
+    }*/
 
-}
-*/
  //------------------------------------------------------------------------------
  // Private methods
  //------------------------------------------------------------------------------
@@ -279,7 +279,8 @@ void AliEventServerWindow::StartOfRun(Int_t run)
        fRunList->AddEntrySort(TString::Format("%d", run), run);
        fRunList->Layout();
        gClient->NeedRedraw(fRunList);
-       
+
+       if(fRecoServer){fRecoServer->StopReconstruction();}
        StartReco(run);
 }
 
@@ -289,8 +290,9 @@ void AliEventServerWindow::EndOfRun(Int_t run)
        
        // Slot called from DIM handler on stop of run.
        AliInfo(Form("called for Run %d", run) );
-       if(fRecoServer) fRecoServer->StopReconstruction();
+       if(fRecoServer){fRecoServer->StopReconstruction();}
        
+       printf("Updating GUI");
        fRunList->RemoveEntry(run);
        fRunList->Layout();
        gClient->NeedRedraw(fRunList);
index 96b82cc..6ca6029 100644 (file)
@@ -8,15 +8,33 @@
  
 #include <TApplication.h>
 #include "AliEventServerWindow.h"
+#include "AliEventServer.h"
+#include <iostream>
+#include <string.h>
 
 int main(int argc, char **argv)
 {
   TApplication app("AliEventServer", &argc, argv);
 
+  if(argc<2)
+    {
+ std::cout<<"Starting Event Server without GUI"<<std::endl;
+      AliEventServer *server = new AliEventServer;
+      app.Run(kTRUE);
+      if(server){delete server;}
+    }
+  else if(strcmp(argv[1],"gui")==0)
+    {
+      std::cout<<"Starting Event Server in GUI mode"<<std::endl;
   AliEventServerWindow *win = new AliEventServerWindow;
   app.Run(kTRUE);
   
   if(win){delete win;}
-  
+    }
+  else
+    {
+      std::cout<<"Call without parameters to run without GUI.\nCall with \"gui\" parameter to launch with GUI"<<std::endl;
+    }
+
   return 0;
 }
index 46bd6f3..11352e4 100644 (file)
@@ -427,9 +427,13 @@ AliESDEvent* AliStorageEventManager::GetEvent(storageSockets socket,int timeout)
   mess->ResetMap();
        
   AliESDEvent* data = (AliESDEvent*)(mess->ReadObjectAny(AliESDEvent::Class()));
-    
+
   if (data)
   {
+    data->GetStdContent();
+    if(message){delete message;}
+    return data; 
+    /*
     TTree* tree= new TTree("esdTree", "esdTree");
     data->WriteToTree(tree);
     tree->Fill();
@@ -440,6 +444,7 @@ AliESDEvent* AliStorageEventManager::GetEvent(storageSockets socket,int timeout)
     if(tree){delete tree;}
     if(message){delete message;}
     return event;
+    */
   }
   else
   {