Warning, file /geant4/examples/extended/eventgenerator/pythia/py8decayer/src/Py8Decayer.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include "Py8Decayer.hh"
0033
0034 #include "Py8DecayerEngine.hh"
0035
0036 #include "G4DynamicParticle.hh"
0037 #include "G4ParticleTable.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4Track.hh"
0040
0041 using namespace Pythia8;
0042
0043
0044
0045 Py8Decayer::Py8Decayer() : G4VExtDecayer("Py8Decayer"), fDecayer(nullptr)
0046 {
0047
0048
0049 fDecayer = new Pythia("../share/Pythia8/xmldoc", false);
0050
0051 fDecayer->setRndmEnginePtr(std::make_shared<Py8DecayerEngine>());
0052
0053
0054
0055 fDecayer->readString("ProcessLevel:all = off");
0056
0057 fDecayer->readString("ProcessLevel:resonanceDecays=on");
0058
0059
0060
0061 fDecayer->readString("Init:showAllSettings=false");
0062 fDecayer->readString("Init:showChangedSettings=false");
0063 fDecayer->readString("Init:showAllParticleData=false");
0064 fDecayer->readString("Init:showChangedParticleData=false");
0065
0066
0067
0068
0069 fDecayer->readString("Next:numberShowProcess = 0");
0070 fDecayer->readString("Next:numberShowEvent = 10");
0071
0072 fDecayer->init();
0073
0074
0075
0076
0077
0078 fDecayer->readString("111:onMode = off");
0079 }
0080
0081
0082
0083 Py8Decayer::~Py8Decayer()
0084 {
0085 delete fDecayer;
0086 }
0087
0088
0089
0090 G4DecayProducts* Py8Decayer::ImportDecayProducts(const G4Track& track)
0091 {
0092 fDecayer->event.reset();
0093
0094 G4DecayProducts* dproducts = nullptr;
0095
0096 G4ParticleDefinition* pd = track.GetDefinition();
0097 int pdgid = pd->GetPDGEncoding();
0098
0099
0100
0101 if (!fDecayer->particleData.findParticle(pdgid)) {
0102 G4cout << " can NOT find pdgid = " << pdgid << " in Pythia8::ParticleData" << G4endl;
0103 return dproducts;
0104 }
0105
0106 if (!fDecayer->particleData.canDecay(pdgid)) {
0107 G4cout << " Particle of pdgid = " << pdgid << " can NOT be decayed by Pythia8" << G4endl;
0108 return dproducts;
0109 }
0110
0111
0112
0113 fDecayer->event.append(pdgid, 1, 0, 0, track.GetMomentum().x() / CLHEP::GeV,
0114 track.GetMomentum().y() / CLHEP::GeV, track.GetMomentum().z() / CLHEP::GeV,
0115 track.GetDynamicParticle()->GetTotalEnergy() / CLHEP::GeV,
0116 pd->GetPDGMass() / CLHEP::GeV);
0117
0118
0119
0120
0121
0122
0123
0124
0125 fDecayer->event.back().pol(
0126 round(std::cos(track.GetPolarization().angle(track.GetMomentumDirection()))));
0127
0128 int npart_before_decay = fDecayer->event.size();
0129
0130 fDecayer->next();
0131
0132 int npart_after_decay = fDecayer->event.size();
0133
0134
0135
0136 dproducts = new G4DecayProducts(*(track.GetDynamicParticle()));
0137
0138
0139
0140
0141 for (int ip = npart_before_decay; ip < npart_after_decay; ++ip) {
0142
0143
0144
0145
0146
0147
0148
0149 if (fDecayer->event[ip].status() < 0) continue;
0150
0151
0152
0153
0154 G4ParticleDefinition* pddec =
0155 G4ParticleTable::GetParticleTable()->FindParticle(fDecayer->event[ip].id());
0156 if (!pddec) continue;
0157 G4ThreeVector momentum =
0158 G4ThreeVector(fDecayer->event[ip].px() * CLHEP::GeV, fDecayer->event[ip].py() * CLHEP::GeV,
0159 fDecayer->event[ip].pz() * CLHEP::GeV);
0160 dproducts->PushProducts(new G4DynamicParticle(pddec, momentum));
0161 }
0162
0163 return dproducts;
0164 }
0165
0166