8 for(std::vector<const Candidate*>::const_iterator
t = cands.begin();
9 t != cands.end(); ++
t, ++
i)
10 pSum_ += (p_[i] = (*t)->momentum()).
r();
11 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;
26 thr[i * nSegsPhi + j] = thrust(
Vector(r*
cos(phi), r*
sin(phi), z));
27 if (thr[i*nSegsPhi + j] > max) {
28 index = i*nSegsPhi + j;
41 if (ind1 >= nSegsPhi) ind1 -= nSegsPhi;
43 if (ind2 < 0) ind2 += nSegsPhi;
44 a = (thr[ind1] + thr[ind2] - 2*
c) / 2;
45 b = thr[ind1] - a -
c;
47 if (a != 0) maxPhiInd = -b/(2*
a);
49 if (indI == 0 || indI == (nSegsTheta - 1))
54 a = (thr[ind1] + thr[ind2] - 2*
c) / 2;
55 b = thr[ind1] - a -
c;
57 if (a != 0) maxThetaInd = - b/(2*
a);
59 return ThetaPhi(
pi*(maxThetaInd + indI) / (nSegsTheta - 1),
60 pi2*(maxPhiInd + indJ) / nSegsPhi);
64 static const double epsilon = 0.0001;
65 double maxChange1=0.0, maxChange2=0.0,
a=0.0,
b=0.0,
c=0.0, thr=0.0;
66 int mandCt = 3, maxCt = 1000;
71 axis(best.
theta + epsilon, best.
phi),
72 axis(best.
theta - epsilon, best.
phi));
73 maxChange1 = 10*(
b < 0 ? -1 : 1);
74 if (
a != 0) maxChange1 = -
b/(2*
a);
75 while (fabs(maxChange1 * epsilon) >
pi_4) maxChange1 /= 2;
76 if (maxChange1 == 0 && (best.
theta == 0 || best.
theta ==
pi)) {
81 axis(best.
theta + epsilon, best.
phi),
82 axis(best.
theta - epsilon, best.
phi));
83 maxChange1 = 10 * (
b < 0 ? -1 : 1);
84 if (
a != 0) maxChange1 = -
b / (2 *
a);
88 thr = thrust(axis(best.
theta + maxChange1 * epsilon, best.
phi)) +
epsilon;
89 if (thr <
c) maxChange1 /= 2;
105 axis(best.
theta, best.
phi + epsilon),
106 axis(best.
theta, best.
phi - epsilon));
107 maxChange2 = 10 * (
b < 0 ? -1 : 1);
108 if (
a != 0) maxChange2 = -
b / (2 *
a);
109 while (fabs(maxChange2 * epsilon) >
pi_4) { maxChange2 /= 2; }
112 thr = thrust(axis(best.
theta, best.
phi + maxChange2 * epsilon)) +
epsilon;
113 if (thr <
c) maxChange2 /= 2;
118 if (mandCt > 0) mandCt --;
120 done = (fabs(maxChange1) > 1 || fabs(maxChange2) > 1 || mandCt) && (maxCt > 0);
128 double t1 = thrust(a1), t2 = thrust(a2), t3 = thrust(a3);
129 a = (t2 - 2 * c + t3) / 2;
135 double theSin =
sin(theta);
142 for (
unsigned int i = 0;
i < n_; ++
i)
143 sum += fabs(axis.Dot(p_[
i]));
144 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
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 * > &)