3 #ifndef ALIHLTTPCCLUSTERACCESSHLTOUT_H
4 #define ALIHLTTPCCLUSTERACCESSHLTOUT_H
5 //* This file is property of and copyright by the ALICE HLT 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 "AliTPCclusterMI.h"
21 class AliTPCClustersRow;
25 typedef std::map<AliHLTUInt32_t, AliHLTTPCClusterMCLabel> AliHLTTPCClusterMCDataList;
28 * @class AliHLTTPCClusterAccessHLTOUT
29 * Generator for TPC cluster array from HLT TPC clusters in the HLTOUT
30 * data stream. It uses the TObject method interface. Combined with dynamic
31 * loading, any cross dependency between the TPC code and HLT libraries
34 * Creating the instance:
35 * The class is implemented in libAliHLTTPC.so and can be loaded
36 * through the TClass interface (you might want to add
37 * further error messages on the various error conditions).
39 * TObject* pClusterAccess=NULL;
41 * ROOT::NewFunc_t pNewFunc=NULL;
43 * pCl=TClass::GetClass("AliHLTTPCClusterAccessHLTOUT");
44 * } while (!pCl && gSystem->Load("libAliHLTTPC.so")==0);
45 * if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
46 * void* p=(*pNewFunc)(NULL);
48 * pClusterAccess=reinterpret_cast<TObject*>(p);
54 * TObject::Execute can be used to execute commands. Command 'read'
55 * will get hold on the HLTOUT data and read the clusters. The const char*
56 * parameter 'param' is used to select the region.
57 * - param="sector=sectorno"
58 * 'sectorno' specifies sector number in the offline code, range 0 and 71,
59 * enumerating first the 36 inner (partitions 0+1) and then 36 outer sectors
60 * (partitions 2-5).<br>
61 * If the error pointer parameter is provided the result code is returned
62 * - >=0 success, number of clusters
63 * - -ENODATA no data in HLTOUT
64 * - -EINVAL invalid parameter/argument
65 * - -ENOMEM memory allocation failed
66 * - -EACCESS no access to HLTOUT
67 * - -NODEV internal error, can not get AliHLTSystem
68 * - -ENOBUFS internal error, can not get cluster array
70 * Command 'verbosity=level' sets the verbositylevel which is default 0
74 * pClusterAccess->Execute("read", param);
75 * TObject* pClusterAccess->FindObject("clusterarray");
78 * After processing the loop of sectors, the instance should be cleaned.
80 * pClusterAccess->Clear("event");
85 class AliHLTTPCClusterAccessHLTOUT : public TObject
88 /** standard constructor */
89 AliHLTTPCClusterAccessHLTOUT();
91 ~AliHLTTPCClusterAccessHLTOUT();
93 /// inherited from TObject: abstract command interface
94 virtual void Execute(const char *method, const char *params, Int_t *error=0);
96 /// inherited from TObject: return the cluster array if name id "clusterarray"
97 virtual TObject *FindObject(const char *name) const;
99 /// inherited from TObject: cleanup
100 virtual void Clear(Option_t * option ="");
102 /// inherited from TObject
103 virtual void Print(Option_t *option="") const;
105 /// process the cluster data block of various formats from HLTOUT
106 int ProcessClusters(const char* params);
108 /// process the cluster mc data block {CLMCINFO:TPC } from HLTOUT
109 int ReadAliHLTTPCClusterMCData(AliHLTOUT* pHLTOUT, AliHLTTPCClusterMCDataList &tpcClusterLabels) const;
111 /// process the cluster data block {CLUSTERS:TPC } from HLTOUT
112 int ReadAliHLTTPCClusterData(AliHLTOUT* pHLTOUT, TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels=NULL) const;
114 /// process the cluster data block {CLUSTRAW:TPC } from HLTOUT
115 int ReadAliHLTTPCRawClusterData(AliHLTOUT* pHLTOUT, TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels);
117 /// process the clusters of type {REMCLSCM:TPC } from HLTOUT
118 int ReadRemainingClustersCompressed(AliHLTOUT* pHLTOUT, TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels);
120 /// process clusters encoded by AliHLTDataDeflaterSimple
121 int ReadAliHLTTPCRawClusterDataDeflateSimple(const AliHLTUInt8_t* pData, int dataSize,
122 int nofClusters, AliHLTUInt32_t specification,
123 TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels);
126 * @class AliTPCclusterMIContainer
127 * Cluster read interface for offline.
128 * The class implements the interface to be used in the decoding
129 * of compressed TPC data.
131 class AliTPCclusterMIContainer {
133 AliTPCclusterMIContainer();
134 virtual ~AliTPCclusterMIContainer();
136 struct AliClusterIdBlock {
137 AliClusterIdBlock() : fIds(NULL), fSize(0) {}
138 AliHLTUInt32_t* fIds; //!
139 AliHLTUInt32_t fSize; //!
144 iterator() : fClusterNo(-1), fData(NULL), fCluster(NULL), fClusterId(kAliHLTVoidDataSpec), fRowOffset(0) {}
145 iterator(AliTPCclusterMIContainer* pData) : fClusterNo(-1), fData(pData), fCluster(NULL), fClusterId(fData?fData->GetClusterId(fClusterNo):kAliHLTVoidDataSpec), fRowOffset(0) {}
146 iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fCluster(other.fCluster), fClusterId(other.fClusterId), fRowOffset(other.fRowOffset) {}
147 iterator& operator=(const iterator& other) {
148 if (this==&other) return *this;
149 fClusterNo=other.fClusterNo; fData=other.fData; fCluster=other.fCluster, fClusterId=other.fClusterId; fRowOffset=other.fRowOffset; return *this;
153 void SetPadRow(int row) {if (fCluster) fCluster->SetRow(row-fRowOffset);}
154 void SetPad(float pad) {if (fCluster) fCluster->SetPad(pad);}
155 void SetTime(float time) {if (fCluster) fCluster->SetTimeBin(time);}
156 void SetSigmaY2(float sigmaY2) {if (fCluster) fCluster->SetSigmaY2(sigmaY2);}
157 void SetSigmaZ2(float sigmaZ2) {if (fCluster) fCluster->SetSigmaZ2(sigmaZ2);}
158 void SetCharge(unsigned charge) {if (fCluster) fCluster->SetQ(charge);}
159 void SetQMax(unsigned qmax) {if (fCluster) fCluster->SetMax(qmax);}
160 void SetMC(const AliHLTTPCClusterMCLabel* pMC) {
161 if (!fCluster || !pMC) return;
162 for (int k=0; k<3; k++) fCluster->SetLabel(pMC->fClusterID[k].fMCID, k);
165 // switch to next cluster
166 iterator& Next(int slice, int partition);
169 int fClusterNo; //! cluster no in the current block
170 AliTPCclusterMIContainer* fData; //! pointer to actual data
171 AliTPCclusterMI* fCluster; //! pointer to current cluster
172 AliHLTUInt32_t fClusterId; //! id of the cluster, from optional cluster id blocks
173 int fRowOffset; //! row offset for current partition
176 /// iterator of remaining clusters block of specification
177 iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
178 /// iterator of track model clusters
179 iterator& BeginTrackModelClusterBlock(int count);
181 /// add cluster mc data block
182 int AddClusterMCData(const AliHLTComponentBlockData* pDesc);
183 /// add cluster id block for remaining or track model clusters
184 int AddClusterIds(const AliHLTComponentBlockData* pDesc);
185 /// get the cluster id from the current cluster id block (optional)
186 AliHLTUInt32_t GetClusterId(int clusterNo) const;
189 virtual void Clear(Option_t * option="");
190 /// get the cluster array for a sector
191 TObjArray* GetSectorArray(unsigned sector) const;
193 virtual void Print(Option_t *option=NULL) const;
196 /// load next cluster from array of the sepcific sector
197 AliTPCclusterMI* NextCluster(int slice, int partition);
198 /// set MC data for the cluster
199 int SetMC(AliTPCclusterMI* cluster, AliHLTUInt32_t clusterId);
202 AliTPCclusterMIContainer(const AliTPCclusterMIContainer&);
203 AliTPCclusterMIContainer& operator=(const AliTPCclusterMIContainer&);
205 vector<TClonesArray*> fClusterArrays; //! cluster arrays per sector (offline notation 0-71)
206 vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
207 AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
208 AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
209 vector<const AliHLTTPCClusterMCData*> fClusterMCData; //! references to MC data blocks
210 iterator fIterator; //!
214 /// copy constructor prohibited
215 AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
216 /// assignment operator prohibited
217 AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
220 // skip the track clusters
221 kSkipTrackClusters = BIT(15),
222 // skip the partition (remaining) clusters
223 kSkipPartitionClusters = BIT(16)
226 int fVerbosity; //! verbosity level
227 AliTPCclusterMIContainer* fClusters; //! cluster container
228 int fCurrentSector; //! current sector
230 ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)