]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterAccessHLTOUT.h
treatment of MC labels added
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterAccessHLTOUT.h
CommitLineData
c54aa300 1//-*- Mode: C++ -*-
2// $Id$
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 *
8
9/// @file AliHLTTPCClusterAccessHLTOUT.h
10/// @author Matthias Richter
11/// @date 2011-06-06
12/// @brief Interface to HLT TPC clusters
13///
14
15#include "TObject.h"
81e7f739 16#include "AliHLTDataTypes.h"
17#include "AliHLTTPCClusterMCData.h"
b60d3f6a 18#include "AliTPCclusterMI.h"
81e7f739 19#include <map>
c54aa300 20
21class AliTPCClustersRow;
22class AliHLTOUT;
23class TClonesArray;
24
81e7f739 25typedef std::map<AliHLTUInt32_t, AliHLTTPCClusterMCLabel> AliHLTTPCClusterMCDataList;
26
c54aa300 27/**
28 * @class AliHLTTPCClusterAccessHLTOUT
29 * Generator for TPC cluster array from HLT TPC clusters in the HLTOUT
81e7f739 30 * data stream. It uses the TObject method interface. Combined with dynamic
31 * loading, any cross dependency between the TPC code and HLT libraries
32 * can be avoided.
c54aa300 33 *
81e7f739 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).
38 * <pre>
39 * TObject* pClusterAccess=NULL;
40 * TClass* pCl=NULL;
41 * ROOT::NewFunc_t pNewFunc=NULL;
42 * do {
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);
47 * if (p) {
48 * pClusterAccess=reinterpret_cast<TObject*>(p);
49 * }
50 * }
51 * </pre>
52 *
53 * Usage:
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.
81e7f739 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
b60d3f6a 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
81e7f739 69 *
70 * Command 'verbosity=level' sets the verbositylevel which is default 0
71 * (no info output).
b60d3f6a 72 *
81e7f739 73 * <pre>
81e7f739 74 * pClusterAccess->Execute("read", param);
75 * TObject* pClusterAccess->FindObject("clusterarray");
76 * </pre>
b60d3f6a 77 *
78 * After processing the loop of sectors, the instance should be cleaned.
79 * <pre>
80 * pClusterAccess->Clear("event");
81 * </pre>
81e7f739 82 *
c54aa300 83 * @ingroup alihlt_tpc
84 */
85class AliHLTTPCClusterAccessHLTOUT : public TObject
86{
87 public:
88 /** standard constructor */
89 AliHLTTPCClusterAccessHLTOUT();
90 /** destructor */
91 ~AliHLTTPCClusterAccessHLTOUT();
92
93 /// inherited from TObject: abstract command interface
94 virtual void Execute(const char *method, const char *params, Int_t *error=0);
95
96 /// inherited from TObject: return the cluster array if name id "clusterarray"
97 virtual TObject *FindObject(const char *name) const;
98
99 /// inherited from TObject: cleanup
100 virtual void Clear(Option_t * option ="");
101
102 /// inherited from TObject
103 virtual void Print(Option_t *option="") const;
104
105 /// process the cluster data block of various formats from HLTOUT
81e7f739 106 int ProcessClusters(const char* params);
107
108 /// process the cluster mc data block {CLMCINFO:TPC } from HLTOUT
109 int ReadAliHLTTPCClusterMCData(AliHLTOUT* pHLTOUT, AliHLTTPCClusterMCDataList &tpcClusterLabels) const;
c54aa300 110
111 /// process the cluster data block {CLUSTERS:TPC } from HLTOUT
81e7f739 112 int ReadAliHLTTPCClusterData(AliHLTOUT* pHLTOUT, TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels=NULL) const;
c54aa300 113
5e75f4e0 114 /// process the cluster data block {CLUSTRAW:TPC } from HLTOUT
115 int ReadAliHLTTPCRawClusterData(AliHLTOUT* pHLTOUT, TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels);
116
2827cd62 117 /// process the clusters of type {REMCLSCM:TPC } from HLTOUT
118 int ReadRemainingClustersCompressed(AliHLTOUT* pHLTOUT, TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels);
119
120 /// process clusters encoded by AliHLTDataDeflaterSimple
61e66346 121 int ReadAliHLTTPCRawClusterDataDeflateSimple(const AliHLTUInt8_t* pData, int dataSize,
122 int nofClusters, AliHLTUInt32_t specification,
123 TClonesArray* pClusters, const AliHLTTPCClusterMCDataList *tpcClusterLabels);
124
b60d3f6a 125 /**
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.
130 */
131 class AliTPCclusterMIContainer {
132 public:
133 AliTPCclusterMIContainer();
134 virtual ~AliTPCclusterMIContainer();
135
136 struct AliClusterIdBlock {
137 AliClusterIdBlock() : fIds(NULL), fSize(0) {}
138 AliHLTUInt32_t* fIds; //!
139 AliHLTUInt32_t fSize; //!
140 };
141
142 class iterator {
143 public:
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) {
b22da46d 148 if (this==&other) return *this;
b60d3f6a 149 fClusterNo=other.fClusterNo; fData=other.fData; fCluster=other.fCluster, fClusterId=other.fClusterId; fRowOffset=other.fRowOffset; return *this;
150 }
151 ~iterator() {}
152
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
161 // switch to next cluster
162 iterator& Next(int slice, int partition);
163
164 private:
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
170 };
171
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);
176
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;
183
184 /// internal cleanup
185 virtual void Clear(Option_t * option="");
186 /// get the cluster array for a sector
187 TObjArray* GetSectorArray(unsigned sector) const;
188 /// print info
189 virtual void Print(Option_t *option=NULL) const;
190
191 protected:
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);
196
197 private:
198 AliTPCclusterMIContainer(const AliTPCclusterMIContainer&);
199 AliTPCclusterMIContainer& operator=(const AliTPCclusterMIContainer&);
200
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; //!
207 };
208
c54aa300 209 private:
210 /// copy constructor prohibited
211 AliHLTTPCClusterAccessHLTOUT(const AliHLTTPCClusterAccessHLTOUT&);
212 /// assignment operator prohibited
213 AliHLTTPCClusterAccessHLTOUT& operator=(const AliHLTTPCClusterAccessHLTOUT&);
214
b60d3f6a 215 enum EOptions {
216 // skip the track clusters
217 kSkipTrackClusters = BIT(15),
218 // skip the partition (remaining) clusters
219 kSkipPartitionClusters = BIT(16)
220 };
221
81e7f739 222 int fVerbosity; //! verbosity level
b60d3f6a 223 AliTPCclusterMIContainer* fClusters; //! cluster container
224 int fCurrentSector; //! current sector
c54aa300 225
226 ClassDef(AliHLTTPCClusterAccessHLTOUT, 0)
227};
228#endif