00001
00002
00003
00004
00020 #ifndef HITFIT_RUNHITFIT_H
00021 #define HITFIT_RUNHITFIT_H
00022
00023 #include <algorithm>
00024
00025 #include "TopQuarkAnalysis/TopHitFit/interface/Defaults_Text.h"
00026 #include "TopQuarkAnalysis/TopHitFit/interface/LeptonTranslatorBase.h"
00027 #include "TopQuarkAnalysis/TopHitFit/interface/JetTranslatorBase.h"
00028 #include "TopQuarkAnalysis/TopHitFit/interface/METTranslatorBase.h"
00029 #include "TopQuarkAnalysis/TopHitFit/interface/Fit_Result.h"
00030 #include "TopQuarkAnalysis/TopHitFit/interface/Lepjets_Event.h"
00031 #include "TopQuarkAnalysis/TopHitFit/interface/Top_Fit.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 namespace hitfit{
00067
00153 template <class AElectron,
00154 class AMuon,
00155 class AJet,
00156 class AMet>
00157 class RunHitFit {
00158
00159 private:
00160
00164 LeptonTranslatorBase<AElectron> _ElectronTranslator;
00165
00169 LeptonTranslatorBase<AMuon> _MuonTranslator;
00170
00174 JetTranslatorBase<AJet> _JetTranslator;
00175
00179 METTranslatorBase<AMet> _METTranslator;
00180
00186 Lepjets_Event _event;
00187
00202 std::vector<AJet> _jets;
00203
00213 bool _jetObjRes;
00214
00218 Top_Fit _Top_Fit;
00219
00223 std::vector<Lepjets_Event> _Unfitted_Events;
00224
00228 std::vector<Fit_Result> _Fit_Results;
00229
00230 public:
00231
00259 RunHitFit(const LeptonTranslatorBase<AElectron>& el,
00260 const LeptonTranslatorBase<AMuon>& mu,
00261 const JetTranslatorBase<AJet>& jet,
00262 const METTranslatorBase<AMet>& met,
00263 const std::string default_file,
00264 double lepw_mass,
00265 double hadw_mass,
00266 double top_mass):
00267 _ElectronTranslator(el),
00268 _MuonTranslator(mu),
00269 _JetTranslator(jet),
00270 _METTranslator(met),
00271 _event(0,0),
00272 _jetObjRes(false),
00273 _Top_Fit(Top_Fit_Args(Defaults_Text(default_file)),lepw_mass,hadw_mass,top_mass)
00274 {
00275 }
00276
00280 ~RunHitFit()
00281 {
00282 }
00283
00287 void
00288 clear()
00289 {
00290 _event = Lepjets_Event(0,0);
00291 _jets.clear();
00292 _jetObjRes = false;
00293 _Unfitted_Events.clear();
00294 _Fit_Results.clear();
00295 }
00296
00306 void
00307 AddLepton(const AElectron& electron,
00308 bool useObjRes = false)
00309 {
00310 _event.add_lep(_ElectronTranslator(electron,electron_label,useObjRes));
00311 return;
00312 }
00313
00323 void
00324 AddLepton(const AMuon& muon,
00325 bool useObjRes = false)
00326 {
00327 _event.add_lep(_MuonTranslator(muon,muon_label,useObjRes));
00328 return;
00329 }
00330
00351 void
00352 AddJet(const AJet& jet,
00353 bool useObjRes = false)
00354 {
00355
00356
00357
00358 if (_jets.empty()) {
00359 _jetObjRes = useObjRes;
00360 }
00361
00362 if (_jets.size() < MAX_HITFIT_JET) {
00363 _jets.push_back(jet);
00364 }
00365 return;
00366 }
00367
00371 void
00372 SetMet(const AMet& met,
00373 bool useObjRes = false)
00374 {
00375 _event.met() = _METTranslator(met,useObjRes);
00376 _event.kt_res() = _METTranslator.KtResolution(met,useObjRes);
00377 return;
00378 }
00379
00385 void
00386 SetKtResolution(const Resolution& res)
00387 {
00388 _event.kt_res() = res;
00389 return;
00390 }
00391
00398 void
00399 SetMETResolution(const Resolution& res)
00400 {
00401 SetKtResolution(res);
00402 return;
00403 }
00404
00408 const Top_Fit&
00409 GetTopFit() const
00410 {
00411 return _Top_Fit;
00412 }
00413
00418 std::vector<Fit_Result>::size_type
00419 FitAllPermutation()
00420 {
00421
00422 if (_jets.size() < MIN_HITFIT_JET) {
00423
00424
00425 return 0;
00426 }
00427
00428 if (_jets.size() > MAX_HITFIT_JET) {
00429
00430
00431 return 0;
00432 }
00433
00434 _Unfitted_Events.clear();
00435 _Fit_Results.clear();
00436
00437
00438 std::vector<int> jet_types (_jets.size(), unknown_label);
00439 jet_types[0] = lepb_label;
00440 jet_types[1] = hadb_label;
00441 jet_types[2] = hadw1_label;
00442 jet_types[3] = hadw1_label;
00443
00444 if (_Top_Fit.args().do_higgs_flag() && _jets.size() >= MIN_HITFIT_TTH) {
00445 jet_types[4] = higgs_label;
00446 jet_types[5] = higgs_label;
00447 }
00448
00449 std::stable_sort(jet_types.begin(),jet_types.end());
00450
00451 do {
00452
00453
00454 for (int nusol = 0 ; nusol != 2 ; nusol++) {
00455
00456 bool nuz = bool(nusol);
00457
00458
00459 Lepjets_Event fev = _event;
00460
00461
00462
00463
00464
00465
00466
00467 for (size_t j = 0 ; j != _jets.size(); j++) {
00468 fev.add_jet(_JetTranslator(_jets[j],jet_types[j],_jetObjRes));
00469 }
00470
00471
00472
00473 Lepjets_Event ufev = fev;
00474
00475
00476 fev.set_jet_types(jet_types);
00477 ufev.set_jet_types(jet_types);
00478
00479
00480 _Unfitted_Events.push_back(ufev);
00481
00482
00483 double umwhad;
00484 double utmass;
00485 double mt;
00486 double sigmt;
00487 Column_Vector pullx;
00488 Column_Vector pully;
00489
00490
00491 double chisq= _Top_Fit.fit_one_perm(fev,
00492 nuz,
00493 umwhad,
00494 utmass,
00495 mt,
00496 sigmt,
00497 pullx,
00498 pully);
00499
00500 _Fit_Results.push_back(Fit_Result(chisq,
00501 fev,
00502 pullx,
00503 pully,
00504 umwhad,
00505 utmass,
00506 mt,
00507 sigmt));
00508
00509 }
00510
00511 } while (std::next_permutation (jet_types.begin(), jet_types.end()));
00512
00513
00514 return _Fit_Results.size();
00515
00516 }
00517
00521 std::vector<Lepjets_Event>
00522 GetUnfittedEvent()
00523 {
00524 return _Unfitted_Events;
00525 }
00526
00531 std::vector<Fit_Result>
00532 GetFitAllPermutation()
00533 {
00534 return _Fit_Results;
00535 }
00536
00540 static const unsigned int MIN_HITFIT_JET = 4 ;
00541
00545 static const unsigned int MIN_HITFIT_TTH = 6 ;
00546
00550 static const unsigned int MAX_HITFIT_JET = 8 ;
00551
00555 static const unsigned int MAX_HITFIT = 1680;
00556
00560 static const unsigned int MAX_HITFIT_VAR = 32 ;
00561
00562
00563 };
00564
00565 }
00566
00567 #endif // #ifndef RUNHITFIT_H