Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-gex133B Try to avoid reference to depreciated EDFilter/EDAnalyzer codes in GeneratorInterface #37792

Merged
merged 2 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ process.jpsi_from_bhadron_filter = cms.EDFilter("PythiaFilterMultiAncestor",
// user include files
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"

// #include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/global/EDFilter.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand Down
44 changes: 18 additions & 26 deletions GeneratorInterface/Herwig6Interface/plugins/Herwig6Filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/stream/EDFilter.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
Expand All @@ -15,34 +15,26 @@
// class declaration
//

class Herwig6Filter : public edm::EDFilter {
public:
explicit Herwig6Filter(const edm::ParameterSet&);
~Herwig6Filter();
class Herwig6Filter : public edm::stream::EDFilter<> {
public:
explicit Herwig6Filter(const edm::ParameterSet&);
~Herwig6Filter() override = default;

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

Herwig6Filter::Herwig6Filter(const edm::ParameterSet& ppp)
{}

Herwig6Filter::~Herwig6Filter()
{}

bool
Herwig6Filter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;

std::vector< Handle<HepMCProduct> > AllProds;
iEvent.getManyByType(AllProds);

if(AllProds.size()==0) {
LogInfo("")<<" Event is skipped and removed.\n";
return false;
}
else return true;
Herwig6Filter::Herwig6Filter(const edm::ParameterSet& ppp) {}

bool Herwig6Filter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
std::vector<Handle<HepMCProduct> > AllProds;
iEvent.getManyByType(AllProds);

if (AllProds.size() == 0) {
edm::LogInfo("") << " Event is skipped and removed.\n";
return false;
} else
return true;
}

//define this as a plug-in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ class TauSpinnerFilter : public edm::stream::EDFilter<> {
void setRandomEngine(CLHEP::HepRandomEngine* v) { fRandomEngine = v; }

private:
edm::InputTag src_;
const edm::EDGetTokenT<double> WTToken_;
CLHEP::HepRandomEngine* fRandomEngine;
double ntaus_;
edm::EDGetTokenT<double> WTToken_;
};

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
#include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h"

TauSpinnerFilter::TauSpinnerFilter(const edm::ParameterSet& pset)
: src_(pset.getParameter<edm::InputTag>("src")), fRandomEngine(nullptr), ntaus_(0) {
: WTToken_(consumes<double>(pset.getParameter<edm::InputTag>("src"))), fRandomEngine(nullptr), ntaus_(0) {
if (pset.getParameter<int>("ntaus") == 1)
ntaus_ = 1.0;
if (pset.getParameter<int>("ntaus") == 2)
ntaus_ = 2.0;
WTToken_ = consumes<double>(src_);
}

bool TauSpinnerFilter::filter(edm::Event& e, edm::EventSetup const& es) {
edm::RandomEngineSentry<TauSpinnerFilter> randomEngineSentry(this, e.streamID());
edm::Handle<double> WT;
e.getByToken(WTToken_, WT);
const edm::Handle<double>& WT = e.getHandle(WTToken_);
if (*(WT.product()) >= 0 && *(WT.product()) <= 4.0) {
double weight = (*(WT.product()));
if (fRandomEngine->flat() * ntaus_ * 2.0 < weight) {
Expand Down