Initial version of the ECS start-of-run trigger which will be used in order to start...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Aug 2009 11:07:16 +0000 (11:07 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 26 Aug 2009 11:07:16 +0000 (11:07 +0000)
MONITOR/AliOnlineRecoTrigger.cxx [new file with mode: 0644]
MONITOR/AliOnlineRecoTrigger.h [new file with mode: 0644]
MONITOR/MONITORLinkDef.h
MONITOR/SORNotifier.cxx [new file with mode: 0644]
MONITOR/SORNotifier.h [new file with mode: 0644]
MONITOR/libMONITOR.pkg

diff --git a/MONITOR/AliOnlineRecoTrigger.cxx b/MONITOR/AliOnlineRecoTrigger.cxx
new file mode 100644 (file)
index 0000000..29bcc34
--- /dev/null
@@ -0,0 +1,153 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+#include "AliOnlineRecoTrigger.h"
+
+#include <TSystem.h>
+
+#include "AliLog.h"
+#ifdef ALI_DATE
+#include "SORNotifier.h"
+#endif
+
+ClassImp(TerminateSignalHandler)
+ClassImp(AliOnlineRecoTrigger)
+
+//______________________________________________________________________________________________
+Bool_t TerminateSignalHandler::Notify()
+{
+// Sentd terminate command to the Shuttle trigger
+
+       AliInfo("Terminate signal received ...");
+       fTrigger->Terminate();
+
+       return kTRUE;
+}
+
+//______________________________________________________________________________________________
+AliOnlineRecoTrigger::AliOnlineRecoTrigger():
+       fNotified(kFALSE), fTerminate(kFALSE),
+       fMutex(), fCondition(&fMutex),
+       fQuitSignalHandler(0),
+       fInterruptSignalHandler(0)
+{
+  // Default constructor
+  //
+
+  fQuitSignalHandler = new TerminateSignalHandler(this, kSigQuit);
+  fInterruptSignalHandler = new TerminateSignalHandler(this, kSigInterrupt);
+
+  gSystem->AddSignalHandler(fQuitSignalHandler);
+  gSystem->AddSignalHandler(fInterruptSignalHandler);
+}
+
+//______________________________________________________________________________________________
+AliOnlineRecoTrigger::~AliOnlineRecoTrigger() 
+{
+  // destructor
+
+  gSystem->RemoveSignalHandler(fQuitSignalHandler);
+  gSystem->RemoveSignalHandler(fInterruptSignalHandler);
+
+  delete fQuitSignalHandler;
+  fQuitSignalHandler = 0;
+
+  delete fInterruptSignalHandler;
+  fInterruptSignalHandler = 0;
+}
+
+//______________________________________________________________________________________________
+Bool_t AliOnlineRecoTrigger::Notify() {
+       //
+       // The method is called automaticly by SORNotifier on "start of run" 
+       // notification event from ECS
+       //
+
+       fMutex.Lock();
+
+       fNotified = kTRUE;
+       fCondition.Signal();
+
+       fMutex.UnLock();
+
+       return kTRUE;
+}
+
+//______________________________________________________________________________________________
+void AliOnlineRecoTrigger::Terminate() {
+       //
+       // Stop triggers listen mode and exist from Run()
+       // Usually called automaticly by TerminateSignalHandler.
+       //
+
+       fTerminate = kTRUE;
+       fCondition.Signal();
+}
+
+//______________________________________________________________________________________________
+Int_t AliOnlineRecoTrigger::Run() {
+       //
+       // AliOnlineRecoTrigger main loop for asynchronized (listen) mode.
+       // It spawns DIM service listener and waits for DAQ "start of run"
+       // notification.
+       //
+
+       fTerminate = kFALSE;
+
+#ifdef ALI_DATE
+       SORNotifier* notifier = new SORNotifier(this);
+#endif
+       Int_t received=0;
+       
+       AliInfo("Listening for ECS SOR trigger");
+       
+       fMutex.Lock();
+
+       while (!(fNotified || fTerminate)) {
+         received=fCondition.TimedWaitRelative(1000*86400); //wait 24h
+         if (received==1) break; // 1 = timeout
+       }
+
+       fNotified = kFALSE;
+               
+       fMutex.UnLock();
+
+       Int_t run = -1;
+#ifdef ALI_DATE
+       run = notifier->GetRun();
+       delete notifier;
+#endif
+
+       if (fTerminate) {
+         AliInfo("Terminated.");
+         return -1;
+       }
+
+       if (received == 0)
+         {
+           AliInfo("Trigger from ECS received!");
+           if (run < 0) {
+             AliError("Invalid run number received!");
+             return -1;
+           }
+           return run;
+         } else if (received == 1) {
+           AliWarning("Timeout waiting for trigger!");
+           return -1;
+         } else {
+           AliError("Error receiving trigger from ECS!");
+           return -1;
+         }
+}
diff --git a/MONITOR/AliOnlineRecoTrigger.h b/MONITOR/AliOnlineRecoTrigger.h
new file mode 100644 (file)
index 0000000..a622edb
--- /dev/null
@@ -0,0 +1,62 @@
+#ifndef ALIONLINERECOTRIGGER_H
+#define ALIONLINERECOTRIGGER_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+#include <TObject.h>
+#include <TSysEvtHandler.h>
+#include <TMutex.h>
+#include <TCondition.h>
+
+
+class AliOnlineRecoTrigger;
+class SORNotifier;
+
+class TerminateSignalHandler: public TSignalHandler {
+       
+public:
+       TerminateSignalHandler(): TSignalHandler((ESignals) 0,0), fTrigger(0) { }
+       TerminateSignalHandler(AliOnlineRecoTrigger* trigger, ESignals signal):
+       TSignalHandler(signal, kFALSE), fTrigger(trigger) {}
+
+       virtual ~TerminateSignalHandler() { }
+       virtual Bool_t Notify();
+
+private:
+       TerminateSignalHandler(const TerminateSignalHandler& other);
+       TerminateSignalHandler& operator= (const TerminateSignalHandler& other);
+  
+       AliOnlineRecoTrigger* fTrigger;  // pointer to the current AliOnlineRecoTrigger
+
+       ClassDef(TerminateSignalHandler, 0)
+};
+
+class AliOnlineRecoTrigger: public TObject {
+
+public:
+       AliOnlineRecoTrigger();
+       virtual ~AliOnlineRecoTrigger();
+
+       virtual Bool_t Notify();
+       void Terminate();
+
+       Int_t Run();
+
+private:
+       AliOnlineRecoTrigger(const AliOnlineRecoTrigger& other);
+       AliOnlineRecoTrigger& operator= (const AliOnlineRecoTrigger& other);
+
+       Bool_t fNotified;               // Notified flag
+       Bool_t fTerminate;              // Terminate flag
+
+       TMutex fMutex;                  // Mutex
+       TCondition fCondition;          // Condition 
+
+       TerminateSignalHandler* fQuitSignalHandler;             // Quit signal
+       TerminateSignalHandler* fInterruptSignalHandler;        // Interrupt signal
+
+       ClassDef(AliOnlineRecoTrigger, 0)
+};
+
+#endif
index bc18939..93b6dbd 100644 (file)
@@ -29,5 +29,7 @@
 #pragma link C++ class  AliQAHistViewer+;
 #pragma link C++ class  AliQADirList+;
 #pragma link C++ class  AliQADirListItem+;
+#pragma link C++ class  AliOnlineRecoTrigger+;
+#pragma link C++ class  TerminateSignalHandler+;
 #endif
 
diff --git a/MONITOR/SORNotifier.cxx b/MONITOR/SORNotifier.cxx
new file mode 100644 (file)
index 0000000..8ab79e0
--- /dev/null
@@ -0,0 +1,27 @@
+#include "SORNotifier.h"
+
+#include "AliLog.h"
+#include "AliOnlineRecoTrigger.h"
+
+//______________________________________________________________________
+void SORNotifier::infoHandler()
+{
+// Info handler
+
+       Int_t run = -1;
+       if (getData())
+               run = getInt();
+       AliInfoGeneral("SORNotifier::infoHandler()", Form("ECS SOR notification received for run %d...", run));
+       fRun = run;
+       fTrigger->Notify();
+}
+
+//______________________________________________________________________
+void SORNotifier::errorHandler(int severity, int code, char *msg)
+{
+// Error handler
+
+       AliInfoGeneral("SORNotifier::errorHandler()",
+               Form("DIM Error: severity<%d>, code<%d> , message<%s>",
+               severity, code, msg));
+}
diff --git a/MONITOR/SORNotifier.h b/MONITOR/SORNotifier.h
new file mode 100644 (file)
index 0000000..83537ff
--- /dev/null
@@ -0,0 +1,40 @@
+/**************************************************************************
+ * Copyright(c) 2007-2009, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               *
+ **************************************************************************/
+#ifndef SORNOTIFIER_H
+#define SORNOTIFIER_H
+
+//______________________________________________________________________________
+//
+// ECS Start-of-Run notifier
+//
+// This class "listens" to the SOR coming from the ECS.
+//
+
+// DIM
+#include <dic.hxx>
+
+class AliOnlineRecoTrigger;
+
+class SORNotifier: public DimUpdatedInfo
+{
+public:
+        SORNotifier(AliOnlineRecoTrigger* trigger): 
+         DimUpdatedInfo("/LOGBOOK/SUBSCRIBE/ECS_SOR_PHYSICS", -1), fRun(-1), fTrigger(trigger) {}
+
+       void infoHandler();
+
+       void errorHandler(int severity, int code, char *msg);
+
+       int GetRun() const {return fRun;}
+private:
+       SORNotifier(const SORNotifier& other);
+       SORNotifier& operator = (const SORNotifier& other);
+
+       int fRun;
+
+       AliOnlineRecoTrigger* fTrigger;
+};
+
+#endif
index 333376c..fbe2b4e 100644 (file)
@@ -7,10 +7,16 @@ SRCS:=  AliMonitorPlot.cxx AliMonitorHisto.cxx AliMonitorTrend.cxx \
        AliMonitorDataTPC.cxx \
        AliMonitorProcess.cxx AliMonitorControl.cxx \
        AliMonitorDialog.cxx AliMonitorClient.cxx \
-       AliQAHistNavigator.cxx AliQAHistViewer.cxx
+       AliQAHistNavigator.cxx AliQAHistViewer.cxx \
+       AliOnlineRecoTrigger.cxx
 
-# Matthias 2007-10-03 HLT legacy code disabled
-#      AliMonitorHLT.cxx AliMonitorHLTHough.cxx \
+CINTHDRS:= $(SRCS:.cxx=.h)
+
+ifdef DATE_ROOT
+
+SRCS += SORNotifier.cxx
+
+endif
 
 HDRS:= $(SRCS:.cxx=.h)
 
@@ -18,6 +24,14 @@ DHDR:= MONITORLinkDef.h
 
 EINCLUDE:= TPC ITS RAW
 
+ifdef DATE_ROOT
+
+EINCLUDE += $(DIMDIR)/dim
+ELIBS := dim
+ELIBSDIR := $(DIMDIR)/$(ALICE_TARGET)
+
+endif
+
 ifeq (win32gcc,$(ALICE_TARGET))
 PACKSOFLAGS:= $(SOFLAGS) -L$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET) \
                          -lSTEER -lSTEERBase -lESD \