Online reco now listens only in PHYSICS_1
authorjniedzie <jeremi.niedziela@cern.ch>
Tue, 11 Nov 2014 07:45:54 +0000 (08:45 +0100)
committerjniedzie <jeremi.niedziela@cern.ch>
Tue, 11 Nov 2014 07:46:16 +0000 (08:46 +0100)
MONITOR/alionlinereco/AliOnlineReconstruction.cxx
MONITOR/alionlinereco/onlinereco.cxx
MONITOR/alistoragemanager/AliDIMListenerThread.cxx
MONITOR/alistoragemanager/AliDIMListenerThread.h

index b921c45..13a2dd2 100644 (file)
 #include <TSQLRow.h>
 #include <TTimeStamp.h>
 
+#include <signal.h>
 #include <iostream>
 
 using namespace std;
 
+bool gQuit = false;
+void GotSignal(int){gQuit = true;}
+
 AliOnlineReconstruction::AliOnlineReconstruction(int run) :
   fRun(run),
   fDataSource(""),
@@ -26,14 +30,32 @@ AliOnlineReconstruction::AliOnlineReconstruction(int run) :
   fAliReco(new AliReconstruction()),
   fCDBmanager(AliCDBManager::Instance())
 {
+  // make sure that destructor is called when kill signal comes
+  struct sigaction sa;
+  memset(&sa,0,sizeof(sa));
+  sa.sa_handler = GotSignal;
+  sigfillset(&sa.sa_mask);
+  sigaction(SIGINT,&sa,NULL);
+
+  printf("CDB Lock is %s\n",AliCDBManager::Instance()->GetLock() ? "ON":"OFF");
+
+
   fSettings.ReadFile(AliOnlineReconstructionUtil::GetPathToServerConf(), kEnvUser);
   StartOfRun();
+  cout<<"after startofrun"<<endl;
 }
 
 AliOnlineReconstruction::~AliOnlineReconstruction()
 {
-  if(fAliReco){delete fAliReco;fAliReco=0;}
+  cout<<"AliOnlineReconstruction -- destructor called...";
+  if(fAliReco)
+    {
+      //       fAliReco->SlaveTerminate();
+      //       fAliReco->Terminate(); 
+      //       delete fAliReco;fAliReco=0;
+    }
   if(fCDBmanager){fCDBmanager->Destroy();fCDBmanager=0;}
+  cout<<"OK"<<endl;
 }
 
 void AliOnlineReconstruction::StartOfRun()
@@ -139,7 +161,7 @@ void AliOnlineReconstruction::ReconstructionLoop()
        //******* The loop over events
        Int_t iEvent = 0;
        AliESDEvent* event;
-       while (fAliReco->HasNextEventAfter(iEvent))
+       while (fAliReco->HasNextEventAfter(iEvent) && !gQuit)
        {
                if (!fAliReco->HasEnoughResources(iEvent)) break;
                Bool_t status = fAliReco->ProcessEvent(iEvent);
@@ -153,11 +175,14 @@ void AliOnlineReconstruction::ReconstructionLoop()
                  cout<<"Event server -- aborting"<<endl;
                  fAliReco->Abort("ProcessEvent",TSelector::kAbortFile);
                }
+               cout<<"clean"<<endl;
                fAliReco->CleanProcessedEvent();
+               cout<<"iEvent++"<<endl;
                iEvent++;
        }
-       fAliReco->SlaveTerminate();
-       if (fAliReco->GetAbort() != TSelector::kContinue) return;
-       fAliReco->Terminate();
-       if (fAliReco->GetAbort() != TSelector::kContinue) return; 
+       cout<<"after while"<<endl;
+       //      fAliReco->SlaveTerminate();
+       //if (fAliReco->GetAbort() != TSelector::kContinue) return;
+       //fAliReco->Terminate();
+       //if (fAliReco->GetAbort() != TSelector::kContinue) return; 
 }
index 8faa633..fba23e0 100644 (file)
@@ -48,12 +48,13 @@ int main(int argc, char **argv)
       return 0;
     }
 
-  TApplication app("AliOnlineReconstruction", &argc, argv);
+  //TApplication app("AliOnlineReconstruction", &argc, argv);
 
   std::cout<<"Starting Online Reconstruction for run:"<<atoi(argv[1])<<std::endl;
   AliOnlineReconstruction *onlineReconstruction = new AliOnlineReconstruction(atoi(argv[1]));
-  app.Run(kTRUE);
+  //app.Run(kTRUE);
+  std::cout<<"after run"<<std::endl;
   if(onlineReconstruction){delete onlineReconstruction;}
-  
+  std::cout<<"deleted"<<std::endl;
   return 0;
 }
index 44b0d5d..f4a1450 100644 (file)
@@ -7,11 +7,35 @@
 
 using namespace std;
 
-AliDIMListenerThread::AliDIMListenerThread()
-{
-    InitDIMListeners();
+AliDIMListenerThread::AliDIMListenerThread() : 
+  fDimSORListener(0),
+  fDimEORListener(0),
+  fOnlineReconstructionHostname(""),
+  fOnlineReconstructionUsername("")
+{    
+    ifstream configFile (GetConfigFilePath());
     
+    if (configFile.is_open())
+    {
+        string line;
+        int from,to;
+        while(configFile.good())
+        {
+            getline(configFile,line);
+            from = line.find("\"")+1;
+            to = line.find_last_of("\"");
+            if(line.find("EVENT_SERVER=")==0){fOnlineReconstructionHostname=line.substr(from,to-from);}
+            else if(line.find("EVENT_SERVER_USER=")==0){fOnlineReconstructionUsername=line.substr(from,to-from);}
+        }
+        if(configFile.eof()){configFile.clear();}
+        configFile.close();
+    }
+    else{cout<<"AliDIMListenerThread -- Unable to open config file"<<endl;}
+
+    InitDIMListeners();
+
 #ifdef ALI_DATE
+    // check if there is a run in partition PHYSICS_1
     DimCurrentInfo SORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1",-1);
     DimCurrentInfo EORrunNumber("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1",-1);
 
@@ -22,27 +46,34 @@ AliDIMListenerThread::AliDIMListenerThread()
         
         if(SORrunNumber.getInt() != EORrunNumber.getInt()){StartOfRun(SORrunNumber.getInt());}
     }
-    else{cout<<"DIM Listener -- no data received from dim server"<<endl;}
+    else{cout<<"AliDIMListenerThread -- no data received from dim server"<<endl;}
 #endif
 }
 
 AliDIMListenerThread::~AliDIMListenerThread()
 {
+  if(fDimSORListener){delete fDimSORListener;fDimSORListener = 0;}
+  if(fDimEORListener){delete fDimEORListener;fDimEORListener = 0;}
+
+  /*
     for (int i = 0; i < 5; ++i){
         if(fDimSORListener[i]) delete fDimSORListener[i];
         if(fDimEORListener[i]) delete fDimEORListener[i];
         
         fDimSORListener[i] = 0;
         fDimEORListener[i] = 0;
-    }
+       }*/
 }
 
 void AliDIMListenerThread::InitDIMListeners()
 {
-    for (int i = 0; i < 5; ++i)
-    {
+
 #ifdef ALI_DATE
-             if (i == 0)
+  /*
+  for (int i = 0; i < 5; ++i)
+  {
+  
+  if (i == 0)
         {
             fDimSORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS");
             fDimEORListener[i] = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS");
@@ -52,46 +83,29 @@ void AliDIMListenerThread::InitDIMListeners()
             fDimSORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_%d", i));
             fDimEORListener[i] = new AliDimIntNotifier(Form("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_%d", i));
         }
-        
         fDimSORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
         fDimEORListener[i]->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
-#else
-        fDimSORListener[i]=0x0;
-        fDimEORListener[i]=0x0;
+}
+  */
+  fDimSORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_SOR_PHYSICS_1");
+  fDimEORListener = new AliDimIntNotifier("/LOGBOOK/SUBSCRIBE/DAQ_EOR_PHYSICS_1");
+  fDimSORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "StartOfRun(int)");
+  fDimEORListener->Connect("DimMessage(int)", "AliDIMListenerThread", this, "EndOfRun(int)");
 #endif
-    }
 }
 
 void AliDIMListenerThread::StartOfRun(int run)
 {
-    cout<<"DIM Listener -- SOR signal received for run:"<<run<<endl;
-
-    ifstream configFile (GetConfigFilePath());
-    string username,hostname;
-    
-    if (configFile.is_open())
-    {
-        string line;
-        int from,to;
-        while(configFile.good())
-        {
-            getline(configFile,line);
-            from = line.find("\"")+1;
-            to = line.find_last_of("\"");
-            if(line.find("EVENT_SERVER=")==0){hostname=line.substr(from,to-from);}
-            else if(line.find("EVENT_SERVER_USER=")==0){username=line.substr(from,to-from);}
-        }
-        if(configFile.eof()){configFile.clear();}
-        configFile.close();
-    }
-    else{cout<<"Event Manager Editor -- Unable to open config file"<<endl;}
-
-    // Kill reconstruction server
-    gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco;alionlinereco %d\"",username.c_str(),hostname.c_str(),run));
-
+    cout<<"AliDIMListenerThread -- SOR signal received for run:"<<run<<endl;
+   
+    // Kill reconstruction and start new one
+    gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco;alionlinereco %d\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str(),run));
 }
 
 void AliDIMListenerThread::EndOfRun(int run)
 {
-    cout<<"DIM Listener -- EOR signal received for run:"<<run<<endl;
+    cout<<"AliDIMListenerThread -- EOR signal received for run:"<<run<<endl;
+
+    // kill all running reconstructions (to be changed later)
+    gSystem->Exec(Form("ssh -n -f %s@%s \"killall alionlinereco\"",fOnlineReconstructionUsername.c_str(),fOnlineReconstructionHostname.c_str()));
 }
index 0bf9c82..cadcad2 100644 (file)
@@ -2,11 +2,7 @@
 #define __AliDIMListenerThread__
 
 #include "AliDimIntNotifier.h"
-/*
-#ifdef ALI_DATE
-#include <dic.hxx>
-#endif
-*/
+
 class AliDimIntNotifier;
 
 class AliDIMListenerThread
@@ -21,8 +17,11 @@ public:
 private:
     void InitDIMListeners();
     
-    AliDimIntNotifier *fDimSORListener[5];
-    AliDimIntNotifier *fDimEORListener[5];
+    AliDimIntNotifier *fDimSORListener;//[5]; //now listening just in PHYSICS_1
+    AliDimIntNotifier *fDimEORListener;//[5];
+
+    std::string fOnlineReconstructionHostname;
+    std::string fOnlineReconstructionUsername;
 };
 
-#endif /* defined(__AliDIMListenerThread__) */
+#endif