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 *
9 /// @file AliHLTTPCClusterAccessHLTOUT.h
10 /// @author Matthias Richter
12 /// @brief Interface to HLT TPC clusters
16 #include "AliHLTDataTypes.h"
17 #include "AliHLTTPCClusterMCData.h"
18 #include "AliHLTTPCRawCluster.h"
23 class AliHLTTPCDataCompressionDecoder;
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
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).
37 * TObject* pClusterAccess=NULL;
39 * ROOT::NewFunc_t pNewFunc=NULL;
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);
46 * pClusterAccess=reinterpret_cast<TObject*>(p);
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
68 * Command 'verbosity=level' sets the verbositylevel which is default 0
72 * pClusterAccess->Execute("read", param);
73 * TObject* pClusterAccess->FindObject("clusterarray");
76 * After processing the loop of sectors, the instance should be cleaned.
78 * pClusterAccess->Clear("event");
83 class AliHLTTPCClusterAccessHLTOUT : public TObject
86 /** standard constructor */
87 AliHLTTPCClusterAccessHLTOUT();
89 virtual ~AliHLTTPCClusterAccessHLTOUT();
91 /// inherited from TObject: abstract command interface
92 virtual void Execute(const char *method, const char *params, Int_t *error=0);
94 /// inherited from TObject: return the cluster array if name id "clusterarray"
95 virtual TObject *FindObject(const char *name) const;
97 /// inherited from TObject: supports writing of data to AliTPCClustersRow
98 virtual void Copy(TObject &object) const;
100 /// inherited from TObject: cleanup
101 virtual void Clear(Option_t * option ="");
103 /// inherited from TObject
104 virtual void Print(Option_t *option="") const;
106 /// process the cluster data block of various formats from HLTOUT
107 int ProcessClusters(const char* params);
109 /// helper struct to store cluster in a map together with MC info
110 struct AliRawClusterEntry {
111 AliRawClusterEntry() : fCluster(), fMC() {}
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;
118 AliHLTTPCRawCluster fCluster; //! cluster
119 AliHLTTPCClusterMCLabel fMC; //! MC labels
122 typedef vector<AliRawClusterEntry> AliRawClusterEntryVector;
125 * @class AliRawClusterContainer
126 * Cluster read interface for offline.
127 * The class implements the interface to be used in the decoding
128 * of compressed TPC data. The container handles
130 class AliRawClusterContainer {
132 AliRawClusterContainer();
133 virtual ~AliRawClusterContainer();
135 struct AliClusterIdBlock {
136 AliClusterIdBlock() : fIds(NULL), fSize(0) {}
137 AliHLTUInt32_t* fIds; //!
138 AliHLTUInt32_t fSize; //!
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) {}
146 iterator& operator=(const iterator& other) {
147 if (this==&other) return *this;
148 fClusterNo=other.fClusterNo; fData=other.fData; fEntry=other.fEntry; fRowOffset=other.fRowOffset; return *this;
150 virtual ~iterator() {}
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);}
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;
166 void SetMC(const AliHLTTPCClusterMCLabel* pMC) {
167 if (fEntry && pMC ) fEntry->fMC=*pMC;
170 // switch to next cluster
171 iterator& Next(int slice, int partition);
175 static const Int_t fkRowOffsetOuterSector; //! transient
177 int fClusterNo; //! cluster no in the current block
178 AliRawClusterContainer* fData; //! pointer to actual data
179 AliRawClusterEntry* fEntry; //! pointer to current cluster
180 int fRowOffset; //! row offset for current partition
183 /// legacy, to be removed later
184 iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification) {
185 return BeginPartitionClusterBlock(count, specification);
187 /// iterator of partition clusters block of specification
188 iterator& BeginPartitionClusterBlock(int count, AliHLTUInt32_t specification);
189 /// iterator of track model clusters
190 iterator& BeginTrackModelClusterBlock(int count);
193 virtual void Clear(Option_t * option="");
194 /// get the cluster array for a sector
195 TObjArray* GetSectorArray(unsigned sector) const;
196 /// fill the cluster array for a sector and specific row if specified
197 int FillSectorArray(TClonesArray* pSectorArray, unsigned sector, int row=-1) const;
199 virtual void Print(Option_t *option=NULL) const;
202 /// load next cluster from array of the sepcific sector
203 AliRawClusterEntry* NextCluster(int slice, int partition);
206 /// copy constructor prohibited
207 AliRawClusterContainer(const AliRawClusterContainer&);
208 /// assignment operator prohibited
209 AliRawClusterContainer& operator=(const AliRawClusterContainer&);
211 vector<AliRawClusterEntryVector*> fClusterMaps; //! cluster pointer vectors per sector (offline notation 0-71)
212 TClonesArray* fSectorArray; //! current sector array of clusters provided to caller
213 iterator fIterator; //!
217 /// copy constructor prohibited
218 AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
219 /// assignment operator prohibited
220 AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
223 // skip the track clusters
224 kSkipTrackClusters = BIT(15),
225 // skip the partition (remaining) clusters
226 kSkipPartitionClusters = BIT(16)
229 int fVerbosity; //! verbosity level
230 AliRawClusterContainer* fClusters; //! cluster container
231 int fCurrentSector; //! current sector
232 AliHLTTPCDataCompressionDecoder* fpDecoder; //! decoder instance
233 AliTPCParam* fTPCParam; //! pointer to TPC param
235 ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)