CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
LHEGenericFilter Class Reference

#include <LHEGenericFilter.h>

Inheritance diagram for LHEGenericFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 LHEGenericFilter (const edm::ParameterSet &)
 
 ~LHEGenericFilter () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  logic_ { LT, GT, EQ, NE }
 

Private Member Functions

void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string acceptLogic_
 
int numRequired_
 
std::vector< int > particleID_
 
int passedEvents_
 
edm::EDGetTokenT< LHEEventProductsrc_
 
int totalEvents_
 
logic_ whichlogic
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 39 of file LHEGenericFilter.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

LHEGenericFilter::LHEGenericFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 6 of file LHEGenericFilter.cc.

References acceptLogic_, EQ, edm::ParameterSet::getParameter(), GT, LT, NE, src_, and whichlogic.

6  :
7 numRequired_(iConfig.getParameter<int>("NumRequired")),
8 acceptLogic_(iConfig.getParameter<std::string>("AcceptLogic")),
9 particleID_(iConfig.getParameter< std::vector<int> >("ParticleID")),
11 {
12  //here do whatever other initialization is needed
13  src_ = consumes<LHEEventProduct>(iConfig.getParameter<edm::InputTag>("src"));
14 
15  if(acceptLogic_=="LT") whichlogic = LT;
16  else if(acceptLogic_=="GT") whichlogic = GT;
17  else if(acceptLogic_=="EQ") whichlogic = EQ;
18  else if(acceptLogic_=="NE") whichlogic = NE;
19  else edm::LogError ("cat_A") << "wrong input for AcceptLogic string";
20 
21 
22 }
T getParameter(std::string const &) const
edm::EDGetTokenT< LHEEventProduct > src_
std::string acceptLogic_
std::vector< int > particleID_
LHEGenericFilter::~LHEGenericFilter ( )
override

Definition at line 24 of file LHEGenericFilter.cc.

25 {
26 
27  // do anything here that needs to be done at destruction time
28  // (e.g. close files, deallocate resources etc.)
29 
30 }

Member Function Documentation

void LHEGenericFilter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 71 of file LHEGenericFilter.cc.

References DEFINE_FWK_MODULE, passedEvents_, and totalEvents_.

71  {
72  edm::LogInfo("LHEGenericFilter") << "=== Results of LHEGenericFilter: passed "
73  << passedEvents_ << "/" << totalEvents_ << " events" << std::endl;
74 }
bool LHEGenericFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 34 of file LHEGenericFilter.cc.

References funct::abs(), EQ, edm::Event::getByToken(), GT, LHEEventProduct::hepeup(), mps_fire::i, lhef::HEPEUP::IDUP, lhef::HEPEUP::ISTUP, LT, NE, numRequired_, lhef::HEPEUP::NUP, particleID_, passedEvents_, src_, totalEvents_, and whichlogic.

35 {
37  iEvent.getByToken( src_ , EvtHandle ) ;
38 
39  totalEvents_++;
40  int nFound = 0;
41 
42  for (int i = 0; i < EvtHandle->hepeup().NUP; ++i) {
43  if (EvtHandle->hepeup().ISTUP[i] != 1) { // keep only outgoing particles
44  continue;
45  }
46  for (unsigned int j = 0; j < particleID_.size(); ++j) {
47  if (particleID_[j] == 0 || abs(particleID_[j]) == abs(EvtHandle->hepeup().IDUP[i]) ) {
48  nFound++;
49  break; // only match a given particle once!
50  }
51  } // loop over targets
52 
53  } // loop over particles
54 
55  // event accept/reject logic
56  if (
57  (whichlogic==LT && nFound < numRequired_)
58  || (whichlogic==GT && nFound > numRequired_)
59  || (whichlogic==EQ && nFound == numRequired_)
60  || (whichlogic==NE && nFound != numRequired_)
61  ) {
62  passedEvents_++;
63  return true;
64  } else {
65  return false;
66  }
67 
68 }
const lhef::HEPEUP & hepeup() const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< LHEEventProduct > src_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > ISTUP
Definition: LesHouches.h:243
std::vector< int > IDUP
Definition: LesHouches.h:238
std::vector< int > particleID_

Member Data Documentation

std::string LHEGenericFilter::acceptLogic_
private

Definition at line 52 of file LHEGenericFilter.h.

Referenced by LHEGenericFilter().

int LHEGenericFilter::numRequired_
private

Definition at line 51 of file LHEGenericFilter.h.

Referenced by filter().

std::vector<int> LHEGenericFilter::particleID_
private

Definition at line 56 of file LHEGenericFilter.h.

Referenced by filter().

int LHEGenericFilter::passedEvents_
private

Definition at line 58 of file LHEGenericFilter.h.

Referenced by endJob(), and filter().

edm::EDGetTokenT<LHEEventProduct> LHEGenericFilter::src_
private

Definition at line 50 of file LHEGenericFilter.h.

Referenced by filter(), and LHEGenericFilter().

int LHEGenericFilter::totalEvents_
private

Definition at line 57 of file LHEGenericFilter.h.

Referenced by endJob(), and filter().

logic_ LHEGenericFilter::whichlogic
private

Definition at line 60 of file LHEGenericFilter.h.

Referenced by filter(), and LHEGenericFilter().