Line data Source code
1 : //-*- Mode: C++ -*-
2 : // $Id$
3 : #ifndef ALIHLTTPCDATAPUBLISHERCOMPONENT_H
4 : #define ALIHLTTPCDATAPUBLISHERCOMPONENT_H
5 : //* This file is property of and copyright by the *
6 : //* ALICE Experiment at CERN, All rights reserved. *
7 : //* See cxx source for full Copyright notice *
8 :
9 : /// @file AliHLTTPCDataPublisherComponent.h
10 : /// @author Matthias Richter
11 : /// @date 2011-11-18
12 : /// @brief Specific publisher for TPC raw data from the AliRawReader
13 : ///
14 :
15 : #include "AliHLTRawReaderPublisherComponent.h"
16 : #include "AliHLTTPCRawCluster.h"
17 : #include <map>
18 :
19 : class AliHLTTPCClusterMCLabel;
20 : class AliHLTTPCClusterMCData;
21 : class AliHLTTPCDataCompressionDecoder;
22 :
23 : /**
24 : * @class AliHLTTPCDataPublisherComponent
25 : * This component uses the functionality of AliHLTRawReaderPublisherComponent
26 : * and overloads IsSelected and GetSpecificationFromEquipmentId. Blocks are
27 : * only generated if the corresponding partition is missing in HLTOUT.
28 : *
29 : * It is used in an emulation chain which produces all compressed cluster
30 : * blocks which are missing in HLTOUT. If TPC reconstruction requires HLT
31 : * clusters, the emulator is automatically executed and the compressed
32 : * data produced if raw data is available.
33 : *
34 : * <h2>General properties:</h2>
35 : *
36 : * Component ID: \b TPCRawReaderPublisher <br>
37 : * Library: \b libAliHLTTPC.so <br>
38 : * Input Data Types: <br>
39 : * Output Data Types: <br>
40 : *
41 : * <h2>Mandatory arguments:</h2>
42 : * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
43 : *
44 : * <h2>Optional arguments:</h2>
45 : * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
46 :
47 : * <h2>Configuration:</h2>
48 : * <!-- NOTE: ignore the \li. <i> and </i>: it's just doxygen formatting -->
49 : *
50 : * <h2>Default CDB entries:</h2>
51 : *
52 : * <h2>Performance:</h2>
53 : *
54 : * <h2>Memory consumption:</h2>
55 : *
56 : * <h2>Output size:</h2>
57 : *
58 : *
59 : * @ingroup alihlt_tpc
60 : */
61 : class AliHLTTPCDataPublisherComponent : public AliHLTRawReaderPublisherComponent {
62 : public:
63 : /// standard constructor
64 : AliHLTTPCDataPublisherComponent();
65 : /// destructor
66 : ~AliHLTTPCDataPublisherComponent();
67 :
68 : enum {
69 : kPublisherModeDefault = 0,
70 : kRegisterClusterBlocks= 0x1, // only register data blocks
71 : kPublishClustersAll = 0x2, // unpack data blocks
72 : kPublishRawAll = 0x4, // publish all raw data
73 : kPublishRawFiltered = 0x8, // publish raw data filtered by existence of clusters
74 : kLastContainerMode
75 : };
76 :
77 :
78 : /// get the output data types of the component.
79 :
80 : AliHLTComponentDataType GetOutputDataType();
81 : int GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList);
82 :
83 : /// set mode
84 0 : void SetMode(int mode) {fMode=mode;}
85 :
86 0 : bool CheckMode(int flag) const {return (fMode&flag)==flag;}
87 :
88 : /// inherited from AliHLTComponent: id of the component
89 : virtual const char* GetComponentID();
90 :
91 : /// inherited from AliHLTComponent: spawn function.
92 : virtual AliHLTComponent* Spawn();
93 :
94 : /**
95 : * @class AliRawClusterContainer
96 : * Container of AliHLTTPCRawCluster, The class implements the interface to be
97 : * used in the decoding of compressed TPC data.
98 : * Data is decoded into an external buffer.
99 : */
100 : class AliRawClusterContainer : public AliHLTLogging {
101 : public:
102 : AliRawClusterContainer();
103 : virtual ~AliRawClusterContainer();
104 :
105 : /// set/reset the external target buffer
106 : int SetTargetBuffer(AliHLTUInt8_t* pBuffer, int size);
107 :
108 : /// merge track model clusters into partition cluster blocks
109 : int Sort();
110 :
111 : /// fill block descriptors of extracted partition cluster blocks to target list
112 : int CopyBlockDescriptors(AliHLTComponentBlockDataList& target) const;
113 : /// get reference to block descriptor list
114 : const AliHLTComponentBlockDataList& GetBlockDescriptors() const {
115 0 : return fDescriptors;
116 : }
117 :
118 : struct AliClusterIdBlock {
119 : AliClusterIdBlock() : fIds(NULL), fSize(0) {}
120 : AliHLTUInt32_t* fIds; //!
121 : AliHLTUInt32_t fSize; //!
122 : };
123 :
124 : class iterator: public AliHLTLogging {
125 : public:
126 0 : iterator() : fClusterNo(-1), fCluster(NULL), fClusterId(kAliHLTVoidDataSpec), fContainer(NULL), fRowOffset(0) {}
127 0 : iterator(AliRawClusterContainer* pContainer) : fClusterNo(-1), fCluster(NULL), fClusterId(kAliHLTVoidDataSpec), fContainer(pContainer), fRowOffset(0) {}
128 : iterator(const iterator& other) : fClusterNo(other.fClusterNo), fCluster(other.fCluster), fClusterId(other.fClusterId), fContainer(other.fContainer), fRowOffset(other.fRowOffset) {}
129 : iterator& operator=(const iterator& other) {
130 : if (this==&other) return *this;
131 : fClusterNo=other.fClusterNo; fCluster=other.fCluster, fClusterId=other.fClusterId; fContainer=other.fContainer; fRowOffset=other.fRowOffset; return *this;
132 : }
133 0 : ~iterator() {fCluster=NULL; fContainer=NULL;}
134 :
135 0 : void SetPadRow(int row) {if (fCluster) fCluster->SetPadRow(row-fRowOffset);}
136 0 : void SetPad(float pad) {if (fCluster) fCluster->SetPad(pad);}
137 0 : void SetTime(float time) {if (fCluster) fCluster->SetTime(time);}
138 0 : void SetSigmaY2(float sigmaY2) {if (fCluster) fCluster->SetSigmaPad2(sigmaY2);}
139 0 : void SetSigmaZ2(float sigmaZ2) {if (fCluster) fCluster->SetSigmaTime2(sigmaZ2);}
140 0 : void SetCharge(unsigned charge) {if (fCluster) fCluster->SetCharge(charge);}
141 0 : void SetQMax(unsigned qmax) {if (fCluster) fCluster->SetQMax(qmax);}
142 0 : void SetFlags(unsigned short flags) {if (fCluster) fCluster->SetFlags(flags);}
143 : void SetMC(const AliHLTTPCClusterMCLabel* pMC) {
144 0 : if (!fCluster || !pMC) return;
145 0 : }
146 :
147 : // switch to next cluster
148 : iterator& Next(int slice, int partition);
149 :
150 : private:
151 : int fClusterNo; //! cluster no in the current block
152 : AliHLTTPCRawCluster* fCluster; //! pointer to current cluster
153 : AliHLTUInt32_t fClusterId; //! id of the cluster, from optional cluster id blocks
154 : AliRawClusterContainer* fContainer; // instance of container
155 : int fRowOffset; //! row offset for current partition
156 : };
157 :
158 : /// legacy, to be removed later
159 : iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification) {
160 0 : return BeginPartitionClusterBlock(count, specification);
161 : }
162 : /// iterator of partition clusters block of specification
163 : iterator& BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification);
164 : /// iterator of track model clusters
165 : iterator& BeginTrackModelClusterBlock(int count);
166 : /// base method to start cluster iterator
167 : iterator& ClusterIterator(int count, AliHLTComponentDataType dt, AliHLTUInt32_t specification, AliHLTTPCRawClusterData* &pData);
168 :
169 : /// get block count, i.e. number of calls to create an iterator
170 0 : int GetBlockCount() const {return fBlockCount;}
171 : /// get number of decoded clusters
172 : /// Note: only if there is enough space in the target buffer the clusters
173 : // will be properly written
174 0 : int GetClusterCount() const {return fTotalClusterCount;}
175 : /// get the state of the cluster decoding
176 0 : int GetState() const {return fState;}
177 :
178 : /// internal cleanup
179 : virtual void Clear(Option_t * option="");
180 : /// print info
181 : virtual void Print(Option_t *option=NULL) const;
182 :
183 : protected:
184 : AliHLTTPCRawCluster* NextCluster(int slice, int partition);
185 :
186 : private:
187 : AliRawClusterContainer(const AliRawClusterContainer&);
188 : AliRawClusterContainer& operator=(const AliRawClusterContainer&);
189 :
190 : int fBlockCount; //! number of data blocks with clusters
191 : int fTotalClusterCount; //! total number of decoded clusters
192 : int fBlockClusterCount; //! number of decoded clusters in current block
193 : AliHLTUInt8_t* fpBuffer; //! target buffer for decoded data
194 : int fBufferSize; //! size of target buffer
195 : AliHLTComponentBlockDataList fDescriptors; //! list of block descriptors
196 : AliHLTTPCRawClusterData* fCurrentBlock; // current cluster block
197 : AliHLTTPCRawClusterData* fTrackModelClusters; //! track model cluster block
198 : vector<AliHLTUInt32_t> fTrackModelClusterMap; //! slice-partition map for track model clusters
199 : iterator fIterator; //! iterator for filling of data
200 : int fState; //! state
201 : };
202 :
203 : protected:
204 : /// inherited from AliHLTDataSource: get one event
205 : int GetEvent( const AliHLTComponentEventData& evtData,
206 : AliHLTComponentTriggerData& trigData,
207 : AliHLTUInt8_t* outputPtr,
208 : AliHLTUInt32_t& size,
209 : AliHLTComponentBlockDataList& outputBlocks );
210 :
211 : /// inherited from AliHLTComponent: initialize
212 : int DoInit( int argc, const char** argv );
213 :
214 : /// inherited from AliHLTComponent: cleanup
215 : int DoDeinit();
216 :
217 : /// inherited from AliHLTComponent: argument scan
218 : int ScanConfigurationArgument(int argc, const char** argv);
219 :
220 : /// read cluster from HLTInput
221 : int ReadClusterFromHLTInput(AliRawClusterContainer* pContainer);
222 :
223 : /// inherited from AliHLTRawReaderPublisherComponent: get specification
224 : virtual int GetSpecificationFromEquipmentId(int id, AliHLTUInt32_t &specification) const;
225 :
226 : /// inherited from AliHLTRawReaderPublisherComponent: check if a block is selected or not
227 : virtual bool IsSelected(int equipmentId) const;
228 :
229 : private:
230 : AliHLTTPCDataPublisherComponent(const AliHLTTPCDataPublisherComponent&);
231 : AliHLTTPCDataPublisherComponent& operator=(const AliHLTTPCDataPublisherComponent&);
232 :
233 : int fMode; //! operation mode
234 : bool* fArraySelected; //! transient
235 : AliRawClusterContainer* fClusters; // target for decoded clusters
236 : AliHLTTPCDataCompressionDecoder* fpDecoder; // decoder for compressed cluster blocks
237 :
238 6 : ClassDef(AliHLTTPCDataPublisherComponent, 0)
239 : };
240 :
241 : #endif //ALIHLTTPCDATAPUBLISHERCOMPONENT_H
|