103 G4int pdgEncoding = particleDefinition->GetPDGEncoding();
104 TParticlePDG* particlePDG =
105 TDatabasePDG::Instance()->GetParticle(pdgEncoding);
106 if (particlePDG)
return;
109 G4String g4Name = particleDefinition->GetParticleName();
110 G4int pdgQ = G4int(particleDefinition->GetPDGCharge() / eplus);
112 G4String g4Type = particleDefinition->GetParticleType();
113 G4String rootType = g4Type;
114 if (g4Type ==
"nucleus" || g4Type ==
"anti_nucleus") rootType =
"Ion";
117 G4cout <<
"Adding particle to TDatabasePDG " << G4endl;
118 G4cout <<
" name: " << g4Name << G4endl;
119 G4cout <<
" g4name: " << name << G4endl;
120 G4cout <<
" PDG: " << pdgEncoding << G4endl;
121 G4cout <<
" pdgQ: " << pdgQ << G4endl;
122 G4cout <<
" type: " << rootType << G4endl;
126#ifdef G4MULTITHREADED
127 G4AutoLock lm(&addParticleMutex);
129 TDatabasePDG::Instance()->AddParticle(name, g4Name,
131 particleDefinition->GetPDGStable(),
133 rootType, pdgEncoding);
134#ifdef G4MULTITHREADED
149 const Int_t kspe = 50000000;
150 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
153 if (!pdgDB->GetParticle(kspe + 50))
155 "Cherenkov",
"Cherenkov", 0, kFALSE, 0, 0,
"Special", kspe + 50);
159 if (!pdgDB->GetParticle(kspe + 51))
160 pdgDB->AddParticle(
"FeedbackPhoton",
"FeedbackPhoton", 0, kFALSE, 0, 0,
161 "Special", kspe + 51);
167 if (!pdgDB->GetParticle(kspe + 60))
169 "GenericIon",
"GenericIon", 0.938272, kTRUE, 0, 1,
"Special", kspe + 60);
174 const Double_t kGeV = 0.9314943228;
175 const Double_t kHslash = 1.0545726663e-27;
176 const Double_t kErgGeV = 1 / 1.6021773349e-3;
177 const Double_t kHshGeV = kHslash * kErgGeV;
178 const Double_t kYearsToSec = 3600 * 24 * 365.25;
180 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
183 particle = particleTable->FindParticle(
"deuteron");
184 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
185 pdgDB->AddParticle(
"Deuteron",
"Deuteron", 2 * kGeV + 8.071e-3, kTRUE, 0, 3,
186 "Ion", particle->GetPDGEncoding());
189 particle = particleTable->FindParticle(
"triton");
190 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
191 pdgDB->AddParticle(
"Triton",
"Triton", 3 * kGeV + 14.931e-3, kFALSE,
192 kHshGeV / (12.33 * kYearsToSec), 3,
"Ion", particle->GetPDGEncoding());
195 particle = particleTable->FindParticle(
"alpha");
196 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
197 pdgDB->AddParticle(
"Alpha",
"Alpha", 4 * kGeV + 2.424e-3, kTRUE,
198 kHshGeV / (12.33 * kYearsToSec), 6,
"Ion", particle->GetPDGEncoding());
201 particle = particleTable->FindParticle(
"He3");
202 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
203 pdgDB->AddParticle(
"HE3",
"HE3", 3 * kGeV + 14.931e-3, kFALSE, 0, 6,
"Ion",
204 particle->GetPDGEncoding());
210 particle = particleTable->FindParticle(
"anti_deuteron");
211 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
212 pdgDB->AddParticle(
"AntiDeuteron",
"AntiDeuteron", 1.875613, kTRUE, 0, -3,
213 "Ion", particle->GetPDGEncoding());
216 particle = particleTable->FindParticle(
"anti_triton");
217 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
218 pdgDB->AddParticle(
"AntiTriton",
"AntiTriton", 2.808921, kTRUE, 0, -3,
219 "Ion", particle->GetPDGEncoding());
222 particle = particleTable->FindParticle(
"anti_alpha");
223 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
224 pdgDB->AddParticle(
"AntiAlpha",
"AntiAlpha", 3.727379, kTRUE, 0, -6,
"Ion",
225 particle->GetPDGEncoding());
228 particle = particleTable->FindParticle(
"anti_He3");
229 if (particle && !pdgDB->GetParticle(particle->GetPDGEncoding())) {
230 pdgDB->AddParticle(
"AntiHE3",
"AntiHE3", 2.808391, kTRUE, 0, -6,
"Ion",
231 particle->GetPDGEncoding());
235 particle = particleTable->FindParticle(
"monopole");
237 if (!pdgDB->GetParticle(60000000)) {
238 G4cout <<
"Adding monnopole in TDatabase with mass "
239 << particle->GetPDGMass() / GeV << G4endl;
240 pdgDB->AddParticle(
"Monopole",
"Monopole", particle->GetPDGMass() / GeV,
241 kTRUE, particle->GetPDGCharge() / eplus * 3.,
243 "Special", 60000000);
248 "Cannot add monopole with PDG=60000000 in TDatabasePDG.");
268 TMCParticleType mcType, Double_t mass, Double_t charge, Double_t lifetime,
269 const TString& pType, Double_t width, Int_t iSpin, Int_t iParity,
270 Int_t iConjugation, Int_t iIsospin, Int_t iIsospinZ, Int_t gParity,
271 Int_t lepton, Int_t baryon, Bool_t stable, Bool_t shortlived,
272 const TString& subType, Int_t antiEncoding, Double_t magMoment,
278 G4cout <<
"Adding particle with: " << G4endl <<
" pdg = " << pdg
279 << G4endl <<
" name = " << name << G4endl
280 <<
" mcType = " << mcType << G4endl
281 <<
" mass [GeV} = " << mass << G4endl
282 <<
" charge [e] = " << charge << G4endl
283 <<
" lifetime [s] = " << lifetime << G4endl
284 <<
" pType = " << pType.Data() << G4endl
285 <<
" width = " << width << G4endl
286 <<
" iSpin = " << iSpin << G4endl
287 <<
" iParity = " << iParity << G4endl
288 <<
" iConjugation= " << iConjugation << G4endl
289 <<
" iIsospin = " << iIsospin << G4endl
290 <<
" iIsospinZ = " << iIsospinZ << G4endl
291 <<
" gParity = " << gParity << G4endl
292 <<
" lepton = " << lepton << G4endl
293 <<
" baryon = " << baryon << G4endl
294 <<
" stable = " << stable << G4endl
295 <<
" shortlived = " << shortlived << G4endl
296 <<
" subType = " << subType.Data() << G4endl
297 <<
" antiEncoding = " << antiEncoding << G4endl
298 <<
" magMoment = " << magMoment << G4endl
299 <<
" excitation [GeV] = " << excitation << G4endl;
308 iIsospinZ, gParity, pType.Data(), lepton, baryon, pdg, stable,
314 if (antiEncoding != 0) anti = antiEncoding;
316 TDatabasePDG* pdgDB = TDatabasePDG::Instance();
317 if (!pdgDB->GetParticle(pdg)) {
318 pdgDB->AddParticle(name.Data(), name.Data(), mass, stable, width,
319 charge * 3, pType.Data(), pdg, anti);
371 Int_t pdg, Float_t bratio[6], Int_t mode[6][3])
378 "Cannot define decay mode for particle with PDG=0");
381 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
384 if (!particleDefinition) {
388 "Particle PDG=" + pdgs +
" was not found in G4ParticleTable.");
391 G4String particleName = particleDefinition->GetParticleName();
392 G4DecayTable* decayTable =
new G4DecayTable();
396 for (Int_t kz = 0; kz < 6; ++kz) {
399 if (bratio[kz] == 0.)
break;
402 G4int nofDaughters = 0;
403 std::vector<G4String> daughtersNames(3);
404 for (G4int i = 0; i < 3; i++) {
405 daughtersNames[i] =
"";
406 if (mode[kz][i] != 0) {
408 particleTable->FindParticle(mode[kz][i]);
413 "Daughter particle PDG=" + pdgs +
414 " was not found in G4ParticleTable.");
416 daughtersNames[i] = daughter->GetParticleName();
422 G4VDecayChannel* decayChannel =
423 new G4PhaseSpaceDecayChannel(particleName, bratio[kz] / 100.0,
424 nofDaughters, daughtersNames[0], daughtersNames[1], daughtersNames[2]);
425 decayTable->Insert(decayChannel);
428 particleDefinition->SetDecayTable(decayTable);
430 if (
VerboseLevel() > 1) particleDefinition->DumpTable();
Definition of the TG4ParticlesManager class.
Definition of the TG4UserParticle class.
Provides mapping between TDatabasePDG and Geant4 particles.
void AddIon(const G4String &name, G4int Z, G4int A, G4int Q, G4double excEnergy)
UserIonMap fUserIonMap
user defined ions mappped by their names
G4DynamicParticle * CreateDynamicParticle(const TParticle *particle) const
G4ThreeVector GetParticlePolarization(const TParticle *particle) const
UserParticleVector fUserParticles
vector of user defined particles
G4ParticleDefinition * GetParticleDefinition(const TParticle *particle, G4bool warn=true) const
Bool_t SetDecayMode(Int_t pdg, Float_t bratio[6], Int_t mode[6][3])
G4ThreeVector GetParticlePosition(const TParticle *particle) const
TG4NameMap fParticleNameMap
the mapping between G4 particle names and TDatabasePDG names for special particles
TG4UserIon * GetUserIon(const G4String &ionName, G4bool warn=true) const
TParticle * GetParticle(const TClonesArray *particles, G4int index) const
void AddParticle(Int_t pdg, const TString &name, TMCParticleType mcType, Double_t mass, Double_t charge, Double_t lifetime, const TString &pType, Double_t width, Int_t iSpin, Int_t iParity, Int_t iConjugation, Int_t iIsospin, Int_t iIsospinZ, Int_t gParity, Int_t lepton, Int_t baryon, Bool_t stable, Bool_t shortlived=kFALSE, const TString &subType="", Int_t antiEncoding=0, Double_t magMoment=0.0, Double_t excitation=0.0)
G4ThreeVector GetParticleMomentum(const TParticle *particle) const
static TG4ParticlesManager * fgInstance
this instance
void AddParticleToPdgDatabase(const G4String &name, G4ParticleDefinition *particleDefinition)
The class for user particle definition.