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 Member Functions | Private Attributes
PartonSelector Class Reference
Inheritance diagram for PartonSelector:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PartonSelector (const edm::ParameterSet &)
 
 ~PartonSelector ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool acceptNoDaughters
 
unsigned int skipFirstN
 
edm::EDGetTokenT
< reco::GenParticleCollection
tokenGenParticles_
 
bool withLeptons
 
bool withTop
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
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 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 36 of file PartonSelector.cc.

Constructor & Destructor Documentation

PartonSelector::PartonSelector ( const edm::ParameterSet iConfig)

Definition at line 53 of file PartonSelector.cc.

References edm::ParameterSet::exists(), and edm::ParameterSet::getParameter().

54 {
55  produces<reco::GenParticleRefVector>();
56  withLeptons = iConfig.getParameter<bool>("withLeptons");
57  tokenGenParticles_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("src"));
58  if ( iConfig.exists("acceptNoDaughters") ) {
59  acceptNoDaughters = iConfig.getParameter<bool>("acceptNoDaughters");
60  } else {
61  acceptNoDaughters=false;
62  }
63  if ( iConfig.exists("skipFirstN") ) {
64  skipFirstN = iConfig.getParameter<unsigned int>("skipFirstN");
65  } else {
66  skipFirstN=6;
67  }
68  if ( iConfig.exists("withTop") ) {
69  withTop = iConfig.getParameter<bool>("withTop");
70  } else {
71  withTop = false;
72  }
73 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
unsigned int skipFirstN
PartonSelector::~PartonSelector ( )

Definition at line 77 of file PartonSelector.cc.

78 {
79 }

Member Function Documentation

void PartonSelector::produce ( edm::Event iEvent,
const edm::EventSetup iEs 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 83 of file PartonSelector.cc.

References funct::abs(), reco::CompositeRefCandidateT< D >::daughter(), reco::flavour(), edm::Event::getByToken(), i, visualization-live-secondInstance_cfg::m, nPart(), reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::Candidate::pdgId(), reco::LeafCandidate::pdgId(), edm::Event::put(), and reco::LeafCandidate::status().

84 {
85 
86  //edm::Handle <reco::CandidateView> particles;
88  iEvent.getByToken (tokenGenParticles_, particles );
89  edm::LogVerbatim("PartonSelector") << "=== GenParticle size:" << particles->size();
90  int nPart=0;
91 
92  auto_ptr<GenParticleRefVector> thePartons ( new GenParticleRefVector);
93 
94  for (size_t m = 0; m < particles->size(); m++) {
95 
96  // Don't take into account first 6 particles in generator list
97  if (m<skipFirstN) continue;
98 
99  const GenParticle & aParticle = (*particles)[ m ];
100 
101  bool isAParton = false;
102  bool isALepton = false;
103  int flavour = abs(aParticle.pdgId());
104  if(flavour == 1 ||
105  flavour == 2 ||
106  flavour == 3 ||
107  flavour == 4 ||
108  flavour == 5 ||
109  (flavour == 6 && withTop) ||
110  flavour == 21 ) isAParton = true;
111  if(flavour == 11 ||
112  flavour == 12 ||
113  flavour == 13 ||
114  flavour == 14 ||
115  flavour == 15 ||
116  flavour == 16 ) isALepton = true;
117 
118 
119  //Add Partons status 3
120  if( aParticle.status() == 3 && isAParton ) {
121  thePartons->push_back( GenParticleRef( particles, m ) );
122  nPart++;
123  }
124 
125  //Add Partons status 2
126  int nparton_daughters = 0;
127  if( ( aParticle.numberOfDaughters() > 0 || acceptNoDaughters) && isAParton ) {
128 
129  for (unsigned int i=0; i < aParticle.numberOfDaughters(); i++){
130 
131  int daughterFlavour = abs(aParticle.daughter(i)->pdgId());
132  if( (daughterFlavour == 1 || daughterFlavour == 2 || daughterFlavour == 3 ||
133  daughterFlavour == 4 || daughterFlavour == 5 || daughterFlavour == 6 || daughterFlavour == 21)) {
134  nparton_daughters++;
135  }
136 
137  }
138  if(nparton_daughters == 0){
139  nPart++;
140  thePartons->push_back( GenParticleRef( particles, m ) );
141  }
142 
143  }
144 
145  //Add Leptons
146  // Here you have to decide what to do with taus....
147  // Now all leptons, including e and mu from leptonic tau decays, are added
148  if( withLeptons && aParticle.status() == 3 && isALepton ) {
149  thePartons->push_back( GenParticleRef( particles, m ) );
150  nPart++;
151  }
152  }
153 
154  edm::LogVerbatim("PartonSelector") << "=== GenParticle selected:" << nPart;
155  iEvent.put( thePartons );
156 
157 }
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const
PDG identifier.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
virtual int status() const
status word
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
unsigned int skipFirstN
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:115
virtual size_t numberOfDaughters() const
number of daughters
virtual const Candidate * daughter(size_type) const
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual int pdgId() const =0
PDG identifier.
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
int flavour(const Candidate &part)
Definition: pdgIdUtils.h:31

Member Data Documentation

bool PartonSelector::acceptNoDaughters
private

Definition at line 47 of file PartonSelector.cc.

unsigned int PartonSelector::skipFirstN
private

Definition at line 48 of file PartonSelector.cc.

edm::EDGetTokenT<reco::GenParticleCollection> PartonSelector::tokenGenParticles_
private

Definition at line 49 of file PartonSelector.cc.

bool PartonSelector::withLeptons
private

Definition at line 45 of file PartonSelector.cc.

bool PartonSelector::withTop
private

Definition at line 46 of file PartonSelector.cc.