Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes
G4TextPPRetriever Class Reference

#include <G4TextPPRetriever.hh>

Inheritance diagram for G4TextPPRetriever:
G4VParticlePropertyRetriever

Public Member Functions

 G4TextPPRetriever ()
 
virtual ~G4TextPPRetriever ()
 
virtual void Retrieve (const G4String &option="")
 
- Public Member Functions inherited from G4VParticlePropertyRetriever
 G4VParticlePropertyRetriever ()
 
virtual ~G4VParticlePropertyRetriever ()
 
G4int operator== (const G4VParticlePropertyRetriever &right) const
 
G4int 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 46 of file G4TextPPRetriever.hh.

Constructor & Destructor Documentation

G4TextPPRetriever::G4TextPPRetriever ( )

Definition at line 49 of file G4TextPPRetriever.cc.

G4TextPPRetriever::~G4TextPPRetriever ( )
virtual

Definition at line 54 of file G4TextPPRetriever.cc.

55 {
56 }

Member Function Documentation

G4bool G4TextPPRetriever::ModifyPropertyTable ( const G4ParticleDefinition particle)
protected

Definition at line 92 of file G4TextPPRetriever.cc.

References baseDir, encoding, G4DecayTable::entries(), python.hepunit::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(), python.hepunit::GeV, G4VParticlePropertyRetriever::pPropertyTable, python.hepunit::second, G4VDecayChannel::SetBR(), G4ParticlePropertyTable::SetParticleProperty(), G4ParticlePropertyData::SetPDGCharge(), G4ParticlePropertyData::SetPDGLifeTime(), G4ParticlePropertyData::SetPDGMass(), G4ParticlePropertyData::SetPDGWidth(), and width.

Referenced by Retrieve().

93 {
94  G4String name = particle->GetParticleName();
95 
96  //--- open file -----
97  G4String fileName = baseDir + name + ".txt";
98  // exception
99  if (name == "J/psi") fileName = baseDir +"jpsi.txt";
100 
101  std::ifstream inFile(fileName, std::ios::in );
102  if (!inFile) return false;
103 
104  // GetParticleProperty
106 
107  // particle name encoding
108  G4String name_t;
109  G4int encoding;
110  inFile >> name_t >> encoding;
111  if ( (name != name_t) || (encoding != pData->GetPDGEncoding()) ){
112  G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
113  G4cout << "particle name or encoding mismatch for " << name ;
114  G4cout << G4endl;
115  return false;
116  }
117 
118  // IJPC
119  G4int iIsoSpin, iSpin, iParity, iConj;
120  inFile >> iIsoSpin >> iSpin >> iParity >> iConj;
121  if ( ( iIsoSpin != pData->GetPDGiIsospin()) ||
122  ( iSpin != pData->GetPDGiSpin()) ||
123  ( iParity != pData->GetPDGiParity()) ||
124  ( iConj != pData->GetPDGiConjugation()) ){
125  G4cout << "G4TextPPRetriever::ModifyPropertyTable: ";
126  G4cout << "IJPC mismatch for " << name ;
127  G4cout << G4endl;
128  return false;
129  }
130 
131  // mass, width, charge
132  G4double mass, width, charge;
133  inFile >> mass >> width >> charge;
134  mass *= GeV;
135  width *= GeV;
136  charge *= eplus;
137  if (mass != pData->GetPDGMass()){ pData->SetPDGMass(mass);}
138  if (width != pData->GetPDGWidth()){ pData->SetPDGWidth(width);}
139  if (charge != pData->GetPDGCharge()){ pData->SetPDGCharge(charge);}
140 
141  // life time
142  G4double tlife;
143  inFile >> tlife;
144  tlife *= second;
145  if (tlife != pData->GetPDGLifeTime()){ pData->SetPDGLifeTime(tlife);}
146 
148 
149  // Decay Table
150  G4DecayTable* dcyTable = particle->GetDecayTable();
151  if (dcyTable == 0) return true;
152 
153  G4int idx =0;
154  while (!inFile.eof() ) {
155  G4double br;
156  G4int n_daughters;
157  inFile >> br >> n_daughters;
158 
159  G4VDecayChannel * channel = dcyTable->GetDecayChannel(idx);
160 
161  if ( n_daughters == channel->GetNumberOfDaughters()) {
162  channel->SetBR(br);
163  }
164 
165  idx += 1;
166  if (idx>= dcyTable->entries()) break;
167  }
168  return true;
169 }
G4bool SetParticleProperty(const G4ParticlePropertyData &newProperty)
void SetBR(G4double value)
G4int GetNumberOfDaughters() const
G4ParticlePropertyData * GetParticleProperty(const G4String &aParticleName)
#define width
const XML_Char * name
G4VDecayChannel * GetDecayChannel(G4int index) const
int G4int
Definition: G4Types.hh:78
G4ParticlePropertyTable * pPropertyTable
void SetPDGCharge(G4double newCharge)
const G4String & GetParticleName() const
G4int entries() const
G4DecayTable * GetDecayTable() const
void SetPDGWidth(G4double newWidth)
G4GLOB_DLL std::ostream G4cout
#define encoding
Definition: xmlparse.cc:588
void SetPDGLifeTime(G4double newLifeTime)
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetPDGMass(G4double newMass)
void G4TextPPRetriever::Retrieve ( const G4String option = "")
virtual

Implements G4VParticlePropertyRetriever.

Definition at line 59 of file G4TextPPRetriever.cc.

References G4ParticleTable::GetIterator(), G4ParticleTable::GetParticleTable(), ModifyPropertyTable(), G4ParticleTableIterator< K, V >::reset(), SparseOption(), theParticleIterator, and G4ParticleTableIterator< K, V >::value().

60 {
61  SparseOption( option );
62 
63  // pointer to the particle table
66  theParticleIterator = theParticleTable->GetIterator();
67 
68  // loop over all particles in G4ParticleTable
69  theParticleIterator->reset();
70  while( (*theParticleIterator)() ){
71  G4ParticleDefinition* particle = theParticleIterator->value();
72  ModifyPropertyTable(particle);
73  }
74 }
G4bool ModifyPropertyTable(const G4ParticleDefinition *)
void SparseOption(const G4String &option)
void reset(G4bool ifSkipIon=true)
static G4ParticleTable * GetParticleTable()
G4PTblDicIterator * GetIterator() const
#define theParticleIterator
void G4TextPPRetriever::SparseOption ( const G4String option)
protected

Definition at line 77 of file G4TextPPRetriever.cc.

References baseDir, and G4String::isNull().

Referenced by Retrieve().

78 {
79  G4Tokenizer savedToken( option );
80 
81  // 1st option : base directory
82  baseDir = savedToken();
83  if (!baseDir.isNull()) {
84  if(baseDir(baseDir.length()-1)!='/') {
85  baseDir += "/";
86  }
87  }
88 }
G4bool isNull() const

Field Documentation

G4String G4TextPPRetriever::baseDir
protected

Definition at line 63 of file G4TextPPRetriever.hh.

Referenced by ModifyPropertyTable(), and SparseOption().


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