diff --git a/GeneratorInterface/Core/BuildFile.xml b/GeneratorInterface/Core/BuildFile.xml
index a03408acc000e..9300e65937915 100644
--- a/GeneratorInterface/Core/BuildFile.xml
+++ b/GeneratorInterface/Core/BuildFile.xml
@@ -3,6 +3,7 @@
+
diff --git a/GeneratorInterface/Core/interface/PartonShowerBsHepMCFilter.h b/GeneratorInterface/Core/interface/PartonShowerBsHepMCFilter.h
index 1f21d90f8c7e2..8f1e3da786ae8 100644
--- a/GeneratorInterface/Core/interface/PartonShowerBsHepMCFilter.h
+++ b/GeneratorInterface/Core/interface/PartonShowerBsHepMCFilter.h
@@ -24,10 +24,7 @@ class PartonShowerBsHepMCFilter : public BaseHepMCFilter{
private:
- int particle_id;
- int exclude_status_id;
- int status_id;
};
-#endif
+#endif
\ No newline at end of file
diff --git a/GeneratorInterface/Core/src/HepMCFilterDriver.cc b/GeneratorInterface/Core/src/HepMCFilterDriver.cc
index caef408b0ea67..1cf49279bce87 100644
--- a/GeneratorInterface/Core/src/HepMCFilterDriver.cc
+++ b/GeneratorInterface/Core/src/HepMCFilterDriver.cc
@@ -87,4 +87,4 @@ void HepMCFilterDriver::resetStatistics() {
sumtotal_w_ = 0;
sumtotal_w2_ = 0;
-}
+}
\ No newline at end of file
diff --git a/GeneratorInterface/Core/src/PartonShowerBsHepMCFilter.cc b/GeneratorInterface/Core/src/PartonShowerBsHepMCFilter.cc
index d1a3b53fbee40..2717b6dcef469 100644
--- a/GeneratorInterface/Core/src/PartonShowerBsHepMCFilter.cc
+++ b/GeneratorInterface/Core/src/PartonShowerBsHepMCFilter.cc
@@ -1,6 +1,7 @@
#include "GeneratorInterface/Core/interface/PartonShowerBsHepMCFilter.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include
+#include "HepPDT/ParticleID.hh"
using namespace edm;
@@ -8,15 +9,7 @@ using namespace std;
//constructor
-PartonShowerBsHepMCFilter::PartonShowerBsHepMCFilter(const edm::ParameterSet& iConfig) :
-
- // particle id of the gen particles that you want to filter
- particle_id(iConfig.getParameter("Particle_id")),
- // status id of the particles that you want to exclude from the filter
- exclude_status_id(iConfig.getUntrackedParameter("Exclude_status_id",-1)),
- // status id of the particles that you want to filetr on
- status_id(iConfig.getUntrackedParameter("Status_id",-1))
-
+PartonShowerBsHepMCFilter::PartonShowerBsHepMCFilter(const edm::ParameterSet& iConfig)
{
}
@@ -35,26 +28,21 @@ PartonShowerBsHepMCFilter::~PartonShowerBsHepMCFilter()
// ------------ method called to produce the data ------------
bool PartonShowerBsHepMCFilter::filter(const HepMC::GenEvent* evt)
{
-
- if( exclude_status_id > 0. && status_id > 0.){
- std::cout << "ERROR: Skipping event: Configuration has both exclude and status id set to a value > 0. They can not be used simultaneously." << std::endl;
- return false; // skip event
- }
- for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin();
- p != evt->particles_end(); ++p ) {
+ // loop over gen particles
+ for ( HepMC::GenEvent::particle_const_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p ){
- if( abs((*p)->pdg_id()) == particle_id ){
- if( exclude_status_id > 0. && (*p)->status() != exclude_status_id )
- return true; // keep event
- else if( status_id > 0. && (*p)->status() == status_id )
- return true; // keep event
- else
- return true; // keep event
+ // check only status 2 particles
+ if( (*p)->status()==2 ){
+ // if one of the status 2 particles is a B-hadron, accept the event
+ HepPDT::ParticleID pid((*p)->pdg_id());
+ if( pid.hasBottom() ){
+ return true; // accept event
+ }
}
-
+
}
return false; // skip event
-}
+}
\ No newline at end of file
diff --git a/GeneratorInterface/GenFilters/interface/LHEGenericFilter.h b/GeneratorInterface/GenFilters/interface/LHEGenericFilter.h
index 5218a1c0fceb6..919cfee693bf5 100644
--- a/GeneratorInterface/GenFilters/interface/LHEGenericFilter.h
+++ b/GeneratorInterface/GenFilters/interface/LHEGenericFilter.h
@@ -49,10 +49,14 @@ class LHEGenericFilter : public edm::EDFilter {
edm::EDGetTokenT src_;
int numRequired_; // number of particles required to pass filter
- bool acceptMore_; // if true (default), accept numRequired or more.
- // if false, accept events with exactly equal to numRequired.
+ std::string acceptLogic_; // LT meaning <
+ // GT >
+ // EQ =
+ // NE !=
std::vector particleID_; // vector of particle IDs to look for
int totalEvents_; // counters
int passedEvents_;
+ enum logic_ { LT, GT, EQ, NE};
+ logic_ whichlogic;
};
#endif
diff --git a/GeneratorInterface/GenFilters/python/LHEGenericFilter_cfi.py b/GeneratorInterface/GenFilters/python/LHEGenericFilter_cfi.py
new file mode 100644
index 0000000000000..e17c987c05932
--- /dev/null
+++ b/GeneratorInterface/GenFilters/python/LHEGenericFilter_cfi.py
@@ -0,0 +1,8 @@
+import FWCore.ParameterSet.Config as cms
+
+lheGenericFilter = cms.EDFilter("LHEGenericFilter",
+ src = cms.InputTag("source"),
+ NumRequired = cms.int32(2),
+ ParticleID = cms.vint32(5),
+ AcceptLogic = cms.string("LT") # LT meaning < NumRequired, GT >, EQ =, NE !=
+)
diff --git a/GeneratorInterface/GenFilters/src/LHEGenericFilter.cc b/GeneratorInterface/GenFilters/src/LHEGenericFilter.cc
index 8e027b7989fd2..232938dfca027 100644
--- a/GeneratorInterface/GenFilters/src/LHEGenericFilter.cc
+++ b/GeneratorInterface/GenFilters/src/LHEGenericFilter.cc
@@ -1,20 +1,31 @@
#include "GeneratorInterface/GenFilters/interface/LHEGenericFilter.h"
+using namespace edm;
+using namespace std;
+
LHEGenericFilter::LHEGenericFilter(const edm::ParameterSet& iConfig) :
- numRequired_(iConfig.getParameter("NumRequired")),
- acceptMore_(iConfig.getParameter("AcceptMore")),
- particleID_(iConfig.getParameter< std::vector >("ParticleID")),
- totalEvents_(0), passedEvents_(0)
+numRequired_(iConfig.getParameter("NumRequired")),
+acceptLogic_(iConfig.getParameter("AcceptLogic")),
+particleID_(iConfig.getParameter< std::vector >("ParticleID")),
+totalEvents_(0), passedEvents_(0)
{
//here do whatever other initialization is needed
src_ = consumes(iConfig.getParameter("src"));
+
+ if(acceptLogic_.compare("LT")==0) whichlogic = LT;
+ else if(acceptLogic_.compare("GT")==0) whichlogic = GT;
+ else if(acceptLogic_.compare("EQ")==0) whichlogic = EQ;
+ else if(acceptLogic_.compare("NE")==0) whichlogic = NE;
+ else edm::LogError ("cat_A") << "wrong input for AcceptLogic string";
+
+
}
LHEGenericFilter::~LHEGenericFilter()
{
-
- // do anything here that needs to be done at destruction time
- // (e.g. close files, deallocate resources etc.)
+
+ // do anything here that needs to be done at destruction time
+ // (e.g. close files, deallocate resources etc.)
}
@@ -29,20 +40,25 @@ bool LHEGenericFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
int nFound = 0;
for (int i = 0; i < EvtHandle->hepeup().NUP; ++i) {
- if (EvtHandle->hepeup().ISTUP[i] != 1) {
- continue;
- }
+ if (EvtHandle->hepeup().ISTUP[i] != 1) { // keep only outgoing particles
+ continue;
+ }
for (unsigned int j = 0; j < particleID_.size(); ++j) {
if (particleID_[j] == 0 || abs(particleID_[j]) == abs(EvtHandle->hepeup().IDUP[i]) ) {
- nFound++;
- break; // only match a given particle once!
+ nFound++;
+ break; // only match a given particle once!
}
} // loop over targets
- if (acceptMore_ && nFound == numRequired_) break; // stop looking if we don't mind having more
} // loop over particles
- if (nFound == numRequired_) {
+ // event accept/reject logic
+ if (
+ (whichlogic==LT && nFound < numRequired_)
+ || (whichlogic==GT && nFound > numRequired_)
+ || (whichlogic==EQ && nFound == numRequired_)
+ || (whichlogic==NE && nFound != numRequired_)
+ ) {
passedEvents_++;
return true;
} else {
@@ -54,7 +70,7 @@ bool LHEGenericFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
// ------------ method called once each job just after ending the event loop ------------
void LHEGenericFilter::endJob() {
edm::LogInfo("LHEGenericFilter") << "=== Results of LHEGenericFilter: passed "
- << passedEvents_ << "/" << totalEvents_ << " events" << std::endl;
+ << passedEvents_ << "/" << totalEvents_ << " events" << std::endl;
}
//define this as a plug-in