]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/Ref/AliHLTTPCVertexArray.cxx
Added a Makefile with rules for component libraries conforming to the
[u/mrichter/AliRoot.git] / HLT / TPCLib / Ref / AliHLTTPCVertexArray.cxx
CommitLineData
78001a73 1// @(#) $Id$
2
3// Author: Uli Frankenfeld <mailto:franken@fi.uib.no>
4//*-- Copyright &copy ALICE HLT Group
5
6#include "AliHLTTPCStandardIncludes.h"
7
8#include "AliHLTTPCLogging.h"
9#include "AliHLTTPCVertexArray.h"
10
11
12/** \class AliHLTTPCVertexArray
13<pre>
14//_____________________________________________________________
15// AliHLTTPCVertexArray
16//
17// The L3 Fast Vertex Finder Base Class
18//
19// usage:
20//
21//for(Int_t sec=0;sec<NSEC;sec++){
22// ResetSector();
23// FillSectorSeed3D(x,y,z);
24// FillSector3D(x,y,z);
25// FindSectorVertex();
26// Double_t z = GetZSector();
27// Double_t zerr = GetZSectorErr();
28// // do somethink with z, zerr
29//}
30</pre>
31*/
32
33ClassImp(AliHLTTPCVertexArray)
34void AliHLTTPCVertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len){
35//loop over all seeds and all vertex position
36 LOG(AliHLTTPCLog::kInformational,"AliHLTTPCVertexArray::AnalyzeSector","Analyze")
37 <<AliHLTTPCLog::kDec<<"Number of Seeds: "<<fNSeed<<ENDLOG;
38 for(Int_t i =0;i<fNSeed;i++)
39 for(Int_t bin = 0;bin<len;bin++)
40 array[bin] += Trace(fZSeed[i],fRSeed[i],fSecSeed[i],vertex[bin]);
41}
42
43void AliHLTTPCVertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin){
44//define position and range for search and
45//loop over all seeds
46//and find position of vertex and error
47 const Int_t len = nbin;
48 const Double_t width = range;
49 const Double_t xmin = pos - width/2;
50 const Double_t step = width/len;
51 const Double_t start = xmin + step/2.;
52 Int_t * array = new Int_t[len];
53 Float_t * ver = new Float_t[len];
54 for(Int_t i=0;i<len;i++){
55 ver[i] = start + step * i;
56 array[i] = 0;
57 }
58 AnalyzeSector(ver,array,len);
59 FindMean(ver,array,len);
60 delete[] array;
61 delete[] ver;
62}
63
64void AliHLTTPCVertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len){
65//find mean and error of array and store it in
66//fZSector and fZSectorErr
67 const Int_t nbin = len;
68 Int_t xbin =0;
69 Int_t max=0;
70 for(Int_t i = 0;i<nbin;i++){
71 if(array[i]>max){
72 max = array[i];
73 xbin =i;
74 }
75 }
76 Int_t hmax = max/2;
77 Int_t xmin,xmax;
78 Int_t ops = 0;
79 xmin = xbin;
80 while(xmin--){
81 if(xmin<0) {ops++;break;}
82 if(array[xmin]<hmax) {
83 break;
84 }
85 }
86 xmax = xbin;
87 while(xmax++){
88 if(xmax>=nbin) {ops++;break;}
89 if(array[xmax]<hmax){
90 break;
91 }
92 }
93 if(ops){
94 if(xbin >= nbin/2){xmin = 2 * xbin - nbin +1;xmax = nbin-1;}
95 else{xmin = 0;xmax = 2 * xbin;}
96 }
97 Double_t sumw=0;
98 Double_t sumw2=0;
99 Double_t sumwx=0;
100 Double_t sumwx2=0;
101 for(Int_t bin = xmin;bin<=xmax;bin++){
102 sumw += array[bin];
103 sumw2 += array[bin] * array[bin];
104 sumwx += array[bin] * vertex[bin];
105 sumwx2 += array[bin] * vertex[bin] * vertex[bin];
106 }
107 if(sumw){
108 Double_t mean = sumwx/sumw;
109 Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
110 fZSectorErr = sqrt(rms2/sumw);
111 fZSector = mean;
112 }
113 else{fZSectorErr = fZSector = 0;}
114 sumw=sumw2=sumwx=sumwx2=0;
115 for(Int_t bin = 0;bin<nbin;bin++){
116 sumw += array[bin];
117 sumw2 += array[bin] * array[bin];
118 sumwx += array[bin] * vertex[bin];
119 sumwx2 += array[bin] * vertex[bin] * vertex[bin];
120 }
121 if(sumw){
122 Double_t mean = fZSector;
123 Double_t rms2 = fabs(sumwx2/sumw - mean*mean);
124 fZSectorErr = sqrt(rms2/sumw);
125 }
126}
127