Skip to content

Commit

Permalink
backport of LHEJetFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
Otto Hindrichs committed Aug 20, 2019
1 parent da3846c commit db23136
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions GeneratorInterface/GenFilters/BuildFile.xml
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"/>
Expand Down
8 changes: 8 additions & 0 deletions GeneratorInterface/GenFilters/python/LHEJetFilter_cfi.py
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')
)

71 changes: 71 additions & 0 deletions GeneratorInterface/GenFilters/src/LHEJetFilter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <vector>

#include "FWCore/Framework/interface/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::EDFilter {
public:
explicit LHEJetFilter(const edm::ParameterSet&);
~LHEJetFilter() override {}

private:
bool filter(edm::Event&, const edm::EventSetup&) override;

edm::EDGetTokenT<LHEEventProduct> tokenLHEEvent_;
double jetPtMin_;
JetDefinition jetdef_;

vector<PseudoJet> jetconsts_;
};

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::Event& evt, const edm::EventSetup& params) {
edm::Handle<LHEEventProduct> lheinfo;
evt.getByToken(tokenLHEEvent_, lheinfo);

if (!lheinfo.isValid()) {
return true;
}

jetconsts_.clear();
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 = sorted_by_pt(cs.inclusive_jets());

if (jets.empty()) {
return false;
}

return jets[0].perp() > jetPtMin_;
}

// Define module as a plug-in
DEFINE_FWK_MODULE(LHEJetFilter);

0 comments on commit db23136

Please sign in to comment.