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