13{
17
20
21 const bool useThreeD = true;
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 double thrust_major = -1;
41 double thrust_minor = -1;
42
44
45 std::vector<fastjet::PseudoJet>::const_iterator iBeg =
clusters.begin();
46 std::vector<fastjet::PseudoJet>::const_iterator iEnd =
clusters.end();
47
49
50 int agree = 0;
51 int disagree = 0;
52
53 TVector3 n_0[20];
54 short add0[20] = { 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,-1,-1,-1,-1,-1,-1,-1,-1 };
55 short add1[20] = { 0, 1, 0, 0, 1, 1, 1, 1,-1,-1,-1,-1, 1, 1, 1, 1,-1,-1,-1,-1 };
56 short add2[20] = { 0, 0, 1, 0, 1, 1,-1,-1, 1, 1,-1,-1, 1, 1,-1,-1, 1, 1,-1,-1 };
57 short add3[20] = { 0, 0, 0, 1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1, 1,-1 };
58
59 std::vector<fastjet::PseudoJet> clusters_Esorted = fastjet::sorted_by_E(clusters);
60 std::vector<fastjet::PseudoJet> v_copy(4);
61 for(
int i=0;
i<4;
i++) {
62 v_copy[
i] = clusters_Esorted[
i];
63 }
64
65 int n_tests = 0;
67 do {
68 n_0[n_tests]=TVector3(0,0,0);
69
70
71 n_0[n_tests] +=
72 add0[n_tests] * TVector3(v_copy.at(0).px(), v_copy.at(0).py(), v_copy.at(0).pz()) +
73 add1[n_tests] * TVector3(v_copy.at(1).px(), v_copy.at(1).py(), v_copy.at(1).pz()) +
74 add2[n_tests] * TVector3(v_copy.at(2).px(), v_copy.at(2).py(), v_copy.at(2).pz()) +
75 add3[n_tests] * TVector3(v_copy.at(3).px(), v_copy.at(3).py(), v_copy.at(3).pz());
76
77 if (!useThreeD)
78 n_0[n_tests].SetZ(0);
79
80
81 if (n_0[n_tests].Mag() > 0)
82 n_0[n_tests] *= 1/n_0[n_tests].Mag();
83
86 do {
87 TVector3 n_1(0,0,0);
88 for (std::vector<fastjet::PseudoJet>::const_iterator i = iBeg;
i != iEnd; ++
i) {
89 const fastjet::PseudoJet &itr = *
i;
90 if ((itr).
px() * n_0[n_tests].
x() +
91 (itr).
py() * n_0[n_tests].
y() +
92 (itr).
pz() * n_0[n_tests].
z() > 0)
93 n_1 += TVector3((itr).
px(), (itr).
py(), (itr).
pz());
94 else
95 n_1 -= TVector3((itr).
px(), (itr).
py(), (itr).
pz());
96 }
97
98 if (!useThreeD)
99 n_1.SetZ(0);
100
101
102 if (n_1.Mag() > 0)
103 n_1 *= 1/n_1.Mag();
104
105
106 run = (n_0[n_tests] != n_1) && (-n_0[n_tests] != n_1) &&
loop++ < 10;
107 n_0[n_tests] = n_1;
108 } while (run);
109
110
111
112 if (n_tests > 0 && (n_0[0] == n_0[n_tests] || n_0[0] == -n_0[n_tests])) agree++;
113 if (n_tests > 0 && n_0[0] != n_0[n_tests] && n_0[0] != -n_0[n_tests]) disagree++;
114
115
116
117 } while ((disagree > 0 || agree < 4) && ++n_tests < max_tests);
118
119
120
121
122 n_tests = 0;
123
124
125 do {
127 double numerator_t = 0;
128 double numerator_m = 0;
129 for(std::vector<fastjet::PseudoJet>::const_iterator i = iBeg;
i != iEnd; ++
i) {
130 const fastjet::PseudoJet & itr = *
i;
131
132 TLorentzVector
v((itr).
px(), (itr).
py(), (itr).
pz(), (itr).
e());
133 TVector3
c(
v.Vect());
134 numerator_t += fabs(
c.Dot(n_0[n_tests]));
135 numerator_m += (
c.Cross(n_0[n_tests])).Mag();
137 }
138
139 if(denominator < 1e-20) {
141 }
142
143 if (numerator_t / denominator > thrust_major) {
147 }
148 } while (disagree > 0 && ++n_tests < max_tests);
149
152
154}
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
CLHEP::Hep3Vector thrust(const I4MomIter_t &iBeg, const I4MomIter_t &iEnd, double &thrust_major, double &thrust_minor, bool useThreeD=false)
std::vector< fastjet::PseudoJet > boostToCenterOfMass(const fastjet::PseudoJet &jet, std::vector< fastjet::PseudoJet > constituents)