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 ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

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

Private Attributes

edm::InputTag inputTagGenParticles_
 
bool withLeptons
 
bool withTop
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 51 of file PartonSelector.cc.

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

52 {
53  produces<reco::GenParticleRefVector>();
54  withLeptons = iConfig.getParameter<bool>("withLeptons");
56  if ( iConfig.exists("withTop") ) {
57  withTop = iConfig.getParameter<bool>("withTop");
58  } else {
59  withTop = false;
60  }
61 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::InputTag inputTagGenParticles_
PartonSelector::~PartonSelector ( )

Definition at line 65 of file PartonSelector.cc.

66 {
67 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 71 of file PartonSelector.cc.

References abs, reco::CompositeRefCandidateT< D >::daughter(), reco::flavour(), edm::Event::getByLabel(), i, m, reco::CompositeRefCandidateT< D >::numberOfDaughters(), reco::Candidate::pdgId(), reco::LeafCandidate::pdgId(), edm::Event::put(), and reco::LeafCandidate::status().

72 {
73 
74  //edm::Handle <reco::CandidateView> particles;
76  iEvent.getByLabel (inputTagGenParticles_, particles );
77  edm::LogVerbatim("PartonSelector") << "=== GenParticle size:" << particles->size();
78  int nPart=0;
79 
80  auto_ptr<GenParticleRefVector> thePartons ( new GenParticleRefVector);
81 
82  for (size_t m = 0; m < particles->size(); m++) {
83 
84  // Don't take into account first 6 particles in generator list
85  if (m<6) continue;
86 
87  const GenParticle & aParticle = (*particles)[ m ];
88 
89  bool isAParton = false;
90  bool isALepton = false;
91  int flavour = abs(aParticle.pdgId());
92  if(flavour == 1 ||
93  flavour == 2 ||
94  flavour == 3 ||
95  flavour == 4 ||
96  flavour == 5 ||
97  (flavour == 6 && withTop) ||
98  flavour == 21 ) isAParton = true;
99  if(flavour == 11 ||
100  flavour == 12 ||
101  flavour == 13 ||
102  flavour == 14 ||
103  flavour == 15 ||
104  flavour == 16 ) isALepton = true;
105 
106 
107  //Add Partons status 3
108  if( aParticle.status() == 3 && isAParton ) {
109  thePartons->push_back( GenParticleRef( particles, m ) );
110  nPart++;
111  }
112 
113  //Add Partons status 2
114  int nparton_daughters = 0;
115  if( aParticle.numberOfDaughters() > 0 && isAParton ) {
116 
117  for (unsigned int i=0; i < aParticle.numberOfDaughters(); i++){
118 
119  int daughterFlavour = abs(aParticle.daughter(i)->pdgId());
120  if( (daughterFlavour == 1 || daughterFlavour == 2 || daughterFlavour == 3 ||
121  daughterFlavour == 4 || daughterFlavour == 5 || daughterFlavour == 6 || daughterFlavour == 21)) {
122  nparton_daughters++;
123  }
124 
125  }
126  if(nparton_daughters == 0){
127  nPart++;
128  thePartons->push_back( GenParticleRef( particles, m ) );
129  }
130 
131  }
132 
133  //Add Leptons
134  // Here you have to decide what to do with taus....
135  // Now all leptons, including e and mu from leptonic tau decays, are added
136  if( withLeptons && aParticle.status() == 3 && isALepton ) {
137  thePartons->push_back( GenParticleRef( particles, m ) );
138  nPart++;
139  }
140  }
141 
142  edm::LogVerbatim("PartonSelector") << "=== GenParticle selected:" << nPart;
143  iEvent.put( thePartons );
144 
145 }
int i
Definition: DBlmapReader.cc:9
virtual int pdgId() const GCC11_FINAL
PDG identifier.
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
#define abs(x)
Definition: mlp_lapack.h:159
edm::InputTag inputTagGenParticles_
virtual int status() const GCC11_FINAL
status word
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
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) ...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual int pdgId() const =0
PDG identifier.
int flavour(const Candidate &part)
Definition: pdgIdUtils.h:31

Member Data Documentation

edm::InputTag PartonSelector::inputTagGenParticles_
private

Definition at line 47 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.