CMS 3D CMS Logo

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

#include <MCSingleParticleFilter.h>

Inheritance diagram for MCSingleParticleFilter:
edm::global::EDFilter<> edm::global::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (edm::StreamID, edm::Event &, const edm::EventSetup &) const override
 
 MCSingleParticleFilter (const edm::ParameterSet &)
 
 ~MCSingleParticleFilter () override
 
- Public Member Functions inherited from edm::global::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () 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

const double betaBoost
 
std::vector< double > etaMax
 
std::vector< double > etaMin
 
std::vector< int > particleID
 
std::vector< double > ptMin
 
std::vector< int > status
 
const edm::EDGetTokenT< edm::HepMCProducttoken_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDFilterBase
typedef EDFilterBase 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::global::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- 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 42 of file MCSingleParticleFilter.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file MCSingleParticleFilter.cc.

References funct::abs(), betaBoost, etaMax, etaMin, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, particleID, ptMin, and status.

12  :
13 token_(consumes<edm::HepMCProduct>(edm::InputTag(iConfig.getUntrackedParameter("moduleLabel",std::string("generator")),"unsmeared"))),
14 betaBoost(iConfig.getUntrackedParameter("BetaBoost",0.))
15 {
16  //here do whatever other initialization is needed
17  vector<int> defpid ;
18  defpid.push_back(0) ;
19  particleID = iConfig.getUntrackedParameter< vector<int> >("ParticleID",defpid);
20  vector<double> defptmin ;
21  defptmin.push_back(0.);
22  ptMin = iConfig.getUntrackedParameter< vector<double> >("MinPt", defptmin);
23 
24  vector<double> defetamin ;
25  defetamin.push_back(-10.);
26  etaMin = iConfig.getUntrackedParameter< vector<double> >("MinEta", defetamin);
27  vector<double> defetamax ;
28  defetamax.push_back(10.);
29  etaMax = iConfig.getUntrackedParameter< vector<double> >("MaxEta", defetamax);
30  vector<int> defstat ;
31  defstat.push_back(0);
32  status = iConfig.getUntrackedParameter< vector<int> >("Status", defstat);
33 
34 
35  // check for same size
36  if ( (ptMin.size() > 1 && particleID.size() != ptMin.size())
37  || (etaMin.size() > 1 && particleID.size() != etaMin.size())
38  || (etaMax.size() > 1 && particleID.size() != etaMax.size())
39  || (status.size() > 1 && particleID.size() != status.size()) ) {
40  edm::LogInfo("MCSingleParticleFilter") << "WARNING: size of MinPthat and/or MaxPthat not matching with ProcessID size!!" << endl;
41  }
42 
43  // if ptMin size smaller than particleID , fill up further with defaults
44  if (particleID.size() > ptMin.size() ){
45  vector<double> defptmin2 ;
46  for (unsigned int i = 0; i < particleID.size(); i++){ defptmin2.push_back(0.);}
47  ptMin = defptmin2;
48  }
49  // if etaMin size smaller than particleID , fill up further with defaults
50  if (particleID.size() > etaMin.size() ){
51  vector<double> defetamin2 ;
52  for (unsigned int i = 0; i < particleID.size(); i++){ defetamin2.push_back(-10.);}
53  etaMin = defetamin2;
54  }
55  // if etaMax size smaller than particleID , fill up further with defaults
56  if (particleID.size() > etaMax.size() ){
57  vector<double> defetamax2 ;
58  for (unsigned int i = 0; i < particleID.size(); i++){ defetamax2.push_back(10.);}
59  etaMax = defetamax2;
60  }
61  // if status size smaller than particleID , fill up further with defaults
62  if (particleID.size() > status.size() ){
63  vector<int> defstat2 ;
64  for (unsigned int i = 0; i < particleID.size(); i++){ defstat2.push_back(0);}
65  status = defstat2;
66  }
67 
68  // check if beta is smaller than 1
69  if (std::abs(betaBoost) >= 1 ){
70  edm::LogError("MCSingleParticleFilter") << "Input beta boost is >= 1 !";
71  }
72 
73 }
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > ptMin
const edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > etaMin
std::vector< double > etaMax
std::vector< int > particleID
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MCSingleParticleFilter::~MCSingleParticleFilter ( )
override

Definition at line 76 of file MCSingleParticleFilter.cc.

77 {
78 
79  // do anything here that needs to be done at desctruction time
80  // (e.g. close files, deallocate resources etc.)
81 
82 }

Member Function Documentation

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

Definition at line 86 of file MCSingleParticleFilter.cc.

References cms::dd::accepted(), betaBoost, etaMax, etaMin, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), mps_fire::i, AlCaHLTBitMon_ParallelJobs::p, particleID, ptMin, status, token_, and MCFilterZboostHelper::zboost().

87 {
88  using namespace edm;
89  bool accepted = false;
91  iEvent.getByToken(token_, evt);
92 
93  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
94 
95 
96  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
97  p != myGenEvent->particles_end(); ++p ) {
98 
99 
100  for (unsigned int i = 0; i < particleID.size(); i++){
101  if (particleID[i] == (*p)->pdg_id() || particleID[i] == 0) {
102 
103  if ( (*p)->momentum().perp() > ptMin[i]
104  && ((*p)->status() == status[i] || status[i] == 0)) {
105 
106  HepMC::FourVector mom = MCFilterZboostHelper::zboost((*p)->momentum(),betaBoost);
107  if ( mom.eta() > etaMin[i] && mom.eta() < etaMax[i] ) {
108  accepted = true;
109  }
110 
111  }
112 
113  }
114  }
115 
116 
117  }
118 
119  return accepted;
120 
121 }
HepMC::FourVector zboost(const HepMC::FourVector &, double)
std::vector< double > ptMin
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > etaMin
std::vector< double > etaMax
std::vector< int > particleID
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
bool accepted(std::vector< std::string_view > const &, std::string_view)
HLT enums.

Member Data Documentation

const double MCSingleParticleFilter::betaBoost
private

Definition at line 59 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

std::vector<double> MCSingleParticleFilter::etaMax
private

Definition at line 57 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

std::vector<double> MCSingleParticleFilter::etaMin
private

Definition at line 56 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

std::vector<int> MCSingleParticleFilter::particleID
private

Definition at line 54 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

std::vector<double> MCSingleParticleFilter::ptMin
private

Definition at line 55 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

std::vector<int> MCSingleParticleFilter::status
private
const edm::EDGetTokenT<edm::HepMCProduct> MCSingleParticleFilter::token_
private

Definition at line 53 of file MCSingleParticleFilter.h.

Referenced by filter().