CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::GenParticleCollection
tokenGenParticles_
 
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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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

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 }
bool exists(std::string const &parameterName) const
checks if a parameter exists
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
unsigned int skipFirstN
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
overrideprivatevirtual

Implements edm::global::EDProducerBase.

Definition at line 78 of file PartonSelector.cc.

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

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 }
Log< level::Info, true > LogVerbatim
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
size_t numberOfDaughters() const override
number of daughters
edm::EDGetTokenT< reco::GenParticleCollection > tokenGenParticles_
int status() const final
status word
int pdgId() const final
PDG identifier.
unsigned int skipFirstN
def move
Definition: eostools.py:511
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)
edm::Ref< edm::HepMCProduct, HepMC::GenParticle > GenParticleRef
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...

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.