]>
Commit | Line | Data |
---|---|---|
65106d07 | 1 | // -*- Mode: C++ -*- |
2 | // $Id$ | |
3 | ||
4 | #ifndef ALIHLTROOTSCHEMAEVOLUTIONCOMPONENT_H | |
5 | #define ALIHLTROOTSCHEMAEVOLUTIONCOMPONENT_H | |
94d06b79 | 6 | //* This file is property of and copyright by the ALICE * |
65106d07 | 7 | //* ALICE Experiment at CERN, All rights reserved. * |
8 | //* See cxx source for full Copyright notice * | |
9 | ||
94d06b79 | 10 | /// @file AliHLTRootSchemaEvolutionComponent.h |
11 | /// @author Matthias Richter | |
12 | /// @date 2009-10-18 | |
13 | /// @brief Handler component for ROOT schema evolution of streamed objects | |
14 | /// | |
65106d07 | 15 | |
b64e4d93 | 16 | #include "AliHLTCalibrationProcessor.h" |
05948425 | 17 | #include "TString.h" |
a22cde70 | 18 | #include <vector> |
65106d07 | 19 | |
20 | class TObjArray; | |
a22cde70 | 21 | class TObject; |
22 | class TStopwatch; | |
23 | class AliHLTMessage; | |
65106d07 | 24 | |
25 | /** | |
26 | * @class AliHLTRootSchemaEvolutionComponent | |
a22cde70 | 27 | * Collects streamer info for all input objects and produces the corresponding |
28 | * calibration object for reconstruction of HLT. The component runs with a | |
29 | * configurable rate constraint and skips the processing of known data blocks | |
30 | * for the sake of performance. New data blocks are always processed and added | |
31 | * to the list. | |
65106d07 | 32 | * |
33 | * <h2>General properties:</h2> | |
34 | * | |
878f7b64 | 35 | * Component ID: \b ROOTSchemaEvolutionComponent <br> |
65106d07 | 36 | * Library: \b libAliHLTUtil.so <br> |
37 | * Input Data Types: ::kAliHLTAnyDataType <br> | |
38 | * Output Data Types: none <br> | |
39 | * | |
40 | * <h2>Mandatory arguments:</h2> | |
41 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> | |
42 | * | |
43 | * <h2>Optional arguments:</h2> | |
44 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> | |
b64e4d93 | 45 | * \li -fxs<=[n,off]> <br> |
65106d07 | 46 | * push streamer info to FXS, fetched by Shuttle and store in the entry |
b64e4d93 | 47 | * HLT/Calib/StreamerInfo <br> |
48 | * if a scalar greather then 0 is specified the calibration object is | |
49 | * pushed during the event processing with the specified scale down<br> | |
50 | * always pushed on EOR, default on | |
65106d07 | 51 | * \li -hltout<=[all,first,eor,off]> <br> |
52 | * push streamer info to output, the streamer info is stored in the | |
53 | * events in all, the first, and/or the EOR. | |
a22cde70 | 54 | * \li -file=filename <br> |
05948425 | 55 | * write to file at EOR |
a22cde70 | 56 | * \li -rate=hz <br> |
57 | * required processing rate in Hz, default 2000Hz | |
65106d07 | 58 | * |
59 | * <h2>Configuration:</h2> | |
60 | * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting --> | |
61 | * Configuration by component arguments. | |
62 | * | |
63 | * <h2>Default CDB entries:</h2> | |
64 | * The component loads no CDB entries. | |
65 | * | |
66 | * <h2>Performance:</h2> | |
878f7b64 | 67 | * TODO: update performance requirements for unpacking ESDs and creating the |
68 | * streamer info | |
65106d07 | 69 | * |
70 | * <h2>Memory consumption:</h2> | |
71 | * The component does not process any event data. | |
72 | * | |
73 | * <h2>Output size:</h2> | |
74 | * Depending on the mode. | |
75 | * | |
76 | * @ingroup alihlt_util_components | |
77 | */ | |
b64e4d93 | 78 | class AliHLTRootSchemaEvolutionComponent : public AliHLTCalibrationProcessor |
65106d07 | 79 | { |
80 | public: | |
81 | /// standard constructor | |
82 | AliHLTRootSchemaEvolutionComponent(); | |
83 | /// destructor | |
84 | virtual ~AliHLTRootSchemaEvolutionComponent(); | |
85 | ||
86 | /// inherited from AliHLTComponent: return id of the component. | |
87 | virtual const char* GetComponentID() {return "ROOTSchemaEvolutionComponent";}; | |
88 | /// inherited from AliHLTComponent: input data types | |
94d06b79 | 89 | virtual void GetInputDataTypes(AliHLTComponentDataTypeList& list); |
65106d07 | 90 | /// inherited from AliHLTComponent: output data types |
91 | virtual AliHLTComponentDataType GetOutputDataType(); | |
92 | /// inherited from AliHLTComponent: output data size | |
93 | virtual void GetOutputDataSize(unsigned long&, double&); | |
94 | ||
95 | /// inherited from AliHLTComponent: spawn function, create an instance. | |
96 | virtual AliHLTComponent* Spawn() {return new AliHLTRootSchemaEvolutionComponent;} | |
97 | ||
98 | enum { | |
99 | /// push streamer info to the HLTOUT for the first event | |
100 | kHLTOUTatFirstEvent = 0x1, | |
101 | /// push streamer info to the HLTOUT for all events | |
102 | kHLTOUTatAllEvents = 0x2, | |
103 | /// push streamer info to the HLTOUT at EOR, this has no relevance | |
104 | /// for reconstruction as it is too late and just in one raw file, | |
105 | /// but it allows archival at the end of the run | |
106 | kHLTOUTatEOR = 0x4, | |
107 | /// push streamer info to FXS | |
108 | kFXS = 0x100, | |
109 | }; | |
110 | ||
111 | /// Update the array of known streamer infos from a list of infos | |
112 | /// Checks whether the provided infos are already there in the present version | |
113 | /// and adds if it is a new info. | |
114 | int UpdateStreamerInfos(const TList* list, TObjArray* infos) const; | |
115 | ||
9ddb0769 | 116 | /// merge streamer info entries from source array to target array |
117 | /// add all existing infos if not existing in the current one, or having | |
118 | /// different class version | |
119 | /// return 1 if target array has been changed | |
120 | static int MergeStreamerInfo(TObjArray* tgt, const TObjArray* src); | |
121 | ||
a22cde70 | 122 | class AliHLTDataBlockItem |
123 | { | |
124 | public: | |
125 | AliHLTDataBlockItem(AliHLTComponentDataType dt=kAliHLTVoidDataType, | |
126 | AliHLTUInt32_t spec=kAliHLTVoidDataSpec); | |
127 | ~AliHLTDataBlockItem(); | |
128 | ||
129 | /// extract data block to root object, and update performance parameters | |
130 | /// object needs to be deleted externally | |
131 | TObject* Extract(const AliHLTComponentBlockData* bd); | |
132 | ||
133 | /// stream object and update performance parameters | |
94d06b79 | 134 | int Stream(const TObject* obj, AliHLTMessage& msg); |
a22cde70 | 135 | |
136 | bool IsObject() const {return fIsObject;} | |
94d06b79 | 137 | bool operator==(const AliHLTDataBlockItem& i) const {return fDt==i.fDt && fSpecification==i.fSpecification;} |
a22cde70 | 138 | bool operator==(AliHLTComponentDataType dt) const {return fDt==dt;} |
139 | bool operator==(AliHLTUInt32_t spec) const {return fSpecification==spec;} | |
a22cde70 | 140 | operator const AliHLTComponentDataType&() const {return fDt;} |
141 | AliHLTUInt32_t GetSpecification() const {return fSpecification;} | |
142 | ||
143 | /// average extraction time in usec | |
144 | AliHLTUInt32_t GetExtractionTime() const {return fNofExtractions>0?fExtractionTimeUsec/fNofExtractions:0;} | |
145 | /// average streaming time in usec | |
146 | AliHLTUInt32_t GetStreamingTime() const {return fNofStreamings>0?fStreamingTimeUsec/fNofStreamings:0;} | |
147 | /// average total time in usec | |
148 | AliHLTUInt32_t GetTotalTime() const {return GetExtractionTime() + GetStreamingTime();} | |
149 | ||
150 | /// print status | |
151 | void Print(const char* option) const; | |
152 | ||
a22cde70 | 153 | private: |
154 | /// data type of the block | |
155 | AliHLTComponentDataType fDt; //! transient | |
156 | /// specification of the block | |
157 | AliHLTUInt32_t fSpecification; //! transient | |
158 | /// flag for TObject | |
159 | bool fIsObject; //! transient | |
160 | ||
161 | /// number of extractions | |
162 | AliHLTUInt32_t fNofExtractions; //! transient | |
163 | /// object extraction time in usec | |
164 | AliHLTUInt32_t fExtractionTimeUsec; //! transient | |
165 | /// timestamp of last extraction in usec | |
166 | AliHLTUInt32_t fLastExtraction; //! transient | |
167 | /// number of streamings | |
168 | AliHLTUInt32_t fNofStreamings; //! transient | |
169 | /// object streaming time in usec | |
170 | AliHLTUInt32_t fStreamingTimeUsec; //! transient | |
171 | /// timestamp of last streaming in usec | |
172 | AliHLTUInt32_t fLastStreaming; // !transient | |
173 | }; | |
174 | ||
175 | /// find item in the list | |
176 | AliHLTDataBlockItem* FindItem(AliHLTComponentDataType dt, | |
177 | AliHLTUInt32_t spec); | |
178 | ||
65106d07 | 179 | protected: |
b64e4d93 | 180 | /// inherited from AliHLTCalibrationProcessor: custom initialization |
181 | int InitCalibration(); | |
182 | /// inherited from AliHLTCalibrationProcessor: custom argument scan | |
183 | /// the AliHLTCalibrationProcessor so far does not use the base class | |
184 | /// methods for argument scan. | |
185 | int ScanArgument( int argc, const char** argv ) { | |
186 | int result=ScanConfigurationArgument(argc, argv); return result>0?result-1:result; | |
187 | } | |
188 | /// inherited from AliHLTCalibrationProcessor: cleanup | |
189 | int DeinitCalibration(); | |
190 | ||
191 | /// inherited from AliHLTCalibrationProcessor processing | |
192 | virtual int ProcessCalibration( const AliHLTComponentEventData& evtData, | |
193 | AliHLTComponentTriggerData& trigData ); | |
65106d07 | 194 | |
b64e4d93 | 195 | using AliHLTCalibrationProcessor::ProcessCalibration; |
196 | ||
197 | /// inherited from AliHLTCalibrationProcessor processing | |
198 | int ShipDataToFXS( const AliHLTComponentEventData& evtData, | |
199 | AliHLTComponentTriggerData& trigData); | |
200 | ||
201 | using AliHLTCalibrationProcessor::ShipDataToFXS; | |
65106d07 | 202 | |
203 | /** | |
204 | * Inherited from AliHLTComponent | |
205 | * Scan one argument and adjacent parameters. | |
206 | * @return number of scanned parameters, neg. error code if failed | |
207 | */ | |
208 | virtual int ScanConfigurationArgument(int argc, const char** argv); | |
209 | ||
94d06b79 | 210 | void SetBits(AliHLTUInt32_t b) {fPropertyFlags|=b;} |
211 | void ClearBits(AliHLTUInt32_t b) {fPropertyFlags&=~b;} | |
212 | bool TestBits(AliHLTUInt32_t b) const {return (fPropertyFlags&b) != 0;} | |
05948425 | 213 | int WriteToFile(const char* filename, const TObjArray* infos) const; |
65106d07 | 214 | |
215 | private: | |
216 | /** copy constructor prohibited */ | |
217 | AliHLTRootSchemaEvolutionComponent(const AliHLTRootSchemaEvolutionComponent&); | |
218 | /** assignment operator prohibited */ | |
219 | AliHLTRootSchemaEvolutionComponent& operator=(const AliHLTRootSchemaEvolutionComponent&); | |
220 | ||
a22cde70 | 221 | vector<AliHLTDataBlockItem> fList; //! list of block properties |
222 | ||
94d06b79 | 223 | AliHLTUInt32_t fPropertyFlags; //! property flags |
65106d07 | 224 | |
225 | TObjArray* fpStreamerInfos; //! array of streamer infos | |
a22cde70 | 226 | TStopwatch* fpEventTimer; //! stopwatch for event processing |
227 | TStopwatch* fpCycleTimer; //! stopwatch for event cycle | |
228 | AliHLTUInt32_t fMaxEventTime; //! required maximum processing time in usec | |
65106d07 | 229 | |
230 | AliHLTUInt32_t fFXSPrescaler; //! prescalar for the publishing to FXS | |
231 | ||
05948425 | 232 | TString fFileName; //! file name for dump at EOR |
233 | ||
65106d07 | 234 | static const char* fgkConfigurationObject; //! configuration object |
a22cde70 | 235 | static const AliHLTUInt32_t fgkTimeScale; //! timescale base |
65106d07 | 236 | |
a22cde70 | 237 | ClassDef(AliHLTRootSchemaEvolutionComponent, 0) // ROOT schema evolution component |
65106d07 | 238 | }; |
239 | #endif |