CMS 3D CMS Logo

RunHitFit.h
Go to the documentation of this file.
1 //
2 //
3 
19 #ifndef HITFIT_RUNHITFIT_H
20 #define HITFIT_RUNHITFIT_H
21 
22 #include <algorithm>
23 
31 
32 // Explanation about the MIN/MAX definitions:
33 //
34 // For a given number of jets, there is a corresponding number of
35 // permutations how to assign each jet in the event to the corresponding
36 // parton-level jet.
37 // The number of permutations up to 10 jets are given below for Tt and
38 // TtH events.
39 //
40 // NJet Npermutation (Tt) Npermutation (TtH)
41 // 4 24 --
42 // 5 120 --
43 // 6 360 360
44 // 7 840 2520
45 // 8 1680 10080
46 // 9 3024 30240
47 // 10 5040 75600
48 //
49 // The formulas for the number of permutations for Tt and TtH events
50 // given n jets in the event are
51 //
52 // n!
53 // Tt: -------- ; n >= 4
54 // (n - 4)!
55 //
56 // n!
57 // TtH: ---------- ; n >= 6
58 // (n - 6)!2!
59 //
60 // The current MAX settings are chosen for a maximum number of 8 jets
61 // Increasing this limit should be done with caution, as it will
62 // increase the number of permutations rapidly.
63 //
64 
65 namespace hitfit {
66 
152  template <class AElectron, class AMuon, class AJet, class AMet>
153  class RunHitFit {
154  private:
159 
164 
169 
174 
181 
196  std::vector<AJet> _jets;
197 
208 
213 
217  std::vector<Lepjets_Event> _Unfitted_Events;
218 
222  std::vector<Fit_Result> _Fit_Results;
223 
224  public:
256  const std::string default_file,
257  double lepw_mass,
258  double hadw_mass,
259  double top_mass)
260  : _ElectronTranslator(el),
264  _event(0, 0),
265  _jetObjRes(false),
266  _Top_Fit(Top_Fit_Args(Defaults_Text(default_file)), lepw_mass, hadw_mass, top_mass) {}
267 
272 
276  void clear() {
277  _event = Lepjets_Event(0, 0);
278  _jets.clear();
279  _jetObjRes = false;
280  _Unfitted_Events.clear();
281  _Fit_Results.clear();
282  }
283 
293  void AddLepton(const AElectron& electron, bool useObjRes = false) {
295  return;
296  }
297 
307  void AddLepton(const AMuon& muon, bool useObjRes = false) {
309  return;
310  }
311 
332  void AddJet(const AJet& jet, bool useObjRes = false) {
333  // Only set flag when adding the first jet
334  // the additional jets then WILL be treated in the
335  // same way like the first jet.
336  if (_jets.empty()) {
337  _jetObjRes = useObjRes;
338  }
339 
340  if (_jets.size() < MAX_HITFIT_JET) {
341  _jets.push_back(jet);
342  }
343  return;
344  }
345 
349  void SetMet(const AMet& met, bool useObjRes = false) {
350  _event.met() = _METTranslator(met, useObjRes);
351  _event.kt_res() = _METTranslator.KtResolution(met, useObjRes);
352  return;
353  }
354 
361  _event.kt_res() = res;
362  return;
363  }
364 
373  return;
374  }
375 
379  const Top_Fit& GetTopFit() const { return _Top_Fit; }
380 
386  if (_jets.size() < MIN_HITFIT_JET) {
387  // For ttbar lepton+jets, a minimum of MIN_HITFIT_JETS jets
388  // is required
389  return 0;
390  }
391 
392  if (_jets.size() > MAX_HITFIT_JET) {
393  // Restrict the maximum number of jets in the fit
394  // to prevent loop overflow
395  return 0;
396  }
397 
398  _Unfitted_Events.clear();
399  _Fit_Results.clear();
400 
401  // Prepare the array of jet types for permutation
402  std::vector<int> jet_types(_jets.size(), unknown_label);
403  jet_types[0] = lepb_label;
404  jet_types[1] = hadb_label;
405  jet_types[2] = hadw1_label;
406  jet_types[3] = hadw1_label;
407 
408  if (_Top_Fit.args().do_higgs_flag() && _jets.size() >= MIN_HITFIT_TTH) {
409  jet_types[4] = higgs_label;
410  jet_types[5] = higgs_label;
411  }
412 
413  std::stable_sort(jet_types.begin(), jet_types.end());
414 
415  do {
416  // begin loop over all jet permutation
417  for (int nusol = 0; nusol != 2; nusol++) {
418  // loop over two neutrino solution
419  bool nuz = bool(nusol);
420 
421  // Copy the event
422  Lepjets_Event fev = _event;
423 
424  // Add jets into the event, with the assumed type
425  // in accord with the permutation.
426  // The translator _JetTranslator will correctly
427  // return object of Lepjets_Event_Jet with
428  // jet energy correction applied in accord with
429  // the assumed jet type (b or light).
430  for (size_t j = 0; j != _jets.size(); j++) {
431  fev.add_jet(_JetTranslator(_jets[j], jet_types[j], _jetObjRes));
432  }
433 
434  // Clone fev (intended to be fitted event)
435  // to ufev (intended to be unfitted event)
436  Lepjets_Event ufev = fev;
437 
438  // Set jet types.
439  fev.set_jet_types(jet_types);
440  ufev.set_jet_types(jet_types);
441 
442  // Store the unfitted event
443  _Unfitted_Events.push_back(ufev);
444 
445  // Prepare the placeholder for various kinematic quantities
446  double umwhad;
447  double utmass;
448  double mt;
449  double sigmt;
450  Column_Vector pullx;
451  Column_Vector pully;
452 
453  // Do the fit
454  double chisq = _Top_Fit.fit_one_perm(fev, nuz, umwhad, utmass, mt, sigmt, pullx, pully);
455  // Store output of the fit
456  _Fit_Results.push_back(Fit_Result(chisq, fev, pullx, pully, umwhad, utmass, mt, sigmt));
457 
458  } // end loop over two neutrino solution
459 
460  } while (std::next_permutation(jet_types.begin(), jet_types.end()));
461  // end loop over all jet permutations
462 
463  return _Fit_Results.size();
464  }
465 
469  std::vector<Lepjets_Event> GetUnfittedEvent() { return _Unfitted_Events; }
470 
475  std::vector<Fit_Result> GetFitAllPermutation() { return _Fit_Results; }
476 
480  static const unsigned int MIN_HITFIT_JET = 4;
481 
485  static const unsigned int MIN_HITFIT_TTH = 6;
486 
490  static const unsigned int MAX_HITFIT_JET = 8;
491 
495  static const unsigned int MAX_HITFIT = 1680;
496 
500  static const unsigned int MAX_HITFIT_VAR = 32;
501  };
502 
503 } // namespace hitfit
504 
505 #endif // #ifndef RUNHITFIT_H
hitfit::RunHitFit::_jetObjRes
bool _jetObjRes
Definition: RunHitFit.h:207
hitfit::RunHitFit
Template class of experiment-independent interface to HitFit. This class is intended to be used insid...
Definition: RunHitFit.h:153
hitfit::Column_Vector
CLHEP::HepVector Column_Vector
Definition: matutil.h:63
hitfit::RunHitFit::_METTranslator
METTranslatorBase< AMet > _METTranslator
Definition: RunHitFit.h:173
electrons_cff.bool
bool
Definition: electrons_cff.py:372
hitfit
Definition: Base_Constrainer.h:43
hitfit::hadb_label
Definition: Lepjets_Event_Jet.h:57
hitfit::RunHitFit::SetKtResolution
void SetKtResolution(const Resolution &res)
Set the resolution of the internal event.
Definition: RunHitFit.h:360
hitfit::RunHitFit::clear
void clear()
Clear the internal event, fit results, and jets.
Definition: RunHitFit.h:276
hitfit::RunHitFit::MIN_HITFIT_JET
static const unsigned int MIN_HITFIT_JET
Definition: RunHitFit.h:480
funct::false
false
Definition: Factorize.h:34
hitfit::lepb_label
Definition: Lepjets_Event_Jet.h:56
muon
Definition: MuonCocktails.h:17
hitfit::RunHitFit::MAX_HITFIT_VAR
static const unsigned int MAX_HITFIT_VAR
Definition: RunHitFit.h:500
hitfit::RunHitFit::GetTopFit
const Top_Fit & GetTopFit() const
Return a constant reference to the underlying Top_Fit object.
Definition: RunHitFit.h:379
amptDefaultParameters_cff.mu
mu
Definition: amptDefaultParameters_cff.py:16
hitfit::Top_Fit_Args
Hold on to parameters for the Top_Fit class.
Definition: Top_Fit.h:69
hitfit::RunHitFit::_Unfitted_Events
std::vector< Lepjets_Event > _Unfitted_Events
Definition: RunHitFit.h:217
hitfit::Fit_Result
Hold the result of one kinematic fit.
Definition: Fit_Result.h:50
hitfit::RunHitFit::AddJet
void AddJet(const AJet &jet, bool useObjRes=false)
Add one jet into the internal event. This function will do nothing if the internal event has already ...
Definition: RunHitFit.h:332
Fit_Result.h
Hold the result of one kinematic fit.
hitfit::RunHitFit::_event
Lepjets_Event _event
Definition: RunHitFit.h:180
hitfit::METTranslatorBase
Template class of function object to translate missing transverse energy physics object to HitFit's F...
Definition: METTranslatorBase.h:49
hitfit::RunHitFit::GetFitAllPermutation
std::vector< Fit_Result > GetFitAllPermutation()
Return the results of fitting all permutations of the internal event.
Definition: RunHitFit.h:475
Top_Fit.h
Handle and fit jet permutations of an event. This is the primary interface between user's Lepjets_Eve...
hitfit::RunHitFit::_jets
std::vector< AJet > _jets
Definition: RunHitFit.h:196
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
hitfit::hadw1_label
Definition: Lepjets_Event_Jet.h:58
Lepjets_Event.h
Represent a simple event consisting of lepton(s) and jet(s).
hitfit::Lepjets_Event::met
Fourvec & met()
Return a reference to the missing transverse energy.
Definition: Lepjets_Event.cc:182
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
METTranslatorBase.h
Template class of function object to translate missing transverse energy object to HitFit's Fourvec o...
hitfit::RunHitFit::SetMETResolution
void SetMETResolution(const Resolution &res)
Set the resolution of the internal event.
Definition: RunHitFit.h:371
hitfit::Lepjets_Event
Represent a simple event consisting of lepton(s) and jet(s). An instance of this class holds a list o...
Definition: Lepjets_Event.h:62
LeptonTranslatorBase.h
Template class of function object to translate lepton physics object to HitFit's Lepjets_Event_Lep ob...
hitfit::Defaults_Text
A lightweight implementation of the Defaults interface that uses simple ASCII text files.
Definition: Defaults_Text.h:117
metsig::electron
Definition: SignAlgoResolutions.h:48
hitfit::Top_Fit_Args::do_higgs_flag
bool do_higgs_flag() const
Return the do_higgs_flag parameter.
Definition: Top_Fit.cc:90
hitfit::RunHitFit::SetMet
void SetMet(const AMet &met, bool useObjRes=false)
Set the missing transverse energy of the internal event.
Definition: RunHitFit.h:349
JetTranslatorBase.h
Template class of function object to translate jet physics object to HitFit's Lepjets_Event_Jet objec...
hitfit::RunHitFit::_Fit_Results
std::vector< Fit_Result > _Fit_Results
Definition: RunHitFit.h:222
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
hitfit::Lepjets_Event::add_jet
void add_jet(const Lepjets_Event_Jet &jet)
Add a new jet to the event.
Definition: Lepjets_Event.cc:361
hitfit::Lepjets_Event::set_jet_types
bool set_jet_types(const std::vector< int > &)
Set the jet types in the event.
Definition: Lepjets_Event.cc:420
hitfit::RunHitFit::MIN_HITFIT_TTH
static const unsigned int MIN_HITFIT_TTH
Definition: RunHitFit.h:485
hitfit::RunHitFit::MAX_HITFIT
static const unsigned int MAX_HITFIT
Definition: RunHitFit.h:495
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::LeptonTranslatorBase< AElectron >
hitfit::RunHitFit::AddLepton
void AddLepton(const AElectron &electron, bool useObjRes=false)
Add one electron into the internal event.
Definition: RunHitFit.h:293
res
Definition: Electron.h:6
hitfit::Resolution
Definition: Resolution.h:98
hitfit::JetTranslatorBase
Template class of function object to translate jet physics object to HitFit's Lepjets_Event_Jet objec...
Definition: JetTranslatorBase.h:44
hitfit::RunHitFit::GetUnfittedEvent
std::vector< Lepjets_Event > GetUnfittedEvent()
Return the unfitted events for all permutations.
Definition: RunHitFit.h:469
hitfit::RunHitFit::_MuonTranslator
LeptonTranslatorBase< AMuon > _MuonTranslator
Definition: RunHitFit.h:163
hitfit::RunHitFit::~RunHitFit
~RunHitFit()
Destructor.
Definition: RunHitFit.h:271
hitfit::Top_Fit
Handle and fit jet permutations of an event. This is the primary interface between user's Lepjets_Eve...
Definition: Top_Fit.h:232
Defaults_Text.h
Define a concrete interface for getting parameter settings from an ASCII text file.
hitfit::higgs_label
Definition: Lepjets_Event_Jet.h:60
hitfit::electron_label
Definition: Lepjets_Event_Lep.h:53
metsig::jet
Definition: SignAlgoResolutions.h:47
hitfit::RunHitFit::MAX_HITFIT_JET
static const unsigned int MAX_HITFIT_JET
Definition: RunHitFit.h:490
hitfit::muon_label
Definition: Lepjets_Event_Lep.h:54
hitfit::RunHitFit::_ElectronTranslator
LeptonTranslatorBase< AElectron > _ElectronTranslator
Definition: RunHitFit.h:158
TtSemiLepEvtBuilder_cfi.mt
mt
Definition: TtSemiLepEvtBuilder_cfi.py:47
hitfit::RunHitFit::RunHitFit
RunHitFit(const LeptonTranslatorBase< AElectron > &el, const LeptonTranslatorBase< AMuon > &mu, const JetTranslatorBase< AJet > &jet, const METTranslatorBase< AMet > &met, const std::string default_file, double lepw_mass, double hadw_mass, double top_mass)
Constructor.
Definition: RunHitFit.h:252
hitfit::Lepjets_Event::kt_res
Resolution & kt_res()
Return a reference to the resolution.
Definition: Lepjets_Event.cc:204
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
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hitfit::RunHitFit::_Top_Fit
Top_Fit _Top_Fit
Definition: RunHitFit.h:212
hitfit::RunHitFit::_JetTranslator
JetTranslatorBase< AJet > _JetTranslator
Definition: RunHitFit.h:168
hitfit::Lepjets_Event::add_lep
void add_lep(const Lepjets_Event_Lep &lep)
Add a new lepton to the event.
Definition: Lepjets_Event.cc:350
hitfit::unknown_label
Definition: Lepjets_Event_Jet.h:61
hitfit::RunHitFit::FitAllPermutation
std::vector< Fit_Result >::size_type FitAllPermutation()
Fit all permutations of the internal event. Returns the number of permutations.
Definition: RunHitFit.h:385
hitfit::RunHitFit::AddLepton
void AddLepton(const AMuon &muon, bool useObjRes=false)
Add one muon into the internal event.
Definition: RunHitFit.h:307