1 #include "AliITSUClusterLines.h"
7 ClassImp(AliITSUClusterLines);
9 //////////////////////////////////////////////////////////////////////
10 // This class is used by the AliITSUVertexer to compute and store //
11 // information about vertex candidates. //
12 // The cluster is seeded starting from two lines, then it is //
13 // possible to attach other lines. Whenever a new line is attached //
14 // the weight and coefficient matrices are computed. //
15 // Origin puccio@to.infn.it Feb. 20 2014 //
16 //////////////////////////////////////////////////////////////////////
19 //____________________________________________________________________________________________________________
20 AliITSUClusterLines::AliITSUClusterLines() : TObject(),
25 // Default Constructor
27 for(Int_t i=0;i<9;++i) fW[i] = 0.;
30 //____________________________________________________________________________________________________________
31 AliITSUClusterLines::AliITSUClusterLines(UInt_t first, AliStrLine *line1, UInt_t second, AliStrLine *line2,Bool_t weight) : TObject(),
36 // Standard constructor
37 fLabels.push_back(first);
38 fLabels.push_back(second);
39 Double_t wmat1[9],wmat2[9],p1[3],p2[3],cd1[3],cd2[3],sq1[3]={1.,1.,1.},sq2[3]={1.,1.,1.};
40 line1->GetWMatrix(wmat1);
41 line2->GetWMatrix(wmat2);
42 for(Int_t i=0;i<9;++i) fW[i]=wmat1[i]+wmat2[i];
48 line1->GetSigma2P0(sq1);
49 line2->GetSigma2P0(sq2);
52 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];
53 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];
55 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;
56 fA[1]=-cd1[0]*cd1[1]*sq1[2]/det1-cd2[0]*cd2[1]*sq2[2]/det2;
57 fA[2]=-cd1[0]*cd1[2]*sq1[1]/det1-cd2[0]*cd2[2]*sq2[1]/det2;
58 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;
59 fA[4]=-cd1[1]*cd1[2]*sq1[0]/det1-cd2[1]*cd2[2]*sq2[0]/det2;
60 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;
62 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;
63 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;
64 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;
65 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;
66 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;
67 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;
69 this->ComputeClusterCentroid();
73 //____________________________________________________________________________________________________________
74 AliITSUClusterLines::~AliITSUClusterLines() {
78 //____________________________________________________________________________________________________________
79 void AliITSUClusterLines::Add(UInt_t label, AliStrLine *line, Bool_t weight) {
80 // Add a line to the cluster. It changes the weight matrix of the cluster and its parameters
81 fLabels.push_back(label);
82 Double_t wmat[9],p[3],cd[3],sq[3]={1.,1.,1.};
83 line->GetWMatrix(wmat);
87 for(Int_t i=0;i<9;++i) fW[i]+=wmat[i];
88 if(weight) line->GetSigma2P0(sq);
90 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];
91 fA[0]+=(cd[2]*cd[2]*sq[1]+cd[1]*cd[1]*sq[2])/det;
92 fA[1]+=-cd[0]*cd[1]*sq[2]/det;
93 fA[2]+=-cd[0]*cd[2]*sq[1]/det;
94 fA[3]+=(cd[2]*cd[2]*sq[0]+cd[0]*cd[0]*sq[2])/det;
95 fA[4]+=-cd[1]*cd[2]*sq[0]/det;
96 fA[5]+=(cd[1]*cd[1]*sq[0]+cd[0]*cd[0]*sq[1])/det;
98 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;
99 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;
100 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;
102 this->ComputeClusterCentroid();
105 //____________________________________________________________________________________________________________
106 Int_t AliITSUClusterLines::Compare(const TObject* obj) const {
107 // Comparison criteria between two clusters
108 const AliITSUClusterLines *cl=(const AliITSUClusterLines*)obj;
109 if(fLabels.size()<cl->GetSize()) return 1;
110 if(fLabels.size()>cl->GetSize()) return -1;
114 //____________________________________________________________________________________________________________
115 void AliITSUClusterLines::ComputeClusterCentroid() {
116 // Calculation of the centroid
121 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]);
124 cout << "Could not invert weight matrix" << endl;
127 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;
128 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;
129 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;
132 //____________________________________________________________________________________________________________
133 void AliITSUClusterLines::GetCovMatrix(Float_t cov[6]) {
134 // Returns the covariance matrix (single precision)
136 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]);
138 cout << "Could not invert weight matrix" << endl;
141 cov[0]=(w[4]*w[8]-w[5]*w[7])/den;
142 cov[1]=-(w[1]*w[8]-w[7]*w[2])/den;
143 cov[2]=(w[1]*w[5]-w[4]*w[2])/den;
144 cov[3]=(w[0]*w[8]-w[6]*w[2])/den;
145 cov[4]=-(w[0]*w[5]-w[3]*w[2])/den;
146 cov[5]=(w[0]*w[4]-w[1]*w[3])/den;
149 //____________________________________________________________________________________________________________
150 void AliITSUClusterLines::GetCovMatrix(Double_t cov[6]) {
151 // Returns the covariance matrix (double precision)
153 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]);
155 cout << "Could not invert weight matrix" << endl;
158 cov[0]=(w[4]*w[8]-w[5]*w[7])/den;
159 cov[1]=-(w[1]*w[8]-w[7]*w[2])/den;
160 cov[2]=(w[1]*w[5]-w[4]*w[2])/den;
161 cov[3]=(w[0]*w[8]-w[6]*w[2])/den;
162 cov[4]=-(w[0]*w[5]-w[3]*w[2])/den;
163 cov[5]=(w[0]*w[4]-w[1]*w[3])/den;
167 //____________________________________________________________________________________________________________
168 Bool_t AliITSUClusterLines::IsEqual(const TObject* obj) const {
169 // Comparison criteria between two clusters
170 const AliITSUClusterLines *cl=(const AliITSUClusterLines*)obj;
171 if(fLabels.size()==cl->GetSize()) return kTRUE;