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