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 "AliTPCclusterMI.h"
21 class AliTPCClustersRow;
24 class AliHLTTPCDataCompressionDecoder;
26 typedef std::map<AliHLTUInt32_t, AliHLTTPCClusterMCLabel> AliHLTTPCClusterMCDataList;
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: 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);
110 * @class AliTPCclusterMIContainer
111 * Cluster read interface for offline.
112 * The class implements the interface to be used in the decoding
113 * of compressed TPC data.
115 class AliTPCclusterMIContainer {
117 AliTPCclusterMIContainer();
118 virtual ~AliTPCclusterMIContainer();
120 struct AliClusterIdBlock {
121 AliClusterIdBlock() : fIds(NULL), fSize(0) {}
122 AliHLTUInt32_t* fIds; //!
123 AliHLTUInt32_t fSize; //!
128 iterator() : fClusterNo(-1), fData(NULL), fCluster(NULL), fRowOffset(0) {}
129 iterator(AliTPCclusterMIContainer* pData) : fClusterNo(-1), fData(pData), fCluster(NULL), fRowOffset(0) {}
130 iterator(const iterator& other) : fClusterNo(other.fClusterNo), fData(other.fData), fCluster(other.fCluster), fRowOffset(other.fRowOffset) {}
131 iterator& operator=(const iterator& other) {
132 if (this==&other) return *this;
133 fClusterNo=other.fClusterNo; fData=other.fData; fCluster=other.fCluster; fRowOffset=other.fRowOffset; return *this;
137 void SetPadRow(int row) {if (fCluster) fCluster->SetRow(row-fRowOffset);}
138 void SetPad(float pad) {if (fCluster) fCluster->SetPad(pad);}
139 void SetTime(float time) {if (fCluster) fCluster->SetTimeBin(time);}
140 void SetSigmaY2(float sigmaY2) {if (fCluster) fCluster->SetSigmaY2(sigmaY2);}
141 void SetSigmaZ2(float sigmaZ2) {if (fCluster) fCluster->SetSigmaZ2(sigmaZ2);}
142 void SetCharge(unsigned charge) {if (fCluster) fCluster->SetQ(charge);}
143 void SetQMax(unsigned qmax) {if (fCluster) fCluster->SetMax(qmax);}
144 void SetMC(const AliHLTTPCClusterMCLabel* pMC) {
145 if (!fCluster || !pMC) return;
146 for (int k=0; k<3; k++) fCluster->SetLabel(pMC->fClusterID[k].fMCID, k);
149 // switch to next cluster
150 iterator& Next(int slice, int partition);
153 int fClusterNo; //! cluster no in the current block
154 AliTPCclusterMIContainer* fData; //! pointer to actual data
155 AliTPCclusterMI* fCluster; //! pointer to current cluster
156 int fRowOffset; //! row offset for current partition
159 /// iterator of remaining clusters block of specification
160 iterator& BeginRemainingClusterBlock(int count, AliHLTUInt32_t specification);
161 /// iterator of track model clusters
162 iterator& BeginTrackModelClusterBlock(int count);
165 virtual void Clear(Option_t * option="");
166 /// get the cluster array for a sector
167 TObjArray* GetSectorArray(unsigned sector) const;
169 virtual void Print(Option_t *option=NULL) const;
172 /// load next cluster from array of the sepcific sector
173 AliTPCclusterMI* NextCluster(int slice, int partition);
176 AliTPCclusterMIContainer(const AliTPCclusterMIContainer&);
177 AliTPCclusterMIContainer& operator=(const AliTPCclusterMIContainer&);
179 vector<TClonesArray*> fClusterArrays; //! cluster arrays per sector (offline notation 0-71)
180 vector<AliClusterIdBlock> fRemainingClusterIds; //! clusters ids for remaining cluster ids
181 AliClusterIdBlock fTrackModelClusterIds; //! cluster ids for track model clusters
182 AliClusterIdBlock* fCurrentClusterIds; //! id block currently active in the iteration
183 vector<const AliHLTTPCClusterMCData*> fClusterMCData; //! references to MC data blocks
184 iterator fIterator; //!
188 /// copy constructor prohibited
189 AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
190 /// assignment operator prohibited
191 AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
194 // skip the track clusters
195 kSkipTrackClusters = BIT(15),
196 // skip the partition (remaining) clusters
197 kSkipPartitionClusters = BIT(16)
200 int fVerbosity; //! verbosity level
201 AliTPCclusterMIContainer* fClusters; //! cluster container
202 int fCurrentSector; //! current sector
203 AliHLTTPCDataCompressionDecoder* fpDecoder; //! decoder instance
205 ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)