Geant4 11.1.1
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

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

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 45 of file G4TextPPRetriever.hh.

Constructor & Destructor Documentation

◆ G4TextPPRetriever()

G4TextPPRetriever::G4TextPPRetriever ( )

◆ ~G4TextPPRetriever()

G4TextPPRetriever::~G4TextPPRetriever ( )
virtual

Definition at line 53 of file G4TextPPRetriever.cc.

54{
55}

Member Function Documentation

◆ ModifyPropertyTable()

G4bool G4TextPPRetriever::ModifyPropertyTable ( const G4ParticleDefinition particle)
protected

Definition at line 91 of file G4TextPPRetriever.cc.

92{
93 G4String name = particle->GetParticleName();
94
95 //--- open file -----
96 G4String fileName = baseDir + name + ".txt";
97 // exception
98 if (name == "J/psi") fileName = baseDir +"jpsi.txt";
99
100 std::ifstream inFile(fileName, std::ios::in );
101 if (!inFile) return false;
102
103 // GetParticleProperty
105
106 // particle name encoding
107 G4String name_t;
109 inFile >> name_t >> encoding;
110 if ( (name != name_t) || (encoding != pData->GetPDGEncoding()) ){
111 G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
112 G4cout << "particle name or encoding mismatch for " << name ;
113 G4cout << G4endl;
114 return false;
115 }
116
117 // IJPC
118 G4int iIsoSpin, iSpin, iParity, iConj;
119 inFile >> iIsoSpin >> iSpin >> iParity >> iConj;
120 if ( ( iIsoSpin != pData->GetPDGiIsospin()) ||
121 ( iSpin != pData->GetPDGiSpin()) ||
122 ( iParity != pData->GetPDGiParity()) ||
123 ( iConj != pData->GetPDGiConjugation()) ){
124 G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
125 G4cout << "IJPC mismatch for " << name ;
126 G4cout << G4endl;
127 return false;
128 }
129
130 // mass, width, charge
131 G4double mass, width, charge;
132 inFile >> mass >> width >> charge;
133 mass *= GeV;
134 width *= GeV;
135 charge *= eplus;
136 if (mass != pData->GetPDGMass()){ pData->SetPDGMass(mass);}
137 if (width != pData->GetPDGWidth()){ pData->SetPDGWidth(width);}
138 if (charge != pData->GetPDGCharge()){ pData->SetPDGCharge(charge);}
139
140 // life time
141 G4double tlife;
142 inFile >> tlife;
143 tlife *= second;
144 if (tlife != pData->GetPDGLifeTime()){ pData->SetPDGLifeTime(tlife);}
145
147
148 // Decay Table
149 G4DecayTable* dcyTable = particle->GetDecayTable();
150 if (dcyTable == 0) return true;
151
152 G4int idx =0;
153 while (!inFile.eof() ) { // Loop checking, 09.08.2015, K.Kurashige
154 G4double br;
155 G4int n_daughters;
156 inFile >> br >> n_daughters;
157
158 G4VDecayChannel * channel = dcyTable->GetDecayChannel(idx);
159
160 if ( n_daughters == channel->GetNumberOfDaughters()) {
161 channel->SetBR(br);
162 }
163
164 idx += 1;
165 if (idx>= dcyTable->entries()) break;
166 }
167 return true;
168}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
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
G4ParticlePropertyTable * pPropertyTable
const char * name(G4int ptype)

Referenced by Retrieve().

◆ Retrieve()

void G4TextPPRetriever::Retrieve ( const G4String option = "")
virtual

Implements G4VParticlePropertyRetriever.

Definition at line 58 of file G4TextPPRetriever.cc.

59{
60 SparseOption( option );
61
62 // pointer to the particle table
65 theParticleIterator = theParticleTable->GetIterator();
66
67 // loop over all particles in G4ParticleTable
68 theParticleIterator->reset();
69 while( (*theParticleIterator)() ){ // Loop checking, 09.08.2015, K.Kurashige
70 G4ParticleDefinition* particle = theParticleIterator->value();
71 ModifyPropertyTable(particle);
72 }
73}
#define theParticleIterator
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 76 of file G4TextPPRetriever.cc.

77{
78 G4Tokenizer savedToken( option );
79
80 // 1st option : base directory
81 baseDir = savedToken();
82 if (!baseDir.empty()) {
83 if(baseDir.back()!='/') {
84 baseDir += "/";
85 }
86 }
87}

Referenced by Retrieve().

Member Data Documentation

◆ baseDir

G4String G4TextPPRetriever::baseDir
protected

Definition at line 62 of file G4TextPPRetriever.hh.

Referenced by ModifyPropertyTable(), and SparseOption().


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