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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 7.1.p1)


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