Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TextPPRetriever Class Reference

#include <G4TextPPRetriever.hh>

+ Inheritance diagram for G4TextPPRetriever:

Public Member Functions

void Retrieve (const G4String &option="") override
 
- Public Member Functions inherited from G4VParticlePropertyRetriever
 G4VParticlePropertyRetriever ()
 
virtual ~G4VParticlePropertyRetriever ()
 
G4bool operator== (const G4VParticlePropertyRetriever &right) const
 
G4bool operator!= (const G4VParticlePropertyRetriever &right) const
 

Protected Member Functions

void SparseOption (const G4String &option)
 
G4bool ModifyPropertyTable (const G4ParticleDefinition *)
 

Protected Attributes

G4String baseDir
 
- Protected Attributes inherited from G4VParticlePropertyRetriever
G4ParticlePropertyTablepPropertyTable
 

Detailed Description

Definition at line 32 of file G4TextPPRetriever.hh.

Member Function Documentation

◆ ModifyPropertyTable()

G4bool G4TextPPRetriever::ModifyPropertyTable ( const G4ParticleDefinition * particle)
protected

Definition at line 69 of file G4TextPPRetriever.cc.

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
int G4int
Definition G4Types.hh:85
#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 SetBR(G4double value)
G4int GetNumberOfDaughters() const
const char * name(G4int ptype)

Referenced by Retrieve().

◆ Retrieve()

void G4TextPPRetriever::Retrieve ( const G4String & option = "")
overridevirtual

Implements G4VParticlePropertyRetriever.

Definition at line 39 of file G4TextPPRetriever.cc.

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}
#define theParticleIterator
void reset(G4bool ifSkipIon=true)
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
void SparseOption(const G4String &option)
G4bool ModifyPropertyTable(const G4ParticleDefinition *)

◆ SparseOption()

void G4TextPPRetriever::SparseOption ( const G4String & option)
protected

Definition at line 56 of file G4TextPPRetriever.cc.

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}

Referenced by Retrieve().

Member Data Documentation

◆ baseDir

G4String G4TextPPRetriever::baseDir
protected

Definition at line 42 of file G4TextPPRetriever.hh.

Referenced by ModifyPropertyTable(), and SparseOption().


The documentation for this class was generated from the following files: