]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/global/AliHLTGlobalDCSPublisherComponent.h
first working version of the DCSPublisher
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalDCSPublisherComponent.h
index 36bf9e3d828a8bcc731b7760511706fef09b7030..b47ccb4010382991a65af89df1d3b270a6b458d5 100644 (file)
@@ -14,8 +14,8 @@
     @brief  DIM publisher component for global HLT data
 */
 #include "AliHLTDataSink.h"
-
-class AliHLTDimServer;
+#include "AliHLTDimServer.h"
+#include <functional>
 
 /**
  * @class AliHLTGlobalDCSPublisherComponent
@@ -25,9 +25,9 @@ class AliHLTDimServer;
  * - Vertex_X
  * - Vertex_Y
  * - Vertex_Z
- * - ResVertex_X
- * - ResVertex_Y
- * - ResVertex_Z
+ * - RmsVertex_X
+ * - RmsVertex_Y
+ * - RmsVertex_Z
  * 
  */
 class AliHLTGlobalDCSPublisherComponent : public AliHLTDataSink {
@@ -35,6 +35,18 @@ public:
   AliHLTGlobalDCSPublisherComponent();
   ~AliHLTGlobalDCSPublisherComponent();
 
+  /// service enumerators
+  enum {
+    kVertexX,
+    kVertexY,
+    kVertexZ,
+    kDimensions,
+    kVertexRmsX=kDimensions,
+    kVertexRmsY,
+    kVertexRmsZ,
+    kLastService
+  };
+
   virtual const char* GetComponentID();
   virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
   virtual AliHLTComponent* Spawn();
@@ -53,6 +65,7 @@ public:
   using AliHLTDataSink::DumpEvent;
 
   int ScanConfigurationArgument(int argc, const char** argv);
+  int Publish(bool reset=false);
 
 private:
   /// copy constructor not permitted
@@ -60,7 +73,48 @@ private:
   /// assignment operator not permitted
   AliHLTGlobalDCSPublisherComponent& operator=(const AliHLTGlobalDCSPublisherComponent&);
 
-  AliHLTDimServer* fpServer; //! dim server instance
+  /// binary function for the calculation of rms using std::accumulate
+  template <class T> class MeanSqtOp {
+  public:
+    MeanSqtOp() : fMean(0) {}
+    MeanSqtOp(T mean) : fMean(mean) {}
+    T operator() (const T& x, const T& y) const {
+      T val=x+(y-fMean)*(y-fMean);
+      return val;
+    }
+  private:
+    T fMean;
+  };
+
+  void Reset(vector<float>& sample, int size) const;
+  template <class T> T Mean(const vector<T>& sample, int count) const;
+  template <class T> T Rms(const vector<T>& sample, T mean, int count) const;
+
+  /// dim server name
+  string fServerName; //!
+  /// dim DNS server name
+  string fDimdns; //!
+  /// dim server instance
+  AliHLTDimServer* fpServer; //!
+
+  /// position in the event buffer
+  int fPosition; //!
+  /// size of the event buffer
+  int fEventBufferSize; //!
+  /// last update time
+  unsigned int fLastUpdate; //!
+  /// update period in seconds
+  unsigned int fUpdatePeriod; //!
+
+  /// event buffers
+  vector<float> fEventBuffers[kDimensions]; //!
+  /// array of dim services
+  AliHLTDimServer::AliHLTDimService* fDimServices[kLastService]; //!
+  /// dim service for the number of samples for
+  AliHLTDimServer::AliHLTDimService* fDimServiceEventCount; //!
+
+  /// names of services
+  static const char* fgkServiceNames[kLastService]; //!
 
   ClassDef(AliHLTGlobalDCSPublisherComponent, 0)
 };