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 hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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(), edm::ParameterSet::getParameter(), and hltBtagJetMCTools_cff::withLeptons.

51  {
52  produces<reco::GenParticleRefVector>();
53  withLeptons = iConfig.getParameter<bool>("withLeptons");
54  tokenGenParticles_ = consumes<reco::GenParticleCollection>(iConfig.getParameter<edm::InputTag>("src"));
55  if (iConfig.exists("acceptNoDaughters")) {
56  acceptNoDaughters = iConfig.getParameter<bool>("acceptNoDaughters");
57  } else {
58  acceptNoDaughters = false;
59  }
60  if (iConfig.exists("skipFirstN")) {
61  skipFirstN = iConfig.getParameter<unsigned int>("skipFirstN");
62  } else {
63  skipFirstN = 6;
64  }
65  if (iConfig.exists("withTop")) {
66  withTop = iConfig.getParameter<bool>("withTop");
67  } else {
68  withTop = false;
69  }
70 }
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 74 of file PartonSelector.cc.

74 {}

Member Function Documentation

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

Definition at line 78 of file PartonSelector.cc.

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

78  {
79  //edm::Handle <reco::CandidateView> particles;
81  iEvent.getByToken(tokenGenParticles_, particles);
82  edm::LogVerbatim("PartonSelector") << "=== GenParticle size:" << particles->size();
83  int nPart = 0;
84 
85  auto thePartons = std::make_unique<GenParticleRefVector>();
86 
87  for (size_t m = 0; m < particles->size(); m++) {
88  // Don't take into account first 6 particles in generator list
89  if (m < skipFirstN)
90  continue;
91 
92  const GenParticle& aParticle = (*particles)[m];
93 
94  bool isAParton = false;
95  bool isALepton = false;
96  int flavour = abs(aParticle.pdgId());
97  if (flavour == 1 || flavour == 2 || flavour == 3 || flavour == 4 || flavour == 5 || (flavour == 6 && withTop) ||
98  flavour == 21)
99  isAParton = true;
100  if (flavour == 11 || flavour == 12 || flavour == 13 || flavour == 14 || flavour == 15 || flavour == 16)
101  isALepton = true;
102 
103  //Add Partons status 3
104  if (aParticle.status() == 3 && isAParton) {
105  thePartons->push_back(GenParticleRef(particles, m));
106  nPart++;
107  }
108 
109  //Add Partons status 2
110  int nparton_daughters = 0;
111  if ((aParticle.numberOfDaughters() > 0 || acceptNoDaughters) && isAParton) {
112  for (unsigned int i = 0; i < aParticle.numberOfDaughters(); i++) {
113  int daughterFlavour = abs(aParticle.daughter(i)->pdgId());
114  if ((daughterFlavour == 1 || daughterFlavour == 2 || daughterFlavour == 3 || daughterFlavour == 4 ||
115  daughterFlavour == 5 || daughterFlavour == 6 || daughterFlavour == 21)) {
116  nparton_daughters++;
117  }
118  }
119  if (nparton_daughters == 0) {
120  nPart++;
121  thePartons->push_back(GenParticleRef(particles, m));
122  }
123  }
124 
125  //Add Leptons
126  // Here you have to decide what to do with taus....
127  // Now all leptons, including e and mu from leptonic tau decays, are added
128  if (withLeptons && aParticle.status() == 3 && isALepton) {
129  thePartons->push_back(GenParticleRef(particles, m));
130  nPart++;
131  }
132  }
133 
134  edm::LogVerbatim("PartonSelector") << "=== GenParticle selected:" << nPart;
135  iEvent.put(std::move(thePartons));
136 }
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:131
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
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)
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
size_t numberOfDaughters() const override
number of daughters
int status() const final
status word
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

bool PartonSelector::acceptNoDaughters
private

Definition at line 45 of file PartonSelector.cc.

unsigned int PartonSelector::skipFirstN
private

Definition at line 46 of file PartonSelector.cc.

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

Definition at line 47 of file PartonSelector.cc.

bool PartonSelector::withLeptons
private

Definition at line 43 of file PartonSelector.cc.

bool PartonSelector::withTop
private

Definition at line 44 of file PartonSelector.cc.