4 #ifndef ALIHLTFILEPUBLISHER_H
5 #define ALIHLTFILEPUBLISHER_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 AliHLTFilePublisher.h
11 @author Matthias Richter
13 @brief An HLT file publishing (data source) component.
14 @note The class is used in Offline (AliRoot) context
17 #include "AliHLTDataSource.h"
22 * @class AliHLTFilePublisher
23 * An HLT data source component which publishes data from one or a sequence
26 * Component ID: \b FilePublisher <br>
27 * Library: \b libAliHLTUtil.
29 * Mandatory arguments: <br>
30 * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
31 * \li -datafile <i> filename </i>
32 * \li -datafilelist <i> file pattern </i> <br>
34 * \li -datatype <i> datatype dataorigin </i> <br>
35 * data type ID and origin, e.g. <tt>-datatype 'CLUSTERS' 'TPC ' </tt>
36 * \li -dataspec <i> specification </i> <br>
37 * data specification treated as decimal number or hex number if
40 * indicate files published by the next event
42 * Optional arguments:<br>
44 * The component needs at least one argument \em -datafile or \em -datafilelist.
45 * Both can occur multiple times. The \em -datatype and \em -dataspec
46 * parameters are valid for all files until the next occurrence of
48 * All files er published within one event, unless the \em -nexevent specifies
49 * where to break into multiple events.
50 * @ingroup alihlt_component
52 class AliHLTFilePublisher : public AliHLTDataSource {
54 /** standard constructor */
55 AliHLTFilePublisher();
57 virtual ~AliHLTFilePublisher();
59 const char* GetComponentID();
60 AliHLTComponentDataType GetOutputDataType();
61 void GetOutputDataSize( unsigned long& constBase, double& inputMultiplier );
62 AliHLTComponent* Spawn();
66 * Opens all files for all events from the event list @ref fEvents and adds TFile
67 * opjects to the internal list.
75 int DoInit( int argc, const char** argv );
83 * Data processing method for the component.
84 * @param evtData event data structure
85 * @param trigData trigger data structure
86 * @param outputPtr pointer to target buffer
87 * @param size <i>input</i>: size of target buffer
88 * <i>output</i>:size of produced data
89 * @param outputBlocks list to receive output block descriptors
92 int GetEvent( const AliHLTComponentEventData& evtData,
93 AliHLTComponentTriggerData& trigData,
94 AliHLTUInt8_t* outputPtr,
96 vector<AliHLTComponentBlockData>& outputBlocks );
99 * Scan one argument and adjacent parameters.
100 * Can be overloaded by child classes in order to add additional arguments
101 * beyond the standard arguments of the file publisher. The method is called
102 * whenever a non-standard argument is recognized.
103 * @param argc size of the argument array
104 * @param argv agument array for component initialization
105 * @return number of processed members of the argv <br>
106 * -EINVAL unknown argument <br>
107 * -EPROTO parameter for argument missing <br>
109 virtual int ScanArgument(int argc, const char** argv);
113 * Get the data type which is set for the current file
115 //AliHLTComponentDataType GetCurrentDataType() const;
118 * Get the data specification which is set for the current file
120 //AliHLTUInt32_t GetCurrentSpecification() const;
123 /** prohibit copy constructor */
124 AliHLTFilePublisher(const AliHLTFilePublisher&);
125 /** prohibit assignment operator */
126 AliHLTFilePublisher& operator=(const AliHLTFilePublisher&);
131 class FileDesc : public TObject {
133 /** constructor not implemented */
135 /** constructor to use */
136 FileDesc(const char* name, AliHLTComponentDataType dt, AliHLTUInt32_t spec);
142 * @return size of the file, neg. error code if failed
147 * Get name of the file.
149 const char* GetName() {return fName.Data();}
151 // implicite type conversions
152 operator TFile*() const {return fpInstance;}
153 operator AliHLTComponentDataType() {return fDataType;}
154 operator AliHLTUInt32_t() {return fSpecification;}
157 /** prohibited copy constructor */
159 /** prohibited copy operator */
160 FileDesc& operator=(FileDesc&);
163 TString fName; //! transient
165 TFile* fpInstance; //! transient
167 AliHLTComponentDataType fDataType; //! transient
168 /** data specification */
169 AliHLTUInt32_t fSpecification; //! transient
173 * Compound to store all files and meta information for one event.
175 class EventFiles : public TObject {
178 EventFiles() : fFiles(), fSize(0) {fFiles.SetOwner();}
183 * Add a file descriptor
185 void Add(TObject* pObj) {fFiles.Add(pObj);}
187 operator TList&() {return fFiles;}
190 /** list of file names for the event */
191 TList fFiles; //! transient
192 /** size of all the files in that event */
193 Int_t fSize; //! transient
197 * Insert a file descriptor into the event descriptor.
198 * If the event descriptor is NULL it is created before the file descriptor
200 * @param pCurrEvent reference of the event descriptor pointer
201 * @param pDesc file decriptor
202 * @return neg. error value if failed
204 int InsertFile(EventFiles* &pCurrEvent, FileDesc* pDesc);
208 * The event descriptor is added to the list and the reference is cleared.
209 * @param pEvent event decriptor
210 * @return neg. error value if failed
212 int InsertEvent(EventFiles* &pEvent);
214 /** the current event */
215 TObjLink *fpCurrent; //! transient
217 /** the list of events to be published */
218 TList fEvents; //! transient
220 /** the maximum buffer size i.e. size of the biggest file */
221 Int_t fMaxSize; //! transient
223 ClassDef(AliHLTFilePublisher, 1)