CMS 3D CMS Logo

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 232 of file Top_Fit.h.

Constructor & Destructor Documentation

◆ Top_Fit()

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

350  : _args(args),
351  _constrainer(args.constrainer_args(), lepw_mass, hadw_mass, top_mass),
352  _lepw_mass(lepw_mass),
353  _hadw_mass(hadw_mass) {}

Member Function Documentation

◆ args()

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

Return a constant reference to the fit arguments.

Definition at line 563 of file Top_Fit.cc.

563 { return _args; }

References _args.

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

◆ fit()

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

466  {
467  // Make a new Fit_Results object.
468  Fit_Results res(_args.nkeep(), n_lists);
469 
470  // Set up the vector of jet types.
471  vector<int> jet_types(ev.njets(), isr_label);
472  assert(ev.njets() >= 4);
473  jet_types[0] = lepb_label;
474  jet_types[1] = hadb_label;
475  jet_types[2] = hadw1_label;
476  jet_types[3] = hadw1_label;
477 
478  if (_args.do_higgs_flag() && ev.njets() >= 6) {
479  jet_types[4] = higgs_label;
480  jet_types[5] = higgs_label;
481  }
482 
483  // Must be in sorted order.
484  stable_sort(jet_types.begin(), jet_types.end());
485 
486  do {
487  // Loop over the two possible neutrino solution
488  for (int nusol = 0; nusol != 2; nusol++) {
489  // Set up the neutrino solution to be used
490  bool nuz = bool(nusol);
491 
492  // Copy the event.
493  Lepjets_Event fev = ev;
494 
495  // Install the new jet types.
496  set_jet_types(jet_types, fev);
497 
498  // Figure out on what lists this permutation should go.
499  vector<int> list_flags = classify_jetperm(jet_types, ev);
500 
501  // Set up the output variables for fit results.
502  double umwhad, utmass, mt, sigmt;
503  Column_Vector pullx;
504  Column_Vector pully;
505  double chisq;
506 
507  // Tracing.
508  cout << "Top_Fit::fit(): Before fit: (";
509  for (vector<int>::size_type i = 0; i < jet_types.size(); i++) {
510  if (i)
511  cout << " ";
512  cout << jet_types[i];
513  }
514  cout << " nuz = " << nuz;
515  cout << ") " << std::endl;
516 
517  // Do the fit.
518  chisq = fit_one_perm(fev, nuz, umwhad, utmass, mt, sigmt, pullx, pully);
519 
520  // Print the result, if requested.
521  if (_args.print_event_flag()) {
522  cout << "Top_Fit::fit(): After fit:\n";
523  char buf[256];
524  sprintf(
525  buf, "chisq: %8.3f mt: %6.2f pm %5.2f %c\n", chisq, mt, sigmt, (list_flags[noperm_list] ? '*' : ' '));
526  cout << buf;
527  }
528 
529  // Add it to the results.
530  res.push(chisq, fev, pullx, pully, umwhad, utmass, mt, sigmt, list_flags);
531 
532  } // end of for loop over the two neutrino solution
533 
534  // Step to the next permutation.
535  } while (next_permutation(jet_types.begin(), jet_types.end()));
536 
537  return res;
538  }

References _args, cms::cuda::assert(), electrons_cff::bool, visDQMUpload::buf, gather_cfg::cout, hitfit::Top_Fit_Args::do_higgs_flag(), ev, fit_one_perm(), hitfit::hadb_label, hitfit::hadw1_label, hitfit::higgs_label, mps_fire::i, hitfit::isr_label, hitfit::lepb_label, TtSemiLepEvtBuilder_cfi::mt, hitfit::n_lists, hitfit::Top_Fit_Args::nkeep(), hitfit::noperm_list, hitfit::Top_Fit_Args::print_event_flag(), and TtSemiLepEvtBuilder_cfi::sigmt.

Referenced by trackingPlots.Iteration::modules().

◆ fit_one_perm()

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

392  {
393  mt = 0;
394  sigmt = 0;
395 
396  // Find the neutrino solutions by requiring either:
397  // 1) that the leptonic top have the same mass as the hadronic top.
398  // 2) that the mass of the lepton and neutrino is equal to the W mass
399 
400  umwhad = Top_Decaykin::hadw(ev).m();
401  double umthad = Top_Decaykin::hadt(ev).m();
402  double nuz1, nuz2;
403 
404  if (_args.solve_nu_tmass()) {
405  Top_Decaykin::solve_nu_tmass(ev, umthad, nuz1, nuz2);
406  } else {
407  Top_Decaykin::solve_nu(ev, _lepw_mass, nuz1, nuz2);
408  }
409 
410  // Set up to use the selected neutrino solution
411  if (!nuz) {
412  ev.met().setZ(nuz1);
413  } else {
414  ev.met().setZ(nuz2);
415  }
416 
417  // Note: We have set the neutrino Pz, but we haven't set the neutrino energy.
418  // Remember that originally the neutrino energy was equal to
419  // sqrt(nu_px*nu_px + nu_py*nu_py). Calculating the invariant mass squared
420  // for the neutrino will give negative mass squared.
421  // Therefore we need to adjust (increase) the neutrino energy in order to
422  // make its mass remain zero.
423 
424  adjust_e_for_mass(ev.met(), 0);
425 
426  // Find the unfit top mass as the average of the two sides.
427  double umtlep = Top_Decaykin::lept(ev).m();
428  utmass = (umthad + umtlep) / 2;
429 
430  // Trace, if requested.
431  if (_args.print_event_flag()) {
432  cout << "Top_Fit::fit_one_perm() : Before fit:\n";
434  }
435 
436  // Maybe reject this event.
437  if (_hadw_mass > 0 && test_for_bad_masses(ev, _args, umwhad, umthad, umtlep)) {
438  cout << "Top_Fit: bad mass comb.\n";
439  return -999;
440  }
441 
442  // Do the fit.
443  double chisq = _constrainer.constrain(ev, mt, sigmt, pullx, pully);
444 
445  // Trace, if requested.
446  if (_args.print_event_flag()) {
447  cout << "Top_Fit::fit_one_perm() : After fit:\n";
448  cout << "chisq: " << chisq << " mt: " << mt << " ";
450  }
451 
452  // Done!
453  return chisq;
454  }

References _args, _constrainer, _hadw_mass, _lepw_mass, hitfit::adjust_e_for_mass(), hitfit::Constrained_Top::constrain(), gather_cfg::cout, hitfit::Top_Decaykin::dump_ev(), ev, hitfit::Top_Decaykin::hadt(), hitfit::Top_Decaykin::hadw(), hitfit::Top_Decaykin::lept(), TtSemiLepEvtBuilder_cfi::mt, hitfit::Top_Fit_Args::print_event_flag(), TtSemiLepEvtBuilder_cfi::sigmt, 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().

Friends And Related Function Documentation

◆ operator<<

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

559  {
560  return s << fitter._constrainer;
561  }

Member Data Documentation

◆ _args

const Top_Fit_Args hitfit::Top_Fit::_args
private

Definition at line 312 of file Top_Fit.h.

Referenced by args(), fit(), and fit_one_perm().

◆ _constrainer

Constrained_Top hitfit::Top_Fit::_constrainer
private

Definition at line 313 of file Top_Fit.h.

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

◆ _hadw_mass

double hitfit::Top_Fit::_hadw_mass
private

Definition at line 315 of file Top_Fit.h.

Referenced by fit_one_perm().

◆ _lepw_mass

double hitfit::Top_Fit::_lepw_mass
private

Definition at line 314 of file Top_Fit.h.

Referenced by fit_one_perm().

hitfit::Column_Vector
CLHEP::HepVector Column_Vector
Definition: matutil.h:63
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
hitfit::Top_Decaykin::solve_nu_tmass
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:72
hitfit::hadb_label
Definition: Lepjets_Event_Jet.h:57
hitfit::Top_Decaykin::hadw
static Fourvec hadw(const Lepjets_Event &ev)
Sum up the appropriate four-momenta to find the hadronic boson.
Definition: Top_Decaykin.cc:282
hitfit::lepb_label
Definition: Lepjets_Event_Jet.h:56
gather_cfg.cout
cout
Definition: gather_cfg.py:144
hitfit::Top_Fit::_args
const Top_Fit_Args _args
Definition: Top_Fit.h:312
cms::cuda::assert
assert(be >=bs)
hitfit::Top_Fit::_hadw_mass
double _hadw_mass
Definition: Top_Fit.h:315
hitfit::Top_Decaykin::solve_nu
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....
Definition: Top_Decaykin.cc:177
hitfit::Top_Fit::_lepw_mass
double _lepw_mass
Definition: Top_Fit.h:314
hitfit::hadw1_label
Definition: Lepjets_Event_Jet.h:58
alignCSCRings.s
s
Definition: alignCSCRings.py:92
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
hitfit::n_lists
Definition: Top_Fit.h:61
hitfit::adjust_e_for_mass
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:119
hitfit::Top_Fit_Args::solve_nu_tmass
bool solve_nu_tmass() const
Return the solve_nu_tmass parameter.
Definition: Top_Fit.cc:144
hitfit::Top_Fit_Args::do_higgs_flag
bool do_higgs_flag() const
Return the do_higgs_flag parameter.
Definition: Top_Fit.cc:90
hitfit::Top_Fit_Args::nkeep
int nkeep() const
Return the nkeep parameter.
Definition: Top_Fit.cc:135
TtSemiLepEvtBuilder_cfi.sigmt
sigmt
Definition: TtSemiLepEvtBuilder_cfi.py:48
hitfit::Top_Fit::args
const Top_Fit_Args & args() const
Return a constant reference to the fit arguments.
Definition: Top_Fit.cc:563
hitfit::Constrained_Top::constrain
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,...
Definition: Constrained_Top.cc:259
hitfit::Top_Fit_Args::print_event_flag
bool print_event_flag() const
Return the print_event_flag parameter.
Definition: Top_Fit.cc:81
res
Definition: Electron.h:6
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
hitfit::higgs_label
Definition: Lepjets_Event_Jet.h:60
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
hitfit::Top_Decaykin::lept
static Fourvec lept(const Lepjets_Event &ev)
Sum up the appropriate four-momenta to find the leptonic top quark.
Definition: Top_Decaykin.cc:353
TtSemiLepEvtBuilder_cfi.mt
mt
Definition: TtSemiLepEvtBuilder_cfi.py:47
hitfit::Top_Decaykin::hadt
static Fourvec hadt(const Lepjets_Event &ev)
Sum up the appropriate four-momenta to find the hadronic top quark.
Definition: Top_Decaykin.cc:339
hitfit::Top_Fit::fit_one_perm
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:355
hitfit::Top_Fit::_constrainer
Constrained_Top _constrainer
Definition: Top_Fit.h:313
hitfit::Top_Decaykin::dump_ev
static std::ostream & dump_ev(std::ostream &s, const Lepjets_Event &ev)
Print the kinematic information for an event.
Definition: Top_Decaykin.cc:367
hitfit::noperm_list
Definition: Top_Fit.h:55
hitfit::Top_Fit_Args::constrainer_args
const Constrained_Top_Args & constrainer_args() const
Definition: Top_Fit.cc:153
hitfit::isr_label
Definition: Lepjets_Event_Jet.h:55