4 #include "Kappa/DataFormats/interface/Kappa.h"
6 #include "Artus/Core/interface/ProducerBase.h"
7 #include "Artus/Utility/interface/Utility.h"
9 #include "HiggsAnalysis/KITHiggsToTauTau/interface/HttTypes.h"
10 #include "HiggsAnalysis/KITHiggsToTauTau/interface/Utility/RecoilCorrector.h"
11 #include "HiggsAnalysis/KITHiggsToTauTau/interface/Utility/MEtSys.h"
13 #include <boost/regex.hpp>
32 TMet product_type::*metMemberCorrected,
33 std::vector<float> product_type::*metCorrections,
42 GetRecoilCorrectorFile(GetRecoilCorrectorFile),
43 GetMetShiftCorrectorFile(GetMetShiftCorrectorFile),
44 GetUpdateMetWithCorrectedLeptons(GetUpdateMetWithCorrectedLeptons)
48 virtual void Init(setting_type
const& settings, metadata_type& metadata)
override
50 ProducerBase<HttTypes>::Init(settings, metadata);
54 if ((settings.GetMetSysType() != 0) || (settings.GetMetSysShift() != 0))
58 if (settings.GetMetSysType() == 1)
62 else if (settings.GetMetSysType() == 2)
69 LOG(FATAL) <<
"Invalid HttSettings::MetSysType option";
72 if (settings.GetMetSysShift() > 0)
83 if (boost::regex_search(settings.GetNickname(),
boost::regex(
"DY.?JetsToLL|W.?JetsToLNu|HToTauTau", boost::regex::extended)))
87 else if (boost::regex_search(settings.GetNickname(),
boost::regex(
"TT", boost::regex::extended)))
95 m_isWJets = boost::regex_search(settings.GetNickname(),
boost::regex(
"W.?JetsToLNu", boost::regex::icase | boost::regex::extended));
97 m_doMetSys = ((settings.GetMetSysType() != 0) || (settings.GetMetSysShift() != 0));
99 if(settings.GetMetCorrectionMethod() ==
"quantileMapping")
101 else if(settings.GetMetCorrectionMethod() ==
"meanResolution")
106 LOG(FATAL) <<
"Invalid MetCorrectionMethod option. Available are 'quantileMapping' and 'meanResolution'";
109 if (settings.GetMetUncertaintyShift())
115 virtual void Produce(event_type
const& event, product_type & product,
116 setting_type
const& settings, metadata_type
const& metadata)
const override
127 float metResolution = std::sqrt(metEnergy * metEnergy - metX * metX - metY * metY);
133 if ((settings.*GetUpdateMetWithCorrectedLeptons)())
136 for (std::vector<std::shared_ptr<KElectron> >::iterator electron = product.m_correctedElectrons.begin();
137 electron != product.m_correctedElectrons.end(); ++electron)
140 if (Utility::ApproxEqual(electron->get()->p4,
const_cast<KLepton*
>(product.m_originalLeptons[electron->get()])->p4))
143 float eX = electron->get()->p4.Px() -
const_cast<KLepton*
>(product.m_originalLeptons[electron->get()])->p4.Px();
144 float eY = electron->get()->p4.Py() -
const_cast<KLepton*
>(product.m_originalLeptons[electron->get()])->p4.Py();
151 for (std::vector<std::shared_ptr<KMuon> >::iterator muon = product.m_correctedMuons.begin();
152 muon != product.m_correctedMuons.end(); ++muon)
155 if (Utility::ApproxEqual(muon->get()->p4,
const_cast<KLepton*
>(product.m_originalLeptons[muon->get()])->p4))
158 float eX = muon->get()->p4.Px() -
const_cast<KLepton*
>(product.m_originalLeptons[muon->get()])->p4.Px();
159 float eY = muon->get()->p4.Py() -
const_cast<KLepton*
>(product.m_originalLeptons[muon->get()])->p4.Py();
166 for (std::vector<std::shared_ptr<KTau> >::iterator tau = product.m_correctedTaus.begin();
167 tau != product.m_correctedTaus.end(); ++tau)
170 if (Utility::ApproxEqual(tau->get()->p4,
const_cast<KLepton*
>(product.m_originalLeptons[tau->get()])->p4))
173 float eX = tau->get()->p4.Px() -
const_cast<KLepton*
>(product.m_originalLeptons[tau->get()])->p4.Px();
174 float eY = tau->get()->p4.Py() -
const_cast<KLepton*
>(product.m_originalLeptons[tau->get()])->p4.Py();
182 int nJets30 = product_type::GetNJetsAbovePtThreshold(product.m_validJets, 30.0);
196 for (KGenParticles::const_iterator genParticle = event.m_genParticles->begin();
197 genParticle !=
event.m_genParticles->end(); ++genParticle)
199 int pdgId = std::abs(genParticle->pdgId);
201 if ( (pdgId >= DefaultValues::pdgIdElectron && pdgId <= DefaultValues::pdgIdNuTau && genParticle->fromHardProcessFinalState()) ||
202 (genParticle->isDirectHardProcessTauDecayProduct()) )
204 genPx += genParticle->p4.Px();
205 genPy += genParticle->p4.Py();
207 if ( !(pdgId == DefaultValues::pdgIdNuE || pdgId == DefaultValues::pdgIdNuMu || pdgId == DefaultValues::pdgIdNuTau) )
209 visPx += genParticle->p4.Px();
210 visPy += genParticle->p4.Py();
221 float correctedMetX, correctedMetY;
255 std::sqrt(metResolution * metResolution + correctedMetX * correctedMetX + correctedMetY * correctedMetY));
261 else if ((settings.*GetUpdateMetWithCorrectedLeptons)())
267 std::sqrt(metResolution * metResolution + metX * metX + metY * metY));
273 else if (settings.GetMetUncertaintyShift())
289 float correctedMetShiftX, correctedMetShiftY;
307 std::sqrt(metResolution * metResolution + correctedMetShiftX * correctedMetShiftX + correctedMetShiftY * correctedMetShiftY));
319 std::string (setting_type::*GetRecoilCorrectorFile)(void)
const;
320 std::string (setting_type::*GetMetShiftCorrectorFile)(void)
const;
330 bool (setting_type::*GetUpdateMetWithCorrectedLeptons)(void)
const;
343 virtual void Init(setting_type
const& settings, metadata_type& metadata)
override;
354 virtual void Init(setting_type
const& settings, metadata_type& metadata)
override;
MEtSys * m_metShiftCorrector
Definition: MetCorrectors.h:322
CorrectionMethod m_correctionMethod
Definition: MetCorrectors.h:328
std::string(setting_type::* GetRecoilCorrectorFile)(void) const
Definition: MetCorrectors.h:319
Definition: MetCorrectors.h:29
virtual void Init(setting_type const &settings, metadata_type &metadata) override
Definition: MetCorrectors.cc:18
MetCorrector()
Definition: MetCorrectors.cc:7
virtual void Init(setting_type const &settings, metadata_type &metadata) override
Definition: MetCorrectors.h:48
int energy
Definition: samples_run2_2015.py:14
void Correct(float MetPx, float MetPy, float genZPx, float genZPy, float diLepPx, float diLepPy, int njets, float &MetCorrPx, float &MetCorrPy)
Definition: RecoilCorrector.cc:214
virtual std::string GetProducerId() const override
Definition: MetCorrectors.cc:44
virtual std::string GetProducerId() const override
Definition: MetCorrectors.cc:104
MetCorrectorBase(TMet *product_type::*metMemberUncorrected, TMet product_type::*metMemberCorrected, std::vector< float > product_type::*metCorrections, std::string(setting_type::*GetRecoilCorrectorFile)(void) const, std::string(setting_type::*GetMetShiftCorrectorFile)(void) const, bool(setting_type::*GetUpdateMetWithCorrectedLeptons)(void) const )
Definition: MetCorrectors.h:31
virtual void Produce(event_type const &event, product_type &product, setting_type const &settings, metadata_type const &metadata) const override
Definition: MetCorrectors.h:115
TMet product_type::* m_metMemberCorrected
Definition: MetCorrectors.h:317
bool(setting_type::* GetUpdateMetWithCorrectedLeptons)(void) const
Definition: MetCorrectors.h:330
Definition: MetCorrectors.h:29
bool m_doMetSys
Definition: MetCorrectors.h:327
TMet *product_type::* m_metMemberUncorrected
Definition: MetCorrectors.h:316
Corrector for (PF) MET.
Definition: MetCorrectors.h:339
ProcessType
Definition: MEtSys.h:70
RecoilCorrector * m_recoilCorrector
Definition: MetCorrectors.h:321
bool m_correctGlobalMet
Definition: MetCorrectors.h:329
MEtSys::SysShift m_sysShift
Definition: MetCorrectors.h:325
SysType
Definition: MEtSys.h:71
static KMETUncertainty::Type ToMETUncertaintyType(std::string const &metUncertainty)
Definition: HttEnumTypes.h:174
bool m_isWJets
Definition: MetCorrectors.h:326
MEtSys::SysType m_sysType
Definition: MetCorrectors.h:324
CorrectionMethod
Definition: MetCorrectors.h:29
MvaMetCorrector()
Definition: MetCorrectors.cc:50
SysShift
Definition: MEtSys.h:72
std::string(setting_type::* GetMetShiftCorrectorFile)(void) const
Definition: MetCorrectors.h:320
std::vector< float > product_type::* m_metCorrections
Definition: MetCorrectors.h:318
all data types which are used for Htt analyses
Definition: HttTypes.h:27
KMETUncertainty::Type m_metUncertaintyType
Definition: MetCorrectors.h:331
tuple regex
Definition: plot_overtraining.py:51
void CorrectByMeanResolution(float MetPx, float MetPy, float genZPx, float genZPy, float diLepPx, float diLepPy, int njets, float &MetCorrPx, float &MetCorrPy)
Definition: RecoilCorrector.cc:342
MEtSys::ProcessType m_processType
Definition: MetCorrectors.h:323
void ApplyMEtSys(float metPx, float metPy, float genVPx, float genVPy, float visVPx, float visVPy, int njets, int bkgdType, int sysType, int shiftType, float &metShiftPx, float &metShiftPy)
Definition: MEtSys.cc:269
Corrector for MVAMET.
Definition: MetCorrectors.h:350
virtual void Init(setting_type const &settings, metadata_type &metadata) override
Definition: MetCorrectors.cc:61
Definition: RecoilCorrector.h:12
Definition: MetCorrectors.h:29
Corrects the MET created by the MET producer.
Definition: MetCorrectors.h:25