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);}
161 // switch to next cluster
162 iterator& Next(int slice, int partition);
165 int fClusterNo; //! cluster no in the current block
166 AliTPCclusterMIContainer* fData; //! pointer to actual data
167 AliTPCclusterMI* fCluster; //! pointer to current cluster
168 AliHLTUInt32_t fClusterId; //! id of the cluster, from optional cluster id blocks
169 int fRowOffset; //! row offset for current partition
172 /// iterator of remaining clusters block of specification
173 iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
174 /// iterator of track model clusters
175 iterator& BeginTrackModelClusterBlock(int count);
177 /// add cluster mc data block
178 int AddClusterMCData(const AliHLTComponentBlockData* pDesc);
179 /// add cluster id block for remaining or track model clusters
180 int AddClusterIds(const AliHLTComponentBlockData* pDesc);
181 /// get the cluster id from the current cluster id block (optional)
182 AliHLTUInt32_t GetClusterId(int clusterNo) const;
185 virtual void Clear(Option_t * option="");
186 /// get the cluster array for a sector
187 TObjArray* GetSectorArray(unsigned sector) const;
189 virtual void Print(Option_t *option=NULL) const;
192 /// load next cluster from array of the sepcific sector
193 AliTPCclusterMI* NextCluster(int slice, int partition);
194 /// set MC data for the cluster
195 int SetMC(AliTPCclusterMI* cluster, AliHLTUInt32_t clusterId);
198 AliTPCclusterMIContainer(const AliTPCclusterMIContainer&);
199 AliTPCclusterMIContainer& operator=(const AliTPCclusterMIContainer&);
201 vector<TClonesArray*> fClusterArrays; //! cluster arrays per sector (offline notation 0-71)
202 vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
203 AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
204 AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
205 vector<const AliHLTTPCClusterMCData*> fClusterMCData; //! references to MC data blocks
206 iterator fIterator; //!
210 /// copy constructor prohibited
211 AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
212 /// assignment operator prohibited
213 AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
216 // skip the track clusters
217 kSkipTrackClusters = BIT(15),
218 // skip the partition (remaining) clusters
219 kSkipPartitionClusters = BIT(16)
222 int fVerbosity; //! verbosity level
223 AliTPCclusterMIContainer* fClusters; //! cluster container
224 int fCurrentSector; //! current sector
226 ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)