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 244 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 368 of file Top_Fit.cc.

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

Member Function Documentation

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

Return a constant reference to the fit arguments.

Definition at line 609 of file Top_Fit.cc.

References _args.

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

610 {
611  return _args;
612 }
const Top_Fit_Args _args
Definition: Top_Fit.h:327
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 499 of file Top_Fit.cc.

References _args, gather_cfg::cout, hitfit::Top_Fit_Args::do_higgs_flag(), 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().

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

430 {
431  mt = 0;
432  sigmt = 0;
433 
434  // Find the neutrino solutions by requiring either:
435  // 1) that the leptonic top have the same mass as the hadronic top.
436  // 2) that the mass of the lepton and neutrino is equal to the W mass
437 
438  umwhad = Top_Decaykin::hadw (ev) . m();
439  double umthad = Top_Decaykin::hadt (ev) . m();
440  double nuz1, nuz2;
441 
442  if (_args.solve_nu_tmass()) {
443  Top_Decaykin::solve_nu_tmass (ev, umthad, nuz1, nuz2);
444  }
445  else {
446  Top_Decaykin::solve_nu (ev, _lepw_mass, nuz1, nuz2);
447  }
448 
449  // Set up to use the selected neutrino solution
450  if (!nuz) {
451  ev.met().setZ(nuz1);
452  }
453  else {
454  ev.met().setZ(nuz2);
455  }
456 
457  // Note: We have set the neutrino Pz, but we haven't set the neutrino energy.
458  // Remember that originally the neutrino energy was equal to
459  // sqrt(nu_px*nu_px + nu_py*nu_py). Calculating the invariant mass squared
460  // for the neutrino will give negative mass squared.
461  // Therefore we need to adjust (increase) the neutrino energy in order to
462  // make its mass remain zero.
463 
464  adjust_e_for_mass(ev.met(),0);
465 
466  // Find the unfit top mass as the average of the two sides.
467  double umtlep = Top_Decaykin::lept (ev) . m();
468  utmass = (umthad + umtlep) / 2;
469 
470  // Trace, if requested.
471  if (_args.print_event_flag()) {
472  cout << "Top_Fit::fit_one_perm() : Before fit:\n";
474  }
475 
476  // Maybe reject this event.
477  if (_hadw_mass > 0 && test_for_bad_masses (ev, _args, umwhad,
478  umthad, umtlep))
479  {
480  cout << "Top_Fit: bad mass comb.\n";
481  return -999;
482  }
483 
484  // Do the fit.
485  double chisq = _constrainer.constrain (ev, mt, sigmt, pullx, pully);
486 
487  // Trace, if requested.
488  if (_args.print_event_flag()) {
489  cout << "Top_Fit::fit_one_perm() : After fit:\n";
490  cout << "chisq: " << chisq << " mt: " << mt << " ";
492  }
493 
494  // Done!
495  return chisq;
496 }
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:82
bool solve_nu_tmass() const
Return the solve_nu_tmass parameter.
Definition: Top_Fit.cc:159
double _hadw_mass
Definition: Top_Fit.h:330
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:124
bool print_event_flag() const
Return the print_event_flag parameter.
Definition: Top_Fit.cc:89
const Top_Fit_Args _args
Definition: Top_Fit.h:327
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:328
double _lepw_mass
Definition: Top_Fit.h:329
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 593 of file Top_Fit.cc.

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

Member Data Documentation

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

Definition at line 328 of file Top_Fit.h.

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

double hitfit::Top_Fit::_hadw_mass
private

Definition at line 330 of file Top_Fit.h.

Referenced by fit_one_perm().

double hitfit::Top_Fit::_lepw_mass
private

Definition at line 329 of file Top_Fit.h.

Referenced by fit_one_perm().