Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes
G4TextPPRetriever Class Reference

#include <G4TextPPRetriever.hh>

Inheritance diagram for G4TextPPRetriever:
G4VParticlePropertyRetriever

Public Member Functions

 G4TextPPRetriever ()
 
G4bool operator!= (const G4VParticlePropertyRetriever &right) const
 
G4bool operator== (const G4VParticlePropertyRetriever &right) const
 
virtual void Retrieve (const G4String &option="")
 
virtual ~G4TextPPRetriever ()
 

Protected Member Functions

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

Protected Attributes

G4String baseDir
 
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}
static constexpr double eplus
Definition: G4SIunits.hh:184
static constexpr double second
Definition: G4SIunits.hh:137
static constexpr double GeV
Definition: G4SIunits.hh:203
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)
#define encoding
Definition: xmlparse.cc:605

References baseDir, encoding, G4DecayTable::entries(), eplus, G4cout, G4endl, G4DecayTable::GetDecayChannel(), G4ParticleDefinition::GetDecayTable(), G4VDecayChannel::GetNumberOfDaughters(), G4ParticleDefinition::GetParticleName(), G4ParticlePropertyTable::GetParticleProperty(), G4ParticlePropertyData::GetPDGCharge(), G4ParticlePropertyData::GetPDGEncoding(), G4ParticlePropertyData::GetPDGiConjugation(), G4ParticlePropertyData::GetPDGiIsospin(), G4ParticlePropertyData::GetPDGiParity(), G4ParticlePropertyData::GetPDGiSpin(), G4ParticlePropertyData::GetPDGLifeTime(), G4ParticlePropertyData::GetPDGMass(), G4ParticlePropertyData::GetPDGWidth(), GeV, G4InuclParticleNames::name(), G4VParticlePropertyRetriever::pPropertyTable, second, G4VDecayChannel::SetBR(), G4ParticlePropertyTable::SetParticleProperty(), G4ParticlePropertyData::SetPDGCharge(), G4ParticlePropertyData::SetPDGLifeTime(), G4ParticlePropertyData::SetPDGMass(), and G4ParticlePropertyData::SetPDGWidth().

Referenced by Retrieve().

◆ operator!=()

G4bool G4VParticlePropertyRetriever::operator!= ( const G4VParticlePropertyRetriever right) const
inlineinherited

Definition at line 59 of file G4VParticlePropertyRetriever.hh.

60 { return (this != &right); }

◆ operator==()

G4bool G4VParticlePropertyRetriever::operator== ( const G4VParticlePropertyRetriever right) const
inlineinherited

Definition at line 56 of file G4VParticlePropertyRetriever.hh.

57 { return (this == &right); }

◆ 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 *)

References G4ParticleTable::GetIterator(), G4ParticleTable::GetParticleTable(), ModifyPropertyTable(), SparseOption(), and theParticleIterator.

◆ 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}

References baseDir.

Referenced by Retrieve().

Field Documentation

◆ baseDir

G4String G4TextPPRetriever::baseDir
protected

Definition at line 62 of file G4TextPPRetriever.hh.

Referenced by ModifyPropertyTable(), and SparseOption().

◆ pPropertyTable

G4ParticlePropertyTable* G4VParticlePropertyRetriever::pPropertyTable
protectedinherited

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