2 // Original: AliHLTVertexArray.cxx,v 1.7 2005/06/14 10:55:21 cvetan
4 // Author: Uli Frankenfeld <mailto:franken@fi.uib.no>
5 //*-- Copyright © ALICE HLT Group
7 #include "AliHLTTPCLogging.h"
8 #include "AliHLTTPCVertexArray.h"
11 /** \class AliHLTTPCVertexArray
13 //_____________________________________________________________
14 // AliHLTTPCVertexArray
16 // The HLTTPC Fast Vertex Finder Base Class
20 //for(Int_t sec=0;sec<NSEC;sec++){
22 // FillSectorSeed3D(x,y,z);
23 // FillSector3D(x,y,z);
24 // FindSectorVertex();
25 // Double_t z = GetZSector();
26 // Double_t zerr = GetZSectorErr();
27 // // do somethink with z, zerr
36 ClassImp(AliHLTTPCVertexArray)
38 AliHLTTPCVertexArray::AliHLTTPCVertexArray()
47 AliHLTTPCVertexArray::AliHLTTPCVertexArray(AliHLTTPCVertexArray&)
56 AliHLTTPCVertexArray::AliHLTTPCVertexArray(Int_t maxseed)
65 AliHLTTPCVertexArray::~AliHLTTPCVertexArray()
69 void AliHLTTPCVertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len)
71 //loop over all seeds and all vertex position
72 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCVertexArray::AnalyzeSector","Analyze")
73 <<AliHLTTPCLog::kDec<<"Number of Seeds: "<<fNSeed<<ENDLOG;
74 for(Int_t i =0;i<fNSeed;i++)
75 for(Int_t bin = 0;bin<len;bin++)
76 array[bin] += Trace(fZSeed[i],fRSeed[i],fSecSeed[i],vertex[bin]);
79 void AliHLTTPCVertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin)
81 //define position and range for search and
83 //and find position of vertex and error
84 const Int_t klen = nbin;
85 const Double_t kwidth = range;
86 const Double_t kxmin = pos - kwidth/2;
87 const Double_t kstep = kwidth/klen;
88 const Double_t kstart = kxmin + kstep/2.;
89 Int_t * array = new Int_t[klen];
90 Float_t * ver = new Float_t[klen];
91 for(Int_t i=0;i<klen;i++){
92 ver[i] = kstart + kstep * i;
95 AnalyzeSector(ver,array,klen);
96 FindMean(ver,array,klen);
101 void AliHLTTPCVertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len)
103 //find mean and error of array and store it in
104 //fZSector and fZSectorErr
105 const Int_t knbin = len;
108 for(Int_t i = 0;i<knbin;i++){
119 if(xmin<0) {ops++;break;}
120 if(array[xmin]<hmax) {
126 if(xmax>=knbin) {ops++;break;}
127 if(array[xmax]<hmax){
132 if(xbin >= knbin/2){xmin = 2 * xbin - knbin +1;xmax = knbin-1;}
133 else{xmin = 0;xmax = 2 * xbin;}
139 for(Int_t bin = xmin;bin<=xmax;bin++){
141 sumw2 += array[bin] * array[bin];
142 sumwx += array[bin] * vertex[bin];
143 sumwx2 += array[bin] * vertex[bin] * vertex[bin];
146 Double_t mean = sumwx/sumw;
147 Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
148 fZSectorErr = sqrt(rms2/sumw);
151 else{fZSectorErr = fZSector = 0;}
152 sumw=sumw2=sumwx=sumwx2=0;
153 for(Int_t bin = 0;bin<knbin;bin++){
155 sumw2 += array[bin] * array[bin];
156 sumwx += array[bin] * vertex[bin];
157 sumwx2 += array[bin] * vertex[bin] * vertex[bin];
160 Double_t mean = fZSector;
161 Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
162 fZSectorErr = sqrt(rms2/sumw);