CMS 3D CMS Logo

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

#include <MCProcessFilter.h>

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

Public Member Functions

bool filter (edm::Event &, const edm::EventSetup &) override
 
 MCProcessFilter (const edm::ParameterSet &)
 
 ~MCProcessFilter () 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 Attributes

std::vector< int > processID
 
std::vector< double > pthatMax
 
std::vector< double > pthatMin
 
edm::EDGetTokenT< edm::HepMCProducttoken_
 

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 43 of file MCProcessFilter.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file MCProcessFilter.cc.

References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, processID, pthatMax, and pthatMin.

11  :
12 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared")))
13 {
14  //here do whatever other initialization is needed
15  vector<int> defproc ;
16  defproc.push_back(0) ;
17  processID = iConfig.getUntrackedParameter< vector<int> >("ProcessID",defproc);
18  vector<double> defpthatmin ;
19  defpthatmin.push_back(0.);
20  pthatMin = iConfig.getUntrackedParameter< vector<double> >("MinPthat", defpthatmin);
21  vector<double> defpthatmax ;
22  defpthatmax.push_back(10000.);
23  pthatMax = iConfig.getUntrackedParameter< vector<double> >("MaxPthat", defpthatmax);
24 
25 
26  // checkin size of phthat vectors -- default is allowed
27  if ( (pthatMin.size() > 1 && processID.size() != pthatMin.size())
28  || (pthatMax.size() > 1 && processID.size() != pthatMax.size()) ) {
29  cout << "WARNING: MCPROCESSFILTER : size of MinPthat and/or MaxPthat not matching with ProcessID size!!" << endl;
30  }
31 
32  // if pthatMin size smaller than processID , fill up further with defaults
33  if (processID.size() > pthatMin.size() ){
34  vector<double> defpthatmin2 ;
35  for (unsigned int i = 0; i < processID.size(); i++){ defpthatmin2.push_back(0.);}
36  pthatMin = defpthatmin2;
37  }
38  // if pthatMax size smaller than processID , fill up further with defaults
39  if (processID.size() > pthatMax.size() ){
40  vector<double> defpthatmax2 ;
41  for (unsigned int i = 0; i < processID.size(); i++){ defpthatmax2.push_back(10000.);}
42  pthatMax = defpthatmax2;
43  }
44 
45 
46 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > pthatMin
std::vector< int > processID
std::vector< double > pthatMax
MCProcessFilter::~MCProcessFilter ( )
override

Definition at line 49 of file MCProcessFilter.cc.

50 {
51 
52  // do anything here that needs to be done at desctruction time
53  // (e.g. close files, deallocate resources etc.)
54 
55 }

Member Function Documentation

bool MCProcessFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 59 of file MCProcessFilter.cc.

References cms::dd::accepted(), edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), mps_fire::i, processID, pthatMax, pthatMin, and token_.

60 {
61  using namespace edm;
62  bool accepted = false;
64  iEvent.getByToken(token_, evt);
65 
66  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
67 
68 
69  // do the selection -- processID 0 is always accepted
70  for (unsigned int i = 0; i < processID.size(); i++){
71  if (processID[i] == myGenEvent->signal_process_id() || processID[i] == 0) {
72 
73  if ( myGenEvent->event_scale() > pthatMin[i] && myGenEvent->event_scale() < pthatMax[i] ) {
74  accepted = true;
75  }
76 
77  }
78  }
79 
80  if (accepted){ return true; } else {return false;}
81 
82 }
edm::EDGetTokenT< edm::HepMCProduct > token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< double > pthatMin
std::vector< int > processID
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
bool accepted(std::vector< std::string_view > const &, std::string_view)
HLT enums.
std::vector< double > pthatMax

Member Data Documentation

std::vector<int> MCProcessFilter::processID
private

Definition at line 54 of file MCProcessFilter.h.

Referenced by filter(), and MCProcessFilter().

std::vector<double> MCProcessFilter::pthatMax
private

Definition at line 56 of file MCProcessFilter.h.

Referenced by filter(), and MCProcessFilter().

std::vector<double> MCProcessFilter::pthatMin
private

Definition at line 55 of file MCProcessFilter.h.

Referenced by filter(), and MCProcessFilter().

edm::EDGetTokenT<edm::HepMCProduct> MCProcessFilter::token_
private

Definition at line 53 of file MCProcessFilter.h.

Referenced by filter().