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"
22 #include "AliHLTTPCClusterMCData.h"
23 #include "AliHLTTPCRawCluster.h"
26 class AliHLTTPCSpacePointData;
27 class AliHLTTPCClusters;
28 class AliTPCTransform;
32 * @class AliHLTTPCClusterFinder
34 * The current cluster finder for HLT
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.
45 * The cluster finder is initialized with the Init function,
46 * providing the slice and patch information to work on.
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.
57 * There are several setters which control the behaviour:
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
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);
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();
107 * @ingroup alihlt_tpc
109 class AliHLTTPCClusterFinder : public AliHLTLogging {
112 struct AliClusterData
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
124 Int_t fRow; //row value
127 typedef struct AliClusterData AliClusterData; //!
129 static Bool_t CompareWeights( const AliHLTTPCClusterMCWeight &mc1, const AliHLTTPCClusterMCWeight &mc2 ){ return mc1.fWeight > mc2.fWeight; }
132 /** standard constructor */
133 AliHLTTPCClusterFinder();
136 virtual ~AliHLTTPCClusterFinder();
138 /** Initialize the slice */
139 void InitSlice(Int_t slice,Int_t patch,Int_t maxpoints);
141 /** Initializes the pad array (vector)*/
142 void InitializePadArray();
144 /** Deinitialize the pad array (vector)*/
145 Int_t DeInitializePadArray();
147 /** Read the data in unsorted format, storing the clustercandidates */
148 void ReadDataUnsorted(void* ptr,unsigned long size);
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);
153 /** Loops over all rows finding the clusters */
156 /** Compare two neighbouring pads for matching clustercandidates */
157 Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
159 /** Fills the hw address list */
160 Int_t FillHWAddressList(AliHLTUInt16_t *hwaddlist, Int_t maxHWAddress);
162 /** Fills the mc info */
163 Int_t FillOutputMCInfo(AliHLTTPCClusterMCLabel * outputMCInfo, Int_t maxNumberOfClusterMCInfo);
165 Int_t FillOutputRaw(AliHLTTPCRawCluster* rawClusters, unsigned sizeInByte) const;
167 /** Set the pointer to the outputbuffer */
168 void SetOutputArray(AliHLTTPCSpacePointData *pt);
170 /** Returns the number of clusters */
171 Int_t GetNumberOfClusters() const {return fNClusters;}
173 /** Returns the Ocuppancy limit */
174 Float_t GetOccupancyLimit() const {return fOccupancyLimit;}
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;}
185 void SetReleaseMemory( Bool_t v ){ fReleaseMemory = v;}
186 void UpdateLastTimeBin(){fLastTimeBin=AliHLTTPCTransform::GetNTimeBins();}
188 //---------------------------------- Under this line the old sorted clusterfinder functions can be found --------------------------------
189 void Read(void* ptr,unsigned long size);
190 void ProcessDigits();
191 void WriteClusters(Int_t n_clusters,AliClusterData *list);
192 void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
193 void PrintClusters();
194 void SetXYError(Float_t f) {fXYErr=f;}
195 void SetZError(Float_t f) {fZErr=f;}
196 void SetThreshold(UInt_t i) {fThreshold=i;}
197 void SetOccupancyLimit(Float_t f) {fOccupancyLimit=f;}
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;}
201 void SetFillRawClusters(Bool_t f=kFALSE) {fFillRawClusters=f;}
202 void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
204 void Set32BitFormat(Bool_t flag){f32BitFormat = flag;}
206 void SetDoMC(Bool_t flag){fDoMC = flag;}
208 vector<AliHLTUInt16_t> fClustersHWAddressVector; //! transient
210 typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
212 vector<AliHLTTPCPadVector> fRowPadVector; //! transient
214 void FillMCClusterVector(vector<AliHLTTPCDigitData> *digitData);
216 vector<AliHLTTPCClusterMCWeight> GetClusterMCInfo() const {return fClusterMCVector;}
218 Bool_t UpdateCalibDB();
221 /** copy constructor prohibited */
222 AliHLTTPCClusterFinder(const AliHLTTPCClusterFinder&);
223 /** assignment operator prohibited */
224 AliHLTTPCClusterFinder& operator=(const AliHLTTPCClusterFinder&);
226 AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
227 AliHLTTPCDigitReader *fDigitReader; //! reader instance
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
235 Bool_t fFillRawClusters; //! store centroids in raw system in separate array
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
250 Float_t fOccupancyLimit; //! Occupancy Limit
252 Int_t fUnsorted; //! enable for processing of unsorted digit data
253 Bool_t fVectorInitialized; //! flag to check if pad vector is initialized
255 vector<AliHLTTPCClusters> fClusters; //! transient
257 vector<AliHLTTPCClusterMCLabel> fClustersMCInfo; //! transient
259 vector<AliHLTTPCDigitData> fMCDigits; //! transient
261 vector<AliHLTTPCRawCluster> fRawClusters; //! transient
263 UInt_t* fNumberOfPadsInRow; //! transient
265 UInt_t fNumberOfRows; //! transient
267 UInt_t fRowOfFirstCandidate; //! transient
269 Bool_t fDoPadSelection; //! transient
271 Int_t fFirstTimeBin; //! transient
273 Int_t fLastTimeBin; //! transient
275 UInt_t fTotalChargeOfPreviousClusterCandidate; //! transient
277 Bool_t fChargeOfCandidatesFalling; //! transient
279 Bool_t f32BitFormat; //! transient
281 Bool_t fDoMC; //! transient
283 vector<AliHLTTPCClusterMCWeight> fClusterMCVector; //! transient
285 AliTPCTransform * fOfflineTransform; //! transient
287 AliTPCParam *fOfflineTPCParam; //! transient
289 AliTPCRecoParam fOfflineTPCRecoParam; //! transient
291 Float_t fTimeMeanDiff; //! transient
293 Bool_t fReleaseMemory; //! flag to release the memory after each event
296 void GetTrackID(Int_t pad,Int_t time,Int_t *trackID) const;
299 ClassDef(AliHLTTPCClusterFinder, 0) //Fast cluster finder