File indexing completed on 2024-04-06 12:31:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 #include "TopQuarkAnalysis/TopHitFit/interface/Constrained_Top.h"
0038 #include "TopQuarkAnalysis/TopHitFit/interface/Fourvec_Event.h"
0039 #include "TopQuarkAnalysis/TopHitFit/interface/Lepjets_Event.h"
0040 #include "TopQuarkAnalysis/TopHitFit/interface/Defaults.h"
0041 #include <ostream>
0042 #include <cassert>
0043 #include <cstdio>
0044
0045 using std::ostream;
0046
0047 namespace hitfit {
0048
0049
0050
0051
0052
0053 Constrained_Top_Args::Constrained_Top_Args(const Defaults& defs)
0054
0055
0056
0057
0058
0059
0060 : _bmass(defs.get_float("bmass")),
0061 _fourvec_constrainer_args(defs),
0062 _equal_side(defs.get_bool("equal_side"))
0063
0064 {}
0065
0066 double Constrained_Top_Args::bmass() const
0067
0068
0069
0070
0071 {
0072 return _bmass;
0073 }
0074
0075 const Fourvec_Constrainer_Args& Constrained_Top_Args::fourvec_constrainer_args() const
0076
0077
0078
0079 {
0080 return _fourvec_constrainer_args;
0081 }
0082
0083 bool Constrained_Top_Args::equal_side() const
0084
0085
0086
0087
0088 {
0089 return _equal_side;
0090 }
0091
0092
0093
0094 Constrained_Top::Constrained_Top(const Constrained_Top_Args& args, double lepw_mass, double hadw_mass, double top_mass)
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107 : _args(args), _constrainer(args.fourvec_constrainer_args()) {
0108 char buf[256];
0109 if (lepw_mass > 0) {
0110 sprintf(buf, "(%d %d) = %f", nu_label, lepton_label, lepw_mass);
0111 _constrainer.add_constraint(buf);
0112 }
0113
0114 if (hadw_mass > 0) {
0115 sprintf(buf, "(%d %d) = %f", hadw1_label, hadw2_label, hadw_mass);
0116 _constrainer.add_constraint(buf);
0117 }
0118
0119 if (args.equal_side()) {
0120 sprintf(buf, "(%d %d %d) = (%d %d %d)", nu_label, lepton_label, lepb_label, hadw1_label, hadw2_label, hadb_label);
0121 _constrainer.add_constraint(buf);
0122 }
0123
0124 if (top_mass > 0) {
0125 sprintf(buf, "(%d %d %d) = %f", hadw1_label, hadw2_label, hadb_label, top_mass);
0126 _constrainer.add_constraint(buf);
0127 } else {
0128 sprintf(buf, "(%d %d %d) = 0", hadw1_label, hadw2_label, hadb_label);
0129 _constrainer.mass_constraint(buf);
0130 }
0131 }
0132
0133 namespace {
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149 FE_Obj make_fe_obj(const Lepjets_Event_Lep& obj, double mass, int type)
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161 {
0162 return FE_Obj(obj.p(), mass, type, obj.p_sigma(), obj.eta_sigma(), obj.phi_sigma(), obj.res().p_res().inverse());
0163 }
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 void do_import(const Lepjets_Event& ev, double bmass, Fourvec_Event& fe)
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194 {
0195 assert(ev.nleps() == 1);
0196 fe.add(make_fe_obj(ev.lep(0), 0, lepton_label));
0197
0198 bool saw_lepb = false;
0199 bool saw_hadb = false;
0200 for (std::vector<Lepjets_Event_Jet>::size_type j = 0; j < ev.njets(); j++) {
0201 if (ev.jet(j).type() == isr_label || ev.jet(j).type() == higgs_label)
0202 continue;
0203 double mass = 0;
0204 if (ev.jet(j).type() == lepb_label && !saw_lepb) {
0205 mass = bmass;
0206 saw_lepb = true;
0207 } else if (ev.jet(j).type() == hadb_label && !saw_hadb) {
0208 mass = bmass;
0209 saw_hadb = true;
0210 }
0211 fe.add(make_fe_obj(ev.jet(j), mass, ev.jet(j).type()));
0212 }
0213
0214 fe.set_nu_p(ev.met());
0215 Fourvec kt = ev.kt();
0216 fe.set_kt_error(ev.kt_res().sigma(kt.x()), ev.kt_res().sigma(kt.y()), 0);
0217 }
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235 void do_export(const Fourvec_Event& fe, Lepjets_Event& ev)
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246 {
0247 ev.lep(0).p() = fe.obj(0).p;
0248 for (std::vector<Lepjets_Event_Jet>::size_type j = 0, k = 1; j < ev.njets(); j++) {
0249 if (ev.jet(j).type() == isr_label || ev.jet(j).type() == higgs_label)
0250 continue;
0251 ev.jet(j).p() = fe.obj(k++).p;
0252 }
0253
0254 ev.met() = fe.nu();
0255 }
0256
0257 }
0258
0259 double Constrained_Top::constrain(
0260 Lepjets_Event& ev, double& mt, double& sigmt, Column_Vector& pullx, Column_Vector& pully)
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280 {
0281 Fourvec_Event fe;
0282 do_import(ev, _args.bmass(), fe);
0283 double chisq = _constrainer.constrain(fe, mt, sigmt, pullx, pully);
0284 do_export(fe, ev);
0285
0286 return chisq;
0287 }
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298 std::ostream& operator<<(std::ostream& s, const Constrained_Top& ct)
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309 {
0310 return s << ct._constrainer;
0311 }
0312
0313 }