]>
Commit | Line | Data |
---|---|---|
30da2335 | 1 | #include "AliITSUClusterLines.h" |
2 | #include <TMath.h> | |
3 | ||
4 | ClassImp(AliITSUClusterLines); | |
5 | ||
6 | ////////////////////////////////////////////////////////////////////// | |
7 | // This class is used by the AliITSUVertexer to compute and store // | |
8 | // information about vertex candidates. // | |
9 | // The cluster is seeded starting from two lines, then it is // | |
10 | // possible to attach other lines. Whenever a new line is attached // | |
11 | // the weight and coefficient matrices are computed. // | |
12 | // Origin puccio@to.infn.it Feb. 20 2014 // | |
13 | ////////////////////////////////////////////////////////////////////// | |
14 | ||
15 | ||
16 | //____________________________________________________________________________________________________________ | |
17 | AliITSUClusterLines::AliITSUClusterLines() : TObject(), | |
18 | fA(), | |
19 | fB(), | |
20 | fLabels(), | |
21 | fV() { | |
22 | // Default Constructor | |
23 | } | |
24 | ||
25 | //____________________________________________________________________________________________________________ | |
26 | AliITSUClusterLines::AliITSUClusterLines(UInt_t first, AliStrLine *line1, UInt_t second, AliStrLine *line2,Bool_t weight) : TObject(), | |
27 | fA(), | |
28 | fB(), | |
29 | fLabels(), | |
30 | fV() { | |
31 | // Standard constructor | |
32 | fLabels.push_back(first); | |
33 | fLabels.push_back(second); | |
34 | Double_t wmat1[9],wmat2[9],p1[3],p2[3],cd1[3],cd2[3],sq1[3]={1.,1.,1.},sq2[3]={1.,1.,1.}; | |
35 | line1->GetWMatrix(wmat1); | |
36 | line2->GetWMatrix(wmat2); | |
37 | for(Int_t i=0;i<9;++i) fW[i]=wmat1[i]+wmat2[i]; | |
38 | line1->GetP0(p1); | |
39 | line2->GetP0(p2); | |
40 | line1->GetCd(cd1); | |
41 | line2->GetCd(cd2); | |
42 | if(weight) { | |
43 | line1->GetSigma2P0(sq1); | |
44 | line2->GetSigma2P0(sq2); | |
45 | } | |
46 | ||
47 | Double_t det1=cd1[2]*cd1[2]*sq1[0]*sq1[1]+cd1[1]*cd1[1]*sq1[0]*sq1[2]+cd1[0]*cd1[0]*sq1[1]*sq1[2]; | |
48 | Double_t det2=cd2[2]*cd2[2]*sq2[0]*sq2[1]+cd2[1]*cd2[1]*sq2[0]*sq2[2]+cd2[0]*cd2[0]*sq2[1]*sq2[2]; | |
49 | ||
50 | fA[0]=(cd1[2]*cd1[2]*sq1[1]+cd1[1]*cd1[1]*sq1[2])/det1+(cd2[2]*cd2[2]*sq2[1]+cd2[1]*cd2[1]*sq2[2])/det2; | |
51 | fA[1]=-cd1[0]*cd1[1]*sq1[2]/det1-cd2[0]*cd2[1]*sq2[2]/det2; | |
52 | fA[2]=-cd1[0]*cd1[2]*sq1[1]/det1-cd2[0]*cd2[2]*sq2[1]/det2; | |
53 | fA[3]=(cd1[2]*cd1[2]*sq1[0]+cd1[0]*cd1[0]*sq1[2])/det1+(cd2[2]*cd2[2]*sq2[0]+cd2[0]*cd2[0]*sq2[2])/det2; | |
54 | fA[4]=-cd1[1]*cd1[2]*sq1[0]/det1-cd2[1]*cd2[2]*sq2[0]/det2; | |
55 | fA[5]=(cd1[1]*cd1[1]*sq1[0]+cd1[0]*cd1[0]*sq1[1])/det1+(cd2[1]*cd2[1]*sq2[0]+cd2[0]*cd2[0]*sq2[1])/det2; | |
56 | ||
57 | fB[0]=(cd1[1]*sq1[2]*(-cd1[1]*p1[0]+cd1[0]*p1[1])+cd1[2]*sq1[1]*(-cd1[2]*p1[0]+cd1[0]*p1[2]))/det1; | |
58 | fB[0]+=(cd2[1]*sq2[2]*(-cd2[1]*p2[0]+cd2[0]*p2[1])+cd2[2]*sq2[1]*(-cd2[2]*p2[0]+cd2[0]*p2[2]))/det2; | |
59 | fB[1]=(cd1[0]*sq1[2]*(-cd1[0]*p1[1]+cd1[1]*p1[0])+cd1[2]*sq1[0]*(-cd1[2]*p1[1]+cd1[1]*p1[2]))/det1; | |
60 | fB[1]+=(cd2[0]*sq2[2]*(-cd2[0]*p2[1]+cd2[1]*p2[0])+cd2[2]*sq2[0]*(-cd2[2]*p2[1]+cd2[1]*p2[2]))/det2; | |
61 | fB[2]=(cd1[0]*sq1[1]*(-cd1[0]*p1[2]+cd1[2]*p1[0])+cd1[1]*sq1[0]*(-cd1[1]*p1[2]+cd1[2]*p1[1]))/det1; | |
62 | fB[2]+=(cd2[0]*sq2[1]*(-cd2[0]*p2[2]+cd2[2]*p2[0])+cd2[1]*sq2[0]*(-cd2[1]*p2[2]+cd2[2]*p2[1]))/det2; | |
63 | ||
64 | this->ComputeClusterCentroid(); | |
65 | ||
66 | } | |
67 | ||
68 | //____________________________________________________________________________________________________________ | |
69 | AliITSUClusterLines::~AliITSUClusterLines() { | |
70 | // Destructor | |
71 | } | |
72 | ||
73 | //____________________________________________________________________________________________________________ | |
74 | void AliITSUClusterLines::Add(UInt_t label, AliStrLine *line, Bool_t weight) { | |
75 | // Add a line to the cluster. It changes the weight matrix of the cluster and its parameters | |
76 | fLabels.push_back(label); | |
77 | Double_t wmat[9],p[3],cd[3],sq[3]={1.,1.,1.}; | |
78 | line->GetWMatrix(wmat); | |
79 | line->GetP0(p); | |
80 | line->GetCd(cd); | |
81 | ||
82 | for(Int_t i=0;i<9;++i) fW[i]+=wmat[i]; | |
83 | if(weight) line->GetSigma2P0(sq); | |
84 | ||
85 | Double_t det=cd[2]*cd[2]*sq[0]*sq[1]+cd[1]*cd[1]*sq[0]*sq[2]+cd[0]*cd[0]*sq[1]*sq[2]; | |
86 | fA[0]+=(cd[2]*cd[2]*sq[1]+cd[1]*cd[1]*sq[2])/det; | |
87 | fA[1]+=-cd[0]*cd[1]*sq[2]/det; | |
88 | fA[2]+=-cd[0]*cd[2]*sq[1]/det; | |
89 | fA[3]+=(cd[2]*cd[2]*sq[0]+cd[0]*cd[0]*sq[2])/det; | |
90 | fA[4]+=-cd[1]*cd[2]*sq[0]/det; | |
91 | fA[5]+=(cd[1]*cd[1]*sq[0]+cd[0]*cd[0]*sq[1])/det; | |
92 | ||
93 | fB[0]+=(cd[1]*sq[2]*(-cd[1]*p[0]+cd[0]*p[1])+cd[2]*sq[1]*(-cd[2]*p[0]+cd[0]*p[2]))/det; | |
94 | fB[1]+=(cd[0]*sq[2]*(-cd[0]*p[1]+cd[1]*p[0])+cd[2]*sq[0]*(-cd[2]*p[1]+cd[1]*p[2]))/det; | |
95 | fB[2]+=(cd[0]*sq[1]*(-cd[0]*p[2]+cd[2]*p[0])+cd[1]*sq[0]*(-cd[1]*p[2]+cd[2]*p[1]))/det; | |
96 | ||
97 | this->ComputeClusterCentroid(); | |
98 | } | |
99 | ||
100 | //____________________________________________________________________________________________________________ | |
101 | Int_t AliITSUClusterLines::Compare(const TObject* obj) const { | |
102 | // Comparison criteria between two clusters | |
103 | const AliITSUClusterLines *cl=(const AliITSUClusterLines*)obj; | |
104 | if(fLabels.size()<cl->GetSize()) return 1; | |
105 | if(fLabels.size()>cl->GetSize()) return -1; | |
106 | return 0; | |
107 | } | |
108 | ||
109 | //____________________________________________________________________________________________________________ | |
110 | void AliITSUClusterLines::ComputeClusterCentroid() { | |
111 | // Calculation of the centroid | |
112 | Double_t *a=fA; | |
113 | Double_t *b=fB; | |
114 | Double_t *v=fV; | |
115 | ||
116 | Double_t det=a[0]*(a[3]*a[5]-a[4]*a[4])-a[1]*(a[1]*a[5]-a[4]*a[2])+a[2]*(a[1]*a[4]-a[2]*a[3]); | |
117 | ||
118 | if(det==0) { | |
119 | cout << "Could not invert weight matrix" << endl; | |
120 | return; | |
121 | } | |
122 | v[0]=-(b[0]*(a[3]*a[5]-a[4]*a[4])-a[1]*(b[1]*a[5]-a[4]*b[2])+a[2]*(b[1]*a[4]-b[2]*a[3]))/det; | |
123 | v[1]=-(a[0]*(b[1]*a[5]-b[2]*a[4])-b[0]*(a[1]*a[5]-a[4]*a[2])+a[2]*(a[1]*b[2]-a[2]*b[1]))/det; | |
124 | v[2]=-(a[0]*(a[3]*b[2]-b[1]*a[4])-a[1]*(a[1]*b[2]-b[1]*a[2])+b[0]*(a[1]*a[4]-a[2]*a[3]))/det; | |
125 | } | |
126 | ||
127 | //____________________________________________________________________________________________________________ | |
128 | void AliITSUClusterLines::GetCovMatrix(Float_t cov[6]) { | |
129 | // Returns the covariance matrix (single precision) | |
130 | Double_t *w=fW; | |
131 | Double_t den=w[0]*(w[4]*w[8]-w[5]*w[7])-w[1]*(w[3]*w[8]-w[5]*w[6])+w[2]*(w[3]*w[7]-w[4]*w[6]); | |
132 | if(den==0) { | |
133 | cout << "Could not invert weight matrix" << endl; | |
134 | return; | |
135 | } | |
136 | cov[0]=(w[4]*w[8]-w[5]*w[7])/den; | |
137 | cov[1]=-(w[1]*w[8]-w[7]*w[2])/den; | |
138 | cov[2]=(w[1]*w[5]-w[4]*w[2])/den; | |
139 | cov[3]=(w[0]*w[8]-w[6]*w[2])/den; | |
140 | cov[4]=-(w[0]*w[5]-w[3]*w[2])/den; | |
141 | cov[5]=(w[0]*w[4]-w[1]*w[3])/den; | |
142 | } | |
143 | ||
144 | //____________________________________________________________________________________________________________ | |
145 | void AliITSUClusterLines::GetCovMatrix(Double_t cov[6]) { | |
146 | // Returns the covariance matrix (double precision) | |
147 | Double_t *w=fW; | |
148 | Double_t den=w[0]*(w[4]*w[8]-w[5]*w[7])-w[1]*(w[3]*w[8]-w[5]*w[6])+w[2]*(w[3]*w[7]-w[4]*w[6]); | |
149 | if(den==0) { | |
150 | cout << "Could not invert weight matrix" << endl; | |
151 | return; | |
152 | } | |
153 | cov[0]=(w[4]*w[8]-w[5]*w[7])/den; | |
154 | cov[1]=-(w[1]*w[8]-w[7]*w[2])/den; | |
155 | cov[2]=(w[1]*w[5]-w[4]*w[2])/den; | |
156 | cov[3]=(w[0]*w[8]-w[6]*w[2])/den; | |
157 | cov[4]=-(w[0]*w[5]-w[3]*w[2])/den; | |
158 | cov[5]=(w[0]*w[4]-w[1]*w[3])/den; | |
159 | ||
160 | } | |
161 | ||
162 | //____________________________________________________________________________________________________________ | |
163 | Bool_t AliITSUClusterLines::IsEqual(const TObject* obj) const { | |
164 | // Comparison criteria between two clusters | |
165 | const AliITSUClusterLines *cl=(const AliITSUClusterLines*)obj; | |
166 | if(fLabels.size()==cl->GetSize()) return kTRUE; | |
167 | return kFALSE; | |
168 | } | |
169 |