Line data Source code
1 : //-*- Mode: C++ -*-
2 : // $Id$
3 : #ifndef ALIHLTTPCCLUSTERACCESSHLTOUT_H
4 : #define ALIHLTTPCCLUSTERACCESSHLTOUT_H
5 : //* This file is property of and copyright by the ALICE Project *
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"
16 : #include "AliHLTDataTypes.h"
17 : #include "AliHLTTPCClusterMCData.h"
18 : #include "AliHLTTPCRawCluster.h"
19 : #include <vector>
20 :
21 : class AliTPCParam;
22 : class TClonesArray;
23 : class AliHLTTPCDataCompressionDecoder;
24 :
25 : /**
26 : * @class AliHLTTPCClusterAccessHLTOUT
27 : * Generator for TPC cluster array from HLT TPC clusters in the HLTOUT
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.
31 : *
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")==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.
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
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
67 : *
68 : * Command 'verbosity=level' sets the verbositylevel which is default 0
69 : * (no info output).
70 : *
71 : * <pre>
72 : * pClusterAccess->Execute("read", param);
73 : * TObject* pClusterAccess->FindObject("clusterarray");
74 : * </pre>
75 : *
76 : * After processing the loop of sectors, the instance should be cleaned.
77 : * <pre>
78 : * pClusterAccess->Clear("event");
79 : * </pre>
80 : *
81 : * @ingroup alihlt_tpc
82 : */
83 : class AliHLTTPCClusterAccessHLTOUT : public TObject
84 : {
85 : public:
86 : /** standard constructor */
87 : AliHLTTPCClusterAccessHLTOUT();
88 : /** destructor */
89 : virtual ~AliHLTTPCClusterAccessHLTOUT();
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 :
97 : /// inherited from TObject: supports writing of data to AliTPCClustersRow
98 : virtual void Copy(TObject &object) const;
99 :
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
107 : int ProcessClusters(const char* params);
108 :
109 : /// scan parameters
110 : /// known: sector=<n> row=<n>
111 : int ScanParameters(const char* params);
112 :
113 : /// helper struct to store cluster in a map together with MC info
114 : struct AliRawClusterEntry {
115 0 : AliRawClusterEntry() : fCluster(), fMC() {}
116 0 : AliRawClusterEntry(const AliRawClusterEntry& other) : fCluster(other.fCluster), fMC(other.fMC) {}
117 : AliRawClusterEntry& operator=(const AliRawClusterEntry& other) {
118 : if (&other==this) return *this;
119 : fCluster=other.fCluster; fMC=other.fMC;
120 : return *this;
121 : }
122 : AliHLTTPCRawCluster fCluster; //! cluster
123 : AliHLTTPCClusterMCLabel fMC; //! MC labels
124 : };
125 :
126 : typedef vector<AliRawClusterEntry> AliRawClusterEntryVector;
127 :
128 : /**
129 : * @class AliRawClusterContainer
130 : * Cluster read interface for offline.
131 : * The class implements the interface to be used in the decoding
132 : * of compressed TPC data. The container handles
133 : */
134 : class AliRawClusterContainer {
135 : public:
136 : AliRawClusterContainer();
137 : virtual ~AliRawClusterContainer();
138 :
139 : struct AliClusterIdBlock {
140 : AliClusterIdBlock() : fIds(NULL), fSize(0) {}
141 : AliHLTUInt32_t* fIds; //!
142 : AliHLTUInt32_t fSize; //!
143 : };
144 :
145 : class iterator {
146 : public:
147 0 : iterator() : fClusterNo(-1), fData(NULL), fEntry(NULL), fRowOffset(0) {}
148 0 : iterator(AliRawClusterContainer* pData) : fClusterNo(-1), fData(pData), fEntry(NULL), fRowOffset(0) {}
149 : iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fEntry(other.fEntry), fRowOffset(other.fRowOffset) {}
150 : iterator& operator=(const iterator& other) {
151 0 : if (this==&other) return *this;
152 0 : fClusterNo=other.fClusterNo; fData=other.fData; fEntry=other.fEntry; fRowOffset=other.fRowOffset; return *this;
153 0 : }
154 0 : virtual ~iterator() {}
155 :
156 0 : void SetPadRow(int row) {if (fEntry ) fEntry->fCluster.SetPadRow(row-fRowOffset);}
157 0 : void SetPad(float pad) {if (fEntry ) fEntry->fCluster.SetPad(pad);}
158 0 : void SetTime(float time) {if (fEntry ) fEntry->fCluster.SetTime(time);}
159 0 : void SetSigmaY2(float sigmaY2) {if (fEntry ) fEntry->fCluster.SetSigmaPad2(sigmaY2);}
160 0 : void SetSigmaZ2(float sigmaZ2) {if (fEntry ) fEntry->fCluster.SetSigmaTime2(sigmaZ2);}
161 0 : void SetCharge(unsigned charge) {if (fEntry ) fEntry->fCluster.SetCharge(charge);}
162 0 : void SetQMax(unsigned qmax) {if (fEntry ) fEntry->fCluster.SetQMax(qmax);}
163 0 : void SetFlags(unsigned short flags) {if (fEntry ) fEntry->fCluster.SetFlags(flags);}
164 : iterator& operator=(const AliHLTTPCRawCluster& rawcluster) {if (fEntry ) {
165 : memcpy(&fEntry->fCluster, &rawcluster, sizeof(AliHLTTPCRawCluster));
166 : // Note: offline code uses a different convention for row offset than the online code
167 : // Online: first row of readout partition
168 : // Offline: first row of readout chamber(inner: partition 0-1; outer: 2-5
169 : fEntry->fCluster.fPadRow-=fRowOffset;
170 : } return *this;}
171 : void SetMC(const AliHLTTPCClusterMCLabel* pMC) {
172 0 : if (fEntry && pMC ) fEntry->fMC=*pMC;
173 0 : }
174 :
175 : // switch to next cluster
176 : iterator& Next(int slice, int partition);
177 :
178 : private:
179 :
180 : static const Int_t fkRowOffsetOuterSector; //! transient
181 :
182 : int fClusterNo; //! cluster no in the current block
183 : AliRawClusterContainer* fData; //! pointer to actual data
184 : AliRawClusterEntry* fEntry; //! pointer to current cluster
185 : int fRowOffset; //! row offset for current partition
186 : };
187 :
188 : /// legacy, to be removed later
189 : iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification) {
190 0 : return BeginPartitionClusterBlock(count, specification);
191 : }
192 : /// iterator of partition clusters block of specification
193 : iterator& BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification);
194 : /// iterator of track model clusters
195 : iterator& BeginTrackModelClusterBlock(int count);
196 :
197 : /// check if the container is filled
198 0 : bool HaveData() const {return fHaveData;}
199 : /// mark the container valid
200 0 : void MarkValid() {fHaveData=true;}
201 : /// internal cleanup
202 : virtual void Clear(Option_t * option="");
203 : /// get the cluster array for a sector
204 : TObjArray* GetSectorArray(unsigned sector, int propagateSplitClusterFlag = 0) const;
205 : /// fill the cluster array for a sector and specific row if specified
206 : int FillSectorArray(TClonesArray* pSectorArray, unsigned sector, int row=-1, int propagateSplitClusterFlag = 0) const;
207 : /// print info
208 : virtual void Print(Option_t *option=NULL) const;
209 :
210 : protected:
211 : /// load next cluster from array of the sepcific sector
212 : AliRawClusterEntry* NextCluster(int slice, int partition);
213 :
214 : private:
215 : /// copy constructor prohibited
216 : AliRawClusterContainer(const AliRawClusterContainer&);
217 : /// assignment operator prohibited
218 : AliRawClusterContainer& operator=(const AliRawClusterContainer&);
219 :
220 : vector<AliRawClusterEntryVector*> fClusterMaps; //! cluster pointer vectors per sector (offline notation 0-71)
221 : TClonesArray* fSectorArray; //! current sector array of clusters provided to caller
222 : iterator fIterator; //!
223 : bool fHaveData; //! indivate that the container is filled
224 : };
225 :
226 : private:
227 : /// copy constructor prohibited
228 : AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
229 : /// assignment operator prohibited
230 : AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
231 :
232 : enum EOptions {
233 : // skip the track clusters
234 : kSkipTrackClusters = BIT(15),
235 : // skip the partition (remaining) clusters
236 : kSkipPartitionClusters = BIT(16)
237 : };
238 :
239 : int fVerbosity; //! verbosity level
240 : AliRawClusterContainer* fClusters; //! cluster container
241 : int fCurrentSector; //! current sector
242 : int fCurrentRow; //! current row
243 : int fPropagateSplitClusterFlag; //! propagate flags for split clusters
244 : AliHLTTPCDataCompressionDecoder* fpDecoder; //! decoder instance
245 : AliTPCParam* fTPCParam; //! pointer to TPC param
246 :
247 6 : ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)
248 : };
249 : #endif
|