8 for (std::vector<const Candidate*>::const_iterator
t =
cands.begin();
t !=
cands.end(); ++
t, ++
i)
9 pSum_ += (p_[
i] = (*t)->momentum()).r();
10 axis_ = axis(finalAxis(initialAxis()));
13 thrust_ = thrust(axis_);
17 static const int nSegsTheta = 10, nSegsPhi = 10, nSegs = nSegsTheta * nSegsPhi;
19 double thr[nSegs],
max = 0;
20 int indI = 0, indJ = 0,
index = -1;
21 for (
i = 0;
i < nSegsTheta; ++
i) {
22 double z =
cos(
pi *
i / (nSegsTheta - 1));
23 double r =
sqrt(1 - z * z);
24 for (
j = 0;
j < nSegsPhi; ++
j) {
25 double phi =
pi2 *
j / nSegsPhi;
27 if (thr[
i * nSegsPhi +
j] >
max) {
47 a = (thr[ind1] + thr[ind2] - 2 *
c) / 2;
48 b = thr[ind1] -
a -
c;
51 maxPhiInd = -
b / (2 *
a);
53 if (indI == 0 || indI == (nSegsTheta - 1))
58 a = (thr[ind1] + thr[ind2] - 2 *
c) / 2;
59 b = thr[ind1] -
a -
c;
62 maxThetaInd = -
b / (2 *
a);
64 return ThetaPhi(
pi * (maxThetaInd + indI) / (nSegsTheta - 1),
pi2 * (maxPhiInd + indJ) / nSegsPhi);
68 static const double epsilon = 0.0001;
69 double maxChange1 = 0.0, maxChange2 = 0.0,
a = 0.0,
b = 0.0,
c = 0.0, thr = 0.0;
70 int mandCt = 3, maxCt = 1000;
73 parabola(
a,
b,
c, axis(best), axis(best.theta +
epsilon, best.phi), axis(best.theta -
epsilon, best.phi));
74 maxChange1 = 10 * (
b < 0 ? -1 : 1);
76 maxChange1 = -
b / (2 *
a);
79 if (maxChange1 == 0 && (best.theta == 0 || best.theta ==
pi)) {
83 parabola(
a,
b,
c, axis(best), axis(best.theta +
epsilon, best.phi), axis(best.theta -
epsilon, best.phi));
84 maxChange1 = 10 * (
b < 0 ? -1 : 1);
86 maxChange1 = -
b / (2 *
a);
90 thr = thrust(axis(best.theta + maxChange1 *
epsilon, best.phi)) +
epsilon;
95 best.theta += maxChange1 *
epsilon;
96 if (best.theta >
pi) {
97 best.theta =
pi - (best.theta -
pi);
102 if (best.theta < 0) {
108 parabola(
a,
b,
c, axis(best), axis(best.theta, best.phi +
epsilon), axis(best.theta, best.phi -
epsilon));
109 maxChange2 = 10 * (
b < 0 ? -1 : 1);
111 maxChange2 = -
b / (2 *
a);
117 thr = thrust(axis(best.theta, best.phi + maxChange2 *
epsilon)) +
epsilon;
121 best.phi += maxChange2 *
epsilon;
129 done = (fabs(maxChange1) > 1 || fabs(maxChange2) > 1 || mandCt) && (maxCt > 0);
136 double t1 = thrust(
a1),
t2 = thrust(
a2),
t3 = thrust(a3);
137 a = (
t2 - 2 *
c +
t3) / 2;
150 for (
unsigned int i = 0;
i < n_; ++
i)
151 sum += fabs(axis.Dot(p_[
i]));
ThetaPhi initialAxis() const
ThetaPhi finalAxis(ThetaPhi) const
Sin< T >::type sin(const T &t)
void parabola(double &a, double &b, double &c, const Vector &, const Vector &, const Vector &) const
double thrust() const
thrust value (in the range [0.5, 1.0])
math::XYZVector Vector
spatial vector
Cos< T >::type cos(const T &t)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float phi(ConstView const &tracks, int32_t i)
const Vector & axis() const
thrust axis (with magnitude = 1)
void init(const std::vector< const reco::Candidate *> &)