G4TextPPRetriever Class Reference

#include <G4TextPPRetriever.hh>

Inheritance diagram for G4TextPPRetriever:

G4VParticlePropertyRetriever

Public Member Functions

 G4TextPPRetriever ()
virtual ~G4TextPPRetriever ()
virtual void Retrieve (const G4String &option="")

Protected Member Functions

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

Protected Attributes

G4String baseDir

Detailed Description

Definition at line 46 of file G4TextPPRetriever.hh.


Constructor & Destructor Documentation

G4TextPPRetriever::G4TextPPRetriever (  ) 

Definition at line 49 of file G4TextPPRetriever.cc.

00049                                     :G4VParticlePropertyRetriever()
00050 { 
00051 }

G4TextPPRetriever::~G4TextPPRetriever (  )  [virtual]

Definition at line 54 of file G4TextPPRetriever.cc.

00055 {
00056 }    


Member Function Documentation

G4bool G4TextPPRetriever::ModifyPropertyTable ( const G4ParticleDefinition  )  [protected]

Definition at line 92 of file G4TextPPRetriever.cc.

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

Referenced by Retrieve().

00093 {
00094   G4String name = particle->GetParticleName();
00095   
00096   //--- open file -----
00097   G4String fileName = baseDir + name + ".txt";
00098   // exception
00099   if (name == "J/psi") fileName = baseDir +"jpsi.txt";
00100 
00101   std::ifstream inFile(fileName, std::ios::in );
00102   if (!inFile) return false;
00103   
00104   // GetParticleProperty
00105   G4ParticlePropertyData* pData = pPropertyTable->GetParticleProperty(name);
00106 
00107   // particle name  encoding
00108   G4String name_t;
00109   G4int    encoding;
00110   inFile >> name_t >> encoding;
00111   if ( (name != name_t) || (encoding !=  pData->GetPDGEncoding()) ){
00112     G4cout << "G4TextPPRetriever::ModifyPropertyTable:   ";
00113     G4cout << "particle name or encoding mismatch for " << name ;
00114     G4cout << G4endl;
00115     return false;
00116   }
00117 
00118   // IJPC
00119   G4int  iIsoSpin, iSpin, iParity, iConj;
00120   inFile >>  iIsoSpin >> iSpin >> iParity >> iConj;   
00121   if  (  ( iIsoSpin != pData->GetPDGiIsospin()) ||
00122          ( iSpin    != pData->GetPDGiSpin())    ||
00123          ( iParity  != pData->GetPDGiParity())  ||
00124          ( iConj    != pData->GetPDGiConjugation()) ){
00125     G4cout << "G4TextPPRetriever::ModifyPropertyTable:   ";
00126     G4cout << "IJPC mismatch for " << name ;
00127     G4cout << G4endl;
00128     return false;
00129   }
00130 
00131   // mass, width, charge 
00132   G4double mass, width, charge;
00133   inFile >> mass >> width >>  charge;
00134   mass *= GeV;
00135   width *= GeV;
00136   charge *= eplus;
00137   if (mass  != pData->GetPDGMass()){ pData->SetPDGMass(mass);}
00138   if (width != pData->GetPDGWidth()){ pData->SetPDGWidth(width);}
00139   if (charge != pData->GetPDGCharge()){ pData->SetPDGCharge(charge);}
00140 
00141   // life time
00142   G4double tlife;
00143   inFile >> tlife;
00144   tlife *= second;
00145   if (tlife  != pData->GetPDGLifeTime()){ pData->SetPDGLifeTime(tlife);}
00146 
00147   pPropertyTable->SetParticleProperty(*pData);
00148 
00149   // Decay Table  
00150   G4DecayTable* dcyTable = particle->GetDecayTable(); 
00151   if (dcyTable == 0) return true;
00152   
00153   G4int idx =0;
00154   while (!inFile.eof() ) {
00155     G4double br;
00156     G4int    n_daughters;
00157     inFile >> br >> n_daughters;
00158 
00159     G4VDecayChannel * channel = dcyTable->GetDecayChannel(idx);
00160 
00161     if ( n_daughters == channel->GetNumberOfDaughters()) {
00162       channel->SetBR(br);
00163     }
00164 
00165     idx += 1;
00166     if (idx>= dcyTable->entries()) break;
00167   }
00168   return true;
00169 }

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(), and G4ParticleTableIterator< K, V >::value().

00060 {
00061   SparseOption( option );
00062  
00063  // pointer to the particle table
00064   G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
00065   G4ParticleTable::G4PTblDicIterator* theParticleIterator;
00066   theParticleIterator = theParticleTable->GetIterator();
00067     
00068   // loop over all particles in G4ParticleTable 
00069   theParticleIterator->reset();
00070   while( (*theParticleIterator)() ){
00071     G4ParticleDefinition* particle = theParticleIterator->value();
00072     ModifyPropertyTable(particle);
00073   }
00074 }    

void G4TextPPRetriever::SparseOption ( const G4String option  )  [protected]

Definition at line 77 of file G4TextPPRetriever.cc.

References baseDir, and G4String::isNull().

Referenced by Retrieve().

00078 {
00079   G4Tokenizer savedToken( option );
00080   
00081   // 1st option : base directory
00082   baseDir = savedToken();
00083   if (!baseDir.isNull()) {
00084     if(baseDir(baseDir.length()-1)!='/') {
00085       baseDir += "/";
00086     }
00087   }
00088 }


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:
Generated on Mon May 27 17:53:29 2013 for Geant4 by  doxygen 1.4.7