]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/util/AliHLTCompStatCollector.h
avoid warning for the default HLT simulation
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTCompStatCollector.h
1 // -*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTCOMPSTATCOLLECTOR_H
5 #define ALIHLTCOMPSTATCOLLECTOR_H
6 //* This file is property of and copyright by the ALICE HLT Project        * 
7 //* ALICE Experiment at CERN, All rights reserved.                         *
8 //* See cxx source for full Copyright notice                               *
9
10 /** @file   AliHLTCompStatCollector.h
11     @author Matthias Richter
12     @date   
13     @brief  Collector component for the component statistics information.
14 */
15
16 #include "AliHLTProcessor.h"
17 #include <ctime>
18
19 class TStopwatch;
20 class TH1F;
21 class TH2F;
22 class TH2C;
23 class TTree;
24 class TFolder;
25 class TFile;
26
27 /**
28  * @class AliHLTCompStatCollector
29  * Collector component for the statistics entries produced by the
30  * AliHLTComponent base class.
31  *
32  * <h2>General properties:</h2>
33  * This components collects all data blocks of types
34  * ::kAliHLTDataTypeComponentStatistics and ::kAliHLTDataTypeComponentTable
35  * which can be produced by the AliHLTComponent base class for every component
36  * and event. Component statistics entries are data blocks of
37  * ::AliHLTComponentStatistics arrays containing a couple of informations
38  * about each component. The information is extracted and stored into a
39  * TTree. The component table entries (AliHLTComponentTable structs) are sent
40  * on SOR and EOR events and are arranged in a TFolder hierarchy.
41  *
42  * The objects are published or/and saved according to the setup. An
43  * event modulo marameter can be used to publish every nth event, a period
44  * argument to publish every nth second. The objects can be optionally saved
45  * directly to file and the publishing can be suppressed. The objects are
46  * published/saved at the EOR event.
47  *
48  * Component ID: \b StatisticsCollector                                 <br>
49  * Library: \b libAliHLTUtil.so                                         <br>
50  * Input Data Types: ::kAliHLTDataTypeComponentStatistics                 <br>
51  * Output Data Types: ::kAliHLTDataTypeHistogram, ::kAliHLTDataTypeTNtuple  <br>
52  *
53  * <h2>Mandatory arguments:</h2>
54  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
55  *
56  * <h2>Optional arguments:</h2>
57  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
58  * \li -file     <i> filename   </i> <br>
59  *      name of root file
60  * \li -publish     <i> 0/1   </i> <br>
61  *      enable/disable publishing to HLT output, default is on
62  * \li -period     <i> n   </i> <br>
63  *      publish/save every n-th second
64  * \li -modulo     <i> n   </i> <br>
65  *      publish/save every n-th event
66  *
67  * <h2>Configuration:</h2>
68  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
69  * Configuration by component arguments.
70  *
71  * <h2>Default CDB entries:</h2>
72  * The component loads no CDB entries.
73  *
74  * <h2>Performance:</h2>
75  *
76  * <h2>Memory consumption:</h2>
77  *
78  * <h2>Output size:</h2>
79  *
80  * @ingroup alihlt_util_components
81  */
82 class AliHLTCompStatCollector : public AliHLTProcessor
83 {
84  public:
85   /** standard constructor */
86   AliHLTCompStatCollector();
87   /** destructor */
88   virtual ~AliHLTCompStatCollector();
89
90   const char* GetComponentID() {return "StatisticsCollector";};
91   AliHLTComponent* Spawn() {return new AliHLTCompStatCollector;}
92   void GetInputDataTypes( vector<AliHLTComponentDataType>& );
93   AliHLTComponentDataType GetOutputDataType();
94   int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
95   void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
96
97  protected:
98   int DoInit( int argc, const char** argv );
99   int DoDeinit();
100   int DoEvent( const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData);
101   
102   using AliHLTProcessor::DoEvent;
103
104   /** mode definition */
105   enum {
106     /** publish objects according to the given period */
107     kPublishObjects = 0x1,
108
109     /** save objects according to the given period */
110     kSaveObjects = 0x2
111   };
112
113  private:
114   /** not a valid copy constructor, defined according to effective C++ style */
115   AliHLTCompStatCollector(const AliHLTCompStatCollector&);
116   /** not a valid assignment op, but defined according to effective C++ style */
117   AliHLTCompStatCollector& operator=(const AliHLTCompStatCollector&);
118
119   /**
120    * Reset all filling variables and lists.
121    */
122   void ResetFillingVariables();
123
124   /**
125    * Fill the lists from the component statistics block.
126    */
127   int FillVariablesSorted(void* ptr, int size, AliHLTUInt32_t eventType);
128
129   /** delete all internal objects */
130   void ClearAll();
131
132   /**
133    * Remove entries from the parent list if they occur further down in the
134    * hierarchy.
135    */
136   int RemoveRecurrence(TFolder* pRoot) const;
137
138   /**
139    * Check event modulo and time period.
140    * If the result is true, the internal counter and time backup is
141    * updated enabled
142    * @param bUpdate   update internal backups if condition was true
143    * @return true if period has excceded
144    */
145   bool CheckPeriod(bool bUpdate=true);
146
147   /** event cycle timer */
148   TStopwatch* fpTimer; //!transient
149
150   /** top folder */
151   TFolder* fpFolder; //!transient
152
153   /** statistics tree */
154   TTree* fpStatTree; //!transient
155
156   /** branch filling variable */
157   Float_t fCycleTime; //!transient
158   /** branch filling variable */
159   Int_t fNofSets; //!transient
160   /** array size */
161   UInt_t fArraySize; //!transient
162   /** current position */
163   UInt_t fPosition; //!transient
164   /** branch filling variable */
165   UInt_t* fpLevelArray; //!transient
166   /** branch filling variable */
167   UInt_t* fpSpecArray; //!transient
168   /** branch filling variable */
169   UInt_t* fpBlockNoArray; //!transient
170   /** branch filling variable */
171   UInt_t* fpIdArray; //!transient
172   /** branch filling variable */
173   UInt_t* fpTimeArray; //!transient
174   /** branch filling variable */
175   UInt_t* fpCTimeArray; //!transient
176   /** branch filling variable */
177   UInt_t* fpInputBlockCountArray; //!transient
178   /** branch filling variable */
179   UInt_t* fpTotalInputSizeArray; //!transient
180   /** branch filling variable */
181   UInt_t* fpNormalizedInputSizeArray; //!transient
182   /** branch filling variable */
183   UInt_t* fpOutputBlockCountArray; //!transient
184   /** branch filling variable */
185   UInt_t* fpTotalOutputSizeArray; //!transient
186   /** branch filling variable */
187   UInt_t* fpInputOutputRatioArray; //!transient
188   /** branch filling variable */
189   UInt_t* fpNormalizedInputOutputRatioArray; //!transient
190   /** branch filling variable */
191   UInt_t* fpComponentCycleTimeArray; //!transient
192   /** branch filling variable */
193   UInt_t* fpEventTypeArray; //!transient
194   /** branch filling variable */
195   UInt_t* fpEventCountArray; //!transient
196
197   /** const base of GetOutputSize, updated on error in DoEvent */
198   int fSizeEstimator; //! transient
199
200   /** mode flags */
201   unsigned int fMode; //! transient
202
203   /** file name to store the objects */
204   string fFileName; //! transient
205
206   /** root file to save objects */
207   TFile* fFile; // !transient
208
209   /** last time, objects have been published or saved */
210   time_t fLastTime; //! transient
211
212   /** period in seconds to save/publish objects */
213   unsigned int fPeriod; //! transient
214
215   /** event modulo to save/publish onjects */
216   unsigned int fEventModulo; //! transient
217
218   ClassDef(AliHLTCompStatCollector, 4)
219 };
220 #endif