Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00036 #include "TopQuarkAnalysis/TopHitFit/interface/fourvec.h"
00037 #include <cmath>
00038
00039 using std::fabs;
00040 using std::sqrt;
00041 using std::sin;
00042 using std::cos;
00043 using std::atan;
00044 using std::exp;
00045 using std::log;
00046 using std::tan;
00047 using std::atan2;
00048
00049
00050 namespace {
00051
00052
00053 double cal_th (double theta, double z)
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 {
00066 const double R_CC = 91.6;
00067 const double Z_EC = 178.9;
00068 const double BIGG = 1e8;
00069
00070 double tanth;
00071 if (fabs (cos (theta)) < 1/BIGG)
00072 tanth = BIGG * sin (theta);
00073 else
00074 tanth = tan (theta);
00075
00076 double z_cc = R_CC / tanth + z;
00077
00078 if (fabs (z_cc) < Z_EC)
00079 theta = atan2 (R_CC, z_cc);
00080
00081 else {
00082 double zz = Z_EC;
00083 if (tanth < 0) zz = - zz;
00084 double r_ec = (zz-z) * tanth;
00085 theta = atan2 (r_ec, zz);
00086 }
00087
00088 if (theta < 0) theta += 2 * M_PI;
00089 return theta;
00090 }
00091
00092
00093 }
00094
00095
00096 namespace hitfit {
00097
00098
00099 void adjust_p_for_mass (Fourvec& v, double mass)
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 {
00112 CLHEP::Hep3Vector vect = v.vect();
00113 double old_p2 = vect.mag2();
00114 if (old_p2 == 0)
00115 return;
00116 double new_p2 = v.e()*v.e() - mass*mass;
00117 if (new_p2 < 0)
00118 new_p2 = 0;
00119 vect *= sqrt (new_p2 / old_p2);
00120 v.setVect (vect);
00121 }
00122
00123
00124 void adjust_e_for_mass (Fourvec& v, double mass)
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 {
00137 v.setE (sqrt (v.vect().mag2() + mass*mass));
00138 }
00139
00140
00141 void rottheta (Fourvec& v, double theta)
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 {
00153 double s = sin (theta), c = cos (theta);
00154 double old_pt = v.perp();
00155 double new_pt = old_pt*c - v.z()*s;
00156 v.setZ (old_pt*s + v.z()*c);
00157
00158 v.setX (v.x() * new_pt / old_pt);
00159 v.setY (v.y() * new_pt / old_pt);
00160 }
00161
00162
00163 void roteta (Fourvec& v, double eta)
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 {
00176 double theta1 = v.theta ();
00177 double eta1 = theta_to_eta (theta1);
00178 double eta2 = eta1 + eta;
00179 double theta2 = eta_to_theta (eta2);
00180
00181 rottheta (v, theta1 - theta2);
00182 }
00183
00184
00185 double eta_to_theta (double eta)
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 {
00196 return 2 * atan (exp (-eta));
00197 }
00198
00199
00200 double theta_to_eta (double theta)
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 {
00211 return - log (tan (theta / 2));
00212 }
00213
00214
00215 double deteta (const Fourvec& v, double zvert)
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 {
00227 return theta_to_eta (cal_th (v.theta(), zvert));
00228 }
00229
00230
00231 double phidiff (double phi)
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 {
00242 while (phi < -M_PI)
00243 phi += 2 * M_PI;
00244 while (phi > M_PI)
00245 phi -= 2*M_PI;
00246 return phi;
00247 }
00248
00249
00250 double delta_r (const Fourvec& a, const Fourvec& b)
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 {
00262 double deta = a.pseudoRapidity() - b.pseudoRapidity();
00263 double dphi = phidiff (a.phi() - b.phi());
00264 return sqrt (deta*deta + dphi*dphi);
00265 }
00266
00267
00268 }