]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/rec/AliRawReaderHLT.h
New functions for exporting the found TCF parameters to an ascii-file
[u/mrichter/AliRoot.git] / HLT / rec / AliRawReaderHLT.h
... / ...
CommitLineData
1//-*- Mode: C++ -*-
2// $Id$
3
4#ifndef ALIRAWREADERHLT_H
5#define ALIRAWREADERHLT_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 AliRawReaderHLT.h
11 @author Matthias Richter
12 @date
13 @brief AliRawReader implementation which replaces original input of
14 detectors with the appropriate HLT output. */
15
16// see below for class documentation
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 "AliHLTDataTypes.h"
23#include "AliRawReader.h" // RAW, base class
24#include "AliHLTReconstructorBase.h"
25#include "TString.h"
26#include <vector>
27
28class AliHLTOUT;
29class AliHLTOUTHandler;
30
31/**
32 * @class AliRawReaderHLT
33 * A specific AliRawReader for detector input replacement by HLTOUT data blocks.
34 *
35 * HLT components can produce output data in the detector ddl raw format.
36 * Data blocks of this format can be fed into the normal detector reconstruction
37 * without changes in the actual reconstruction code by means of the
38 * AliRawReaderHLT implementation of the AliRawReader.
39 *
40 * @section sec_alirawreaderhlt_concept Conceptual design
41 * The AliRawReader provides an abstract interface to the ddl raw data. All
42 * reconstruction code uses this interface to access the data.
43 * HLT components can send their data in the original ddl raw format. The only
44 * difference of such data blocks is the location since they are shipped as
45 * part of the HLTOUT data stream. The AliRawReaderHLT provides redirection of
46 * those data blocks.
47 *
48 * @section sec_alirawreaderhlt_usage Selection of the HLTOUT data stream
49 * The input data of a detector can be replaced by the corresponding HLT
50 * data by calling the <tt>AliReconstruction::SetUseHLTData("...")</tt>, e.g.
51 * <pre>
52 * AliReconstruction rec;
53 * rec.SetUseHLTData("TPC TRD");
54 * </pre>
55 * will replace the input of TPC and TRD.
56 *
57 * @section sec_alirawreaderhlt_module Module implementation
58 * In order to determine the equipment id for the data block, the HLT module
59 * must implement an HLTOUT handler of class AliHLTOUTHandlerEquId which is of
60 * type @ref AliHLTModuleAgent::AliHLTOUTHandlerType ::kRawReader.
61 * The handler must implement the method
62 * <pre>
63 * // AliHLTOUTHandlerEquId::ProcessData(AliHLTOUT*)
64 * virtual int ProcessData(AliHLTOUT* pData);
65 * </pre>
66 * which returns the equipment id and eventually decodes data to be retrieved
67 * by calling AliHLTOUTHandler::GetProcessedData().
68 *
69 * Secondly, the AliHLTModuleAgent implementation of the module has to create
70 * the handler for the data blocks. Depending on the data type and specification,
71 * the the following interface methods return handler description and handler.
72 * <pre>
73 * int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType dt,
74 * AliHLTUInt32_t spec,
75 * AliHLTOUTHandlerDesc& desc) const;
76 *
77 * AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType dt,
78 * AliHLTUInt32_t spec);
79 * </pre>
80 *
81 * @ingroup alihlt_aliroot_reconstruction
82 */
83class AliRawReaderHLT : public AliRawReader, public AliHLTReconstructorBase {
84 public:
85 /** constructor */
86 AliRawReaderHLT(AliRawReader* pParentReader, const char* options=NULL);
87 /** destructor */
88 virtual ~AliRawReaderHLT();
89
90 // interface methods of AliRawReader
91 void Select(Int_t detectorID,
92 Int_t minDDLID = -1, Int_t maxDDLID = -1);
93// void Select(const char *detectorName,
94// Int_t minDDLID = -1, Int_t maxDDLID = -1);
95
96 using AliRawReader::Select;
97
98 void SelectEquipment(Int_t equipmentType,
99 Int_t minEquipmentId = -1,
100 Int_t maxEquipmentId = -1);
101 void SkipInvalid(Bool_t skip = kTRUE);
102 // void SelectEvents(Int_t type);
103
104 UInt_t GetType() const;
105 UInt_t GetRunNumber() const;
106 const UInt_t* GetEventId() const;
107 const UInt_t* GetTriggerPattern() const;
108 const UInt_t* GetDetectorPattern() const;
109 const UInt_t* GetAttributes() const;
110 const UInt_t* GetSubEventAttributes() const;
111 UInt_t GetLDCId() const;
112 UInt_t GetGDCId() const;
113 UInt_t GetTimestamp() const;
114
115 const UInt_t* GetEquipmentAttributes() const;
116 Int_t GetEquipmentElementSize() const;
117 Int_t GetEquipmentHeaderSize() const;
118
119 Int_t GetEquipmentSize() const;
120 Int_t GetEquipmentType() const;
121 Int_t GetEquipmentId() const;
122 Bool_t ReadHeader();
123 Bool_t ReadNextData(UChar_t*& data);
124 Bool_t ReadNextInt(UInt_t& data);
125 Bool_t ReadNextShort(UShort_t& data);
126 Bool_t ReadNextChar(UChar_t& data);
127 Bool_t ReadNext(UChar_t* data, Int_t size);
128
129 Bool_t Reset();
130
131 Bool_t NextEvent();
132 Bool_t RewindEvents();
133
134 protected:
135
136 private:
137 /** standard constructor prohibited */
138 AliRawReaderHLT();
139 /** copy constructor prohibited */
140 AliRawReaderHLT(const AliRawReaderHLT&);
141 /** assignment operator prohibited */
142 AliRawReaderHLT& operator=(const AliRawReaderHLT&);
143
144 /**
145 * Scan the options.
146 * Set the ids for the specified detectors in the detector
147 * list. Currently, no other options are available.
148 */
149 int ScanOptions(const char* options);
150
151 /**
152 * Read the next data block from the HLT stream
153 */
154 Bool_t ReadNextHLTData();
155
156 /**
157 * Check if a ddlid is part of the ones which are selected for
158 * input replacement.
159 */
160 Bool_t IsHLTInput(int ddlid);
161
162 /**
163 * Check if redirection is enabled for at least one detector in the
164 * selected range.
165 * Set the fbHaveHLTData variable
166 * @return true if data has to be read from the HLT stream.
167 */
168 Bool_t EvaluateSelection();
169
170 /**
171 * Release the current HLT data.
172 * Releases the current buffer of either the active HLTOUT data
173 * block handler or the HLTOUT instance. The latter implies a
174 * reset of the reader concerning the HLT data blocks.
175 * @param bReleaseHLTOUT release HLTOUT instance if \em true
176 * only current data buffer if \em false
177 * @return neg. error code if failed
178 */
179 int ReleaseHLTData(bool bReleaseHLTOUT=true);
180
181 /**
182 * Backbone of all Read functions.
183 * Reads the next data into the internal buffer and switches to next
184 * block if enabled.
185 *
186 * @param data target to receive pointer
187 * @param readHeader kTRUE: switch to next block if no more data
188 */
189 Bool_t ReadNextData(UChar_t*& data, Bool_t readHeader);
190
191 /** the rawreader */
192 AliRawReader* fpParentReader; //!transient
193
194 /** options */
195 TString fOptions; //!transient
196
197 /** system options = options w/o detector strings */
198 TString fSystemOptions; //!transient
199
200 /** current data set, either extracted from the HLT stream or parent raw reader */
201 const AliHLTUInt8_t* fpData; // !transient
202
203 /** size of the current data set */
204 int fDataSize; // !transient
205
206 /** current stream offset in the data set */
207 int fOffset; // !transient
208
209 /** current stream position for the ReadNextData function */
210 int fPosition; // !transient
211
212 /** equipment id of the current data set, >0 indicates data set from HLT stream */
213 int fEquipmentId; // !transient
214
215 /** indicates the availibility of data from the HLT stream */
216 bool fbHaveHLTData; // !transient
217
218 /** list of detectors for which data will be taken from HLT stream */
219 vector<int> fDetectors; // !transient
220
221 /** instance of the HLTOUT handler */
222 AliHLTOUT* fpHLTOUT; // !transient
223
224 /** start reading HLTOUT from beginning */
225 bool fbReadFirst; //!transient
226
227 /** instance of the data handler providing the current data buffer */
228 AliHLTOUTHandler* fpDataHandler; // !transient
229
230 ClassDef(AliRawReaderHLT, 4)
231};
232
233#define ALIHLTREC_LIBRARY "libHLTrec.so"
234#define ALIHLTREC_LIBRARY_VERSION 0
235#define ALIRAWREADERHLT_CREATE_INSTANCE "AliRawReaderHLTCreateInstance"
236
237#ifdef __cplusplus
238extern "C" {
239#endif
240 typedef AliRawReader* (*AliRawReaderHLTCreateInstance_t)(AliRawReader* pParentReader, const char* options);
241
242 /**
243 * Create an instance of the AliRawReader class
244 */
245 AliRawReader* AliRawReaderHLTCreateInstance(AliRawReader* pParentReader, const char* options);
246#ifdef __cplusplus
247}
248#endif
249#endif