ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4TextPPRetriever.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
33 //
34 // ---------------------------------------------------------------
35 #include "G4TextPPRetriever.hh"
36 #include "G4ios.hh"
37 #include "globals.hh"
38 #include "G4SystemOfUnits.hh"
39 #include "G4ParticleTable.hh"
40 #include "G4ParticleDefinition.hh"
41 #include "G4DecayTable.hh"
42 #include "G4VDecayChannel.hh"
43 #include "G4Tokenizer.hh"
44 #include <iomanip>
45 #include <fstream>
46 
49 {
50 }
51 
54 {
55 }
56 
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 }
74 
75 
77 {
78  G4Tokenizer savedToken( option );
79 
80  // 1st option : base directory
81  baseDir = savedToken();
82  if (!baseDir.isNull()) {
83  if(baseDir(baseDir.length()-1)!='/') {
84  baseDir += "/";
85  }
86  }
87 }
88 
89 
90 
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;
108  G4int encoding;
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
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 }
169 
170 
171 
172 
173