CMS 3D CMS Logo

GenParticleDecaySelector.cc
Go to the documentation of this file.
1 /* \class GenParticleDecaySelector
2  *
3  * \author Luca Lista, INFN
4  *
5  *
6  */
7 
12 
14 public:
17 
18 private:
20  void produce(edm::Event& e, const edm::EventSetup&) override;
27  int status_;
29  std::pair<reco::GenParticleRef, reco::GenParticle*> add(reco::GenParticleCollection&,
30  const reco::GenParticle&,
32 };
33 
38 
39 using namespace edm;
40 using namespace reco;
41 using namespace std;
42 
44  : firstEvent_(true),
45  srcToken_(consumes<GenParticleCollection>(cfg.getParameter<InputTag>("src"))),
46  particle_(cfg.getParameter<PdtEntry>("particle")),
47  status_(cfg.getParameter<int>("status")) {
48  produces<GenParticleCollection>();
49 }
50 
52  if (firstEvent_) {
53  particle_.setup(es);
54  firstEvent_ = false;
55  }
56 
59  auto decay = std::make_unique<GenParticleCollection>();
61  for (GenParticleCollection::const_iterator g = genParticles->begin(); g != genParticles->end(); ++g)
62  if (g->pdgId() == particle_.pdgId() && g->status() == status_)
63  add(*decay, *g, ref);
64  evt.put(std::move(decay));
65 }
66 
67 pair<GenParticleRef, GenParticle*> GenParticleDecaySelector::add(GenParticleCollection& decay,
68  const GenParticle& p,
69  GenParticleRefProd ref) {
70  size_t idx = decay.size();
71  GenParticleRef r(ref, idx);
72  decay.resize(idx + 1);
73  const LeafCandidate& part = p;
75  size_t n = p.numberOfDaughters();
76  for (size_t i = 0; i < n; ++i) {
77  pair<GenParticleRef, GenParticle*> d = add(decay, *p.daughterRef(i), ref);
78  d.second->addMother(r);
79  g.addDaughter(d.first);
80  }
81  GenParticle& gp = decay[idx] = g;
82  return make_pair(r, &gp);
83 }
84 
86 
edm::RefProd< GenParticleCollection >
edm::Event::getRefBeforePut
RefProd< PROD > getRefBeforePut()
Definition: Event.h:158
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
genParticles2HepMC_cfi.genParticles
genParticles
Definition: genParticles2HepMC_cfi.py:4
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
PdtEntry::pdgId
int pdgId() const
PDG id.
Definition: PdtEntry.cc:7
EDProducer.h
GenParticleDecaySelector::produce
void produce(edm::Event &e, const edm::EventSetup &) override
process one event
Definition: GenParticleDecaySelector.cc:51
reco::GenParticle
Definition: GenParticle.h:21
edm::EDGetTokenT< reco::GenParticleCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
reco::GenParticleCollection
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
Definition: GenParticleFwd.h:13
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
GenParticle
Definition: GenParticle.py:1
edm::Ref< GenParticleCollection >
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
GenParticle.h
MakerMacros.h
part
part
Definition: HCALResponse.h:20
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GenParticleDecaySelector::firstEvent_
bool firstEvent_
Definition: GenParticleDecaySelector.cc:21
GenParticleDecaySelector::particle_
PdtEntry particle_
particle type
Definition: GenParticleDecaySelector.cc:25
GenParticleFwd.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
GenParticleDecaySelector::srcToken_
edm::EDGetTokenT< reco::GenParticleCollection > srcToken_
source collection name
Definition: GenParticleDecaySelector.cc:23
GenParticleDecaySelector::GenParticleDecaySelector
GenParticleDecaySelector(const edm::ParameterSet &)
constructor
Definition: GenParticleDecaySelector.cc:43
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PdtEntry.h
PdtEntry::setup
void setup(const edm::EventSetup &)
fill data from Event Setup
Definition: PdtEntry.cc:28
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
GenParticleDecaySelector::status_
int status_
particle status
Definition: GenParticleDecaySelector.cc:27
edm::EventSetup
Definition: EventSetup.h:57
InputTag.h
looper.cfg
cfg
Definition: looper.py:297
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PA_ZEESkim_cff.decay
decay
Definition: PA_ZEESkim_cff.py:26
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
GenParticleDecaySelector
Definition: GenParticleDecaySelector.cc:13
PdtEntry
Definition: PdtEntry.h:19
edm::EDProducer
Definition: EDProducer.h:35
ztail.d
d
Definition: ztail.py:151
reco::LeafCandidate
Definition: LeafCandidate.h:16
ParameterSet.h
edm::Event
Definition: Event.h:73
GenParticleDecaySelector::add
std::pair< reco::GenParticleRef, reco::GenParticle * > add(reco::GenParticleCollection &, const reco::GenParticle &, reco::GenParticleRefProd)
recursively add a new particle to the output collection
Definition: GenParticleDecaySelector.cc:67
edm::InputTag
Definition: InputTag.h:15
g
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
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37