CMS 3D CMS Logo

PythiaDecays.cc
Go to the documentation of this file.
5 
6 #include <Pythia8/Pythia.h>
7 #include "Pythia8Plugins/HepMC2.h"
8 
10  // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
11  decayer.reset(new Pythia8::Pythia);
13  decayer->setRndmEnginePtr(p8RndmEngine.get());
14  decayer->settings.flag("ProcessLevel:all", false);
15  decayer->settings.flag("PartonLevel:FSRinResonances", false);
16  decayer->settings.flag("ProcessLevel:resonanceDecays", false);
17  decayer->init();
18 
19  // forbid all decays
20  // (decays are allowed selectively in the particleDaughters function)
21  Pythia8::ParticleData& pdt = decayer->particleData;
22  int pid = 1;
23  while (pdt.nextId(pid) > pid) {
24  pid = pdt.nextId(pid);
25  pdt.mayDecay(pid, false);
26  }
27 }
28 
30 
32  CLHEP::HepRandomEngine* engine) {
34 
35  theList.clear();
36 
37  // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
38  int pid = particle.particle().pid();
39  decayer->event.reset();
40  Pythia8::Particle py8part(pid,
41  93,
42  0,
43  0,
44  0,
45  0,
46  0,
47  0,
48  particle.particle().momentum().x(), // note: momentum().x() and Px() are the same
49  particle.particle().momentum().y(),
50  particle.particle().momentum().z(),
51  particle.particle().momentum().t(),
52  particle.particle().mass());
53  py8part.vProd(particle.particle().X(), particle.particle().Y(), particle.particle().Z(), particle.particle().T());
54  decayer->event.append(py8part);
55 
56  int nentries_before = decayer->event.size();
57  decayer->particleData.mayDecay(pid,
58  true); // switch on the decay of this and only this particle (avoid double decays)
59  decayer->next(); // do the decay
60  decayer->particleData.mayDecay(pid, false); // switch it off again
61  int nentries_after = decayer->event.size();
62  if (nentries_after <= nentries_before)
63  return theList;
64 
65  theList.reserve(nentries_after - nentries_before);
66 
67  for (int ipart = nentries_before; ipart < nentries_after; ipart++) {
68  Pythia8::Particle& py8daughter = decayer->event[ipart];
69  theList
70  .emplace_back(makeParticle(
71  particle.particleDataTable(),
72  py8daughter.id(),
73  XYZTLorentzVector(py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e()),
74  XYZTLorentzVector(py8daughter.xProd(), py8daughter.yProd(), py8daughter.zProd(), py8daughter.tProd())))
75  .setMass(py8daughter.m());
76  }
77 
78  return theList;
79 }
BaseParticlePropagator::particle
RawParticle const & particle() const
The particle being propagated.
Definition: BaseParticlePropagator.h:164
RawParticle::momentum
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:321
makeParticle
RawParticle makeParticle(HepPDT::ParticleDataTable const *, int id, const math::XYZTLorentzVector &p)
Definition: makeParticle.cc:28
RawParticle::pid
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:277
PythiaDecays.h
XYZTLorentzVector
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:25
ParticlePropagator::particleDataTable
const HepPDT::ParticleDataTable * particleDataTable() const
Definition: ParticlePropagator.h:100
PythiaDecays::~PythiaDecays
~PythiaDecays()
Definition: PythiaDecays.cc:29
ParticleData
HepPDT::ParticleData ParticleData
Definition: ParticleDataTable.h:9
gen::P8RndmEngine
Definition: P8RndmEngine.h:27
RawParticle::Z
double Z() const
z of vertex
Definition: RawParticle.h:288
PythiaDecays::particleDaughters
const DaughterParticleList & particleDaughters(ParticlePropagator &particle, CLHEP::HepRandomEngine *)
Definition: PythiaDecays.cc:31
DaughterParticleList
std::vector< RawParticle > DaughterParticleList
Definition: PythiaDecays.h:25
ParticlePropagator.h
PythiaDecays::p8RndmEngine
std::unique_ptr< gen::P8RndmEngine > p8RndmEngine
Definition: PythiaDecays.h:37
PythiaDecays::theList
DaughterParticleList theList
Definition: PythiaDecays.h:35
RawParticle::T
double T() const
vertex time
Definition: RawParticle.h:289
ParticlePropagator
Definition: ParticlePropagator.h:28
RawParticle::Y
double Y() const
y of vertex
Definition: RawParticle.h:287
RawParticle::mass
double mass() const
get the MEASURED mass
Definition: RawParticle.h:295
makeParticle.h
RandomEngineSentry.h
edm::RandomEngineSentry
Definition: RandomEngineSentry.h:28
RawParticle::X
double X() const
x of vertex
Definition: RawParticle.h:286
PythiaDecays::decayer
std::unique_ptr< Pythia8::Pythia > decayer
Definition: PythiaDecays.h:36
PythiaDecays::PythiaDecays
PythiaDecays()
Definition: PythiaDecays.cc:9