CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Friends
hitfit::Top_Fit Class Reference

Handle and fit jet permutations of an event. This is the primary interface between user's Lepjets_Event and HitFit kinematic fitting algorithm. More...

#include <Top_Fit.h>

Public Member Functions

const Top_Fit_Argsargs () const
 Return a constant reference to the fit arguments. More...
 
Fit_Results fit (const Lepjets_Event &ev)
 Fit all jets permutations in ev. This function returns a Fit_Results object, which is not easy to extract information from. Users are recommended to use the class RunHitFit as interface to fit all permutations of all event. More...
 
double fit_one_perm (Lepjets_Event &ev, bool &nuz, double &umwhad, double &utmass, double &mt, double &sigmt, Column_Vector &pullx, Column_Vector &pully)
 Fit for a single jet permutation. More...
 
 Top_Fit (const Top_Fit_Args &args, double lepw_mass, double hadw_mass, double top_mass)
 Constructor. More...
 

Private Attributes

const Top_Fit_Args _args
 
Constrained_Top _constrainer
 
double _hadw_mass
 
double _lepw_mass
 

Friends

std::ostream & operator<< (std::ostream &s, const Top_Fit &fitter)
 Output stream operator, print the content of this Top_Fit object to an output stream. More...
 

Detailed Description

Handle and fit jet permutations of an event. This is the primary interface between user's Lepjets_Event and HitFit kinematic fitting algorithm.

Definition at line 243 of file Top_Fit.h.

Constructor & Destructor Documentation

hitfit::Top_Fit::Top_Fit ( const Top_Fit_Args args,
double  lepw_mass,
double  hadw_mass,
double  top_mass 
)

Constructor.

Parameters
argsThe parameter settings.
lepw_massThe mass to which the leptonic $ W- $ boson should be constrained to. A value of zero means this constraint will be removed.
hadw_massThe mass to which the hadronic $ W- $ boson should be constrained to. A value of zero means this constraint will be removed.
top_massThe mass to which the top quark should be constrained to. A value of zero means this constraint will be removed.

Definition at line 367 of file Top_Fit.cc.

383  : _args (args),
385  lepw_mass, hadw_mass, top_mass),
386  _lepw_mass(lepw_mass),
387  _hadw_mass (hadw_mass)
388 {
389 }
double _hadw_mass
Definition: Top_Fit.h:329
const Top_Fit_Args _args
Definition: Top_Fit.h:326
const Constrained_Top_Args & constrainer_args() const
Definition: Top_Fit.cc:168
const Top_Fit_Args & args() const
Return a constant reference to the fit arguments.
Definition: Top_Fit.cc:608
Constrained_Top _constrainer
Definition: Top_Fit.h:327
double _lepw_mass
Definition: Top_Fit.h:328

Member Function Documentation

const Top_Fit_Args & hitfit::Top_Fit::args ( ) const

Return a constant reference to the fit arguments.

Definition at line 608 of file Top_Fit.cc.

References _args.

Referenced by hitfit::RunHitFit< AElectron, AMuon, AJet, AMet >::FitAllPermutation().

609 {
610  return _args;
611 }
const Top_Fit_Args _args
Definition: Top_Fit.h:326
Fit_Results hitfit::Top_Fit::fit ( const Lepjets_Event ev)

Fit all jets permutations in ev. This function returns a Fit_Results object, which is not easy to extract information from. Users are recommended to use the class RunHitFit as interface to fit all permutations of all event.

Parameters
evInput: The event to fit, Output: the event after the fit.

Definition at line 498 of file Top_Fit.cc.

References _args, assert(), gather_cfg::cout, hitfit::Top_Fit_Args::do_higgs_flag(), ev, fit_one_perm(), hitfit::hadb_label, hitfit::hadw1_label, hitfit::higgs_label, i, hitfit::isr_label, hitfit::lepb_label, hitfit::n_lists, hitfit::Lepjets_Event::njets(), hitfit::Top_Fit_Args::nkeep(), hitfit::noperm_list, and hitfit::Top_Fit_Args::print_event_flag().

508 {
509  // Make a new Fit_Results object.
510  Fit_Results res (_args.nkeep(), n_lists);
511 
512  // Set up the vector of jet types.
513  vector<int> jet_types (ev.njets(), isr_label);
514  assert (ev.njets() >= 4);
515  jet_types[0] = lepb_label;
516  jet_types[1] = hadb_label;
517  jet_types[2] = hadw1_label;
518  jet_types[3] = hadw1_label;
519 
520  if (_args.do_higgs_flag() && ev.njets() >= 6) {
521  jet_types[4] = higgs_label;
522  jet_types[5] = higgs_label;
523  }
524 
525  // Must be in sorted order.
526  stable_sort (jet_types.begin(), jet_types.end());
527 
528  do {
529 
530  // Loop over the two possible neutrino solution
531  for (int nusol = 0 ; nusol != 2 ; nusol++) {
532 
533  // Set up the neutrino solution to be used
534  bool nuz = bool(nusol);
535 
536  // Copy the event.
537  Lepjets_Event fev = ev;
538 
539  // Install the new jet types.
540  set_jet_types (jet_types, fev);
541 
542  // Figure out on what lists this permutation should go.
543  vector<int> list_flags = classify_jetperm (jet_types, ev);
544 
545  // Set up the output variables for fit results.
546  double umwhad, utmass, mt, sigmt;
547  Column_Vector pullx;
548  Column_Vector pully;
549  double chisq;
550 
551  // Tracing.
552  cout << "Top_Fit::fit(): Before fit: (";
553  for (vector<int>::size_type i=0; i < jet_types.size(); i++) {
554  if (i) cout << " ";
555  cout << jet_types[i];
556  }
557  cout << " nuz = " << nuz ;
558  cout << ") " << std::endl;
559 
560  // Do the fit.
561  chisq = fit_one_perm (fev, nuz, umwhad, utmass, mt, sigmt, pullx, pully);
562 
563  // Print the result, if requested.
564  if (_args.print_event_flag()) {
565  cout << "Top_Fit::fit(): After fit:\n";
566  char buf[256];
567  sprintf (buf, "chisq: %8.3f mt: %6.2f pm %5.2f %c\n",
568  chisq, mt, sigmt, (list_flags[noperm_list] ? '*' : ' '));
569  cout << buf;
570  }
571 
572  // Add it to the results.
573  res.push (chisq, fev, pullx, pully, umwhad, utmass, mt, sigmt, list_flags);
574 
575  } // end of for loop over the two neutrino solution
576 
577  // Step to the next permutation.
578  } while (next_permutation (jet_types.begin(), jet_types.end()));
579 
580  return res;
581 }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
CLHEP::HepVector Column_Vector
Definition: matutil.h:66
bool ev
uint16_t size_type
bool print_event_flag() const
Return the print_event_flag parameter.
Definition: Top_Fit.cc:88
double fit_one_perm(Lepjets_Event &ev, bool &nuz, double &umwhad, double &utmass, double &mt, double &sigmt, Column_Vector &pullx, Column_Vector &pully)
Fit for a single jet permutation.
Definition: Top_Fit.cc:392
const Top_Fit_Args _args
Definition: Top_Fit.h:326
bool do_higgs_flag() const
Return the do_higgs_flag parameter.
Definition: Top_Fit.cc:98
tuple cout
Definition: gather_cfg.py:121
int nkeep() const
Return the nkeep parameter.
Definition: Top_Fit.cc:148
double hitfit::Top_Fit::fit_one_perm ( Lepjets_Event ev,
bool &  nuz,
double &  umwhad,
double &  utmass,
double &  mt,
double &  sigmt,
Column_Vector pullx,
Column_Vector pully 
)

Fit for a single jet permutation.

Parameters
evInput: The event to fit, Output: the event after the fit.
nuzInput: A flag to indicate which neutrino solution to be used.
FALSE means use solution with smaller absolute value.
TRUE means use solution with larger absolute value.
umwhadThe mass of hadronic $ W- $ boson before the fit.
utmassThe mass of the top quarks before fitting, averaged from the values of leptonic and hadronic top quark mass.
mtThe mass of the top quark after fitting.
sigmtThe uncertainty of the mass of the top quark after fitting.
pullxPull quantities for well-measured variables.
pullyPull quantities for poorly-measured variables.

Definition at line 392 of file Top_Fit.cc.

References _args, _constrainer, _hadw_mass, _lepw_mass, hitfit::adjust_e_for_mass(), hitfit::Constrained_Top::constrain(), gather_cfg::cout, hitfit::Top_Decaykin::dump_ev(), hitfit::Top_Decaykin::hadt(), hitfit::Top_Decaykin::hadw(), hitfit::Top_Decaykin::lept(), visualization-live-secondInstance_cfg::m, hitfit::Lepjets_Event::met(), hitfit::Top_Fit_Args::print_event_flag(), hitfit::Top_Decaykin::solve_nu(), hitfit::Top_Decaykin::solve_nu_tmass(), and hitfit::Top_Fit_Args::solve_nu_tmass().

Referenced by fit(), and hitfit::RunHitFit< AElectron, AMuon, AJet, AMet >::FitAllPermutation().

429 {
430  mt = 0;
431  sigmt = 0;
432 
433  // Find the neutrino solutions by requiring either:
434  // 1) that the leptonic top have the same mass as the hadronic top.
435  // 2) that the mass of the lepton and neutrino is equal to the W mass
436 
437  umwhad = Top_Decaykin::hadw (ev) . m();
438  double umthad = Top_Decaykin::hadt (ev) . m();
439  double nuz1, nuz2;
440 
441  if (_args.solve_nu_tmass()) {
442  Top_Decaykin::solve_nu_tmass (ev, umthad, nuz1, nuz2);
443  }
444  else {
445  Top_Decaykin::solve_nu (ev, _lepw_mass, nuz1, nuz2);
446  }
447 
448  // Set up to use the selected neutrino solution
449  if (!nuz) {
450  ev.met().setZ(nuz1);
451  }
452  else {
453  ev.met().setZ(nuz2);
454  }
455 
456  // Note: We have set the neutrino Pz, but we haven't set the neutrino energy.
457  // Remember that originally the neutrino energy was equal to
458  // sqrt(nu_px*nu_px + nu_py*nu_py). Calculating the invariant mass squared
459  // for the neutrino will give negative mass squared.
460  // Therefore we need to adjust (increase) the neutrino energy in order to
461  // make its mass remain zero.
462 
463  adjust_e_for_mass(ev.met(),0);
464 
465  // Find the unfit top mass as the average of the two sides.
466  double umtlep = Top_Decaykin::lept (ev) . m();
467  utmass = (umthad + umtlep) / 2;
468 
469  // Trace, if requested.
470  if (_args.print_event_flag()) {
471  cout << "Top_Fit::fit_one_perm() : Before fit:\n";
473  }
474 
475  // Maybe reject this event.
476  if (_hadw_mass > 0 && test_for_bad_masses (ev, _args, umwhad,
477  umthad, umtlep))
478  {
479  cout << "Top_Fit: bad mass comb.\n";
480  return -999;
481  }
482 
483  // Do the fit.
484  double chisq = _constrainer.constrain (ev, mt, sigmt, pullx, pully);
485 
486  // Trace, if requested.
487  if (_args.print_event_flag()) {
488  cout << "Top_Fit::fit_one_perm() : After fit:\n";
489  cout << "chisq: " << chisq << " mt: " << mt << " ";
491  }
492 
493  // Done!
494  return chisq;
495 }
static bool solve_nu_tmass(const Lepjets_Event &ev, double tmass, double &nuz1, double &nuz2)
Solve for the neutrino longitudinal momentum that makes the leptonic top have a certain value of mas...
Definition: Top_Decaykin.cc:81
bool solve_nu_tmass() const
Return the solve_nu_tmass parameter.
Definition: Top_Fit.cc:158
double _hadw_mass
Definition: Top_Fit.h:329
void adjust_e_for_mass(Fourvec &v, double mass)
Adjust the energy component of four-vector v (leaving the three-vector part unchanged) so that the fo...
Definition: fourvec.cc:123
bool ev
bool print_event_flag() const
Return the print_event_flag parameter.
Definition: Top_Fit.cc:88
const Top_Fit_Args _args
Definition: Top_Fit.h:326
static bool solve_nu(const Lepjets_Event &ev, double wmass, double &nuz1, double &nuz2)
Solve for the longitudinal momentum that makes the leptonic -boson to have a certain value of mass...
double constrain(Lepjets_Event &ev, double &mt, double &sigmt, Column_Vector &pullx, Column_Vector &pully)
Do a constrained fit of events. Returns the top mass and its error in mt and sigmt, and the pull quantities in pullx and pully. Returns the , this will be negative if the fit failed to converge.
static Fourvec hadt(const Lepjets_Event &ev)
Sum up the appropriate four-momenta to find the hadronic top quark.
Constrained_Top _constrainer
Definition: Top_Fit.h:327
double _lepw_mass
Definition: Top_Fit.h:328
static Fourvec lept(const Lepjets_Event &ev)
Sum up the appropriate four-momenta to find the leptonic top quark.
tuple cout
Definition: gather_cfg.py:121
static Fourvec hadw(const Lepjets_Event &ev)
Sum up the appropriate four-momenta to find the hadronic boson.
static std::ostream & dump_ev(std::ostream &s, const Lepjets_Event &ev)
Print the kinematic information for an event.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const Top_Fit fitter 
)
friend

Output stream operator, print the content of this Top_Fit object to an output stream.

Parameters
sThe output stream to which to write.
fitterThe instance of Top_Fit to be printed.

Definition at line 592 of file Top_Fit.cc.

603 {
604  return s << fitter._constrainer;
605 }

Member Data Documentation

const Top_Fit_Args hitfit::Top_Fit::_args
private
Constrained_Top hitfit::Top_Fit::_constrainer
private

Definition at line 327 of file Top_Fit.h.

Referenced by fit_one_perm(), and hitfit::operator<<().

double hitfit::Top_Fit::_hadw_mass
private

Definition at line 329 of file Top_Fit.h.

Referenced by fit_one_perm().

double hitfit::Top_Fit::_lepw_mass
private

Definition at line 328 of file Top_Fit.h.

Referenced by fit_one_perm().