3 #include <FairLogger.h>
5 #include <Math/Vector3D.h>
50 return std::sqrt(dist2);
56 LOG(error) <<
"Trying to create pattern with wrong number of points " << points.size();
58 auto fPoint = points[0];
59 auto fDirection = points[1] - points[0];
60 if (fDirection.Z() != 0)
61 fDirection /= fabs(fDirection.Z());
63 fPatternPar = {fPoint.X(), fPoint.Y(), fPoint.Z(), fDirection.X(), fDirection.Y(), fDirection.Z()};
88 double Sxx, Sxy, Syy, Sxz, Szz, Syz;
90 double K11, K22, K12, K10, K01, K00;
95 Q = Xm = Ym = Zm = 0.;
96 double total_charge = 0;
97 Sxx = Syy = Szz = Sxy = Sxz = Syz = 0.;
98 bool doChargeWeight = points.size() == charge.size();
100 for (
int i = 0; i < points.size(); ++i) {
101 const auto hitQ = doChargeWeight ? charge[i] : 1;
102 const auto &pos = points[i];
105 Xm += pos.X() * hitQ / 10.;
106 Ym += pos.Y() * hitQ / 10.;
107 Zm += pos.Z() * hitQ / 10.;
108 Sxx += pos.X() * pos.X() * hitQ / 10.;
109 Syy += pos.Y() * pos.Y() * hitQ / 10.;
110 Szz += pos.Z() * pos.Z() * hitQ / 10.;
111 Sxy += pos.X() * pos.Y() * hitQ / 10.;
112 Sxz += pos.X() * pos.Z() * hitQ / 10.;
113 Syz += pos.Y() * pos.Z() * hitQ / 10.;
132 theta = 0.5 * atan((2. * Sxy) / (Sxx - Syy));
134 K11 = (Syy + Szz) * pow(cos(theta), 2) + (Sxx + Szz) * pow(sin(theta), 2) - 2. * Sxy * cos(theta) * sin(theta);
135 K22 = (Syy + Szz) * pow(sin(theta), 2) + (Sxx + Szz) * pow(cos(theta), 2) + 2. * Sxy * cos(theta) * sin(theta);
137 K10 = Sxz * cos(theta) + Syz * sin(theta);
138 K01 = -Sxz * sin(theta) + Syz * cos(theta);
141 c2 = -K00 - K11 - K22;
142 c1 = K00 * K11 + K00 * K22 + K11 * K22 - K01 * K01 - K10 * K10;
143 c0 = K01 * K01 * K11 + K10 * K10 * K22 - K00 * K11 * K22;
145 p = c1 - pow(
c2, 2) / 3.;
146 q = 2. * pow(
c2, 3) / 27. - c1 *
c2 / 3. + c0;
147 r = pow(q / 2., 2) + pow(p, 3) / 27.;
150 dm2 = -
c2 / 3. + pow(-q / 2. + sqrt(r), 1. / 3.) + pow(-q / 2. - sqrt(r), 1. / 3.);
152 rho = sqrt(-pow(p, 3) / 27.);
153 phi = acos(-q / (2. * rho));
154 dm2 = std::min(-
c2 / 3. + 2. * pow(rho, 1. / 3.) * cos(phi / 3.),
155 std::min(-
c2 / 3. + 2. * pow(rho, 1. / 3.) * cos((phi + 2. * TMath::Pi()) / 3.),
156 -
c2 / 3. + 2. * pow(rho, 1. / 3.) * cos((phi + 4. * TMath::Pi()) / 3.)));
159 a = -K10 * cos(theta) / (K11 - dm2) + K01 * sin(theta) / (K22 - dm2);
160 b = -K10 * sin(theta) / (K11 - dm2) - K01 * cos(theta) / (K22 - dm2);
162 Xh = ((1. + b * b) * Xm - a * b * Ym + a * Zm) / (1. + a * a + b * b);
163 Yh = ((1. + a * a) * Ym - a * b * Xm + b * Zm) / (1. + a * a + b * b);
164 Zh = ((a * a + b * b) * Zm + a * Xm + b * Ym) / (1. + a * a + b * b);
170 fChi2 = (fabs(dm2 / Q));
171 fNFree = points.size() - 6;
177 auto retLine =
new TEveLine();
178 Double_t tMin = -10, tMax = 10, deltaPar = 0.05;
179 std::vector<Double_t> tminmax;
181 if (tminmax.size() == 2) {
182 tMin = tminmax.at(0);
183 tMax = tminmax.at(1);
186 Double_t tBuff = tMax;
190 for (
int i = 0; i <= (Int_t)((tMax - tMin) / deltaPar); i++) {
191 auto t = tMin + i * deltaPar;
193 retLine->SetNextPoint(pos.X(), pos.Y(), pos.Z());
200 std::vector<Double_t> result;
201 Double_t a = 0, b = 0,
c = 0, sol1 = 0, sol2 = 0;
205 if (b * b - 4 * a *
c >= 0) {
206 sol1 = (-b + sqrt(b * b - 4 * a *
c)) / (2 * a);
207 sol2 = (-b - sqrt(b * b - 4 * a *
c)) / (2 * a);
208 result.push_back(sol1);
209 result.push_back(sol2);