]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/AliHLTGlobalDCSPublisherComponent.h
AliHLTJET module
[u/mrichter/AliRoot.git] / HLT / global / AliHLTGlobalDCSPublisherComponent.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTGLOBALDCSPUBLISHERCOMPONENT_H
5 #define ALIHLTGLOBALDCSPUBLISHERCOMPONENT_H
6
7 //* This file is property of and copyright by the ALICE HLT Project        * 
8 //* ALICE Experiment at CERN, All rights reserved.                         *
9 //* See cxx source for full Copyright notice                               *
10
11 /** @file   AliHLTGlobalDCSPublisherComponent.h
12     @author Matthias Richter
13     @date   20010-03-10
14     @brief  DIM publisher component for global HLT data
15 */
16 #include "AliHLTDataSink.h"
17 #include "AliHLTDimServer.h"
18 #include <functional>
19
20 /**
21  * @class AliHLTGlobalDCSPublisherComponent
22  * DIM Publisher component for global HLT data.
23  * It implements a DIM server which publishes global HLT data through the
24  * following services:
25  * - Vertex_X
26  * - Vertex_Y
27  * - Vertex_Z
28  * - RmsVertex_X
29  * - RmsVertex_Y
30  * - RmsVertex_Z
31  * 
32  */
33 class AliHLTGlobalDCSPublisherComponent : public AliHLTDataSink {
34 public:
35   AliHLTGlobalDCSPublisherComponent();
36   ~AliHLTGlobalDCSPublisherComponent();
37
38   /// service enumerators
39   enum {
40     kVertexX,
41     kVertexY,
42     kVertexZ,
43     kDimensions,
44     kVertexRmsX=kDimensions,
45     kVertexRmsY,
46     kVertexRmsZ,
47     kLastService
48   };
49
50   virtual const char* GetComponentID();
51   virtual void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
52   virtual AliHLTComponent* Spawn();
53
54  protected:
55   /// component initialization
56   int DoInit( int argc, const char** argv );
57
58   /// component cleanup
59   int DoDeinit();
60
61   /// Data processing method for the component.
62   virtual int DumpEvent( const AliHLTComponentEventData& evtData,
63                          AliHLTComponentTriggerData& trigData );
64
65   using AliHLTDataSink::DumpEvent;
66
67   int ScanConfigurationArgument(int argc, const char** argv);
68   int Publish(bool reset=false);
69
70 private:
71   /// copy constructor not permitted
72   AliHLTGlobalDCSPublisherComponent(const AliHLTGlobalDCSPublisherComponent&);
73   /// assignment operator not permitted
74   AliHLTGlobalDCSPublisherComponent& operator=(const AliHLTGlobalDCSPublisherComponent&);
75
76   /// binary function for the calculation of rms using std::accumulate
77   template <class T> class MeanSqtOp {
78   public:
79     MeanSqtOp() : fMean(0) {}
80     MeanSqtOp(T mean) : fMean(mean) {}
81     T operator() (const T& x, const T& y) const {
82       T val=x+(y-fMean)*(y-fMean);
83       return val;
84     }
85   private:
86     T fMean;
87   };
88
89   void Reset(vector<float>& sample, int size) const;
90   template <class T> T Mean(const vector<T>& sample, int count) const;
91   template <class T> T Rms(const vector<T>& sample, T mean, int count) const;
92
93   /// dim server name
94   string fServerName; //!
95   /// dim DNS server name
96   string fDimdns; //!
97   /// dim server instance
98   AliHLTDimServer* fpServer; //!
99
100   /// position in the event buffer
101   int fPosition; //!
102   /// size of the event buffer
103   int fEventBufferSize; //!
104   /// last update time
105   unsigned int fLastUpdate; //!
106   /// update period in seconds
107   unsigned int fUpdatePeriod; //!
108
109   /// event buffers
110   vector<float> fEventBuffers[kDimensions]; //!
111   /// array of dim services
112   AliHLTDimServer::AliHLTDimService* fDimServices[kLastService]; //!
113   /// dim service for the number of samples for
114   AliHLTDimServer::AliHLTDimService* fDimServiceEventCount; //!
115
116   /// names of services
117   static const char* fgkServiceNames[kLastService]; //!
118
119   ClassDef(AliHLTGlobalDCSPublisherComponent, 0)
120 };
121 #endif