Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-22 06:25:03

0001 #include <iostream>
0002 #include <string>
0003 #include <memory>
0004 
0005 #include "HepMC/GenEvent.h"
0006 #include "HepMC/SimpleVector.h"
0007 
0008 #include "FWCore/Framework/interface/one/EDFilter.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 
0015 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0016 
0017 class LHEFilter : public edm::one::EDFilter<> {
0018 public:
0019   explicit LHEFilter(const edm::ParameterSet &params);
0020   ~LHEFilter() override = default;
0021 
0022 protected:
0023   bool filter(edm::Event &event, const edm::EventSetup &es) override;
0024 
0025 private:
0026   const edm::EDGetTokenT<edm::HepMCProduct> hepMCToken_;
0027 };
0028 
0029 LHEFilter::LHEFilter(const edm::ParameterSet &params)
0030     : hepMCToken_(consumes<edm::HepMCProduct>(params.getParameter<edm::InputTag>("src"))) {}
0031 
0032 bool LHEFilter::filter(edm::Event &event, const edm::EventSetup &es) {
0033   const edm::Handle<edm::HepMCProduct> &product = event.getHandle(hepMCToken_);
0034 
0035   return product->GetEvent();
0036 }
0037 
0038 DEFINE_FWK_MODULE(LHEFilter);