File indexing completed on 2023-03-17 11:26:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "TopQuarkAnalysis/TopHitFit/interface/Fourvec_Event.h"
0014 #include <cassert>
0015 #include <ostream>
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 using std::ostream;
0041
0042 namespace hitfit {
0043
0044 FE_Obj::FE_Obj(const Fourvec& the_p,
0045 double the_mass,
0046 int the_label,
0047 double the_p_error,
0048 double the_phi_error,
0049 double the_eta_error,
0050 bool the_muon_p)
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 : p(the_p),
0065 mass(the_mass),
0066 label(the_label),
0067 p_error(the_p_error),
0068 phi_error(the_phi_error),
0069 eta_error(the_eta_error),
0070 muon_p(the_muon_p) {}
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 std::ostream& operator<<(std::ostream& s, const FE_Obj& o)
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 {
0092 s << o.p << " - " << o.mass << " - " << o.label << "\n";
0093 s << " errors: " << o.p_error << " " << o.phi_error << " " << o.eta_error;
0094 if (o.muon_p)
0095 s << " (mu)";
0096 s << "\n";
0097 return s;
0098 }
0099
0100
0101
0102 Fourvec_Event::Fourvec_Event()
0103
0104
0105
0106 : _kt_x_error(0), _kt_y_error(0), _kt_xy_covar(0), _has_neutrino(false) {}
0107
0108 bool Fourvec_Event::has_neutrino() const
0109
0110
0111
0112
0113
0114
0115 {
0116 return _has_neutrino;
0117 }
0118
0119 int Fourvec_Event::nobjs() const
0120
0121
0122
0123
0124
0125
0126
0127 {
0128 return _objs.size() - (_has_neutrino ? 1 : 0);
0129 }
0130
0131 int Fourvec_Event::nobjs_all() const
0132
0133
0134
0135
0136
0137
0138 {
0139 return _objs.size();
0140 }
0141
0142 const FE_Obj& Fourvec_Event::obj(std::vector<FE_Obj>::size_type i) const
0143
0144
0145
0146
0147
0148
0149 {
0150 assert(i < _objs.size());
0151 return _objs[i];
0152 }
0153
0154 const Fourvec& Fourvec_Event::nu() const
0155
0156
0157
0158 {
0159 assert(_has_neutrino);
0160 return _objs.back().p;
0161 }
0162
0163 const Fourvec& Fourvec_Event::kt() const
0164
0165
0166
0167 {
0168 return _kt;
0169 }
0170
0171 const Fourvec& Fourvec_Event::x() const
0172
0173
0174
0175 {
0176 return _x;
0177 }
0178
0179 double Fourvec_Event::kt_x_error() const
0180
0181
0182
0183
0184
0185
0186 {
0187 return _kt_x_error;
0188 }
0189
0190 double Fourvec_Event::kt_y_error() const
0191
0192
0193
0194
0195
0196
0197 {
0198 return _kt_y_error;
0199 }
0200
0201 double Fourvec_Event::kt_xy_covar() const
0202
0203
0204
0205
0206
0207
0208 {
0209 return _kt_xy_covar;
0210 }
0211
0212
0213
0214
0215
0216
0217
0218
0219
0220 std::ostream& operator<<(std::ostream& s, const Fourvec_Event& fe)
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231 {
0232 s << "kt: (" << fe._kt.x() << ", " << fe._kt.y() << "); "
0233 << " error: " << fe._kt_x_error << " " << fe._kt_y_error << " " << fe._kt_xy_covar << "\n";
0234 s << "x: " << fe._x << "\n";
0235 for (unsigned i = 0; i < fe._objs.size(); i++)
0236 s << i + 1 << ": " << fe._objs[i];
0237 return s;
0238 }
0239
0240 void Fourvec_Event::add(const FE_Obj& obj)
0241
0242
0243
0244
0245
0246
0247
0248 {
0249 assert(obj.label != nu_label);
0250
0251
0252 if (_has_neutrino) {
0253 assert(!_objs.empty());
0254 _objs.insert(_objs.begin() + _objs.size() - 1, obj);
0255 } else
0256 _objs.push_back(obj);
0257
0258
0259 _kt += obj.p;
0260 }
0261
0262 void Fourvec_Event::set_nu_p(const Fourvec& p)
0263
0264
0265
0266
0267
0268
0269
0270 {
0271 if (_has_neutrino) {
0272 _kt -= _objs.back().p;
0273 _objs.back().p = p;
0274 } else {
0275 _has_neutrino = true;
0276 _objs.push_back(FE_Obj(p, 0, nu_label, 0, 0, 0, false));
0277 }
0278
0279 _kt += p;
0280 }
0281
0282 void Fourvec_Event::set_obj_p(std::vector<FE_Obj>::size_type i, const Fourvec& p)
0283
0284
0285
0286
0287
0288
0289
0290 {
0291 assert(i < _objs.size());
0292 _kt -= _objs[i].p;
0293 _objs[i].p = p;
0294 _kt += p;
0295 }
0296
0297 void Fourvec_Event::set_x_p(const Fourvec& p)
0298
0299
0300
0301
0302
0303
0304 {
0305 _kt -= _x;
0306 _x = p;
0307 _kt += p;
0308 }
0309
0310 void Fourvec_Event::set_kt_error(double kt_x_error, double kt_y_error, double kt_xy_covar)
0311
0312
0313
0314
0315
0316
0317
0318
0319 {
0320 _kt_x_error = kt_x_error;
0321 _kt_y_error = kt_y_error;
0322 _kt_xy_covar = kt_xy_covar;
0323 }
0324
0325 }