CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
fastsim::Decayer Class Reference

Implementation of non-stable particle decays. More...

#include <Decayer.h>

Public Member Functions

void decay (const Particle &particle, std::vector< std::unique_ptr< Particle > > &secondaries, CLHEP::HepRandomEngine &engine) const
 Decay particle using pythia. More...
 
 Decayer ()
 Default Constructor. More...
 
 ~Decayer ()
 Default destructor. More...
 

Private Attributes

std::unique_ptr< Pythia8::Pythia > pythia_
 Instance of pythia. More...
 
std::unique_ptr< gen::P8RndmEnginepythiaRandomEngine_
 Instance of pythia Random Engine. More...
 

Detailed Description

Implementation of non-stable particle decays.

Inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc

Definition at line 37 of file Decayer.h.

Constructor & Destructor Documentation

fastsim::Decayer::Decayer ( )

Default Constructor.

Definition at line 12 of file Decayer.cc.

References sysUtil::pid, pythia_, and pythiaRandomEngine_.

13  : pythia_(new Pythia8::Pythia())
15 {
16  pythia_->setRndmEnginePtr(pythiaRandomEngine_.get());
17  pythia_->settings.flag("ProcessLevel:all",false);
18  pythia_->settings.flag("PartonLevel:FSRinResonances",false);
19  pythia_->settings.flag("ProcessLevel:resonanceDecays",false);
20  pythia_->init();
21 
22  // forbid all decays
23  // (decays are allowed selectively in the decay function)
24  Pythia8::ParticleData & pdt = pythia_->particleData;
25  int pid = 0;
26  while(pdt.nextId(pid) > pid)
27  {
28  pid = pdt.nextId(pid);
29  pdt.mayDecay(pid,false);
30  }
31 }
std::unique_ptr< gen::P8RndmEngine > pythiaRandomEngine_
Instance of pythia Random Engine.
Definition: Decayer.h:56
HepPDT::ParticleData ParticleData
std::unique_ptr< Pythia8::Pythia > pythia_
Instance of pythia.
Definition: Decayer.h:55
fastsim::Decayer::~Decayer ( )

Default destructor.

Definition at line 10 of file Decayer.cc.

10 {;}

Member Function Documentation

void fastsim::Decayer::decay ( const Particle particle,
std::vector< std::unique_ptr< Particle > > &  secondaries,
CLHEP::HepRandomEngine &  engine 
) const

Decay particle using pythia.

Parameters
particleThe particle that should be decayed.
secondariesThe decay products.
engineThe Random Engine.

Definition at line 34 of file Decayer.cc.

References funct::abs(), fastsim::Particle::charge(), fastsim::Particle::getMotherDeltaR(), fastsim::Particle::getMotherPdgId(), isExotic(), fastsim::Particle::momentum(), fastsim::Particle::pdgId(), sysUtil::pid, fastsim::Particle::position(), pythia_, pythiaRandomEngine_, and fastsim::Particle::simTrackIndex().

Referenced by FastSimProducer::createFSimTrack(), and FastSimProducer::produce().

35 {
36  // make sure pythia takes random numbers from the engine past through via the function arguments
38 
39  // inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
40  int pid = particle.pdgId();
41  // snip decay products of exotic particles or their children. These decay products are preserved from the event record.
42  // limitation: if exotic incurs heavy energy loss during propagation, the saved decay products could be too hard.
43  if (isExotic(pid) || isExotic(particle.getMotherPdgId())) {
44  return;
45  }
46 
47  pythia_->event.reset();
48 
49  // create a pythia particle which has the same properties as the FastSim particle
50  Pythia8::Particle pythiaParticle( pid , 93, 0, 0, 0, 0, 0, 0,
51  particle.momentum().X(),
52  particle.momentum().Y(),
53  particle.momentum().Z(),
54  particle.momentum().E(),
55  particle.momentum().M() );
56  pythiaParticle.vProd(particle.position().X(), particle.position().Y(), particle.position().Z(), particle.position().T());
57  pythia_->event.append(pythiaParticle);
58 
59 
60  int nentries_before = pythia_->event.size();
61  // switch on the decay of this and only this particle (avoid double decays)
62  pythia_->particleData.mayDecay(pid,true);
63  // do the decay
64  pythia_->next();
65  // switch it off again
66  pythia_->particleData.mayDecay(pid,false);
67  int nentries_after = pythia_->event.size();
68 
69  if(nentries_after <= nentries_before)return;
70 
71  // add decay products back to the event
72  for(int ipart=nentries_before; ipart<nentries_after; ipart++)
73  {
74  Pythia8::Particle& daughter = pythia_->event[ipart];
75 
76  secondaries.emplace_back(new fastsim::Particle(daughter.id()
77  ,math::XYZTLorentzVector(daughter.xProd(),daughter.yProd(),daughter.zProd(),daughter.tProd())
78  ,math::XYZTLorentzVector(daughter.px(), daughter.py(), daughter.pz(), daughter.e())));
79 
80  // daughter can inherit the SimTrackIndex of mother (if both charged): necessary for FastSim (cheat) tracking
81  if(particle.charge() != 0 && std::abs(particle.charge()-daughter.charge()) < 1E-10){
82  secondaries.back()->setMotherDeltaR(particle.momentum());
83  secondaries.back()->setMotherPdgId(particle.getMotherDeltaR() == -1 ? particle.pdgId() : particle.getMotherPdgId());
84  secondaries.back()->setMotherSimTrackIndex(particle.simTrackIndex());
85  }
86  }
87 
88  return;
89 }
std::unique_ptr< gen::P8RndmEngine > pythiaRandomEngine_
Instance of pythia Random Engine.
Definition: Decayer.h:56
double T() const
Definition: Particle.h:55
double X() const
Definition: Particle.h:49
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
double Z() const
Definition: Particle.h:53
bool isExotic(int pdgid_)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition of a generic FastSim Particle which can be propagated through the detector (formerly Parti...
Definition: Particle.h:19
double E() const
Definition: Particle.h:63
std::unique_ptr< Pythia8::Pythia > pythia_
Instance of pythia.
Definition: Decayer.h:55
double Y() const
Definition: Particle.h:51

Member Data Documentation

std::unique_ptr<Pythia8::Pythia> fastsim::Decayer::pythia_
private

Instance of pythia.

Definition at line 55 of file Decayer.h.

Referenced by decay(), and Decayer().

std::unique_ptr<gen::P8RndmEngine> fastsim::Decayer::pythiaRandomEngine_
private

Instance of pythia Random Engine.

Definition at line 56 of file Decayer.h.

Referenced by decay(), and Decayer().