Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27794 from ohindrichs/toplhefilter
Add TopLHEFilter
- Loading branch information
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<use name="fastjet"/> | ||
<use name="boost"/> | ||
<use name="FWCore/PluginManager"/> | ||
<use name="FWCore/ParameterSet"/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
LHEJetFilter = cms.EDFilter('LHEJetFilter', | ||
jetPtMin = cms.double(350.), | ||
jetR = cms.double(0.8), | ||
src = cms.InputTag('externalLHEProducer') | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <vector> | ||
|
||
#include "FWCore/Framework/interface/global/EDFilter.h" | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/Utilities/interface/InputTag.h" | ||
|
||
#include "DataFormats/Common/interface/Handle.h" | ||
|
||
#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h" | ||
|
||
#include "fastjet/PseudoJet.hh" | ||
#include "fastjet/JetDefinition.hh" | ||
#include "fastjet/ClusterSequence.hh" | ||
#include "fastjet/Selector.hh" | ||
|
||
using namespace std; | ||
using namespace fastjet; | ||
|
||
class LHEJetFilter : public edm::global::EDFilter<> { | ||
public: | ||
explicit LHEJetFilter(const edm::ParameterSet&); | ||
~LHEJetFilter() override {} | ||
|
||
private: | ||
bool filter(edm::StreamID strid, edm::Event& evt, const edm::EventSetup& params) const override; | ||
|
||
edm::EDGetTokenT<LHEEventProduct> tokenLHEEvent_; | ||
double jetPtMin_; | ||
JetDefinition jetdef_; | ||
}; | ||
|
||
LHEJetFilter::LHEJetFilter(const edm::ParameterSet& params) | ||
: tokenLHEEvent_(consumes<LHEEventProduct>(params.getParameter<edm::InputTag>("src"))), | ||
jetPtMin_(params.getParameter<double>("jetPtMin")), | ||
jetdef_(antikt_algorithm, params.getParameter<double>("jetR")) {} | ||
|
||
bool LHEJetFilter::filter(edm::StreamID strid, edm::Event& evt, const edm::EventSetup& params) const { | ||
edm::Handle<LHEEventProduct> lheinfo; | ||
evt.getByToken(tokenLHEEvent_, lheinfo); | ||
|
||
if (!lheinfo.isValid()) { | ||
return true; | ||
} | ||
|
||
vector<PseudoJet> jetconsts; | ||
jetconsts.reserve(10); | ||
const lhef::HEPEUP& hepeup = lheinfo->hepeup(); | ||
for (size_t p = 0; p < hepeup.IDUP.size(); ++p) { | ||
if (hepeup.ISTUP[p] == 1) { | ||
const lhef::HEPEUP::FiveVector& mom = hepeup.PUP[p]; | ||
jetconsts.emplace_back(mom[0], mom[1], mom[2], mom[3]); | ||
} | ||
} | ||
|
||
ClusterSequence cs(jetconsts, jetdef_); | ||
vector<PseudoJet> jets = cs.inclusive_jets(jetPtMin_); | ||
|
||
return !jets.empty(); | ||
} | ||
|
||
// Define module as a plug-in | ||
DEFINE_FWK_MODULE(LHEJetFilter); |