CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
PartonSelector Class Reference
Inheritance diagram for PartonSelector:
edm::global::EDProducer<> edm::global::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 PartonSelector (const edm::ParameterSet &)
 
 ~PartonSelector () override
 
- Public Member Functions inherited from edm::global::EDProducer<>
 EDProducer ()=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::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () 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
 
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)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::global::EDProducerBase
typedef EDProducerBase 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::EDProducerBase
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(), edm::ParameterSet::getParameter(), and SelectPartons_cff::withLeptons.

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 ( )
override

Definition at line 77 of file PartonSelector.cc.

78 {
79 }

Member Function Documentation

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

Definition at line 83 of file PartonSelector.cc.

References funct::abs(), reco::CompositeRefCandidateT< D >::daughter(), DEFINE_FWK_MODULE, GenHFHadronMatcher_cff::flavour, edm::Event::getByToken(), mps_fire::i, funct::m, eostools::move(), nPart(), reco::CompositeRefCandidateT< D >::numberOfDaughters(), HadronAndPartonSelector_cfi::particles, reco::Candidate::pdgId(), reco::LeafCandidate::pdgId(), edm::Event::put(), reco::LeafCandidate::status(), and SelectPartons_cff::withLeptons.

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 thePartons = std::make_unique<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(std::move(thePartons) );
156 
157 }
int pdgId() const final
PDG identifier.
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
unsigned int skipFirstN
virtual int pdgId() const =0
PDG identifier.
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
size_t numberOfDaughters() const override
number of daughters
int status() const final
status word
def move(src, dest)
Definition: eostools.py:510

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.