CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PythiaDecays.cc
Go to the documentation of this file.
4 
5 #include <Pythia8/Pythia.h>
6 #include "Pythia8Plugins/HepMC2.h"
7 
9 {
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 PythiaDecays::particleDaughters(ParticlePropagator& particle, CLHEP::HepRandomEngine* engine)
31 {
33 
34  theList.clear();
35 
36  // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
37  int pid = particle.pid();
38  decayer->event.reset();
39  Pythia8::Particle py8part( pid , 93, 0, 0, 0, 0, 0, 0,
40  particle.momentum().x(), // note: momentum().x() and Px() are the same
41  particle.momentum().y(),
42  particle.momentum().z(),
43  particle.momentum().t(),
44  particle.mass() );
45  py8part.vProd( particle.X(), particle.Y(),
46  particle.Z(), particle.T() );
47  decayer->event.append( py8part );
48 
49  int nentries_before = decayer->event.size();
50  decayer->particleData.mayDecay(pid,true); // switch on the decay of this and only this particle (avoid double decays)
51  decayer->next(); // do the decay
52  decayer->particleData.mayDecay(pid,false); // switch it off again
53  int nentries_after = decayer->event.size();
54  if ( nentries_after <= nentries_before ) return theList;
55 
56  theList.resize(nentries_after - nentries_before,RawParticle());
57 
58 
59  for ( int ipart=nentries_before; ipart<nentries_after; ipart++ )
60  {
61  Pythia8::Particle& py8daughter = decayer->event[ipart];
62  theList[ipart-nentries_before].SetXYZT( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
63  theList[ipart-nentries_before].setVertex( py8daughter.xProd(),
64  py8daughter.yProd(),
65  py8daughter.zProd(),
66  py8daughter.tProd() );
67  theList[ipart-nentries_before].setID( py8daughter.id() );
68  theList[ipart-nentries_before].setMass( py8daughter.m() );
69  }
70 
71  return theList;
72 }
const DaughterParticleList & particleDaughters(ParticlePropagator &particle, CLHEP::HepRandomEngine *)
Definition: PythiaDecays.cc:30
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:265
double mass() const
get the MEASURED mass
Definition: RawParticle.h:283
DaughterParticleList theList
Definition: PythiaDecays.h:38
const XYZTLorentzVector & momentum() const
the momentum fourvector
Definition: RawParticle.h:286
double Y() const
y of vertex
Definition: RawParticle.h:275
double Z() const
z of vertex
Definition: RawParticle.h:276
std::auto_ptr< Pythia8::Pythia > decayer
Definition: PythiaDecays.h:39
HepPDT::ParticleData ParticleData
std::unique_ptr< gen::P8RndmEngine > p8RndmEngine
Definition: PythiaDecays.h:40
tuple pid
Definition: sysUtil.py:22
double X() const
x of vertex
Definition: RawParticle.h:274
double T() const
vertex time
Definition: RawParticle.h:277
std::vector< RawParticle > DaughterParticleList
Definition: PythiaDecays.h:25