]>
Commit | Line | Data |
---|---|---|
3e87ef69 | 1 | // @(#) $Id$ |
2 | ||
b661165c | 3 | // Author: Uli Frankenfeld <mailto:franken@fi.uib.no> |
3e87ef69 | 4 | //*-- Copyright © ALICE HLT Group |
108615fc | 5 | |
4aa41877 | 6 | #include "AliHLTStandardIncludes.h" |
118c26c3 | 7 | |
4aa41877 | 8 | #include "AliHLTLogging.h" |
9 | #include "AliHLTVertexArray.h" | |
108615fc | 10 | |
b661165c | 11 | |
4aa41877 | 12 | /** \class AliHLTVertexArray |
3e87ef69 | 13 | <pre> |
108615fc | 14 | //_____________________________________________________________ |
4aa41877 | 15 | // AliHLTVertexArray |
b661165c | 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 | |
5929c18d | 33 | #if __GNUC__ >= 3 |
34 | using namespace std; | |
35 | #endif | |
36 | ||
4aa41877 | 37 | ClassImp(AliHLTVertexArray) |
5929c18d | 38 | |
4aa41877 | 39 | void AliHLTVertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len) |
b1ed0288 | 40 | { |
41 | //loop over all seeds and all vertex position | |
4aa41877 | 42 | LOG(AliHLTLog::kInformational,"AliHLTVertexArray::AnalyzeSector","Analyze") |
43 | <<AliHLTLog::kDec<<"Number of Seeds: "<<fNSeed<<ENDLOG; | |
108615fc | 44 | for(Int_t i =0;i<fNSeed;i++) |
45 | for(Int_t bin = 0;bin<len;bin++) | |
46 | array[bin] += Trace(fZSeed[i],fRSeed[i],fSecSeed[i],vertex[bin]); | |
47 | } | |
48 | ||
4aa41877 | 49 | void AliHLTVertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin) |
b1ed0288 | 50 | { |
51 | //define position and range for search and | |
52 | //loop over all seeds | |
53 | //and find position of vertex and error | |
54 | const Int_t klen = nbin; | |
55 | const Double_t kwidth = range; | |
56 | const Double_t kxmin = pos - kwidth/2; | |
57 | const Double_t kstep = kwidth/klen; | |
58 | const Double_t kstart = kxmin + kstep/2.; | |
59 | Int_t * array = new Int_t[klen]; | |
60 | Float_t * ver = new Float_t[klen]; | |
61 | for(Int_t i=0;i<klen;i++){ | |
62 | ver[i] = kstart + kstep * i; | |
108615fc | 63 | array[i] = 0; |
64 | } | |
b1ed0288 | 65 | AnalyzeSector(ver,array,klen); |
66 | FindMean(ver,array,klen); | |
108615fc | 67 | delete[] array; |
68 | delete[] ver; | |
69 | } | |
70 | ||
4aa41877 | 71 | void AliHLTVertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len) |
b1ed0288 | 72 | { |
73 | //find mean and error of array and store it in | |
74 | //fZSector and fZSectorErr | |
75 | const Int_t knbin = len; | |
108615fc | 76 | Int_t xbin =0; |
77 | Int_t max=0; | |
b1ed0288 | 78 | for(Int_t i = 0;i<knbin;i++){ |
108615fc | 79 | if(array[i]>max){ |
80 | max = array[i]; | |
81 | xbin =i; | |
82 | } | |
83 | } | |
84 | Int_t hmax = max/2; | |
85 | Int_t xmin,xmax; | |
86 | Int_t ops = 0; | |
87 | xmin = xbin; | |
88 | while(xmin--){ | |
89 | if(xmin<0) {ops++;break;} | |
90 | if(array[xmin]<hmax) { | |
91 | break; | |
92 | } | |
93 | } | |
94 | xmax = xbin; | |
95 | while(xmax++){ | |
b1ed0288 | 96 | if(xmax>=knbin) {ops++;break;} |
108615fc | 97 | if(array[xmax]<hmax){ |
98 | break; | |
99 | } | |
100 | } | |
101 | if(ops){ | |
b1ed0288 | 102 | if(xbin >= knbin/2){xmin = 2 * xbin - knbin +1;xmax = knbin-1;} |
108615fc | 103 | else{xmin = 0;xmax = 2 * xbin;} |
104 | } | |
105 | Double_t sumw=0; | |
106 | Double_t sumw2=0; | |
107 | Double_t sumwx=0; | |
108 | Double_t sumwx2=0; | |
109 | for(Int_t bin = xmin;bin<=xmax;bin++){ | |
110 | sumw += array[bin]; | |
111 | sumw2 += array[bin] * array[bin]; | |
112 | sumwx += array[bin] * vertex[bin]; | |
113 | sumwx2 += array[bin] * vertex[bin] * vertex[bin]; | |
114 | } | |
115 | if(sumw){ | |
116 | Double_t mean = sumwx/sumw; | |
117 | Double_t rms2 = fabs(sumwx2/sumw - mean*mean); | |
118 | fZSectorErr = sqrt(rms2/sumw); | |
119 | fZSector = mean; | |
120 | } | |
121 | else{fZSectorErr = fZSector = 0;} | |
c31bdc3f | 122 | sumw=sumw2=sumwx=sumwx2=0; |
b1ed0288 | 123 | for(Int_t bin = 0;bin<knbin;bin++){ |
c31bdc3f | 124 | sumw += array[bin]; |
125 | sumw2 += array[bin] * array[bin]; | |
126 | sumwx += array[bin] * vertex[bin]; | |
127 | sumwx2 += array[bin] * vertex[bin] * vertex[bin]; | |
128 | } | |
129 | if(sumw){ | |
130 | Double_t mean = fZSector; | |
131 | Double_t rms2 = fabs(sumwx2/sumw - mean*mean); | |
132 | fZSectorErr = sqrt(rms2/sumw); | |
133 | } | |
108615fc | 134 | } |
135 |