]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCClusterFinder.h
code documantation and minor cleanup
[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>
18
19class AliHLTTPCPad;
a38a7850 20class AliHLTTPCSpacePointData;
21class AliHLTTPCDigitReader;
297174de 22class AliHLTTPCClusters;
a38a7850 23
297174de 24/**
25 * @class AliHLTTPCClusterFinder
26 *
27 * The current cluster finder for HLT
28 * (Based on STAR L3)
29 *
30 * Basically we have two versions for the cluster finder now.
31 * The default version, reads the data pad by pad, and find the
32 * clusters as it reads the data. The other version has now been
33 * developed to cope with unsorted data. New methods for the unsorted
34 * version can be found at the end of the default one i the source file.
35 * Currently the new version is only build to manage zero-suppressed data.
36 * More functionality will be added later.
37 *
38 * The cluster finder is initialized with the Init function,
39 * providing the slice and patch information to work on.
40 *
41 * The input is a provided by the AliHLTTPCDigitReader class,
42 * using the init() funktion, and the next() funktion in order
43 * to get the next bin. Either packed or unpacked data can be
44 * processed, dependent if one uses AliHLTTPCDigitReaderPacked
45 * class or AliHLTTPCDigitReaderUnpacked class in the
46 * Clusterfinder Component.
47 * The resulting space points will be in the
48 * array given by the SetOutputArray function.
49 *
50 * There are several setters which control the behaviour:
51 *
52 * - SetXYError(Float_t): set fixed error in XY direction
53 * - SetZError(Float_t): set fixed error in Z direction
54 * (used if errors are not calculated)
55 * - SetDeconv(Bool_t): switch on/off deconvolution
56 * - SetThreshold(UInt_t): set charge threshold for cluster
57 * - SetMatchWidth(UInt_t): set the match distance in
58 * time for sequences to be merged
59 * - SetSTDOutput(Bool_t): switch on/off output about found clusters
60 * - SetCalcErr(Bool_t): switch on/off calculation of
61 * space point errors (or widths in raw system)
62 * - SetRawSP(Bool_t): switch on/off convertion to raw system
63 *
64 *
65 * Example Usage:
66 *
67 * <pre>
68 * AliHLTTPCFileHandler *file = new AliHLTTPCFileHandler();
69 * file->SetAliInput(digitfile); //give some input file
70 * for(int slice=0; slice<=35; slice++){
71 * for(int patch=0; pat<6; pat++){
72 * file->Init(slice,patch);
73 * UInt_t ndigits=0;
74 * UInt_t maxclusters=100000;
75 * UInt_t pointsize = maxclusters*sizeof(AliHLTTPCSpacePointData);
76 * AliHLTTPCSpacePointData *points = (AliHLTTPCSpacePointData*)memory->Allocate(pointsize);
77 * AliHLTTPCDigitRowData *digits = (AliHLTTPCDigitRowData*)file->AliAltroDigits2Memory(ndigits,event);
78 * AliHLTTPCClusterFinder *cf = new AliHLTTPCClusterFinder();
79 * cf->SetMatchWidth(2);
80 * cf->InitSlice( slice, patch, row[0], row[1], maxPoints );
81 * cf->SetSTDOutput(kTRUE); //Some output to standard IO
82 * cf->SetRawSP(kFALSE); //Convert space points to local system
83 * cf->SetThreshold(5); //Threshold of cluster charge
84 * cf->SetDeconv(kTRUE); //Deconv in pad and time direction
85 * cf->SetCalcErr(kTRUE); //Calculate the errors of the spacepoints
86 * cf->SetOutputArray(points); //Move the spacepoints to the array
87 * cf->Read(iter->fPtr, iter->fSize ); //give the data to the cf
88 * cf->ProcessDigits(); //process the rows given by init
89 * Int_t npoints = cf->GetNumberOfClusters();
90 * AliHLTTPCMemHandler *out= new AliHLTTPCMemHandler();
91 * out->SetBinaryOutput(fname);
92 * out->Memory2Binary(npoints,points); //store the spacepoints
93 * out->CloseBinaryOutput();
94 * delete out;
95 * file->free();
96 * delete cf;
97 * }
98 * }
99 * </pre>
100 * @ingroup alihlt_tpc
101 */
46b33a24 102class AliHLTTPCClusterFinder : public AliHLTLogging {
a38a7850 103
104 public:
105 struct AliClusterData
106 {
107 UInt_t fTotalCharge; //tot charge of cluster
108 UInt_t fPad; //pad value
109 UInt_t fTime; //time value
110 ULong64_t fPad2; //for error in XY direction
111 ULong64_t fTime2; //for error in Z direction
112 UInt_t fMean; //mean in time
113 UInt_t fFlags; //different flags
114 UInt_t fChargeFalling; //for deconvolution
115 UInt_t fLastCharge; //for deconvolution
116 UInt_t fLastMergedPad; //dont merge twice per pad
d8b2f74a 117 Int_t fRow; //row value
a38a7850 118 };
119 typedef struct AliClusterData AliClusterData; //!
120
8f8bf0af 121 /** standard constructor */
122 AliHLTTPCClusterFinder();
123 /** destructor */
124 virtual ~AliHLTTPCClusterFinder();
125
126 void Read(void* ptr,unsigned long size);
127
128 void InitSlice(Int_t slice,Int_t patch,Int_t firstrow, Int_t lastrow,Int_t maxpoints);
129 void InitSlice(Int_t slice,Int_t patch,Int_t maxpoints);
130 void ProcessDigits();
131
132 void SetOutputArray(AliHLTTPCSpacePointData *pt);
133 void WriteClusters(Int_t n_clusters,AliClusterData *list);
8252a538 134 void PrintClusters();
8f8bf0af 135 void SetXYError(Float_t f) {fXYErr=f;}
136 void SetZError(Float_t f) {fZErr=f;}
137 void SetDeconv(Bool_t f) {fDeconvPad=f; fDeconvTime=f;}
138 void SetThreshold(UInt_t i) {fThreshold=i;}
139 void SetOccupancyLimit(Float_t f) {fOccupancyLimit=f;}
140 void SetSignalThreshold(Int_t i) {fSignalThreshold=i;}
b1c46961 141 void SetNSigmaThreshold(Double_t d) {fNSigmaThreshold=d;}
8f8bf0af 142 void SetMatchWidth(UInt_t i) {fMatch=i;}
143 void SetSTDOutput(Bool_t f=kFALSE) {fStdout=f;}
144 void SetCalcErr(Bool_t f=kTRUE) {fCalcerr=f;}
145 void SetRawSP(Bool_t f=kFALSE) {fRawSP=f;}
146 void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
147 Int_t GetNumberOfClusters() const {return fNClusters;}
148
149 //----------------------------------Methods for the new unsorted way of reading data ----------
a74855c2 150 void ReadDataUnsorted(void* ptr,unsigned long size);
8f8bf0af 151 void FindClusters();
152 void WriteClusters(Int_t nclusters,AliHLTTPCClusters *list);
aff6e981 153 void SetUnsorted(Int_t unsorted){fUnsorted=unsorted;}
8252a538 154 void SetPatch(Int_t patch){fCurrentPatch=patch;}
155 void InitializePadArray();
156 Int_t DeInitializePadArray();
157 Bool_t ComparePads(AliHLTTPCPad *nextPad,AliHLTTPCClusters* candidate,Int_t nextPadToRead);
98034d0d 158 protected:
8f8bf0af 159 /** copy constructor prohibited */
160 AliHLTTPCClusterFinder(const AliHLTTPCClusterFinder&);
161 /** assignment operator prohibited */
162 AliHLTTPCClusterFinder& operator=(const AliHLTTPCClusterFinder&);
163
2a083ac4 164 AliHLTTPCSpacePointData *fSpacePointData; //! array of space points
165 AliHLTTPCDigitReader *fDigitReader; //! reader instance
a38a7850 166
2a083ac4 167 UChar_t* fPtr; //! pointer to packed block
a38a7850 168 unsigned long fSize; //packed block size
169 Bool_t fDeconvTime; //deconv in time direction
170 Bool_t fDeconvPad; //deconv in pad direction
171 Bool_t fStdout; //have print out in write clusters
172 Bool_t fCalcerr; //calculate centroid sigmas
173 Bool_t fRawSP; //store centroids in raw system
174
175
176 Int_t fFirstRow; //first row
177 Int_t fLastRow; //last row
178 Int_t fCurrentRow; //current active row
179 Int_t fCurrentSlice; //current slice
180 Int_t fCurrentPatch; //current patch
181 Int_t fMatch; //size of match
182 UInt_t fThreshold; //threshold for clusters
84645eb0 183 /** threshold for zero suppression (applied per bin) */
b1c46961 184 Int_t fSignalThreshold;// see above
185 /** threshold for zero suppression 2007 December run */
186 Double_t fNSigmaThreshold; // see above
a38a7850 187 Int_t fNClusters; //number of found clusters
188 Int_t fMaxNClusters; //max. number of clusters
189 Float_t fXYErr; //fixed error in XY
190 Float_t fZErr; //fixed error in Z
5235c3e9 191
192 Float_t fOccupancyLimit; // Occupancy Limit
193
aff6e981 194 Int_t fUnsorted; // enable for processing of unsorted digit data
8252a538 195 Bool_t fVectorInitialized;
196
197 typedef vector<AliHLTTPCPad*> AliHLTTPCPadVector;
198
199 vector<AliHLTTPCPadVector> fRowPadVector; //! transient
200
201 vector<AliHLTTPCClusters> fClusters; //! transient
202
203 UInt_t* fNumberOfPadsInRow; //! transient
204
205 UInt_t fNumberOfRows; //! transient
206
207 UInt_t fRowOfFirstCandidate;
a38a7850 208
64defa03 209
a38a7850 210#ifdef do_mc
211 void GetTrackID(Int_t pad,Int_t time,Int_t *trackID);
212#endif
213
8252a538 214 ClassDef(AliHLTTPCClusterFinder,4) //Fast cluster finder
a38a7850 215};
216#endif