3 // Author: Uli Frankenfeld <mailto:franken@fi.uib.no>
4 //*-- Copyright © ALICE HLT Group
6 #include "AliHLTTPCLogging.h"
7 #include "AliHLTTPCVertexArray.h"
10 /** \class AliHLTTPCVertexArray
12 //_____________________________________________________________
13 // AliHLTTPCVertexArray
15 // The HLTTPC Fast Vertex Finder Base Class
19 //for(Int_t sec=0;sec<NSEC;sec++){
21 // FillSectorSeed3D(x,y,z);
22 // FillSector3D(x,y,z);
23 // FindSectorVertex();
24 // Double_t z = GetZSector();
25 // Double_t zerr = GetZSectorErr();
26 // // do somethink with z, zerr
35 ClassImp(AliHLTTPCVertexArray)
37 void AliHLTTPCVertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len)
39 //loop over all seeds and all vertex position
40 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCVertexArray::AnalyzeSector","Analyze")
41 <<AliHLTTPCLog::kDec<<"Number of Seeds: "<<fNSeed<<ENDLOG;
42 for(Int_t i =0;i<fNSeed;i++)
43 for(Int_t bin = 0;bin<len;bin++)
44 array[bin] += Trace(fZSeed[i],fRSeed[i],fSecSeed[i],vertex[bin]);
47 void AliHLTTPCVertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin)
49 //define position and range for search and
51 //and find position of vertex and error
52 const Int_t klen = nbin;
53 const Double_t kwidth = range;
54 const Double_t kxmin = pos - kwidth/2;
55 const Double_t kstep = kwidth/klen;
56 const Double_t kstart = kxmin + kstep/2.;
57 Int_t * array = new Int_t[klen];
58 Float_t * ver = new Float_t[klen];
59 for(Int_t i=0;i<klen;i++){
60 ver[i] = kstart + kstep * i;
63 AnalyzeSector(ver,array,klen);
64 FindMean(ver,array,klen);
69 void AliHLTTPCVertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len)
71 //find mean and error of array and store it in
72 //fZSector and fZSectorErr
73 const Int_t knbin = len;
76 for(Int_t i = 0;i<knbin;i++){
87 if(xmin<0) {ops++;break;}
88 if(array[xmin]<hmax) {
94 if(xmax>=knbin) {ops++;break;}
100 if(xbin >= knbin/2){xmin = 2 * xbin - knbin +1;xmax = knbin-1;}
101 else{xmin = 0;xmax = 2 * xbin;}
107 for(Int_t bin = xmin;bin<=xmax;bin++){
109 sumw2 += array[bin] * array[bin];
110 sumwx += array[bin] * vertex[bin];
111 sumwx2 += array[bin] * vertex[bin] * vertex[bin];
114 Double_t mean = sumwx/sumw;
115 Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
116 fZSectorErr = sqrt(rms2/sumw);
119 else{fZSectorErr = fZSector = 0;}
120 sumw=sumw2=sumwx=sumwx2=0;
121 for(Int_t bin = 0;bin<knbin;bin++){
123 sumw2 += array[bin] * array[bin];
124 sumwx += array[bin] * vertex[bin];
125 sumwx2 += array[bin] * vertex[bin] * vertex[bin];
128 Double_t mean = fZSector;
129 Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
130 fZSectorErr = sqrt(rms2/sumw);