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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /particles/utils/src/G4TextPPRetriever.cc (Version 11.3.0) and /particles/utils/src/G4TextPPRetriever.cc (Version 9.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25                                                <<  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,v 1.2 2006/06/29 19:28:04 gunter Exp $
                                                   >>  33 // GEANT4 tag $Name: geant4-09-01 $
                                                   >>  34 //
                                                   >>  35 // 
                                                   >>  36 // ---------------------------------------------------------------
 26 #include "G4TextPPRetriever.hh"                    37 #include "G4TextPPRetriever.hh"
 27                                                << 
 28 #include "G4DecayTable.hh"                     << 
 29 #include "G4ParticleDefinition.hh"             << 
 30 #include "G4ParticleTable.hh"                  << 
 31 #include "G4SystemOfUnits.hh"                  << 
 32 #include "G4Tokenizer.hh"                      << 
 33 #include "G4VDecayChannel.hh"                  << 
 34 #include "G4ios.hh"                                38 #include "G4ios.hh"
 35 #include "globals.hh"                              39 #include "globals.hh"
                                                   >>  40 #include "G4DecayTable.hh"  
                                                   >>  41 #include "G4Tokenizer.hh"
                                                   >>  42 #include <iomanip>
                                                   >>  43 #include <fstream>       
 36                                                    44 
 37 #include <fstream>                             <<  45 //////////////////////////////
                                                   >>  46 G4TextPPRetriever::G4TextPPRetriever():G4VParticlePropertyRetriever()
                                                   >>  47 { 
                                                   >>  48 }
 38                                                    49 
 39 void G4TextPPRetriever::Retrieve(const G4Strin <<  50 ////////////////////////////
                                                   >>  51 G4TextPPRetriever::~G4TextPPRetriever()
 40 {                                                  52 {
 41   SparseOption(option);                        <<  53 }    
 42                                                    54 
 43   // pointer to the particle table             <<  55 /////////////////////
                                                   >>  56 void G4TextPPRetriever::Retrieve(const G4String& option)
                                                   >>  57 {
                                                   >>  58   SparseOption( option );
                                                   >>  59  
                                                   >>  60  // pointer to the particle table
 44   G4ParticleTable* theParticleTable = G4Partic     61   G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
 45   G4ParticleTable::G4PTblDicIterator* theParti     62   G4ParticleTable::G4PTblDicIterator* theParticleIterator;
 46   theParticleIterator = theParticleTable->GetI     63   theParticleIterator = theParticleTable->GetIterator();
 47                                                <<  64     
 48   // loop over all particles in G4ParticleTabl <<  65   // loop over all particles in G4ParticleTable 
 49   theParticleIterator->reset();                    66   theParticleIterator->reset();
 50   while ((*theParticleIterator)()) {  // Loop  <<  67   while( (*theParticleIterator)() ){
 51     G4ParticleDefinition* particle = thePartic     68     G4ParticleDefinition* particle = theParticleIterator->value();
 52     ModifyPropertyTable(particle);                 69     ModifyPropertyTable(particle);
 53   }                                                70   }
 54 }                                              <<  71 }    
                                                   >>  72 
 55                                                    73 
 56 void G4TextPPRetriever::SparseOption(const G4S     74 void G4TextPPRetriever::SparseOption(const G4String& option)
 57 {                                                  75 {
 58   G4Tokenizer savedToken(option);              <<  76   G4Tokenizer savedToken( option );
 59                                                <<  77   
 60   // 1st option : base directory                   78   // 1st option : base directory
 61   baseDir = savedToken();                          79   baseDir = savedToken();
 62   if (!baseDir.empty()) {                      <<  80   if (!baseDir.isNull()) {
 63     if (baseDir.back() != '/') {               <<  81     if(baseDir(baseDir.length()-1)!='/') {
 64       baseDir += "/";                              82       baseDir += "/";
 65     }                                              83     }
 66   }                                                84   }
 67 }                                                  85 }
 68                                                    86 
 69 G4bool G4TextPPRetriever::ModifyPropertyTable( <<  87 
                                                   >>  88 
                                                   >>  89 G4bool  G4TextPPRetriever::ModifyPropertyTable(G4ParticleDefinition* particle)
 70 {                                                  90 {
 71   G4String name = particle->GetParticleName();     91   G4String name = particle->GetParticleName();
 72                                                <<  92   
 73   //--- open file -----                            93   //--- open file -----
 74   G4String fileName = baseDir + name + ".txt";     94   G4String fileName = baseDir + name + ".txt";
 75   // exception                                     95   // exception
 76   if (name == "J/psi") fileName = baseDir + "j <<  96   if (name == "J/psi") fileName = baseDir +"jpsi.txt";
 77                                                    97 
 78   std::ifstream inFile(fileName, std::ios::in) <<  98   std::ifstream inFile(fileName, std::ios::in );
 79   if (!inFile) return false;                       99   if (!inFile) return false;
 80                                                << 100   
 81   // GetParticleProperty                          101   // GetParticleProperty
 82   G4ParticlePropertyData* pData = pPropertyTab    102   G4ParticlePropertyData* pData = pPropertyTable->GetParticleProperty(name);
 83                                                   103 
 84   // particle name  encoding                      104   // particle name  encoding
 85   G4String name_t;                                105   G4String name_t;
 86   G4int encoding;                              << 106   G4int    encoding;
 87   inFile >> name_t >> encoding;                   107   inFile >> name_t >> encoding;
 88   if ((name != name_t) || (encoding != pData-> << 108   if ( (name != name_t) || (encoding !=  pData->GetPDGEncoding()) ){
 89     G4cout << "G4TextPPRetriever::ModifyProper    109     G4cout << "G4TextPPRetriever::ModifyPropertyTable:   ";
 90     G4cout << "particle name or encoding misma << 110     G4cout << "particle name or encoding mismatch for " << name ;
 91     G4cout << G4endl;                             111     G4cout << G4endl;
 92     return false;                                 112     return false;
 93   }                                               113   }
 94                                                   114 
 95   // IJPC                                         115   // IJPC
 96   G4int iIsoSpin, iSpin, iParity, iConj;       << 116   G4int  iIsoSpin, iSpin, iParity, iConj;
 97   inFile >> iIsoSpin >> iSpin >> iParity >> iC << 117   inFile >>  iIsoSpin >> iSpin >> iParity >> iConj;   
 98   if ((iIsoSpin != pData->GetPDGiIsospin()) || << 118   if  (  ( iIsoSpin != pData->GetPDGiIsospin()) ||
 99       || (iParity != pData->GetPDGiParity()) | << 119          ( iSpin    != pData->GetPDGiSpin())    ||
100   {                                            << 120    ( iParity  != pData->GetPDGiParity())  ||
                                                   >> 121    ( iConj    != pData->GetPDGiConjugation()) ){
101     G4cout << "G4TextPPRetriever::ModifyProper    122     G4cout << "G4TextPPRetriever::ModifyPropertyTable:   ";
102     G4cout << "IJPC mismatch for " << name;    << 123     G4cout << "IJPC mismatch for " << name ;
103     G4cout << G4endl;                             124     G4cout << G4endl;
104     return false;                                 125     return false;
105   }                                               126   }
106                                                   127 
107   // mass, width, charge                       << 128   // mass, width, charge 
108   G4double mass, width, charge;                   129   G4double mass, width, charge;
109   inFile >> mass >> width >> charge;           << 130   inFile >> mass >> width >>  charge;
110   mass *= GeV;                                    131   mass *= GeV;
111   width *= GeV;                                   132   width *= GeV;
112   charge *= eplus;                                133   charge *= eplus;
113   if (mass != pData->GetPDGMass()) {           << 134   if (mass  != pData->GetPDGMass()){ pData->SetPDGMass(mass);}
114     pData->SetPDGMass(mass);                   << 135   if (width != pData->GetPDGWidth()){ pData->SetPDGWidth(width);}
115   }                                            << 136   if (charge != pData->GetPDGCharge()){ pData->SetPDGCharge(charge);}
116   if (width != pData->GetPDGWidth()) {         << 
117     pData->SetPDGWidth(width);                 << 
118   }                                            << 
119   if (charge != pData->GetPDGCharge()) {       << 
120     pData->SetPDGCharge(charge);               << 
121   }                                            << 
122                                                   137 
123   // life time                                    138   // life time
124   G4double tlife;                                 139   G4double tlife;
125   inFile >> tlife;                                140   inFile >> tlife;
126   tlife *= second;                                141   tlife *= second;
127   if (tlife != pData->GetPDGLifeTime()) {      << 142   if (tlife  != pData->GetPDGLifeTime()){ pData->SetPDGLifeTime(tlife);}
128     pData->SetPDGLifeTime(tlife);              << 
129   }                                            << 
130                                                   143 
131   pPropertyTable->SetParticleProperty(*pData);    144   pPropertyTable->SetParticleProperty(*pData);
132                                                   145 
133   // Decay Table                               << 146   // Decay Table  
134   G4DecayTable* dcyTable = particle->GetDecayT << 147   G4DecayTable* dcyTable = particle->GetDecayTable(); 
135   if (dcyTable == nullptr) return true;        << 148   if (dcyTable == 0) return true;
136                                                << 149   
137   G4int idx = 0;                               << 150   G4int idx =0;
138   while (!inFile.eof()) {  // Loop checking, 0 << 151   while (!inFile.eof() ) {
139     G4double br;                                  152     G4double br;
140     G4int n_daughters;                         << 153     G4int    n_daughters;
141     inFile >> br >> n_daughters;                  154     inFile >> br >> n_daughters;
142                                                   155 
143     G4VDecayChannel* channel = dcyTable->GetDe << 156     G4VDecayChannel * channel = dcyTable->GetDecayChannel(idx);
144                                                   157 
145     if (n_daughters == channel->GetNumberOfDau << 158     if ( n_daughters == channel->GetNumberOfDaughters()) {
146       channel->SetBR(br);                         159       channel->SetBR(br);
147     }                                             160     }
148                                                   161 
149     idx += 1;                                     162     idx += 1;
150     if (idx >= dcyTable->entries()) break;     << 163     if (idx>= dcyTable->entries()) break;
151   }                                               164   }
152   return true;                                    165   return true;
153 }                                                 166 }
                                                   >> 167 
                                                   >> 168 
                                                   >> 169 
                                                   >> 170 
                                                   >> 171 
154                                                   172