]>
Commit | Line | Data |
---|---|---|
108615fc | 1 | //Author: Uli Frankenfeld |
2 | //Last Modified: 07.11.2000 | |
3 | ||
4 | #include "AliL3Logging.h" | |
5 | //#include <TMath.h> | |
6 | #include <iostream.h> | |
7 | #include "AliL3VertexArray.h" | |
8 | ||
9 | //_____________________________________________________________ | |
10 | // The L3 Fast Vertex Finder Base Class | |
11 | // | |
12 | // usage: | |
13 | // | |
14 | //for(Int_t sec=0;sec<NSEC;sec++){ | |
15 | // ResetSector(); | |
16 | // FillSectorSeed3D(x,y,z); | |
17 | // FillSector3D(x,y,z); | |
18 | // FindSectorVertex(); | |
19 | // Double_t z = GetZSector(); | |
20 | // Double_t zerr = GetZSectorErr(); | |
21 | //// do somethink with z, zerr | |
22 | //} | |
23 | ||
24 | ClassImp(AliL3VertexArray) | |
25 | void AliL3VertexArray::AnalyzeSector(Float_t *vertex, Int_t *array, Int_t len){ | |
26 | //loop over all seeds and all vertex position | |
27 | LOG(AliL3Log::kInformational,"AliL3VertexArray::AnalyzeSector","Analyze") | |
28 | <<AliL3Log::kDec<<"Number of Seeds: "<<fNSeed<<ENDLOG; | |
29 | for(Int_t i =0;i<fNSeed;i++) | |
30 | for(Int_t bin = 0;bin<len;bin++) | |
31 | array[bin] += Trace(fZSeed[i],fRSeed[i],fSecSeed[i],vertex[bin]); | |
32 | } | |
33 | ||
34 | void AliL3VertexArray::FindSectorVertex(Double_t pos, Double_t range, Int_t nbin){ | |
35 | //define position and range for search and | |
36 | //loop over all seeds | |
37 | //and find position of vertex and error | |
38 | const Int_t len = nbin; | |
39 | const Double_t width = range; | |
40 | const Double_t xmin = pos - width/2; | |
41 | const Double_t step = width/len; | |
42 | const Double_t start = xmin + step/2.; | |
43 | Int_t * array = new Int_t[len]; | |
44 | Float_t * ver = new Float_t[len]; | |
45 | for(Int_t i=0;i<len;i++){ | |
46 | ver[i] = start + step * i; | |
47 | array[i] = 0; | |
48 | } | |
49 | AnalyzeSector(ver,array,len); | |
50 | FindMean(ver,array,len); | |
51 | delete[] array; | |
52 | delete[] ver; | |
53 | } | |
54 | ||
55 | void AliL3VertexArray::FindMean(Float_t *vertex,Int_t *array, Int_t len){ | |
56 | //find mean and error of array and store it in | |
57 | //fZSector and fZSectorErr | |
58 | const Int_t nbin = len; | |
59 | Int_t xbin =0; | |
60 | Int_t max=0; | |
61 | for(Int_t i = 0;i<nbin;i++){ | |
62 | if(array[i]>max){ | |
63 | max = array[i]; | |
64 | xbin =i; | |
65 | } | |
66 | } | |
67 | Int_t hmax = max/2; | |
68 | Int_t xmin,xmax; | |
69 | Int_t ops = 0; | |
70 | xmin = xbin; | |
71 | while(xmin--){ | |
72 | if(xmin<0) {ops++;break;} | |
73 | if(array[xmin]<hmax) { | |
74 | break; | |
75 | } | |
76 | } | |
77 | xmax = xbin; | |
78 | while(xmax++){ | |
79 | if(xmax>=nbin) {ops++;break;} | |
80 | if(array[xmax]<hmax){ | |
81 | break; | |
82 | } | |
83 | } | |
84 | if(ops){ | |
85 | if(xbin >= nbin/2){xmin = 2 * xbin - nbin +1;xmax = nbin-1;} | |
86 | else{xmin = 0;xmax = 2 * xbin;} | |
87 | } | |
88 | Double_t sumw=0; | |
89 | Double_t sumw2=0; | |
90 | Double_t sumwx=0; | |
91 | Double_t sumwx2=0; | |
92 | for(Int_t bin = xmin;bin<=xmax;bin++){ | |
93 | sumw += array[bin]; | |
94 | sumw2 += array[bin] * array[bin]; | |
95 | sumwx += array[bin] * vertex[bin]; | |
96 | sumwx2 += array[bin] * vertex[bin] * vertex[bin]; | |
97 | } | |
98 | if(sumw){ | |
99 | Double_t mean = sumwx/sumw; | |
100 | Double_t rms2 = fabs(sumwx2/sumw - mean*mean); | |
101 | fZSectorErr = sqrt(rms2/sumw); | |
102 | fZSector = mean; | |
103 | } | |
104 | else{fZSectorErr = fZSector = 0;} | |
105 | } | |
106 |