-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Otto Hindrichs
committed
Aug 20, 2019
1 parent
da3846c
commit db23136
Showing
3 changed files
with
80 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,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); |