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"
22 class AliTPCClustersRow;
23 class AliTPCclusterMI;
26 class AliHLTTPCDataCompressionDecoder;
29 * @class AliHLTTPCClusterAccessHLTOUT
30 * Generator for TPC cluster array from HLT TPC clusters in the HLTOUT
31 * data stream. It uses the TObject method interface. Combined with dynamic
32 * loading, any cross dependency between the TPC code and HLT libraries
35 * Creating the instance:
36 * The class is implemented in libAliHLTTPC.so and can be loaded
37 * through the TClass interface (you might want to add
38 * further error messages on the various error conditions).
40 * TObject* pClusterAccess=NULL;
42 * ROOT::NewFunc_t pNewFunc=NULL;
44 * pCl=TClass::GetClass("AliHLTTPCClusterAccessHLTOUT");
45 * } while (!pCl && gSystem->Load("libAliHLTTPC.so")==0);
46 * if (pCl && (pNewFunc=pCl->GetNew())!=NULL) {
47 * void* p=(*pNewFunc)(NULL);
49 * pClusterAccess=reinterpret_cast<TObject*>(p);
55 * TObject::Execute can be used to execute commands. Command 'read'
56 * will get hold on the HLTOUT data and read the clusters. The const char*
57 * parameter 'param' is used to select the region.
58 * - param="sector=sectorno"
59 * 'sectorno' specifies sector number in the offline code, range 0 and 71,
60 * enumerating first the 36 inner (partitions 0+1) and then 36 outer sectors
61 * (partitions 2-5).<br>
62 * If the error pointer parameter is provided the result code is returned
63 * - >=0 success, number of clusters
64 * - -ENODATA no data in HLTOUT
65 * - -EINVAL invalid parameter/argument
66 * - -ENOMEM memory allocation failed
67 * - -EACCESS no access to HLTOUT
68 * - -NODEV internal error, can not get AliHLTSystem
69 * - -ENOBUFS internal error, can not get cluster array
71 * Command 'verbosity=level' sets the verbositylevel which is default 0
75 * pClusterAccess->Execute("read", param);
76 * TObject* pClusterAccess->FindObject("clusterarray");
79 * After processing the loop of sectors, the instance should be cleaned.
81 * pClusterAccess->Clear("event");
86 class AliHLTTPCClusterAccessHLTOUT : public TObject
89 /** standard constructor */
90 AliHLTTPCClusterAccessHLTOUT();
92 ~AliHLTTPCClusterAccessHLTOUT();
94 /// inherited from TObject: abstract command interface
95 virtual void Execute(const char *method, const char *params, Int_t *error=0);
97 /// inherited from TObject: return the cluster array if name id "clusterarray"
98 virtual TObject *FindObject(const char *name) const;
100 /// inherited from TObject: supports writing of data to AliTPCClustersRow
101 virtual void Copy(TObject &object) const;
103 /// inherited from TObject: cleanup
104 virtual void Clear(Option_t * option ="");
106 /// inherited from TObject
107 virtual void Print(Option_t *option="") const;
109 /// process the cluster data block of various formats from HLTOUT
110 int ProcessClusters(const char* params);
112 /// helper struct to store cluster pointers in a map together with MC info
113 struct AliRawClusterEntry {
114 AliRawClusterEntry() : fCluster(NULL), fMC(NULL) {}
115 AliRawClusterEntry(AliHLTTPCRawCluster* pCluster) : fCluster(pCluster), fMC(NULL) {}
116 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;
122 AliHLTTPCRawCluster* fCluster; //! pointer to cluster in the array of all clusters
123 const AliHLTTPCClusterMCLabel* fMC; //! pointer to corresponding MC data in HLTOUT block
126 typedef vector<AliHLTTPCRawCluster> AliHLTTPCRawClusterVector;
127 typedef vector<AliRawClusterEntry> AliRawClusterEntryVector;
130 * @class AliRawClusterContainer
131 * Cluster read interface for offline.
132 * The class implements the interface to be used in the decoding
133 * of compressed TPC data.
135 class AliRawClusterContainer {
137 AliRawClusterContainer();
138 virtual ~AliRawClusterContainer();
140 struct AliClusterIdBlock {
141 AliClusterIdBlock() : fIds(NULL), fSize(0) {}
142 AliHLTUInt32_t* fIds; //!
143 AliHLTUInt32_t fSize; //!
148 iterator() : fClusterNo(-1), fData(NULL), fEntry(NULL), fRowOffset(0) {}
149 iterator(AliRawClusterContainer* pData) : fClusterNo(-1), fData(pData), fEntry(NULL), fRowOffset(0) {}
150 iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fEntry(other.fEntry), fRowOffset(other.fRowOffset) {}
151 iterator& operator=(const iterator& other) {
152 if (this==&other) return *this;
153 fClusterNo=other.fClusterNo; fData=other.fData; fEntry=other.fEntry; fRowOffset=other.fRowOffset; return *this;
157 void SetPadRow(int row) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetPadRow(row-fRowOffset);}
158 void SetPad(float pad) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetPad(pad);}
159 void SetTime(float time) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetTime(time);}
160 void SetSigmaY2(float sigmaY2) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetSigmaY2(sigmaY2);}
161 void SetSigmaZ2(float sigmaZ2) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetSigmaZ2(sigmaZ2);}
162 void SetCharge(unsigned charge) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetCharge(charge);}
163 void SetQMax(unsigned qmax) {if (fEntry && fEntry->fCluster) fEntry->fCluster->SetQMax(qmax);}
164 void SetMC(const AliHLTTPCClusterMCLabel* pMC) {
165 if (fEntry) fEntry->fMC=pMC;
168 // switch to next cluster
169 iterator& Next(int slice, int partition);
172 int fClusterNo; //! cluster no in the current block
173 AliRawClusterContainer* fData; //! pointer to actual data
174 AliRawClusterEntry* fEntry; //! pointer to current cluster
175 int fRowOffset; //! row offset for current partition
178 /// iterator of remaining clusters block of specification
179 iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
180 /// iterator of track model clusters
181 iterator& BeginTrackModelClusterBlock(int count);
184 virtual void Clear(Option_t * option="");
185 /// get the cluster array for a sector
186 TObjArray* GetSectorArray(unsigned sector) const;
187 /// fill the cluster array for a sector and specific row if specified
188 int FillSectorArray(TClonesArray* pSectorArray, unsigned sector, int row=-1) const;
190 virtual void Print(Option_t *option=NULL) const;
193 /// load next cluster from array of the sepcific sector
194 AliRawClusterEntry* NextCluster(int slice, int partition);
197 /// copy constructor prohibited
198 AliRawClusterContainer(const AliRawClusterContainer&);
199 /// assignment operator prohibited
200 AliRawClusterContainer& operator=(const AliRawClusterContainer&);
202 vector<AliHLTTPCRawClusterVector*> fClusterVectors; //! instances of cluster arrays
203 vector<AliRawClusterEntryVector*> fClusterMaps; //! cluster pointer vectors per sector (offline notation 0-71)
204 TClonesArray* fSectorArray; //! current sector array of clusters provided to caller
205 iterator fIterator; //!
209 /// copy constructor prohibited
210 AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
211 /// assignment operator prohibited
212 AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
215 // skip the track clusters
216 kSkipTrackClusters = BIT(15),
217 // skip the partition (remaining) clusters
218 kSkipPartitionClusters = BIT(16)
221 int fVerbosity; //! verbosity level
222 AliRawClusterContainer* fClusters; //! cluster container
223 int fCurrentSector; //! current sector
224 AliHLTTPCDataCompressionDecoder* fpDecoder; //! decoder instance
225 AliTPCParam* fTPCParam; //! pointer to TPC param
227 ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)