]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/src/AliL3VertexArray.cxx
Compilation on Alpha
[u/mrichter/AliRoot.git] / HLT / src / AliL3VertexArray.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
2
b661165c 3// Author: Uli Frankenfeld <mailto:franken@fi.uib.no>
3e87ef69 4//*-- Copyright &copy ALICE HLT Group
108615fc 5
118c26c3 6#include "AliL3StandardIncludes.h"
7
108615fc 8#include "AliL3Logging.h"
108615fc 9#include "AliL3VertexArray.h"
10
b661165c 11
3e87ef69 12/** \class AliL3VertexArray
13<pre>
108615fc 14//_____________________________________________________________
b661165c 15// AliL3VertexArray
16//
108615fc 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();
3e87ef69 28// // do somethink with z, zerr
108615fc 29//}
3e87ef69 30</pre>
31*/
108615fc 32
33ClassImp(AliL3VertexArray)
34void AliL3VertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len){
35//loop over all seeds and all vertex position
36 LOG(AliL3Log::kInformational,"AliL3VertexArray::AnalyzeSector","Analyze")
37 <<AliL3Log::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 AliL3VertexArray::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 AliL3VertexArray::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;}
c31bdc3f 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 }
108615fc 126}
127