CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
MCSingleParticleFilter Class Reference

#include <MCSingleParticleFilter.h>

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

Public Member Functions

virtual bool filter (edm::Event &, const edm::EventSetup &)
 
 MCSingleParticleFilter (const edm::ParameterSet &)
 
 ~MCSingleParticleFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::vector< double > etaMax
 
std::vector< double > etaMin
 
std::vector< int > particleID
 
std::vector< double > ptMin
 
std::vector< int > status
 
edm::EDGetTokenT
< edm::HepMCProduct
token_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
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 &)
 
- 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 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 11 of file MCSingleParticleFilter.cc.

References gather_cfg::cout, etaMax, etaMin, edm::ParameterSet::getUntrackedParameter(), i, particleID, ptMin, and status.

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> defpid ;
16  defpid.push_back(0) ;
17  particleID = iConfig.getUntrackedParameter< vector<int> >("ParticleID",defpid);
18  vector<double> defptmin ;
19  defptmin.push_back(0.);
20  ptMin = iConfig.getUntrackedParameter< vector<double> >("MinPt", defptmin);
21 
22  vector<double> defetamin ;
23  defetamin.push_back(-10.);
24  etaMin = iConfig.getUntrackedParameter< vector<double> >("MinEta", defetamin);
25  vector<double> defetamax ;
26  defetamax.push_back(10.);
27  etaMax = iConfig.getUntrackedParameter< vector<double> >("MaxEta", defetamax);
28  vector<int> defstat ;
29  defstat.push_back(0);
30  status = iConfig.getUntrackedParameter< vector<int> >("Status", defstat);
31 
32 
33  // check for same size
34  if ( (ptMin.size() > 1 && particleID.size() != ptMin.size())
35  || (etaMin.size() > 1 && particleID.size() != etaMin.size())
36  || (etaMax.size() > 1 && particleID.size() != etaMax.size())
37  || (status.size() > 1 && particleID.size() != status.size()) ) {
38  cout << "WARNING: MCPROCESSFILTER : size of MinPthat and/or MaxPthat not matching with ProcessID size!!" << endl;
39  }
40 
41  // if ptMin size smaller than particleID , fill up further with defaults
42  if (particleID.size() > ptMin.size() ){
43  vector<double> defptmin2 ;
44  for (unsigned int i = 0; i < particleID.size(); i++){ defptmin2.push_back(0.);}
45  ptMin = defptmin2;
46  }
47  // if etaMin size smaller than particleID , fill up further with defaults
48  if (particleID.size() > etaMin.size() ){
49  vector<double> defetamin2 ;
50  for (unsigned int i = 0; i < particleID.size(); i++){ defetamin2.push_back(-10.);}
51  etaMin = defetamin2;
52  }
53  // if etaMax size smaller than particleID , fill up further with defaults
54  if (particleID.size() > etaMax.size() ){
55  vector<double> defetamax2 ;
56  for (unsigned int i = 0; i < particleID.size(); i++){ defetamax2.push_back(10.);}
57  etaMax = defetamax2;
58  }
59  // if status size smaller than particleID , fill up further with defaults
60  if (particleID.size() > status.size() ){
61  vector<int> defstat2 ;
62  for (unsigned int i = 0; i < particleID.size(); i++){ defstat2.push_back(0);}
63  status = defstat2;
64  }
65 
66 
67 
68 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< double > ptMin
edm::EDGetTokenT< edm::HepMCProduct > token_
std::vector< double > etaMin
std::vector< double > etaMax
std::vector< int > particleID
tuple cout
Definition: gather_cfg.py:121
MCSingleParticleFilter::~MCSingleParticleFilter ( )

Definition at line 71 of file MCSingleParticleFilter.cc.

72 {
73 
74  // do anything here that needs to be done at desctruction time
75  // (e.g. close files, deallocate resources etc.)
76 
77 }

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 81 of file MCSingleParticleFilter.cc.

References etaMax, etaMin, edm::Event::getByToken(), i, AlCaHLTBitMon_ParallelJobs::p, particleID, ptMin, status, and token_.

82 {
83  using namespace edm;
84  bool accepted = false;
86  iEvent.getByToken(token_, evt);
87 
88  const HepMC::GenEvent * myGenEvent = evt->GetEvent();
89 
90 
91  for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
92  p != myGenEvent->particles_end(); ++p ) {
93 
94 
95  for (unsigned int i = 0; i < particleID.size(); i++){
96  if (particleID[i] == (*p)->pdg_id() || particleID[i] == 0) {
97 
98  if ( (*p)->momentum().perp() > ptMin[i] && (*p)->momentum().eta() > etaMin[i]
99  && (*p)->momentum().eta() < etaMax[i] && ((*p)->status() == status[i] || status[i] == 0)) {
100  accepted = true;
101  }
102 
103  }
104  }
105 
106 
107  }
108 
109  if (accepted){ return true; } else {return false;}
110 
111 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > ptMin
edm::EDGetTokenT< edm::HepMCProduct > token_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
std::vector< double > etaMin
std::vector< double > etaMax
std::vector< int > particleID

Member Data Documentation

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

Definition at line 56 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

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

Definition at line 55 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

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

Definition at line 53 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

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

Definition at line 54 of file MCSingleParticleFilter.h.

Referenced by filter(), and MCSingleParticleFilter().

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

Definition at line 52 of file MCSingleParticleFilter.h.

Referenced by filter().