CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PythiaDecays Class Reference

#include <PythiaDecays.h>

Public Member Functions

const DaughterParticleListparticleDaughtersPy6 (ParticlePropagator &particle, CLHEP::HepRandomEngine *)
 
const DaughterParticleListparticleDaughtersPy8 (ParticlePropagator &particle, CLHEP::HepRandomEngine *)
 
 PythiaDecays (std::string program)
 
 ~PythiaDecays ()
 

Private Attributes

std::auto_ptr< Pythia8::Pythia > decayer
 
std::unique_ptr
< gen::P8RndmEngine
p8RndmEngine
 
std::string program_
 
Pythia6jetspyjets
 
gen::Pythia6Servicepyservice
 
DaughterParticleList theList
 

Detailed Description

Definition at line 34 of file PythiaDecays.h.

Constructor & Destructor Documentation

PythiaDecays::PythiaDecays ( std::string  program)

Definition at line 23 of file PythiaDecays.cc.

References gather_cfg::cout, decayer, p8RndmEngine, sysUtil::pid, program_, pyjets, pyservice, and Pythia6jets::Pythia6jets().

24 {
25  program_=program;
26  if (program_ == "pythia6") {
28  pyjets = new Pythia6jets();
30  // The PYTHIA decay tables will be initialized later
31  } else if (program_ == "pythia8") {
32 
34 
35  // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
36  decayer.reset(new Pythia8::Pythia);
38  decayer->setRndmEnginePtr(p8RndmEngine.get());
39  decayer->settings.flag("ProcessLevel:all",false);
40  decayer->settings.flag("PartonLevel:FSRinResonances",false);
41  decayer->settings.flag("ProcessLevel:resonanceDecays",false);
42  decayer->init();
43 
44  // forbid all decays
45  Pythia8::ParticleData & pdt = decayer->particleData;
46  int pid = 1;
47  while(pdt.nextId(pid) > pid){
48  pid = pdt.nextId(pid);
49  pdt.mayDecay(pid,false);
50  }
51 
52  } else {
53  std::cout << "WARNING: you are requesting an option which is not available in PythiaDecays::PythiaDecays " << std::endl;
54  }
55 
56 }
gen::Pythia6Service * pyservice
Definition: PythiaDecays.h:49
std::auto_ptr< Pythia8::Pythia > decayer
Definition: PythiaDecays.h:52
std::string program_
Definition: PythiaDecays.h:47
HepPDT::ParticleData ParticleData
std::unique_ptr< gen::P8RndmEngine > p8RndmEngine
Definition: PythiaDecays.h:53
tuple pid
Definition: sysUtil.py:22
Pythia6jets * pyjets
Definition: PythiaDecays.h:50
tuple cout
Definition: gather_cfg.py:121
PythiaDecays::~PythiaDecays ( )

Definition at line 58 of file PythiaDecays.cc.

References program_, pyjets, and pyservice.

58  {
59  if (program_ == "pythia6") {
60  delete pyjets;
61  delete pyservice;
62  }
63 }
gen::Pythia6Service * pyservice
Definition: PythiaDecays.h:49
std::string program_
Definition: PythiaDecays.h:47
Pythia6jets * pyjets
Definition: PythiaDecays.h:50

Member Function Documentation

const DaughterParticleList & PythiaDecays::particleDaughtersPy6 ( ParticlePropagator particle,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 111 of file PythiaDecays.cc.

References i, Pythia6jets::k(), RawParticle::mass(), bookConverter::max, Pythia6jets::n(), Pythia6jets::p(), RawParticle::pid(), pyjets, pyservice, PYTHIA6PYDECY, RawParticle::T(), theList, Pythia6jets::v(), RawParticle::X(), RawParticle::Y(), and RawParticle::Z().

Referenced by TrajectoryManager::updateWithDaughters().

112 {
114 
115  gen::Pythia6Service::InstanceWrapper guard(pyservice); // grab Py6 context
116 
117  // Pythia6jets pyjets;
118  int ip;
119 
120  pyjets->k(1,1) = 1;
121  pyjets->k(1,2) = particle.pid();
122  pyjets->p(1,1) = particle.Px();
123  pyjets->p(1,2) = particle.Py();
124  pyjets->p(1,3) = particle.Pz();
125  pyjets->p(1,4) = std::max(particle.mass(),particle.e());
126  pyjets->p(1,5) = particle.mass();
127  pyjets->v(1,1) = particle.X();
128  pyjets->v(1,2) = particle.Y();
129  pyjets->v(1,3) = particle.Z();
130  pyjets->v(1,4) = particle.T();
131  pyjets->n() = 1;
132 
133  ip = 1;
134  PYTHIA6PYDECY(&ip);
135 
136  // Fill the list of daughters
137  theList.clear();
138  if ( pyjets->n()==1 ) return theList;
139 
140  theList.resize(pyjets->n()-1,RawParticle());
141 
142  for (int i=2;i<=pyjets->n();++i) {
143 
144  theList[i-2].SetXYZT(pyjets->p(i,1),pyjets->p(i,2),
145  pyjets->p(i,3),pyjets->p(i,4));
146  theList[i-2].setVertex(pyjets->v(i,1),pyjets->v(i,2),
147  pyjets->v(i,3),pyjets->v(i,4));
148  theList[i-2].setID(pyjets->k(i,2));
149  theList[i-2].setMass(pyjets->p(i,5));
150 
151  }
152 
153  return theList;
154 
155 }
int i
Definition: DBlmapReader.cc:9
int & n(void)
Definition: Pythia6jets.cc:37
gen::Pythia6Service * pyservice
Definition: PythiaDecays.h:49
int pid() const
get the HEP particle ID number
Definition: RawParticle.h:265
double mass() const
get the MEASURED mass
Definition: RawParticle.h:283
double & v(int i, int j)
Definition: Pythia6jets.cc:73
DaughterParticleList theList
Definition: PythiaDecays.h:46
double Y() const
y of vertex
Definition: RawParticle.h:275
double Z() const
z of vertex
Definition: RawParticle.h:276
int & k(int i, int j)
Definition: Pythia6jets.cc:49
double X() const
x of vertex
Definition: RawParticle.h:274
#define PYTHIA6PYDECY
Definition: PythiaDecays.cc:17
Pythia6jets * pyjets
Definition: PythiaDecays.h:50
double T() const
vertex time
Definition: RawParticle.h:277
double & p(int i, int j)
Definition: Pythia6jets.cc:61
const DaughterParticleList & PythiaDecays::particleDaughtersPy8 ( ParticlePropagator particle,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 66 of file PythiaDecays.cc.

References decayer, RawParticle::mass(), RawParticle::momentum(), p8RndmEngine, sysUtil::pid, RawParticle::pid(), RawParticle::T(), theList, RawParticle::X(), RawParticle::Y(), and RawParticle::Z().

Referenced by TrajectoryManager::updateWithDaughters().

67 {
69 
70  theList.clear();
71 
72  // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
73  int pid = particle.pid();
74  decayer->event.reset();
75  Pythia8::Particle py8part( pid , 93, 0, 0, 0, 0, 0, 0,
76  particle.momentum().x(), // note: momentum().x() and Px() are the same
77  particle.momentum().y(),
78  particle.momentum().z(),
79  particle.momentum().t(),
80  particle.mass() );
81  py8part.vProd( particle.X(), particle.Y(),
82  particle.Z(), particle.T() );
83  decayer->event.append( py8part );
84 
85  int nentries_before = decayer->event.size();
86  decayer->particleData.mayDecay(pid,true); // switch on the decay of this and only this particle (avoid double decays)
87  decayer->next(); // do the decay
88  decayer->particleData.mayDecay(pid,false); // switch it off again
89  int nentries_after = decayer->event.size();
90  if ( nentries_after <= nentries_before ) return theList;
91 
92  theList.resize(nentries_after - nentries_before,RawParticle());
93 
94 
95  for ( int ipart=nentries_before; ipart<nentries_after; ipart++ )
96  {
97  Pythia8::Particle& py8daughter = decayer->event[ipart];
98  theList[ipart-nentries_before].SetXYZT( py8daughter.px(), py8daughter.py(), py8daughter.pz(), py8daughter.e() );
99  theList[ipart-nentries_before].setVertex( py8daughter.xProd(),
100  py8daughter.yProd(),
101  py8daughter.zProd(),
102  py8daughter.tProd() );
103  theList[ipart-nentries_before].setID( py8daughter.id() );
104  theList[ipart-nentries_before].setMass( py8daughter.m() );
105  }
106 
107  return theList;
108 }
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:46
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:52
std::unique_ptr< gen::P8RndmEngine > p8RndmEngine
Definition: PythiaDecays.h:53
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

Member Data Documentation

std::auto_ptr<Pythia8::Pythia> PythiaDecays::decayer
private

Definition at line 52 of file PythiaDecays.h.

Referenced by particleDaughtersPy8(), and PythiaDecays().

std::unique_ptr<gen::P8RndmEngine> PythiaDecays::p8RndmEngine
private

Definition at line 53 of file PythiaDecays.h.

Referenced by particleDaughtersPy8(), and PythiaDecays().

std::string PythiaDecays::program_
private

Definition at line 47 of file PythiaDecays.h.

Referenced by PythiaDecays(), and ~PythiaDecays().

Pythia6jets* PythiaDecays::pyjets
private

Definition at line 50 of file PythiaDecays.h.

Referenced by particleDaughtersPy6(), PythiaDecays(), and ~PythiaDecays().

gen::Pythia6Service* PythiaDecays::pyservice
private

Definition at line 49 of file PythiaDecays.h.

Referenced by particleDaughtersPy6(), PythiaDecays(), and ~PythiaDecays().

DaughterParticleList PythiaDecays::theList
private

Definition at line 46 of file PythiaDecays.h.

Referenced by particleDaughtersPy6(), and particleDaughtersPy8().