]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/sim/AliHLTOUTComponent.h
implementing the copy contructors for two helper classes because compiler on macos...
[u/mrichter/AliRoot.git] / HLT / sim / AliHLTOUTComponent.h
1 //-*- Mode: C++ -*-
2 // $Id$
3
4 #ifndef ALIHLTOUTCOMPONENT_H
5 #define ALIHLTOUTCOMPONENT_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   AliHLTOUTComponent.h
11 //  @author Matthias Richter
12 //  @date   
13 //  @brief  The HLTOUT data sink component similar to HLTOUT nodes.
14 //  @note   Used in the AliRoot environment only.
15
16 // see class description below
17 // or
18 // refer to README to build package
19 // or
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
21
22 #include "AliHLTOfflineDataSink.h"
23
24 class AliHLTHOMERLibManager;
25 class AliHLTMonitoringWriter;
26 class TFile;
27 class TTree;
28 typedef vector<AliHLTMonitoringWriter*> AliHLTMonitoringWriterPVector;
29
30 /**
31  * @class AliHLTOUTComponent
32  * The HLTOUT data sink component which models the behavior of the HLTOUT
33  * nodes of the HLT cluster.
34  * <h2>General properties:</h2>
35  * The HLTOUT component is attached at the end of a chain. It stores all input
36  * block in the HOMER format, distributed over a number of DDL link. The data
37  * is stored in a digit file or in raw ddl files.
38  *
39  * Component ID: \b HLTOUT <br>
40  * Library: \b libHLTrec.so     <br>
41  * Input Data Types: @ref kAliHLTAnyDataType <br>
42  * Output Data Types: none (offline data sink) <br>
43  *
44  * <h2>Mandatory arguments:</h2>
45  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
46  *
47  * <h2>Optional arguments:</h2>
48  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
49  * \li -links      <i> n   </i> <br>
50  *      number of output ddl links
51  * \li -digitfile  <i> name   </i> <br>
52  *      name of the digit file to write (default HLT.Digits.root)
53  * \li -rawout[=on,off]  <br>
54  *      switch raw output on/off (default on)
55  * \li -digitout[=on,off]  <br>
56  *      switch digit output on/off (default on)
57  *
58  * <h2>Configuration:</h2>
59  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
60  * none
61  *
62  * <h2>Default CDB entries:</h2>
63  * none
64  *
65  * <h2>Performance:</h2>
66  * The component does not any event data processing.
67  *
68  * <h2>Memory consumption:</h2>
69  * The component does not any event data processing.
70  *
71  * <h2>Output size:</h2>
72  * The component is an offline sink component and has no output data.
73  *
74  * The component can be used to write data in the same format as
75  * the HLTOUT on the real HLT. In case of AliRoot simulation, the
76  * component is automatically added to the chain if the specified
77  * chains have output data. By that means, the HLT output is added
78  * to the simulation.
79  *
80  * @ingroup alihlt_aliroot_simulation
81  */
82 class AliHLTOUTComponent : public AliHLTOfflineDataSink  {
83  public:
84   /** standard constructor */
85   AliHLTOUTComponent();
86   /** destructor */
87   virtual ~AliHLTOUTComponent();
88
89   const char* GetComponentID();
90   void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
91   AliHLTComponent* Spawn();
92
93   /**
94    * Enable global options valid for all instances of the component
95    * @param options   bit field
96    */
97   static void SetGlobalOption(unsigned int options);
98
99   /**
100    * Disable global options valid for all instances of the component
101    * @param options   bit field
102    */
103   static void ClearGlobalOption(unsigned int options);
104
105   enum {
106     /** write the raw files of the HLT links */
107     kWriteRawFiles = 0x1,
108     /** write the digit file */
109     kWriteDigits = 0x2
110   };
111
112  protected:
113   /**
114    * Init method.
115    */
116   int DoInit( int argc, const char** argv );
117
118   /// inherited from AliHLTComponent,  component specific argument scan
119   int ScanConfigurationArgument(int argc, const char** argv);
120
121   /**
122    * Deinit method.
123    */
124   int DoDeinit();
125
126   /**
127    * Data processing method for the component.
128    * The function can be overloaded by other file writer components.
129    * @param evtData       event data structure
130    * @param blocks        input data block descriptors
131    * @param trigData      trigger data structure
132    */
133   int DumpEvent( const AliHLTComponentEventData& evtData,
134                  const AliHLTComponentBlockData* blocks, 
135                  AliHLTComponentTriggerData& trigData );
136
137   using AliHLTDataSink::DumpEvent;
138
139   /**
140    * Fill ESD for one event.
141    * Empty now, data written in Write() at the end of DumpEvent()
142    * @param eventNo       event No. \em Note: this is an internal enumeration of the
143    *                      processed events.
144    * @param runLoader     the AliRoot runloader
145    * @return neg. error code if failed 
146    */
147   int FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd);
148
149   /**
150    * Write the ecoded HLTOUT data to raw and digits files.
151    * Originally data was written in the FillESD function of the
152    * AliHLTOfflineInterface. Mainly for the sake of availability of the
153    * AliLoader. This concept has not turned out to be succesful and the
154    * development went a slightly different direction with the concept of
155    * HLTOUT handlers.
156    * 2010-04-14 change the original FillESD() to Write(), keep the body
157    * of the function
158    *
159    * @param eventNo       event No. \em Note: this is an internal enumeration of the
160    *                      processed events.
161    * @param runLoader     the AliRoot runloader
162    * @return neg. error code if failed 
163    */
164   int Write(int eventNo, AliRunLoader* runLoader);
165
166  private:
167   /** copy constructor prohibited */
168   AliHLTOUTComponent(const AliHLTOUTComponent&);
169   /** assignment operator prohibited */
170   AliHLTOUTComponent& operator=(const AliHLTOUTComponent&);
171
172   int ShuffleWriters(AliHLTMonitoringWriterPVector &list, AliHLTUInt32_t size);
173
174   /**
175    * Fill the output buffer and allocate if neccessary.
176    * Assemble ouput buffer with Common Data Header, HLT header and data from the
177    * writer. Works on the same buffer witch is allocated once and eventually
178    * grown in order to avoid frequent allocs/deallocs.   
179    * @param eventNo    number of the event
180    * @param pWriter    [IN]  the HOMER writer
181    * @param pBuffer    [OUT] target to receive the pointer to buffer
182    * @return size of the buffer
183    */
184   int FillOutputBuffer(int eventNo, AliHLTMonitoringWriter* pWriter, const AliHLTUInt8_t* &pBuffer);
185
186   /**
187    * Write data for a DDL link.
188    * @param hltddl     Number of DDL link within the range of HLT
189    * @param pBuffer    buffer to write
190    * @param bufferSize size of the buffer
191    */
192   int WriteDigitArray(int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int bufferSize);
193
194   /**
195    * Write the digits for one DDL
196    * @param eventNo    number of the event
197    * @param runLoader  AliRoot run loader instance
198    * @return neg. error if failed
199    */
200   int WriteDigits(int eventNo, AliRunLoader* runLoader);
201
202   /**
203    * Write the raw file for one DDL
204    * @param eventNo    number of the event
205    * @param runLoader  AliRoot run loader instance
206    * @param hltddl     Number of DDL link within the range of HLT
207    * @param pBuffer    buffer to write
208    * @param size       size of the buffer
209    * @return neg. error if failed
210    */
211   int WriteRawFile(int eventNo, AliRunLoader* runLoader, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size);
212
213   /** list of HOMER writers */
214   AliHLTMonitoringWriterPVector fWriters; //!transient
215
216   /** number of DDLs used*/
217   int fNofDDLs; //!transient
218
219   /** equipment ID of first HLT DDL */
220   int fIdFirstDDL; //!transient
221
222   /** output buffer, allocated once in order to avoid frequent alloc/dealloc */
223   vector<AliHLTUInt8_t> fBuffer; //!transient
224
225   /** instance of the HOMER library manager */
226   AliHLTHOMERLibManager* fpLibManager; // !transient
227
228   /** global options for all instances */
229   static int fgOptions; //! transient
230
231   /** digit file name */
232   TString fDigitFileName; //! transient
233
234   /** the root file for the HLT 'digit' output */
235   TFile* fpDigitFile; //!transient
236
237   /** the tree for the HLT 'digit' output */
238   TTree* fpDigitTree; //!transient
239
240   /** array of TArrayC output buffers and branches */
241   TArrayC** fppDigitArrays; //!transient
242
243   /** Id of HOMER writer kept from previous event */
244   int fReservedWriter; //!transient
245
246   /** Data size kept in the internal buffer */
247   int fReservedData; //!transient
248
249   ClassDef(AliHLTOUTComponent, 4)
250 };
251 #endif