7 void Thrust::init(
const std::vector<const Candidate*>& cands) {
9 for(std::vector<const Candidate*>::const_iterator
t = cands.begin();
10 t != cands.end(); ++
t, ++
i)
11 pSum_ += (p_[i] = (*t)->momentum()).
r();
12 axis_ = axis(finalAxis(initialAxis()));
14 thrust_ = thrust(
axis_);
18 static const int nSegsTheta = 10, nSegsPhi = 10, nSegs = nSegsTheta * nSegsPhi;
20 double thr[nSegs],
max = 0;
21 int indI = 0, indJ = 0,
index = -1;
22 for (i = 0; i < nSegsTheta ; ++
i) {
23 double z =
cos(
pi * i / (nSegsTheta - 1));
24 double r =
sqrt(1 - z*z);
25 for (j = 0; j < nSegsPhi ; ++
j) {
26 double phi =
pi2 * j / nSegsPhi;
27 thr[i * nSegsPhi +
j] = thrust(
Vector(r*
cos(phi), r*
sin(phi), z));
28 if (thr[i*nSegsPhi + j] > max) {
42 if (ind1 >= nSegsPhi) ind1 -= nSegsPhi;
44 if (ind2 < 0) ind2 += nSegsPhi;
45 a = (thr[ind1] + thr[ind2] - 2*
c) / 2;
46 b = thr[ind1] - a -
c;
48 if (a != 0) maxPhiInd = -b/(2*
a);
50 if (indI == 0 || indI == (nSegsTheta - 1))
55 a = (thr[ind1] + thr[ind2] - 2*
c) / 2;
56 b = thr[ind1] - a -
c;
58 if (a != 0) maxThetaInd = - b/(2*
a);
60 return ThetaPhi(
pi*(maxThetaInd + indI) / (nSegsTheta - 1),
61 pi2*(maxPhiInd + indJ) / nSegsPhi);
65 static const double epsilon = 0.0001;
66 double maxChange1=0.0, maxChange2=0.0,
a=0.0,
b=0.0,
c=0.0, thr=0.0;
67 int mandCt = 3, maxCt = 1000;
72 axis(best.
theta + epsilon, best.
phi),
73 axis(best.
theta - epsilon, best.
phi));
74 maxChange1 = 10*(
b < 0 ? -1 : 1);
75 if (
a != 0) maxChange1 = -
b/(2*
a);
76 while (fabs(maxChange1 * epsilon) >
pi_4) maxChange1 /= 2;
77 if (maxChange1 == 0 && (best.
theta == 0 || best.
theta ==
pi)) {
82 axis(best.
theta + epsilon, best.
phi),
83 axis(best.
theta - epsilon, best.
phi));
84 maxChange1 = 10 * (
b < 0 ? -1 : 1);
85 if (
a != 0) maxChange1 = -
b / (2 *
a);
89 thr = thrust(axis(best.
theta + maxChange1 * epsilon, best.
phi)) +
epsilon;
90 if (thr <
c) maxChange1 /= 2;
106 axis(best.
theta, best.
phi + epsilon),
107 axis(best.
theta, best.
phi - epsilon));
108 maxChange2 = 10 * (
b < 0 ? -1 : 1);
109 if (
a != 0) maxChange2 = -
b / (2 *
a);
110 while (fabs(maxChange2 * epsilon) >
pi_4) { maxChange2 /= 2; }
113 thr = thrust(axis(best.
theta, best.
phi + maxChange2 * epsilon)) +
epsilon;
114 if (thr <
c) maxChange2 /= 2;
119 if (mandCt > 0) mandCt --;
121 done = (fabs(maxChange1) > 1 || fabs(maxChange2) > 1 || mandCt) && (maxCt > 0);
129 double t1 = thrust(a1),
t2 = thrust(a2), t3 = thrust(a3);
130 a = (
t2 - 2 * c + t3) / 2;
136 double theSin =
sin(theta);
143 for (
unsigned int i = 0;
i < n_; ++
i)
144 sum += fabs(axis.Dot(p_[
i]));
145 if (pSum_ > 0) result = sum / pSum_;
ROOT::Math::Plane3D::Vector Vector
const Vector & axis() const
thrust axis (with magnitude = 1)
Sin< T >::type sin(const T &t)
ThetaPhi initialAxis() const
Geom::Theta< T > theta() const
math::XYZVector Vector
spatial vector
const T & max(const T &a, const T &b)
auto const T2 &decltype(t1.eta()) t2
Cos< T >::type cos(const T &t)
const reco::Candidate::LorentzVector & axis_
double thrust() const
thrust value (in the range [0.5, 1.0])
ThetaPhi finalAxis(ThetaPhi) const
void parabola(double &a, double &b, double &c, const Vector &, const Vector &, const Vector &) const
void init(const std::vector< const reco::Candidate * > &)