2 // Original: AliHLTClustFinderNew.h,v 1.13 2004/06/18 10:55:26 loizides
4 #ifndef ALIHLTTPCCLUSTERFINDER_H
5 #define ALIHLTTPCCLUSTERFINDER_H
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 *
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
16 #include "AliHLTLogging.h"
18 #include "AliHLTTPCTransform.h"
19 #include "AliHLTTPCDigitData.h"
20 #include "AliHLTTPCDigitReader.h"
21 #include "AliTPCRecoParam.h"
24 class AliHLTTPCSpacePointData;
25 class AliHLTTPCClusters;
26 class AliTPCTransform;
30 * @class AliHLTTPCClusterFinder
32 * The current cluster finder for HLT
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.
43 * The cluster finder is initialized with the Init function,
44 * providing the slice and patch information to work on.
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.
55 * There are several setters which control the behaviour:
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
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);
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();
105 * @ingroup alihlt_tpc
107 class AliHLTTPCClusterFinder : public AliHLTLogging {
110 struct AliClusterData
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
122 Int_t fRow; //row value
125 typedef struct AliClusterData AliClusterData; //!
130 static Bool_t CompareWeights( const MCWeight &mc1, const MCWeight &mc2 ){ return mc1.fWeight > mc2.fWeight; }
132 typedef struct MCWeight MCWeight;
134 struct ClusterMCInfo{
135 MCWeight fClusterID[3]; //!
137 typedef struct ClusterMCInfo ClusterMCInfo;
140 /** standard constructor */
141 AliHLTTPCClusterFinder();
144 virtual ~AliHLTTPCClusterFinder();
146 /** Initialize the slice */
147 void InitSlice(Int_t slice,Int_t patch,Int_t maxpoints);
149 /** Initializes the pad array (vector)*/
150 void InitializePadArray();
152 /** Deinitialize the pad array (vector)*/
153 Int_t DeInitializePadArray();
155 /** Read the data in unsorted format, storing the clustercandidates */
156 void ReadDataUnsorted(void* ptr,unsigned long size);
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);
161 /** Loops over all rows finding the clusters */
164 /** Compare two neighbouring pads for matching clustercandidates */
165 Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
167 /** Fills the hw address list */
168 Int_t FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWAddress);
170 /** Fills the mc info */
171 Int_t FillOutputMCInfo(AliHLTTPCClusterFinder::ClusterMCInfo * outputMCInfo, Int_t maxNumberOfClusterMCInfo);
173 /** Set the pointer to the outputbuffer */
174 void SetOutputArray(AliHLTTPCSpacePointData *pt);
176 /** Returns the number of clusters */
177 Int_t GetNumberOfClusters() const {return fNClusters;}
179 /** Returns the Ocuppancy limit */
180 Float_t GetOccupancyLimit() const {return fOccupancyLimit;}
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;}
191 void SetReleaseMemory( Bool_t v ){ fReleaseMemory = v;}
192 void UpdateLastTimeBin(){fLastTimeBin=AliHLTTPCTransform::GetNTimeBins();}
194 //---------------------------------- Under this line the old sorted clusterfinder functions can be found --------------------------------
195 void Read(void* ptr,unsigned long size);
196 void ProcessDigits();
197 void WriteClusters(Int_t n_clusters,AliClusterData *list);
198 void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
199 void PrintClusters();
200 void SetXYError(Float_t f) {fXYErr=f;}
201 void SetZError(Float_t f) {fZErr=f;}
202 void SetThreshold(UInt_t i) {fThreshold=i;}
203 void SetOccupancyLimit(Float_t f) {fOccupancyLimit=f;}
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;}
210 void Set32BitFormat(Bool_t flag){f32BitFormat = flag;}
212 void SetDoMC(Bool_t flag){fDoMC = flag;}
214 vector<AliHLTUInt16_t> fClustersHWAddressVector; //! transient
216 typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
218 vector<AliHLTTPCPadVector> fRowPadVector; //! transient
220 void FillMCClusterVector(vector<AliHLTTPCDigitData> *digitData);
222 vector<AliHLTTPCClusterFinder::MCWeight> GetClusterMCInfo() const {return fClusterMCVector;}
224 Bool_t UpdateCalibDB();
227 /** copy constructor prohibited */
228 AliHLTTPCClusterFinder(const AliHLTTPCClusterFinder&);
229 /** assignment operator prohibited */
230 AliHLTTPCClusterFinder& operator=(const AliHLTTPCClusterFinder&);
232 AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
233 AliHLTTPCDigitReader *fDigitReader; //! reader instance
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
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
256 Float_t fOccupancyLimit; //! Occupancy Limit
258 Int_t fUnsorted; //! enable for processing of unsorted digit data
259 Bool_t fVectorInitialized; //! flag to check if pad vector is initialized
261 vector<AliHLTTPCClusters> fClusters; //! transient
263 vector<ClusterMCInfo> fClustersMCInfo; //! transient
265 vector<AliHLTTPCDigitData> fMCDigits; //! transient
267 UInt_t* fNumberOfPadsInRow; //! transient
269 UInt_t fNumberOfRows; //! transient
271 UInt_t fRowOfFirstCandidate; //! transient
273 Bool_t fDoPadSelection; //! transient
275 Int_t fFirstTimeBin; //! transient
277 Int_t fLastTimeBin; //! transient
279 UInt_t fTotalChargeOfPreviousClusterCandidate; //! transient
281 Bool_t fChargeOfCandidatesFalling; //! transient
283 Bool_t f32BitFormat; //! transient
285 Bool_t fDoMC; //! transient
287 vector<MCWeight> fClusterMCVector; //! transient
289 AliTPCTransform * fOfflineTransform; //! transient
291 AliTPCParam *fOfflineTPCParam; //! transient
293 AliTPCRecoParam fOfflineTPCRecoParam; //! transient
295 Float_t fTimeMeanDiff; //! transient
297 Bool_t fReleaseMemory; //! flag to release the memory after each event
300 void GetTrackID(Int_t pad,Int_t time,Int_t *trackID) const;
303 ClassDef(AliHLTTPCClusterFinder, 0) //Fast cluster finder