Skip to content

Commit

Permalink
Try to avoid reference to depreciated EDFilter/EDAnalyzer codes in Ge…
Browse files Browse the repository at this point in the history
…neratorInterface
  • Loading branch information
Sunanda committed May 4, 2022
1 parent 303dd5e commit 2fcdef7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 30 deletions.
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
40 changes: 17 additions & 23 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,28 @@
// 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(const edm::ParameterSet& ppp) {}

Herwig6Filter::~Herwig6Filter()
{}

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

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

if(AllProds.size()==0) {
LogInfo("")<<" Event is skipped and removed.\n";
return false;
}
else return true;
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

0 comments on commit 2fcdef7

Please sign in to comment.