]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/sim/AliHLTOUTComponent.h
several bugfixes in the HLTOUT simulation
[u/mrichter/AliRoot.git] / HLT / sim / AliHLTOUTComponent.h
1 // @(#) $Id$
2
3 #ifndef ALIHLTOUTCOMPONENT_H
4 #define ALIHLTOUTCOMPONENT_H
5 /* This file is property of and copyright by the ALICE HLT Project        * 
6  * ALICE Experiment at CERN, All rights reserved.                         *
7  * See cxx source for full Copyright notice                               */
8
9 /** @file   AliHLTOUTComponent.h
10     @author Matthias Richter
11     @date   
12     @brief  The HLTOUT data sink component similar to HLTOUT nodes
13 */
14
15 // see class description below
16 // or
17 // refer to README to build package
18 // or
19 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
20
21 #include <vector>
22 #include "AliHLTOfflineDataSink.h"
23
24 class AliHLTHOMERLibManager;
25 class AliHLTMonitoringWriter;
26 typedef vector<AliHLTMonitoringWriter*> AliHLTMonitoringWriterPVector;
27
28 /**
29  * @class AliHLTOUTComponent
30  * The HLTOUT data sink component which models the behavior of the HLTOUT
31  * nodes of the HLT cluster.
32  * <h2>General properties:</h2>
33  *
34  * Component ID: \b HLTOUT <br>
35  * Library: \b libHLTrec.so     <br>
36  * Input Data Types: @ref kAliHLTAnyDataType <br>
37  * Output Data Types: none (offline data sink) <br>
38  *
39  * <h2>Mandatory arguments:</h2>
40  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
41  *
42  * <h2>Optional arguments:</h2>
43  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
44  * \li -links      <i> n   </i> <br>
45  *      number of output ddl links
46  *
47  * <h2>Configuration:</h2>
48  * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formating -->
49  * none
50  *
51  * <h2>Default CDB entries:</h2>
52  * none
53  *
54  * <h2>Performance:</h2>
55  * The component does not any event data processing.
56  *
57  * <h2>Memory consumption:</h2>
58  * The component does not any event data processing.
59  *
60  * <h2>Output size:</h2>
61  * The component is an offline sink component and has no output data.
62  *
63  * The component can be used to write data in the same format as
64  * the HLTOUT on the real HLT. In case of AliRoot simulation, the
65  * component is automatically added to the chain if the specified
66  * chains have output data. By that means, the HLT output is added
67  * to the simulation.
68  *
69  * @ingroup alihlt_rec
70  */
71 class AliHLTOUTComponent : public AliHLTOfflineDataSink  {
72  public:
73   /** standard constructor */
74   AliHLTOUTComponent();
75   /** destructor */
76   virtual ~AliHLTOUTComponent();
77
78   const char* GetComponentID();
79   void GetInputDataTypes( vector<AliHLTComponentDataType>& list);
80   AliHLTComponent* Spawn();
81
82  protected:
83   /**
84    * Init method.
85    */
86   int DoInit( int argc, const char** argv );
87
88   /**
89    * Deinit method.
90    */
91   int DoDeinit();
92
93   /**
94    * Data processing method for the component.
95    * The function can be overloaded by other file writer components.
96    * @param evtData       event data structure
97    * @param blocks        input data block descriptors
98    * @param trigData      trigger data structure
99    */
100   int DumpEvent( const AliHLTComponentEventData& evtData,
101                  const AliHLTComponentBlockData* blocks, 
102                  AliHLTComponentTriggerData& trigData );
103
104   using AliHLTDataSink::DumpEvent;
105
106   /**
107    * Fill ESD for one event.
108    * @param eventNo       event No. \em Note: this is an internal enumeration of the
109    *                      processed events.
110    * @param runLoader     the AliRoot runloader
111    * @param esd           an AliESDEvent instance
112    * @return neg. error code if failed 
113    */
114   int FillESD(int eventNo, AliRunLoader* runLoader, AliESDEvent* esd);
115
116  private:
117   /** copy constructor prohibited */
118   AliHLTOUTComponent(const AliHLTOUTComponent&);
119   /** assignment operator prohibited */
120   AliHLTOUTComponent& operator=(const AliHLTOUTComponent&);
121
122   int ShuffleWriters(AliHLTMonitoringWriterPVector &list, AliHLTUInt32_t size);
123
124   /**
125    * Fill the output buffer and allocate if neccessary.
126    * Assemble ouput buffer with Common Data Header, HLT header and data from the
127    * writer. Works on the same buffer witch is allocated once and eventually
128    * grown in order to avoid frequent allocs/deallocs.   
129    * @param eventNo    number of the event
130    * @param pWriter    [IN]  the HOMER writer
131    * @param pBuffer    [OUT] target to receive the pointer to buffer
132    * @return size of the buffer
133    */
134   int FillOutputBuffer(int eventNo, AliHLTMonitoringWriter* pWriter, const AliHLTUInt8_t* &pBuffer);
135
136   /**
137    * Write the digits for one DDL
138    * @param eventNo    number of the event
139    * @param runLoader  AliRoot run loader instance
140    * @param hltddl     Number of DDL link within the range of HLT
141    * @param pBuffer    buffer to write
142    * @param size       size of the buffer
143    * @return neg. error if failed
144    */
145   int WriteDigits(int eventNo, AliRunLoader* runLoader, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size);
146
147   /**
148    * Write the raw file for one DDL
149    * @param eventNo    number of the event
150    * @param runLoader  AliRoot run loader instance
151    * @param hltddl     Number of DDL link within the range of HLT
152    * @param pBuffer    buffer to write
153    * @param size       size of the buffer
154    * @return neg. error if failed
155    */
156   int WriteRawFile(int eventNo, AliRunLoader* runLoader, int hltddl, const AliHLTUInt8_t* pBuffer, unsigned int size);
157
158   /** list of HOMER writers */
159   AliHLTMonitoringWriterPVector fWriters; //!transient
160
161   /** number of DDLs used*/
162   int fNofDDLs; //!transient
163
164   /** equipment ID of first HLT DDL */
165   int fIdFirstDDL; //!transient
166
167   /** write digits or not */
168   Bool_t fWriteDigits; //!transient
169
170   /** write raw file or not */
171   Bool_t fWriteRaw; //!transient
172
173   /** output buffer, allocated once in order to avoid frequent alloc/dealloc */
174   vector<AliHLTUInt8_t> fBuffer; //!transient
175
176   /** instance of the HOMER library manager */
177   AliHLTHOMERLibManager* fpLibManager; // !transient
178
179   ClassDef(AliHLTOUTComponent, 0)
180 };
181 #endif