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::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 &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

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, nPart(), 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
PDG identifier.
virtual int status() const
status word
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
#define abs(x)
Definition: mlp_lapack.h:159
edm::InputTag inputTagGenParticles_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
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:356
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

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.