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 *
10 /** @file AliRawReaderHLT.h
11 @author Matthias Richter
13 @brief AliRawReader implementation which replaces original input of
14 detectors with the appropriate HLT output. */
16 // see below for class documentation
18 // refer to README to build package
20 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
22 #include "AliHLTDataTypes.h"
23 #include "AliRawReader.h" // RAW, base class
24 #include "AliHLTReconstructorBase.h"
29 class AliHLTOUTHandler;
32 * @class AliRawReaderHLT
33 * A specific AliRawReader for detector input replacement by HLTOUT data blocks.
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.
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
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.
52 * AliReconstruction rec;
53 * rec.SetUseHLTData("TPC TRD");
55 * will replace the input of TPC and TRD.
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
63 * // AliHLTOUTHandlerEquId::ProcessData(AliHLTOUT*)
64 * virtual int ProcessData(AliHLTOUT* pData);
66 * which returns the equipment id and eventually decodes data to be retrieved
67 * by calling AliHLTOUTHandler::GetProcessedData().
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.
73 * int AliHLTModuleAgent::GetHandlerDescription(AliHLTComponentDataType dt,
74 * AliHLTUInt32_t spec,
75 * AliHLTOUTHandlerDesc& desc) const;
77 * AliHLTOUTHandler* AliHLTModuleAgent::GetOutputHandler(AliHLTComponentDataType dt,
78 * AliHLTUInt32_t spec);
81 * @ingroup alihlt_aliroot_reconstruction
83 class AliRawReaderHLT : public AliRawReader, public AliHLTReconstructorBase {
86 AliRawReaderHLT(AliRawReader* pParentReader, const char* options=NULL);
88 virtual ~AliRawReaderHLT();
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);
96 using AliRawReader::Select;
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);
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;
115 const UInt_t* GetEquipmentAttributes() const;
116 Int_t GetEquipmentElementSize() const;
117 Int_t GetEquipmentHeaderSize() const;
119 Int_t GetEquipmentSize() const;
120 Int_t GetEquipmentType() const;
121 Int_t GetEquipmentId() const;
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);
132 Bool_t RewindEvents();
137 /** standard constructor prohibited */
139 /** copy constructor prohibited */
140 AliRawReaderHLT(const AliRawReaderHLT&);
141 /** assignment operator prohibited */
142 AliRawReaderHLT& operator=(const AliRawReaderHLT&);
146 * Set the ids for the specified detectors in the detector
147 * list. Currently, no other options are available.
149 int ScanOptions(const char* options);
152 * Read the next data block from the HLT stream
154 Bool_t ReadNextHLTData();
157 * Check if a ddlid is part of the ones which are selected for
160 Bool_t IsHLTInput(int ddlid);
163 * Check if redirection is enabled for at least one detector in the
165 * Set the fbHaveHLTData variable
166 * @return true if data has to be read from the HLT stream.
168 Bool_t EvaluateSelection();
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
179 int ReleaseHLTData(bool bReleaseHLTOUT=true);
182 * Backbone of all Read functions.
183 * Reads the next data into the internal buffer and switches to next
186 * @param data target to receive pointer
187 * @param readHeader kTRUE: switch to next block if no more data
189 Bool_t ReadNextData(UChar_t*& data, Bool_t readHeader);
192 AliRawReader* fpParentReader; //!transient
195 TString fOptions; //!transient
197 /** system options = options w/o detector strings */
198 TString fSystemOptions; //!transient
200 /** current data set, either extracted from the HLT stream or parent raw reader */
201 const AliHLTUInt8_t* fpData; // !transient
203 /** size of the current data set */
204 int fDataSize; // !transient
206 /** current stream offset in the data set */
207 int fOffset; // !transient
209 /** current stream position for the ReadNextData function */
210 int fPosition; // !transient
212 /** equipment id of the current data set, >0 indicates data set from HLT stream */
213 int fEquipmentId; // !transient
215 /** indicates the availibility of data from the HLT stream */
216 bool fbHaveHLTData; // !transient
218 /** list of detectors for which data will be taken from HLT stream */
219 vector<int> fDetectors; // !transient
221 /** instance of the HLTOUT handler */
222 AliHLTOUT* fpHLTOUT; // !transient
224 /** start reading HLTOUT from beginning */
225 bool fbReadFirst; //!transient
227 /** instance of the data handler providing the current data buffer */
228 AliHLTOUTHandler* fpDataHandler; // !transient
230 ClassDef(AliRawReaderHLT, 4)
233 #define ALIHLTREC_LIBRARY "libHLTrec.so"
234 #define ALIHLTREC_LIBRARY_VERSION 0
235 #define ALIRAWREADERHLT_CREATE_INSTANCE "AliRawReaderHLTCreateInstance"
240 typedef AliRawReader* (*AliRawReaderHLTCreateInstance_t)(AliRawReader* pParentReader, const char* options);
243 * Create an instance of the AliRawReader class
245 AliRawReader* AliRawReaderHLTCreateInstance(AliRawReader* pParentReader, const char* options);