1 #ifndef TtSemiLepHitFitProducer_h
2 #define TtSemiLepHitFitProducer_h
19 template <
typename LeptonCollection>
98 template <
typename LeptonCollection>
100 : jetsToken_(consumes<std::
vector<pat::
Jet> >(cfg.getParameter<edm::
InputTag>(
"jets"))),
101 lepsToken_(consumes<LeptonCollection>(cfg.getParameter<edm::
InputTag>(
"leps"))),
102 metsToken_(consumes<std::
vector<pat::
MET> >(cfg.getParameter<edm::
InputTag>(
"mets"))),
103 maxNJets_(cfg.getParameter<int>(
"maxNJets")),
104 maxNComb_(cfg.getParameter<int>(
"maxNComb")),
105 bTagAlgo_(cfg.getParameter<std::
string>(
"bTagAlgo")),
106 minBTagValueBJet_(cfg.getParameter<double>(
"minBDiscBJets")),
107 maxBTagValueNonBJet_(cfg.getParameter<double>(
"maxBDiscLightJets")),
108 useBTag_(cfg.getParameter<bool>(
"useBTagging")),
109 mW_(cfg.getParameter<double>(
"mW")),
110 mTop_(cfg.getParameter<double>(
"mTop")),
111 jetCorrectionLevel_(cfg.getParameter<std::
string>(
"jetCorrectionLevel")),
112 jes_(cfg.getParameter<double>(
"jes")),
113 jesB_(cfg.getParameter<double>(
"jesB")),
117 hitfitDefault_(cfg.getUntrackedParameter<edm::FileInPath>(
118 std::
string(
"hitfitDefault"),
119 edm::FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/setting/RunHitFitConfiguration.txt")))),
120 hitfitElectronResolution_(cfg.getUntrackedParameter<edm::FileInPath>(
121 std::
string(
"hitfitElectronResolution"),
122 edm::FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafElectronResolution.txt")))),
123 hitfitMuonResolution_(cfg.getUntrackedParameter<edm::FileInPath>(
124 std::
string(
"hitfitMuonResolution"),
125 edm::FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafMuonResolution.txt")))),
126 hitfitUdscJetResolution_(cfg.getUntrackedParameter<edm::FileInPath>(
127 std::
string(
"hitfitUdscJetResolution"),
128 edm::FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafUdscJetResolution.txt")))),
129 hitfitBJetResolution_(cfg.getUntrackedParameter<edm::FileInPath>(
130 std::
string(
"hitfitBJetResolution"),
131 edm::FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafBJetResolution.txt")))),
132 hitfitMETResolution_(cfg.getUntrackedParameter<edm::FileInPath>(
133 std::
string(
"hitfitMETResolution"),
134 edm::FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafKtResolution.txt")))),
138 electronTranslator_(hitfitElectronResolution_.
fullPath()),
139 muonTranslator_(hitfitMuonResolution_.
fullPath()),
141 hitfitUdscJetResolution_.
fullPath(), hitfitBJetResolution_.
fullPath(), jetCorrectionLevel_, jes_, jesB_),
142 metTranslator_(hitfitMETResolution_.
fullPath())
154 <<
"+++++++++++ TtSemiLepHitFitProducer ++++++++++++ \n"
155 <<
" Due to the eta ranges for which resolutions \n"
156 <<
" are provided in \n"
157 <<
" TopQuarkAnalysis/TopHitFit/data/resolution/ \n"
158 <<
" so far, the following cuts are currently \n"
159 <<
" implemented in the TtSemiLepHitFitProducer: \n"
160 <<
" |eta(muons )| <= " << maxEtaMu_ <<
" \n"
161 <<
" |eta(electrons)| <= " <<
maxEtaEle_ <<
" \n"
163 <<
"++++++++++++++++++++++++++++++++++++++++++++++++ \n";
165 produces<std::vector<pat::Particle> >(
"PartonsHadP");
166 produces<std::vector<pat::Particle> >(
"PartonsHadQ");
167 produces<std::vector<pat::Particle> >(
"PartonsHadB");
168 produces<std::vector<pat::Particle> >(
"PartonsLepB");
169 produces<std::vector<pat::Particle> >(
"Leptons");
170 produces<std::vector<pat::Particle> >(
"Neutrinos");
172 produces<std::vector<std::vector<int> > >();
173 produces<std::vector<double> >(
"Chi2");
174 produces<std::vector<double> >(
"Prob");
175 produces<std::vector<double> >(
"MT");
176 produces<std::vector<double> >(
"SigMT");
177 produces<std::vector<int> >(
"Status");
178 produces<int>(
"NumberOfConsideredJets");
181 template <
typename LeptonCollection>
186 template <
typename LeptonCollection>
188 std::unique_ptr<std::vector<pat::Particle> > pPartonsHadP(
new std::vector<pat::Particle>);
189 std::unique_ptr<std::vector<pat::Particle> > pPartonsHadQ(
new std::vector<pat::Particle>);
190 std::unique_ptr<std::vector<pat::Particle> > pPartonsHadB(
new std::vector<pat::Particle>);
191 std::unique_ptr<std::vector<pat::Particle> > pPartonsLepB(
new std::vector<pat::Particle>);
192 std::unique_ptr<std::vector<pat::Particle> > pLeptons(
new std::vector<pat::Particle>);
193 std::unique_ptr<std::vector<pat::Particle> > pNeutrinos(
new std::vector<pat::Particle>);
195 std::unique_ptr<std::vector<std::vector<int> > > pCombi(
new std::vector<std::vector<int> >);
196 std::unique_ptr<std::vector<double> > pChi2(
new std::vector<double>);
197 std::unique_ptr<std::vector<double> > pProb(
new std::vector<double>);
198 std::unique_ptr<std::vector<double> > pMT(
new std::vector<double>);
199 std::unique_ptr<std::vector<double> > pSigMT(
new std::vector<double>);
200 std::unique_ptr<std::vector<int> > pStatus(
new std::vector<int>);
201 std::unique_ptr<int> pJetsConsidered(
new int);
223 bool foundLepton =
false;
224 if (!leps->empty()) {
225 double maxEtaLep = maxEtaMu_;
226 if (!dynamic_cast<const reco::Muon*>(&((*leps)[0])))
227 maxEtaLep = maxEtaEle_;
228 for (
unsigned iLep = 0; iLep < (*leps).size() && !foundLepton; ++iLep) {
230 HitFit->AddLepton((*leps)[iLep]);
237 unsigned int nJetsFound = 0;
238 for (
unsigned iJet = 0; iJet < (*jets).size() && (int)nJetsFound != maxNJets_; ++iJet) {
239 double jet_eta = (*jets)[iJet].eta();
240 if ((*jets)[iJet].isCaloJet()) {
241 jet_eta = ((
reco::CaloJet*)((*jets)[iJet]).originalObject())->detectorP4().eta();
243 if (
std::abs(jet_eta) <= maxEtaJet_) {
244 HitFit->AddJet((*jets)[iJet]);
248 *pJetsConsidered = nJetsFound;
252 HitFit->SetMet((*mets)[0]);
254 if (!foundLepton || mets->empty() || nJetsFound <
nPartons) {
263 std::vector<int> invalidCombi;
265 invalidCombi.push_back(-1);
266 pCombi->push_back(invalidCombi);
268 pChi2->push_back(-1.);
270 pProb->push_back(-1.);
273 pSigMT->push_back(-1.);
275 pStatus->push_back(-1);
289 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
293 std::list<FitResult> FitResultList;
306 size_t nHitFitJet = 0;
309 std::vector<hitfit::Fit_Result> hitFitResult;
317 nHitFit = HitFit->FitAllPermutation();
324 nHitFitJet = HitFit->GetUnfittedEvent()[0].njets();
327 hitFitResult = HitFit->GetFitAllPermutation();
330 for (
size_t fit = 0;
fit != nHitFit; ++
fit) {
341 std::vector<int> hitCombi(4);
342 for (
size_t jet = 0;
jet != nHitFitJet; ++
jet) {
380 if (hitFitResult[
fit].chisq() > 0
383 && jets->at(hitCombi[TtSemiLepEvtPartons::LightQ]).bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
384 jets->at(hitCombi[TtSemiLepEvtPartons::LightQBar]).bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_ &&
385 jets->at(hitCombi[TtSemiLepEvtPartons::HadB]).bDiscriminator(bTagAlgo_) > minBTagValueBJet_ &&
386 jets->at(hitCombi[TtSemiLepEvtPartons::LepB]).bDiscriminator(bTagAlgo_) > minBTagValueBJet_))) {
389 result.
Chi2 = hitFitResult[
fit].chisq();
390 result.
Prob =
exp(-1.0 * (hitFitResult[
fit].chisq()) / 2.0);
391 result.
MT = hitFitResult[
fit].mt();
392 result.
SigMT = hitFitResult[
fit].sigmt();
406 fittedEvent.
met().x(), fittedEvent.
met().y(), fittedEvent.
met().z(), fittedEvent.
met().t()),
410 FitResultList.push_back(result);
415 FitResultList.sort();
422 if (((
unsigned)FitResultList.size()) < 1) {
430 std::vector<int> invalidCombi;
432 invalidCombi.push_back(-1);
433 pCombi->push_back(invalidCombi);
435 pChi2->push_back(-1.);
437 pProb->push_back(-1.);
440 pSigMT->push_back(-1.);
442 pStatus->push_back(-1);
444 unsigned int iComb = 0;
445 for (
typename std::list<FitResult>::const_iterator
result = FitResultList.begin();
result != FitResultList.end();
447 if (maxNComb_ >= 1 && iComb == (
unsigned int)maxNComb_)
451 pPartonsHadP->push_back(
result->HadP);
452 pPartonsHadQ->push_back(
result->HadQ);
453 pPartonsHadB->push_back(
result->HadB);
454 pPartonsLepB->push_back(
result->LepB);
456 pLeptons->push_back(
result->LepL);
458 pNeutrinos->push_back(
result->LepN);
460 pCombi->push_back(
result->JetCombi);
462 pChi2->push_back(
result->Chi2);
464 pProb->push_back(
result->Prob);
466 pMT->push_back(
result->MT);
467 pSigMT->push_back(
result->SigMT);
469 pStatus->push_back(
result->Status);
484 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
Log< level::Info, true > LogVerbatim
int maxNComb_
maximal number of combinations to be written to the event
double maxEtaEle_
maximum eta value for electrons, needed to limited range in which resolutions are provided ...
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
static const unsigned int nPartons
bool operator<(const FitResult &rhs)
hitfit::JetTranslatorBase< pat::Jet > jetTranslator_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::FileInPath hitfitMETResolution_
Jets made from CaloTowers.
Represent a lepton in an instance of Lepjets_Event class. This class hold the following information: ...
bool getByToken(EDGetToken token, Handle< PROD > &result) const
hitfit::LeptonTranslatorBase< pat::Electron > electronTranslator_
std::vector< int > JetCombi
TtSemiLepHitFitProducer(const edm::ParameterSet &)
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
Exp< T >::type exp(const T &t)
hitfit::LeptonTranslatorBase< pat::Muon > muonTranslator_
Lepjets_Event_Jet & jet(std::vector< Lepjets_Event_Jet >::size_type i)
Return a reference to jet at index position i.
double maxEtaJet_
maximum eta value for jets, needed to limited range in which resolutions are provided ...
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int & type()
Return a reference to the type code.
edm::FileInPath hitfitUdscJetResolution_
void produce(edm::Event &, const edm::EventSetup &) override
edm::FileInPath hitfitMuonResolution_
A class to hold functions to calculate kinematic quantities of interest in events.
bool useBTag_
switch to tell whether to use b-tagging or not
~TtSemiLepHitFitProducer() override
Represent a simple event consisting of lepton(s) and jet(s). An instance of this class holds a list o...
edm::FileInPath hitfitBJetResolution_
Abs< T >::type abs(const T &t)
Template class of function object to translate missing transverse energy object to HitFit's Fourvec o...
A class to represent a jet in an instance of Lepjets_Event class. The class is derived from the Lepje...
int maxNJets_
maximal number of jets (-1 possible to indicate 'all')
Template class of experiment-independent interface to HitFit.
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Template class of experiment-independent interface to HitFit. This class is intended to be used insid...
hitfit::METTranslatorBase< pat::MET > metTranslator_
Template class of function object to translate jet physics object to HitFit's Lepjets_Event_Jet objec...
Fourvec & met()
Return a reference to the missing transverse energy.
Lepjets_Event_Lep & lep(std::vector< Lepjets_Event_Lep >::size_type i)
Return a reference to lepton at index position i.
edm::EDGetTokenT< LeptonCollection > lepsToken_
Template class of function object to translate lepton physics object to HitFit's Lepjets_Event_Lep ob...
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::FileInPath hitfitElectronResolution_
Analysis-level particle class.
std::string jetCorrectionLevel_
jet correction level
Fourvec & p()
Return a reference to the four-momentum.
hitfit::RunHitFit< pat::Electron, pat::Muon, pat::Jet, pat::MET > PatHitFit
edm::FileInPath hitfitDefault_
std::string fullPath() const
double maxEtaMu_
maximum eta value for muons, needed to limited range in which resolutions are provided ...
double minBTagValueBJet_
min value of bTag for a b-jet
std::string bTagAlgo_
input tag for b-tagging algorithm
double jes_
jet energy scale