00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00039 #include "TopQuarkAnalysis/TopHitFit/interface/Constrained_Top.h"
00040 #include "TopQuarkAnalysis/TopHitFit/interface/Fourvec_Event.h"
00041 #include "TopQuarkAnalysis/TopHitFit/interface/Lepjets_Event.h"
00042 #include "TopQuarkAnalysis/TopHitFit/interface/Defaults.h"
00043 #include <ostream>
00044 #include <cassert>
00045 #include <stdio.h>
00046
00047
00048 using std::ostream;
00049
00050
00051 namespace hitfit {
00052
00053
00054
00055
00056
00057
00058
00059 Constrained_Top_Args::Constrained_Top_Args (const Defaults& defs)
00060
00061
00062
00063
00064
00065
00066 : _bmass (defs.get_float ("bmass")),
00067 _fourvec_constrainer_args (defs),
00068 _equal_side(defs.get_bool("equal_side"))
00069
00070 {
00071 }
00072
00073
00074 double Constrained_Top_Args::bmass () const
00075
00076
00077
00078
00079 {
00080 return _bmass;
00081 }
00082
00083
00084 const Fourvec_Constrainer_Args&
00085 Constrained_Top_Args::fourvec_constrainer_args () const
00086
00087
00088
00089 {
00090 return _fourvec_constrainer_args;
00091 }
00092
00093
00094 bool Constrained_Top_Args::equal_side () const
00095
00096
00097
00098
00099 {
00100 return _equal_side;
00101 }
00102
00103
00104
00105
00106
00107 Constrained_Top::Constrained_Top (const Constrained_Top_Args& args,
00108 double lepw_mass,
00109 double hadw_mass,
00110 double top_mass)
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 : _args (args),
00124 _constrainer (args.fourvec_constrainer_args())
00125 {
00126 char buf[256];
00127 if (lepw_mass > 0) {
00128 sprintf (buf, "(%d %d) = %f", nu_label, lepton_label, lepw_mass);
00129 _constrainer.add_constraint (buf);
00130 }
00131
00132 if (hadw_mass > 0) {
00133 sprintf (buf, "(%d %d) = %f", hadw1_label, hadw2_label, hadw_mass);
00134 _constrainer.add_constraint (buf);
00135 }
00136
00137 if (args.equal_side()) {
00138 sprintf (buf, "(%d %d %d) = (%d %d %d)",
00139 nu_label, lepton_label, lepb_label,
00140 hadw1_label, hadw2_label, hadb_label);
00141 _constrainer.add_constraint (buf);
00142 }
00143
00144 if (top_mass > 0) {
00145 sprintf (buf, "(%d %d %d) = %f",
00146 hadw1_label, hadw2_label, hadb_label, top_mass);
00147 _constrainer.add_constraint (buf);
00148 }
00149 else {
00150 sprintf (buf, "(%d %d %d) = 0", hadw1_label, hadw2_label, hadb_label);
00151 _constrainer.mass_constraint (buf);
00152 }
00153 }
00154
00155 namespace {
00156
00157
00172 FE_Obj make_fe_obj (const Lepjets_Event_Lep& obj, double mass, int type)
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 {
00185 return FE_Obj (obj.p(), mass, type,
00186 obj.p_sigma(), obj.eta_sigma(), obj.phi_sigma(),
00187 obj.res().p_res().inverse());
00188 }
00189
00190
00209 void do_import (const Lepjets_Event& ev, double bmass, Fourvec_Event& fe)
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220 {
00221 assert (ev.nleps() == 1);
00222 fe.add (make_fe_obj (ev.lep(0), 0, lepton_label));
00223
00224 bool saw_lepb = false;
00225 bool saw_hadb = false;
00226 for (std::vector<Lepjets_Event_Jet>::size_type j=0; j < ev.njets(); j++) {
00227 if (ev.jet(j).type() == isr_label || ev.jet(j).type() == higgs_label)
00228 continue;
00229 double mass = 0;
00230 if (ev.jet(j).type() == lepb_label && !saw_lepb) {
00231 mass = bmass;
00232 saw_lepb = true;
00233 }
00234 else if (ev.jet(j).type() == hadb_label && !saw_hadb) {
00235 mass = bmass;
00236 saw_hadb = true;
00237 }
00238 fe.add (make_fe_obj (ev.jet(j), mass, ev.jet(j).type()));
00239 }
00240
00241 fe.set_nu_p (ev.met());
00242 Fourvec kt = ev.kt ();
00243 fe.set_kt_error (ev.kt_res().sigma (kt.x()),
00244 ev.kt_res().sigma (kt.y()),
00245 0);
00246 }
00247
00248
00265 void do_export (const Fourvec_Event& fe, Lepjets_Event& ev)
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276 {
00277 ev.lep(0).p() = fe.obj(0).p;
00278 for (std::vector<Lepjets_Event_Jet>::size_type j=0, k=1; j < ev.njets(); j++) {
00279 if (ev.jet(j).type() == isr_label || ev.jet(j).type() == higgs_label)
00280 continue;
00281 ev.jet(j).p() = fe.obj(k++).p;
00282 }
00283
00284 ev.met() = fe.nu();
00285 }
00286
00287
00288 }
00289
00290
00291 double Constrained_Top::constrain (Lepjets_Event& ev,
00292 double& mt,
00293 double& sigmt,
00294 Column_Vector& pullx,
00295 Column_Vector& pully)
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 {
00316 Fourvec_Event fe;
00317 do_import (ev, _args.bmass (), fe);
00318 double chisq = _constrainer.constrain (fe, mt, sigmt, pullx, pully);
00319 do_export (fe, ev);
00320
00321 return chisq;
00322 }
00323
00324
00334 std::ostream& operator<< (std::ostream& s, const Constrained_Top& ct)
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 {
00346 return s << ct._constrainer;
00347 }
00348
00349
00350 }