]>
Commit | Line | Data |
---|---|---|
c54aa300 | 1 | //-*- Mode: C++ -*- |
2 | // $Id$ | |
3 | #ifndef ALIHLTTPCCLUSTERACCESSHLTOUT_H | |
4 | #define ALIHLTTPCCLUSTERACCESSHLTOUT_H | |
0cfe753c | 5 | //* This file is property of and copyright by the ALICE Project * |
c54aa300 | 6 | //* ALICE Experiment at CERN, All rights reserved. * |
7 | //* See cxx source for full Copyright notice * | |
8 | ||
9 | /// @file AliHLTTPCClusterAccessHLTOUT.h | |
10 | /// @author Matthias Richter | |
11 | /// @date 2011-06-06 | |
12 | /// @brief Interface to HLT TPC clusters | |
13 | /// | |
14 | ||
15 | #include "TObject.h" | |
81e7f739 | 16 | #include "AliHLTDataTypes.h" |
17 | #include "AliHLTTPCClusterMCData.h" | |
de2b5702 | 18 | #include "AliHLTTPCRawCluster.h" |
27dc742d | 19 | #include <vector> |
c54aa300 | 20 | |
de2b5702 | 21 | class AliTPCParam; |
c54aa300 | 22 | class TClonesArray; |
768dad20 | 23 | class AliHLTTPCDataCompressionDecoder; |
c54aa300 | 24 | |
25 | /** | |
26 | * @class AliHLTTPCClusterAccessHLTOUT | |
27 | * Generator for TPC cluster array from HLT TPC clusters in the HLTOUT | |
81e7f739 | 28 | * data stream. It uses the TObject method interface. Combined with dynamic |
29 | * loading, any cross dependency between the TPC code and HLT libraries | |
30 | * can be avoided. | |
c54aa300 | 31 | * |
81e7f739 | 32 | * Creating the instance: |
33 | * The class is implemented in libAliHLTTPC.so and can be loaded | |
34 | * through the TClass interface (you might want to add | |
35 | * further error messages on the various error conditions). | |
36 | * <pre> | |
37 | * TObject* pClusterAccess=NULL; | |
38 | * TClass* pCl=NULL; | |
39 | * ROOT::NewFunc_t pNewFunc=NULL; | |
40 | * do { | |
41 | * pCl=TClass::GetClass("AliHLTTPCClusterAccessHLTOUT"); | |
42 | * } while (!pCl && gSystem->Load("libAliHLTTPC.so")==0); | |
43 | * if (pCl && (pNewFunc=pCl->GetNew())!=NULL) { | |
44 | * void* p=(*pNewFunc)(NULL); | |
45 | * if (p) { | |
46 | * pClusterAccess=reinterpret_cast<TObject*>(p); | |
47 | * } | |
48 | * } | |
49 | * </pre> | |
50 | * | |
51 | * Usage: | |
52 | * TObject::Execute can be used to execute commands. Command 'read' | |
53 | * will get hold on the HLTOUT data and read the clusters. The const char* | |
54 | * parameter 'param' is used to select the region. | |
81e7f739 | 55 | * - param="sector=sectorno" |
56 | * 'sectorno' specifies sector number in the offline code, range 0 and 71, | |
57 | * enumerating first the 36 inner (partitions 0+1) and then 36 outer sectors | |
b60d3f6a | 58 | * (partitions 2-5).<br> |
59 | * If the error pointer parameter is provided the result code is returned | |
60 | * - >=0 success, number of clusters | |
61 | * - -ENODATA no data in HLTOUT | |
62 | * - -EINVAL invalid parameter/argument | |
63 | * - -ENOMEM memory allocation failed | |
64 | * - -EACCESS no access to HLTOUT | |
65 | * - -NODEV internal error, can not get AliHLTSystem | |
66 | * - -ENOBUFS internal error, can not get cluster array | |
81e7f739 | 67 | * |
68 | * Command 'verbosity=level' sets the verbositylevel which is default 0 | |
69 | * (no info output). | |
b60d3f6a | 70 | * |
81e7f739 | 71 | * <pre> |
81e7f739 | 72 | * pClusterAccess->Execute("read", param); |
73 | * TObject* pClusterAccess->FindObject("clusterarray"); | |
74 | * </pre> | |
b60d3f6a | 75 | * |
76 | * After processing the loop of sectors, the instance should be cleaned. | |
77 | * <pre> | |
78 | * pClusterAccess->Clear("event"); | |
79 | * </pre> | |
81e7f739 | 80 | * |
c54aa300 | 81 | * @ingroup alihlt_tpc |
82 | */ | |
83 | class AliHLTTPCClusterAccessHLTOUT : public TObject | |
84 | { | |
85 | public: | |
86 | /** standard constructor */ | |
87 | AliHLTTPCClusterAccessHLTOUT(); | |
88 | /** destructor */ | |
27dc742d | 89 | virtual ~AliHLTTPCClusterAccessHLTOUT(); |
c54aa300 | 90 | |
91 | /// inherited from TObject: abstract command interface | |
92 | virtual void Execute(const char *method, const char *params, Int_t *error=0); | |
93 | ||
94 | /// inherited from TObject: return the cluster array if name id "clusterarray" | |
95 | virtual TObject *FindObject(const char *name) const; | |
96 | ||
de2b5702 | 97 | /// inherited from TObject: supports writing of data to AliTPCClustersRow |
98 | virtual void Copy(TObject &object) const; | |
99 | ||
c54aa300 | 100 | /// inherited from TObject: cleanup |
101 | virtual void Clear(Option_t * option =""); | |
102 | ||
103 | /// inherited from TObject | |
104 | virtual void Print(Option_t *option="") const; | |
105 | ||
106 | /// process the cluster data block of various formats from HLTOUT | |
81e7f739 | 107 | int ProcessClusters(const char* params); |
108 | ||
21786b17 | 109 | /// helper struct to store cluster in a map together with MC info |
de2b5702 | 110 | struct AliRawClusterEntry { |
21786b17 | 111 | AliRawClusterEntry() : fCluster(), fMC() {} |
de2b5702 | 112 | AliRawClusterEntry(const AliRawClusterEntry& other) : fCluster(other.fCluster), fMC(other.fMC) {} |
113 | AliRawClusterEntry& operator=(const AliRawClusterEntry& other) { | |
114 | if (&other==this) return *this; | |
115 | fCluster=other.fCluster; fMC=other.fMC; | |
116 | return *this; | |
117 | } | |
21786b17 | 118 | AliHLTTPCRawCluster fCluster; //! cluster |
119 | AliHLTTPCClusterMCLabel fMC; //! MC labels | |
de2b5702 | 120 | }; |
121 | ||
de2b5702 | 122 | typedef vector<AliRawClusterEntry> AliRawClusterEntryVector; |
123 | ||
b60d3f6a | 124 | /** |
de2b5702 | 125 | * @class AliRawClusterContainer |
b60d3f6a | 126 | * Cluster read interface for offline. |
127 | * The class implements the interface to be used in the decoding | |
9ecd3e73 | 128 | * of compressed TPC data. The container handles |
b60d3f6a | 129 | */ |
de2b5702 | 130 | class AliRawClusterContainer { |
b60d3f6a | 131 | public: |
de2b5702 | 132 | AliRawClusterContainer(); |
133 | virtual ~AliRawClusterContainer(); | |
b60d3f6a | 134 | |
135 | struct AliClusterIdBlock { | |
136 | AliClusterIdBlock() : fIds(NULL), fSize(0) {} | |
137 | AliHLTUInt32_t* fIds; //! | |
138 | AliHLTUInt32_t fSize; //! | |
139 | }; | |
140 | ||
141 | class iterator { | |
142 | public: | |
de2b5702 | 143 | iterator() : fClusterNo(-1), fData(NULL), fEntry(NULL), fRowOffset(0) {} |
144 | iterator(AliRawClusterContainer* pData) : fClusterNo(-1), fData(pData), fEntry(NULL), fRowOffset(0) {} | |
145 | iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fEntry(other.fEntry), fRowOffset(other.fRowOffset) {} | |
b60d3f6a | 146 | iterator& operator=(const iterator& other) { |
b22da46d | 147 | if (this==&other) return *this; |
de2b5702 | 148 | fClusterNo=other.fClusterNo; fData=other.fData; fEntry=other.fEntry; fRowOffset=other.fRowOffset; return *this; |
b60d3f6a | 149 | } |
27dc742d | 150 | virtual ~iterator() {} |
b60d3f6a | 151 | |
21786b17 | 152 | void SetPadRow(int row) {if (fEntry ) fEntry->fCluster.SetPadRow(row-fRowOffset);} |
153 | void SetPad(float pad) {if (fEntry ) fEntry->fCluster.SetPad(pad);} | |
154 | void SetTime(float time) {if (fEntry ) fEntry->fCluster.SetTime(time);} | |
155 | void SetSigmaY2(float sigmaY2) {if (fEntry ) fEntry->fCluster.SetSigmaY2(sigmaY2);} | |
156 | void SetSigmaZ2(float sigmaZ2) {if (fEntry ) fEntry->fCluster.SetSigmaZ2(sigmaZ2);} | |
157 | void SetCharge(unsigned charge) {if (fEntry ) fEntry->fCluster.SetCharge(charge);} | |
158 | void SetQMax(unsigned qmax) {if (fEntry ) fEntry->fCluster.SetQMax(qmax);} | |
9ecd3e73 | 159 | iterator& operator=(const AliHLTTPCRawCluster& rawcluster) {if (fEntry ) { |
160 | memcpy(&fEntry->fCluster, &rawcluster, sizeof(AliHLTTPCRawCluster)); | |
161 | // Note: offline code uses a different convention for row offset than the online code | |
162 | // Online: first row of readout partition | |
163 | // Offline: first row of readout chamber(inner: partition 0-1; outer: 2-5 | |
164 | fEntry->fCluster.fPadRow-=fRowOffset; | |
165 | } return *this;} | |
1e7ff439 | 166 | void SetMC(const AliHLTTPCClusterMCLabel* pMC) { |
21786b17 | 167 | if (fEntry && pMC ) fEntry->fMC=*pMC; |
1e7ff439 | 168 | } |
b60d3f6a | 169 | |
170 | // switch to next cluster | |
171 | iterator& Next(int slice, int partition); | |
172 | ||
173 | private: | |
21786b17 | 174 | |
175 | static const Int_t fkRowOffsetOuterSector; //! transient | |
176 | ||
b60d3f6a | 177 | int fClusterNo; //! cluster no in the current block |
de2b5702 | 178 | AliRawClusterContainer* fData; //! pointer to actual data |
179 | AliRawClusterEntry* fEntry; //! pointer to current cluster | |
21786b17 | 180 | int fRowOffset; //! row offset for current partition |
b60d3f6a | 181 | }; |
182 | ||
9ecd3e73 | 183 | /// legacy, to be removed later |
184 | iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification) { | |
185 | return BeginPartitionClusterBlock(count, specification); | |
186 | } | |
187 | /// iterator of partition clusters block of specification | |
188 | iterator& BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification); | |
b60d3f6a | 189 | /// iterator of track model clusters |
190 | iterator& BeginTrackModelClusterBlock(int count); | |
191 | ||
b60d3f6a | 192 | /// internal cleanup |
193 | virtual void Clear(Option_t * option=""); | |
194 | /// get the cluster array for a sector | |
195 | TObjArray* GetSectorArray(unsigned sector) const; | |
de2b5702 | 196 | /// fill the cluster array for a sector and specific row if specified |
197 | int FillSectorArray(TClonesArray* pSectorArray, unsigned sector, int row=-1) const; | |
b60d3f6a | 198 | /// print info |
199 | virtual void Print(Option_t *option=NULL) const; | |
200 | ||
201 | protected: | |
202 | /// load next cluster from array of the sepcific sector | |
de2b5702 | 203 | AliRawClusterEntry* NextCluster(int slice, int partition); |
b60d3f6a | 204 | |
205 | private: | |
de2b5702 | 206 | /// copy constructor prohibited |
207 | AliRawClusterContainer(const AliRawClusterContainer&); | |
208 | /// assignment operator prohibited | |
209 | AliRawClusterContainer& operator=(const AliRawClusterContainer&); | |
210 | ||
de2b5702 | 211 | vector<AliRawClusterEntryVector*> fClusterMaps; //! cluster pointer vectors per sector (offline notation 0-71) |
212 | TClonesArray* fSectorArray; //! current sector array of clusters provided to caller | |
b60d3f6a | 213 | iterator fIterator; //! |
214 | }; | |
215 | ||
c54aa300 | 216 | private: |
217 | /// copy constructor prohibited | |
218 | AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&); | |
219 | /// assignment operator prohibited | |
220 | AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&); | |
221 | ||
b60d3f6a | 222 | enum EOptions { |
223 | // skip the track clusters | |
224 | kSkipTrackClusters = BIT(15), | |
225 | // skip the partition (remaining) clusters | |
226 | kSkipPartitionClusters = BIT(16) | |
227 | }; | |
228 | ||
81e7f739 | 229 | int fVerbosity; //! verbosity level |
de2b5702 | 230 | AliRawClusterContainer* fClusters; //! cluster container |
b60d3f6a | 231 | int fCurrentSector; //! current sector |
768dad20 | 232 | AliHLTTPCDataCompressionDecoder* fpDecoder; //! decoder instance |
de2b5702 | 233 | AliTPCParam* fTPCParam; //! pointer to TPC param |
c54aa300 | 234 | |
235 | ClassDef(AliHLTTPCClusterAccessHLTOUT, 0) | |
236 | }; | |
237 | #endif |