Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TextPPRetriever.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25
26#include "G4TextPPRetriever.hh"
27
28#include "G4DecayTable.hh"
30#include "G4ParticleTable.hh"
31#include "G4SystemOfUnits.hh"
32#include "G4Tokenizer.hh"
33#include "G4VDecayChannel.hh"
34#include "G4ios.hh"
35#include "globals.hh"
36
37#include <fstream>
38
40{
41 SparseOption(option);
42
43 // pointer to the particle table
46 theParticleIterator = theParticleTable->GetIterator();
47
48 // loop over all particles in G4ParticleTable
50 while ((*theParticleIterator)()) { // Loop checking, 09.08.2015, K.Kurashige
51 G4ParticleDefinition* particle = theParticleIterator->value();
52 ModifyPropertyTable(particle);
53 }
54}
55
57{
58 G4Tokenizer savedToken(option);
59
60 // 1st option : base directory
61 baseDir = savedToken();
62 if (!baseDir.empty()) {
63 if (baseDir.back() != '/') {
64 baseDir += "/";
65 }
66 }
67}
68
70{
71 G4String name = particle->GetParticleName();
72
73 //--- open file -----
74 G4String fileName = baseDir + name + ".txt";
75 // exception
76 if (name == "J/psi") fileName = baseDir + "jpsi.txt";
77
78 std::ifstream inFile(fileName, std::ios::in);
79 if (!inFile) return false;
80
81 // GetParticleProperty
83
84 // particle name encoding
85 G4String name_t;
87 inFile >> name_t >> encoding;
88 if ((name != name_t) || (encoding != pData->GetPDGEncoding())) {
89 G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
90 G4cout << "particle name or encoding mismatch for " << name;
91 G4cout << G4endl;
92 return false;
93 }
94
95 // IJPC
96 G4int iIsoSpin, iSpin, iParity, iConj;
97 inFile >> iIsoSpin >> iSpin >> iParity >> iConj;
98 if ((iIsoSpin != pData->GetPDGiIsospin()) || (iSpin != pData->GetPDGiSpin())
99 || (iParity != pData->GetPDGiParity()) || (iConj != pData->GetPDGiConjugation()))
100 {
101 G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
102 G4cout << "IJPC mismatch for " << name;
103 G4cout << G4endl;
104 return false;
105 }
106
107 // mass, width, charge
108 G4double mass, width, charge;
109 inFile >> mass >> width >> charge;
110 mass *= GeV;
111 width *= GeV;
112 charge *= eplus;
113 if (mass != pData->GetPDGMass()) {
114 pData->SetPDGMass(mass);
115 }
116 if (width != pData->GetPDGWidth()) {
117 pData->SetPDGWidth(width);
118 }
119 if (charge != pData->GetPDGCharge()) {
120 pData->SetPDGCharge(charge);
121 }
122
123 // life time
124 G4double tlife;
125 inFile >> tlife;
126 tlife *= second;
127 if (tlife != pData->GetPDGLifeTime()) {
128 pData->SetPDGLifeTime(tlife);
129 }
130
132
133 // Decay Table
134 G4DecayTable* dcyTable = particle->GetDecayTable();
135 if (dcyTable == nullptr) return true;
136
137 G4int idx = 0;
138 while (!inFile.eof()) { // Loop checking, 09.08.2015, K.Kurashige
139 G4double br;
140 G4int n_daughters;
141 inFile >> br >> n_daughters;
142
143 G4VDecayChannel* channel = dcyTable->GetDecayChannel(idx);
144
145 if (n_daughters == channel->GetNumberOfDaughters()) {
146 channel->SetBR(br);
147 }
148
149 idx += 1;
150 if (idx >= dcyTable->entries()) break;
151 }
152 return true;
153}
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define theParticleIterator
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4VDecayChannel * GetDecayChannel(G4int index) const
G4int entries() const
G4DecayTable * GetDecayTable() const
const G4String & GetParticleName() const
void SetPDGMass(G4double newMass)
void SetPDGCharge(G4double newCharge)
void SetPDGLifeTime(G4double newLifeTime)
void SetPDGWidth(G4double newWidth)
G4ParticlePropertyData * GetParticleProperty(const G4String &aParticleName)
G4bool SetParticleProperty(const G4ParticlePropertyData &newProperty)
void reset(G4bool ifSkipIon=true)
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
void SparseOption(const G4String &option)
G4bool ModifyPropertyTable(const G4ParticleDefinition *)
void Retrieve(const G4String &option="") override
void SetBR(G4double value)
G4int GetNumberOfDaughters() const