]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterFinder.h
Technical fix for bug #58138: VZERO breaks in AliVZEROTrending::~AliVZEROTrending()
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterFinder.h
CommitLineData
a38a7850 1// @(#) $Id$
4aa41877 2// Original: AliHLTClustFinderNew.h,v 1.13 2004/06/18 10:55:26 loizides
a38a7850 3
01f43166 4#ifndef AliHLTTPC_CLUSTERFINDER
5#define AliHLTTPC_CLUSTERFINDER
297174de 6//* This file is property of and copyright by the ALICE HLT Project *
7//* ALICE Experiment at CERN, All rights reserved. *
8//* See cxx source for full Copyright notice *
a38a7850 9
01f43166 10/** @file AliHLTTPCClusterFinder.h
297174de 11 @author Anders Vestbo, Constantin Loizides
01f43166 12 Kenneth Aamodt kenneth.aamodt@student.uib.no
01f43166 13 @brief Cluster Finder for the TPC
14*/
15
01f43166 16#include "AliHLTLogging.h"
297174de 17#include <vector>
6b15c309 18#include "AliHLTTPCTransform.h"
deba5d85 19#include "AliHLTTPCDigitData.h"
20#include "AliHLTTPCDigitReader.h"
f14729cb 21#include "AliTPCRecoParam.h"
297174de 22
23class AliHLTTPCPad;
a38a7850 24class AliHLTTPCSpacePointData;
297174de 25class AliHLTTPCClusters;
5ee8e602 26class AliTPCTransform;
a38a7850 27
297174de 28/**
29 * @class AliHLTTPCClusterFinder
30 *
31 * The current cluster finder for HLT
32 * (Based on STAR L3)
33 *
34 * Basically we have two versions for the cluster finder now.
35 * The default version, reads the data pad by pad, and find the
36 * clusters as it reads the data. The other version has now been
37 * developed to cope with unsorted data. New methods for the unsorted
38 * version can be found at the end of the default one i the source file.
39 * Currently the new version is only build to manage zero-suppressed data.
40 * More functionality will be added later.
41 *
42 * The cluster finder is initialized with the Init function,
43 * providing the slice and patch information to work on.
44 *
45 * The input is a provided by the AliHLTTPCDigitReader class,
46 * using the init() funktion, and the next() funktion in order
47 * to get the next bin. Either packed or unpacked data can be
48 * processed, dependent if one uses AliHLTTPCDigitReaderPacked
49 * class or AliHLTTPCDigitReaderUnpacked class in the
50 * Clusterfinder Component.
51 * The resulting space points will be in the
52 * array given by the SetOutputArray function.
53 *
54 * There are several setters which control the behaviour:
55 *
56 * - SetXYError(Float_t): set fixed error in XY direction
57 * - SetZError(Float_t): set fixed error in Z direction
58 * (used if errors are not calculated)
59 * - SetDeconv(Bool_t): switch on/off deconvolution
60 * - SetThreshold(UInt_t): set charge threshold for cluster
61 * - SetMatchWidth(UInt_t): set the match distance in
62 * time for sequences to be merged
63 * - SetSTDOutput(Bool_t): switch on/off output about found clusters
64 * - SetCalcErr(Bool_t): switch on/off calculation of
65 * space point errors (or widths in raw system)
66 * - SetRawSP(Bool_t): switch on/off convertion to raw system
67 *
68 *
69 * Example Usage:
70 *
71 * <pre>
72 * AliHLTTPCFileHandler *file = new AliHLTTPCFileHandler();
73 * file->SetAliInput(digitfile); //give some input file
74 * for(int slice=0; slice<=35; slice++){
75 * for(int patch=0; pat<6; pat++){
76 * file->Init(slice,patch);
77 * UInt_t ndigits=0;
78 * UInt_t maxclusters=100000;
79 * UInt_t pointsize = maxclusters*sizeof(AliHLTTPCSpacePointData);
80 * AliHLTTPCSpacePointData *points = (AliHLTTPCSpacePointData*)memory->Allocate(pointsize);
81 * AliHLTTPCDigitRowData *digits = (AliHLTTPCDigitRowData*)file->AliAltroDigits2Memory(ndigits,event);
82 * AliHLTTPCClusterFinder *cf = new AliHLTTPCClusterFinder();
83 * cf->SetMatchWidth(2);
84 * cf->InitSlice( slice, patch, row[0], row[1], maxPoints );
85 * cf->SetSTDOutput(kTRUE); //Some output to standard IO
86 * cf->SetRawSP(kFALSE); //Convert space points to local system
87 * cf->SetThreshold(5); //Threshold of cluster charge
88 * cf->SetDeconv(kTRUE); //Deconv in pad and time direction
89 * cf->SetCalcErr(kTRUE); //Calculate the errors of the spacepoints
90 * cf->SetOutputArray(points); //Move the spacepoints to the array
91 * cf->Read(iter->fPtr, iter->fSize ); //give the data to the cf
92 * cf->ProcessDigits(); //process the rows given by init
93 * Int_t npoints = cf->GetNumberOfClusters();
94 * AliHLTTPCMemHandler *out= new AliHLTTPCMemHandler();
95 * out->SetBinaryOutput(fname);
96 * out->Memory2Binary(npoints,points); //store the spacepoints
97 * out->CloseBinaryOutput();
98 * delete out;
99 * file->free();
100 * delete cf;
101 * }
102 * }
103 * </pre>
104 * @ingroup alihlt_tpc
105 */
46b33a24 106class AliHLTTPCClusterFinder : public AliHLTLogging {
a38a7850 107
108 public:
109 struct AliClusterData
110 {
111 UInt_t fTotalCharge; //tot charge of cluster
112 UInt_t fPad; //pad value
113 UInt_t fTime; //time value
114 ULong64_t fPad2; //for error in XY direction
115 ULong64_t fTime2; //for error in Z direction
116 UInt_t fMean; //mean in time
117 UInt_t fFlags; //different flags
118 UInt_t fChargeFalling; //for deconvolution
119 UInt_t fLastCharge; //for deconvolution
120 UInt_t fLastMergedPad; //dont merge twice per pad
d8b2f74a 121 Int_t fRow; //row value
6b15c309 122 UInt_t fQMax; //qmax
a38a7850 123 };
124 typedef struct AliClusterData AliClusterData; //!
125
deba5d85 126 struct MCWeight{
127 Int_t fMCID;
128 Float_t fWeight;
129 static Bool_t CompareWeights( const MCWeight &mc1, const MCWeight &mc2 ){ return mc1.fWeight > mc2.fWeight; }
130 };
131 typedef struct MCWeight MCWeight;
132
133 struct ClusterMCInfo{
134 MCWeight fClusterID[3];
135 };
136 typedef struct ClusterMCInfo ClusterMCInfo;
137
138
8f8bf0af 139 /** standard constructor */
140 AliHLTTPCClusterFinder();
a912b63b 141
8f8bf0af 142 /** destructor */
143 virtual ~AliHLTTPCClusterFinder();
144
a912b63b 145 /** Initialize the slice */
8f8bf0af 146 void InitSlice(Int_t slice,Int_t patch,Int_t maxpoints);
8f8bf0af 147
a912b63b 148 /** Initializes the pad array (vector)*/
149 void InitializePadArray();
150
151 /** Deinitialize the pad array (vector)*/
152 Int_t DeInitializePadArray();
153
154 /** Read the data in unsorted format, storing the clustercandidates */
155 void ReadDataUnsorted(void* ptr,unsigned long size);
156
157 /** Read the data in unsorted format, and deconvolute the signals for each pad in time direction */
158 void ReadDataUnsortedDeconvoluteTime(void* ptr,unsigned long size);
159
160 /** Loops over all rows finding the clusters */
161 void FindClusters();
162
163 /** Compare two neighbouring pads for matching clustercandidates */
164 Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
165
166 /** Fills the hw address list */
167 Int_t FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWAddress);
168
deba5d85 169 /** Fills the mc info */
170 Int_t FillOutputMCInfo(AliHLTTPCClusterFinder::ClusterMCInfo * outputMCInfo, Int_t maxNumberOfClusterMCInfo);
171
a912b63b 172 /** Set the pointer to the outputbuffer */
8f8bf0af 173 void SetOutputArray(AliHLTTPCSpacePointData *pt);
a912b63b 174
175 /** Returns the number of clusters */
176 Int_t GetNumberOfClusters() const {return fNClusters;}
177
3f0fd8f1 178 /** Returns the Ocuppancy limit */
179 Float_t GetOccupancyLimit() {return fOccupancyLimit;}
180
a912b63b 181 // setters
182 void SetDeconv(Bool_t f) {fDeconvPad=f; fDeconvTime=f;}
183 void SetDeconvPad(Bool_t f) {fDeconvPad=f;}
184 void SetDeconvTime(Bool_t f) {fDeconvTime=f;}
185 void SetUnsorted(Int_t unsorted){fUnsorted=unsorted;}
186 void SetPatch(Int_t patch){fCurrentPatch=patch;}
187 void SetDoPadSelection(Bool_t input){fDoPadSelection=input;}
188 void SetLastTimeBin(Int_t ltb){fLastTimeBin=ltb;}
189 void SetFirstTimeBin(Int_t ftb){fFirstTimeBin=ftb;}
190 void UpdateLastTimeBin(){fLastTimeBin=AliHLTTPCTransform::GetNTimeBins();}
191
192//---------------------------------- Under this line the old sorted clusterfinder functions can be found --------------------------------
193 void Read(void* ptr,unsigned long size);
194 void ProcessDigits();
8f8bf0af 195 void WriteClusters(Int_t n_clusters,AliClusterData *list);
a912b63b 196 void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
8252a538 197 void PrintClusters();
8f8bf0af 198 void SetXYError(Float_t f) {fXYErr=f;}
199 void SetZError(Float_t f) {fZErr=f;}
8f8bf0af 200 void SetThreshold(UInt_t i) {fThreshold=i;}
201 void SetOccupancyLimit(Float_t f) {fOccupancyLimit=f;}
8f8bf0af 202 void SetMatchWidth(UInt_t i) {fMatch=i;}
203 void SetSTDOutput(Bool_t f=kFALSE) {fStdout=f;}
204 void SetCalcErr(Bool_t f=kTRUE) {fCalcerr=f;}
205 void SetRawSP(Bool_t f=kFALSE) {fRawSP=f;}
206 void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
deba5d85 207
208 void Set32BitFormat(Bool_t flag){f32BitFormat = flag;}
209
210 void SetDoMC(Bool_t flag){fDoMC = flag;}
2fdb1ae7 211
212 vector<AliHLTUInt16_t> fClustersHWAddressVector; //! transient
213
214 typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
215
216 vector<AliHLTTPCPadVector> fRowPadVector; //! transient
deba5d85 217
218 void FillMCClusterVector(vector<AliHLTTPCDigitData> digitData);
219
220 vector<AliHLTTPCClusterFinder::MCWeight> GetClusterMCInfo(){return fClusterMCVector;}
221
4f43db26 222 Bool_t UpdateCalibDB();
223
98034d0d 224 protected:
8f8bf0af 225 /** copy constructor prohibited */
226 AliHLTTPCClusterFinder(const AliHLTTPCClusterFinder&);
227 /** assignment operator prohibited */
228 AliHLTTPCClusterFinder& operator=(const AliHLTTPCClusterFinder&);
229
2a083ac4 230 AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
231 AliHLTTPCDigitReader *fDigitReader; //! reader instance
a38a7850 232
a912b63b 233 UChar_t* fPtr; //! pointer to packed block
234 unsigned long fSize; //! packed block size
235 Bool_t fDeconvTime; //! deconv in time direction
236 Bool_t fDeconvPad; //! deconv in pad direction
237 Bool_t fStdout; //! have print out in write clusters
238 Bool_t fCalcerr; //! calculate centroid sigmas
239 Bool_t fRawSP; //! store centroids in raw system
240
241
242 Int_t fFirstRow; //! first row
243 Int_t fLastRow; //! last row
244 Int_t fCurrentRow; //! current active row
245 Int_t fCurrentSlice; //! current slice
246 Int_t fCurrentPatch; //! current patch
247 Int_t fMatch; //! size of match
248 UInt_t fThreshold; //! threshold for clusters
249 Int_t fNClusters; //! number of found clusters
250 Int_t fMaxNClusters; //! max. number of clusters
251 Float_t fXYErr; //! fixed error in XY
252 Float_t fZErr; //! fixed error in Z
5235c3e9 253
a912b63b 254 Float_t fOccupancyLimit; //! Occupancy Limit
8252a538 255
a912b63b 256 Int_t fUnsorted; //! enable for processing of unsorted digit data
257 Bool_t fVectorInitialized; //! flag to check if pad vector is initialized
258
8252a538 259 vector<AliHLTTPCClusters> fClusters; //! transient
deba5d85 260
261 vector<ClusterMCInfo> fClustersMCInfo; //! transient
262
263 vector<AliHLTTPCDigitData> fMCDigits; //! transient
8252a538 264
265 UInt_t* fNumberOfPadsInRow; //! transient
266
267 UInt_t fNumberOfRows; //! transient
268
2fdb1ae7 269 UInt_t fRowOfFirstCandidate; //! transient
270
271 Bool_t fDoPadSelection; //! transient
a38a7850 272
6b15c309 273 Int_t fFirstTimeBin; //! transient
274
275 Int_t fLastTimeBin; //! transient
276
277 UInt_t fTotalChargeOfPreviousClusterCandidate; //! transient
278
279 Bool_t fChargeOfCandidatesFalling; //! transient
280
deba5d85 281 Bool_t f32BitFormat; //! transient
282
283 Bool_t fDoMC; //! transient
284
285 vector<MCWeight> fClusterMCVector; //! transient
64defa03 286
6a5788b9 287 AliTPCTransform * fOfflineTransform; //! transient
288
f14729cb 289 AliTPCRecoParam fOfflineTPCRecoParam; //! transient
290
6a5788b9 291 Float_t fTimeMeanDiff; //! transient
5ee8e602 292
a38a7850 293#ifdef do_mc
294 void GetTrackID(Int_t pad,Int_t time,Int_t *trackID);
295#endif
296
f14729cb 297 ClassDef(AliHLTTPCClusterFinder,10) //Fast cluster finder
a38a7850 298};
299#endif