CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
GenParticleDecaySelector Class Reference
Inheritance diagram for GenParticleDecaySelector:
edm::stream::EDProducer<>

Public Member Functions

 GenParticleDecaySelector (const edm::ParameterSet &)
 constructor More...
 
- Public Member Functions inherited from edm::stream::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
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

std::pair< reco::GenParticleRef, reco::GenParticle * > add (reco::GenParticleCollection &, const reco::GenParticle &, reco::GenParticleRefProd)
 recursively add a new particle to the output collection More...
 
void produce (edm::Event &e, const edm::EventSetup &) override
 process one event More...
 

Private Attributes

bool firstEvent_
 
PdtEntry particle_
 
edm::EDGetTokenT< reco::GenParticleCollectionsrcToken_
 source collection name More...
 
int status_
 particle status More...
 
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecordtableToken_
 particle type More...
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 16 of file GenParticleDecaySelector.cc.

Constructor & Destructor Documentation

◆ GenParticleDecaySelector()

GenParticleDecaySelector::GenParticleDecaySelector ( const edm::ParameterSet cfg)

constructor

Definition at line 51 of file GenParticleDecaySelector.cc.

52  : firstEvent_(true),
53  srcToken_(consumes<GenParticleCollection>(cfg.getParameter<InputTag>("src"))),
55  particle_(cfg.getParameter<PdtEntry>("particle")),
56  status_(cfg.getParameter<int>("status")) {
57  produces<GenParticleCollection>();
58 }
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
source collection name
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > tableToken_
particle type

Member Function Documentation

◆ add()

pair< GenParticleRef, GenParticle * > GenParticleDecaySelector::add ( reco::GenParticleCollection decay,
const reco::GenParticle p,
reco::GenParticleRefProd  ref 
)
private

recursively add a new particle to the output collection

Definition at line 88 of file GenParticleDecaySelector.cc.

References ztail::d, PA_ZEESkim_cff::decay, g, runTauDisplay::gp, mps_fire::i, heavyIonCSV_trainingSettings::idx, dqmiodumpmetadata::n, AlCaHLTBitMon_ParallelJobs::p, and alignCSCRings::r.

Referenced by produce(), and counter.Counter::register().

90  {
91  size_t idx = decay.size();
92  GenParticleRef r(ref, idx);
93  decay.resize(idx + 1);
94  const LeafCandidate& part = p;
96  size_t n = p.numberOfDaughters();
97  for (size_t i = 0; i < n; ++i) {
98  pair<GenParticleRef, GenParticle*> d = add(decay, *p.daughterRef(i), ref);
99  d.second->addMother(r);
100  g.addDaughter(d.first);
101  }
102  GenParticle& gp = decay[idx] = g;
103  return make_pair(r, &gp);
104 }
std::pair< reco::GenParticleRef, reco::GenParticle * > add(reco::GenParticleCollection &, const reco::GenParticle &, reco::GenParticleRefProd)
recursively add a new particle to the output collection
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
d
Definition: ztail.py:151
part
Definition: HCALResponse.h:20

◆ fillDescriptions()

void GenParticleDecaySelector::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 60 of file GenParticleDecaySelector.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

60  {
62  desc.add<edm::InputTag>("src");
63  desc.addNode(edm::ParameterDescription<int>("particle", true) xor
65  ->setComment("the PdtEntry can be specified as either an 'int' or via its name using a 'string'");
66  desc.add<int>("status");
67 
68  descriptions.addDefault(desc);
69 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ produce()

void GenParticleDecaySelector::produce ( edm::Event e,
const edm::EventSetup es 
)
overrideprivate

process one event

Definition at line 71 of file GenParticleDecaySelector.cc.

References add(), PA_ZEESkim_cff::decay, firstEvent_, g, AJJGenJetFilter_cfi::genParticles, edm::Event::getByToken(), edm::EventSetup::getData(), edm::Event::getRefBeforePut(), eostools::move(), particle_, PdtEntry::pdgId(), edm::Event::put(), PdtEntry::setup(), srcToken_, status_, and tableToken_.

71  {
72  if (firstEvent_) {
73  auto const& pdt = es.getData(tableToken_);
74  particle_.setup(pdt);
75  firstEvent_ = false;
76  }
77 
79  evt.getByToken(srcToken_, genParticles);
80  auto decay = std::make_unique<GenParticleCollection>();
81  const GenParticleRefProd ref = evt.getRefBeforePut<GenParticleCollection>();
82  for (GenParticleCollection::const_iterator g = genParticles->begin(); g != genParticles->end(); ++g)
83  if (g->pdgId() == particle_.pdgId() && g->status() == status_)
84  add(*decay, *g, ref);
85  evt.put(std::move(decay));
86 }
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
std::pair< reco::GenParticleRef, reco::GenParticle * > add(reco::GenParticleCollection &, const reco::GenParticle &, reco::GenParticleRefProd)
recursively add a new particle to the output collection
void setup(const HepPDT::ParticleDataTable &)
fill data from Event Setup
Definition: PdtEntry.cc:26
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
source collection name
int pdgId() const
PDG id.
Definition: PdtEntry.cc:5
edm::ESGetToken< HepPDT::ParticleDataTable, edm::DefaultRecord > tableToken_
particle type
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ firstEvent_

bool GenParticleDecaySelector::firstEvent_
private

Definition at line 26 of file GenParticleDecaySelector.cc.

Referenced by produce().

◆ particle_

PdtEntry GenParticleDecaySelector::particle_
private

Definition at line 31 of file GenParticleDecaySelector.cc.

Referenced by produce().

◆ srcToken_

edm::EDGetTokenT<reco::GenParticleCollection> GenParticleDecaySelector::srcToken_
private

source collection name

Definition at line 28 of file GenParticleDecaySelector.cc.

Referenced by produce().

◆ status_

int GenParticleDecaySelector::status_
private

particle status

Definition at line 33 of file GenParticleDecaySelector.cc.

Referenced by produce().

◆ tableToken_

edm::ESGetToken<HepPDT::ParticleDataTable, edm::DefaultRecord> GenParticleDecaySelector::tableToken_
private

particle type

Definition at line 30 of file GenParticleDecaySelector.cc.

Referenced by produce().