4 #ifndef ALIHLTROOTSCHEMAEVOLUTIONCOMPONENT_H
5 #define ALIHLTROOTSCHEMAEVOLUTIONCOMPONENT_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 *
10 /** @file AliHLTRootSchemaEvolutionComponent.h
11 @author Matthias Richter
13 @brief Handler component for ROOT schema evolution of streamed objects
16 #include "AliHLTCalibrationProcessor.h"
26 * @class AliHLTRootSchemaEvolutionComponent
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
33 * <h2>General properties:</h2>
35 * Component ID: \b ROOTFileWriter <br>
36 * Library: \b libAliHLTUtil.so <br>
37 * Input Data Types: ::kAliHLTAnyDataType <br>
38 * Output Data Types: none <br>
40 * <h2>Mandatory arguments:</h2>
41 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
43 * <h2>Optional arguments:</h2>
44 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
45 * \li -fxs<=[n,off]> <br>
46 * push streamer info to FXS, fetched by Shuttle and store in the entry
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
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.
54 * \li -file=filename <br>
55 * write to file at EOR
57 * required processing rate in Hz, default 2000Hz
59 * <h2>Configuration:</h2>
60 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
61 * Configuration by component arguments.
63 * <h2>Default CDB entries:</h2>
64 * The component loads no CDB entries.
66 * <h2>Performance:</h2>
67 * The component does not process any event data.
69 * <h2>Memory consumption:</h2>
70 * The component does not process any event data.
72 * <h2>Output size:</h2>
73 * Depending on the mode.
75 * @ingroup alihlt_util_components
77 class AliHLTRootSchemaEvolutionComponent : public AliHLTCalibrationProcessor
80 /// standard constructor
81 AliHLTRootSchemaEvolutionComponent();
83 virtual ~AliHLTRootSchemaEvolutionComponent();
85 /// inherited from AliHLTComponent: return id of the component.
86 virtual const char* GetComponentID() {return "ROOTSchemaEvolutionComponent";};
87 /// inherited from AliHLTComponent: input data types
88 virtual void GetInputDataTypes(AliHLTComponentDataTypeList&);
89 /// inherited from AliHLTComponent: output data types
90 virtual AliHLTComponentDataType GetOutputDataType();
91 /// inherited from AliHLTComponent: output data size
92 virtual void GetOutputDataSize(unsigned long&, double&);
94 /// inherited from AliHLTComponent: spawn function, create an instance.
95 virtual AliHLTComponent* Spawn() {return new AliHLTRootSchemaEvolutionComponent;}
98 /// push streamer info to the HLTOUT for the first event
99 kHLTOUTatFirstEvent = 0x1,
100 /// push streamer info to the HLTOUT for all events
101 kHLTOUTatAllEvents = 0x2,
102 /// push streamer info to the HLTOUT at EOR, this has no relevance
103 /// for reconstruction as it is too late and just in one raw file,
104 /// but it allows archival at the end of the run
106 /// push streamer info to FXS
110 /// Update the array of known streamer infos from a list of infos
111 /// Checks whether the provided infos are already there in the present version
112 /// and adds if it is a new info.
113 int UpdateStreamerInfos(const TList* list, TObjArray* infos) const;
115 /// merge streamer info entries from source array to target array
116 /// add all existing infos if not existing in the current one, or having
117 /// different class version
118 /// return 1 if target array has been changed
119 static int MergeStreamerInfo(TObjArray* tgt, const TObjArray* src);
121 class AliHLTDataBlockItem
124 AliHLTDataBlockItem(AliHLTComponentDataType dt=kAliHLTVoidDataType,
125 AliHLTUInt32_t spec=kAliHLTVoidDataSpec);
126 ~AliHLTDataBlockItem();
128 /// extract data block to root object, and update performance parameters
129 /// object needs to be deleted externally
130 TObject* Extract(const AliHLTComponentBlockData* bd);
132 /// stream object and update performance parameters
133 int Stream(TObject* obj, AliHLTMessage& msg);
135 bool IsObject() const {return fIsObject;}
136 bool operator==(AliHLTDataBlockItem& i) const {return fDt==i.fDt && fSpecification==i.fSpecification;}
137 bool operator==(AliHLTComponentDataType dt) const {return fDt==dt;}
138 bool operator==(AliHLTUInt32_t spec) const {return fSpecification==spec;}
139 int operator+(AliHLTDataBlockItem& b) const;
140 operator const AliHLTComponentDataType&() const {return fDt;}
141 AliHLTUInt32_t GetSpecification() const {return fSpecification;}
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();}
151 void Print(const char* option) const;
154 /// data type of the block
155 AliHLTComponentDataType fDt; //! transient
156 /// specification of the block
157 AliHLTUInt32_t fSpecification; //! transient
159 bool fIsObject; //! transient
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
175 /// find item in the list
176 AliHLTDataBlockItem* FindItem(AliHLTComponentDataType dt,
177 AliHLTUInt32_t spec);
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;
188 /// inherited from AliHLTCalibrationProcessor: cleanup
189 int DeinitCalibration();
191 /// inherited from AliHLTCalibrationProcessor processing
192 virtual int ProcessCalibration( const AliHLTComponentEventData& evtData,
193 AliHLTComponentTriggerData& trigData );
195 using AliHLTCalibrationProcessor::ProcessCalibration;
197 /// inherited from AliHLTCalibrationProcessor processing
198 int ShipDataToFXS( const AliHLTComponentEventData& evtData,
199 AliHLTComponentTriggerData& trigData);
201 using AliHLTCalibrationProcessor::ShipDataToFXS;
204 * Inherited from AliHLTComponent
205 * Scan one argument and adjacent parameters.
206 * @return number of scanned parameters, neg. error code if failed
208 virtual int ScanConfigurationArgument(int argc, const char** argv);
210 void SetBits(AliHLTUInt32_t b) {fFlags|=b;}
211 void ClearBits(AliHLTUInt32_t b) {fFlags&=~b;}
212 bool TestBits(AliHLTUInt32_t b) {return (fFlags&b) != 0;}
213 int WriteToFile(const char* filename, const TObjArray* infos) const;
216 /** copy constructor prohibited */
217 AliHLTRootSchemaEvolutionComponent(const AliHLTRootSchemaEvolutionComponent&);
218 /** assignment operator prohibited */
219 AliHLTRootSchemaEvolutionComponent& operator=(const AliHLTRootSchemaEvolutionComponent&);
221 vector<AliHLTDataBlockItem> fList; //! list of block properties
223 AliHLTUInt32_t fFlags; //! property flags
225 TObjArray* fpStreamerInfos; //! array of streamer infos
226 TStopwatch* fpEventTimer; //! stopwatch for event processing
227 TStopwatch* fpCycleTimer; //! stopwatch for event cycle
228 AliHLTUInt32_t fMaxEventTime; //! required maximum processing time in usec
230 AliHLTUInt32_t fFXSPrescaler; //! prescalar for the publishing to FXS
232 TString fFileName; //! file name for dump at EOR
234 static const char* fgkConfigurationObject; //! configuration object
235 static const AliHLTUInt32_t fgkTimeScale; //! timescale base
237 ClassDef(AliHLTRootSchemaEvolutionComponent, 0) // ROOT schema evolution component