Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4TextPPRetriever.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // the GEANT4 collaboration.
27 //
28 // By copying, distributing or modifying the Program (or any work
29 // based on the Program) you indicate your acceptance of this statement,
30 // and all its terms.
31 //
32 // $Id: G4TextPPRetriever.cc 91885 2015-08-10 07:05:56Z gcosmo $
33 //
34 //
35 // ---------------------------------------------------------------
36 #include "G4TextPPRetriever.hh"
37 #include "G4ios.hh"
38 #include "globals.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4ParticleTable.hh"
41 #include "G4ParticleDefinition.hh"
42 #include "G4DecayTable.hh"
43 #include "G4VDecayChannel.hh"
44 #include "G4Tokenizer.hh"
45 #include <iomanip>
46 #include <fstream>
47 
50 {
51 }
52 
55 {
56 }
57 
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)() ){ // Loop checking, 09.08.2015, K.Kurashige
71  G4ParticleDefinition* particle = theParticleIterator->value();
72  ModifyPropertyTable(particle);
73  }
74 }
75 
76 
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 }
89 
90 
91 
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() ) { // Loop checking, 09.08.2015, K.Kurashige
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 }
170 
171 
172 
173 
174 
const XML_Char * name
Definition: expat.h:151
G4bool isNull() const
G4DecayTable * GetDecayTable() const
static G4ParticleTable * GetParticleTable()
#define theParticleIterator
const XML_Char const XML_Char * encoding
Definition: expat.h:187
G4int GetNumberOfDaughters() const
#define G4endl
Definition: G4ios.hh:61
const G4String & GetParticleName() const
static constexpr double second
Definition: G4SIunits.hh:157
G4PTblDicIterator * GetIterator() const
void SetPDGLifeTime(G4double newLifeTime)
void reset(G4bool ifSkipIon=true)
void SetPDGCharge(G4double newCharge)
void SetBR(G4double value)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
#define width
G4ParticlePropertyTable * pPropertyTable
void SetPDGMass(G4double newMass)
void SparseOption(const G4String &option)
G4VDecayChannel * GetDecayChannel(G4int index) const
G4bool ModifyPropertyTable(const G4ParticleDefinition *)
G4bool SetParticleProperty(const G4ParticlePropertyData &newProperty)
static constexpr double eplus
Definition: G4SIunits.hh:199
G4ParticlePropertyData * GetParticleProperty(const G4String &aParticleName)
virtual ~G4TextPPRetriever()
int G4int
Definition: G4Types.hh:78
ifstream in
Definition: comparison.C:7
void SetPDGWidth(G4double newWidth)
G4GLOB_DLL std::ostream G4cout
static constexpr double GeV
Definition: G4SIunits.hh:217
virtual void Retrieve(const G4String &option="")
G4int entries() const