Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/physics_lists/lists/src/G4PhysListRegistry.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 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 /physics_lists/lists/src/G4PhysListRegistry.cc (Version 11.3.0) and /physics_lists/lists/src/G4PhysListRegistry.cc (Version 10.2.p3)


  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 // G4PhysListRegistry                          << 
 27 //                                                 26 //
 28 // Author: R. Hatcher, 2014-10-15              <<  27 // $Id: 
 29 // ------------------------------------------- <<  28 //
                                                   >>  29 // -------------------------------------------------------------------
                                                   >>  30 //
                                                   >>  31 // GEANT4 Class file
                                                   >>  32 //
                                                   >>  33 // File name:    G4PhysListRegistry
                                                   >>  34 //
                                                   >>  35 // Author  R. Hatcher  2014-10-15
                                                   >>  36 //
                                                   >>  37 // Modifications:  based on G4PhysicsConstructorRegistry
                                                   >>  38 //
                                                   >>  39 //#define G4VERBOSE 1
 30                                                    40 
                                                   >>  41 #include "G4ios.hh"
 31 #include <iomanip>                                 42 #include <iomanip>
 32 #include <algorithm>                               43 #include <algorithm>
 33                                                    44 
 34 #include "G4ios.hh"                            << 
 35 #include "G4PhysListRegistry.hh"                   45 #include "G4PhysListRegistry.hh"
 36 #include "G4VModularPhysicsList.hh"                46 #include "G4VModularPhysicsList.hh"
 37 #include "G4PhysListStamper.hh"                    47 #include "G4PhysListStamper.hh"
 38                                                << 
 39 #include "G4PhysicsConstructorRegistry.hh"         48 #include "G4PhysicsConstructorRegistry.hh"
 40 // include G4_REFERENCE_PHYSCONSTR_FACTORY() m << 
 41 // for static builds.   Would do this in  G4Ph << 
 42 // but that causes a circular dependency when  << 
 43 // are broken in a "granular" build.           << 
 44 #define REGREF PhysListReg // REGREF is used t << 
 45 #include "G4RegisterPhysicsConstructors.icc"   << 
 46                                                    49 
 47 // include this with this compilation unit so  <<  50 G4ThreadLocal G4PhysListRegistry* G4PhysListRegistry::theInstance = 0;
 48 #include "G4RegisterPhysLists.icc"             << 
 49                                                << 
 50 G4ThreadLocal G4PhysListRegistry* G4PhysListRe << 
 51                                                << 
 52 const G4int doReplace  = 0x01;  // _ (ReplaceP << 
 53 const G4int isCtorName = 0x02;  // true if act << 
 54                                                    51 
 55 G4PhysListRegistry* G4PhysListRegistry::Instan     52 G4PhysListRegistry* G4PhysListRegistry::Instance()
 56 {                                                  53 {
 57   if ( nullptr == theInstance) {               <<  54   if ( 0 == theInstance) {
 58     theInstance = new G4PhysListRegistry;      <<  55     static G4ThreadLocal G4PhysListRegistry *manager_G4MT_TLS_ = 0; 
 59                                                <<  56     if (!manager_G4MT_TLS_) manager_G4MT_TLS_ = new G4PhysListRegistry;
 60     // common EM overrides                     <<  57     G4PhysListRegistry &manager = *manager_G4MT_TLS_;
 61     theInstance->AddPhysicsExtension("EM0","G4 <<  58     theInstance = &manager;
 62     theInstance->AddPhysicsExtension("EMV","G4 <<  59   }
 63     theInstance->AddPhysicsExtension("EMX","G4 <<  60 
 64     theInstance->AddPhysicsExtension("EMY","G4 <<  61   // common EM overrides
 65     theInstance->AddPhysicsExtension("EMZ","G4 <<  62   theInstance->AddPhysicsExtension("EMV","G4EmStandardPhysics_option1");
 66     theInstance->AddPhysicsExtension("LIV","G4 <<  63   theInstance->AddPhysicsExtension("EMX","G4EmStandardPhysics_option2");
 67     theInstance->AddPhysicsExtension("PEN","G4 <<  64   theInstance->AddPhysicsExtension("EMY","G4EmStandardPhysics_option3");
 68     // the GS EM extension originally required <<  65   theInstance->AddPhysicsExtension("EMZ","G4EmStandardPhysics_option4");
 69     // support either one or two as __GS is co <<  66   theInstance->AddPhysicsExtension("LIV","G4EmLivermorePhysics");
 70     // same for __SS                           <<  67   theInstance->AddPhysicsExtension("PEN","G4EmPenelopePhysics");
 71     theInstance->AddPhysicsExtension("GS" ,"G4 <<  68   // the GS EM extension originally required double underscores
 72     theInstance->AddPhysicsExtension("_GS","G4 <<  69   // support either one or two as __GS is confusing to users
 73     theInstance->AddPhysicsExtension("SS" ,"G4 <<  70   theInstance->AddPhysicsExtension("GS","G4EmStandardPhysicsGS");
 74     theInstance->AddPhysicsExtension("_SS","G4 <<  71   theInstance->AddPhysicsExtension("_GS","G4EmStandardPhysicsGS");
 75                                                << 
 76     theInstance->AddPhysicsExtension("EM0","G4 << 
 77     theInstance->AddPhysicsExtension("WVI","G4 << 
 78     theInstance->AddPhysicsExtension("LE" ,"G4 << 
 79     theInstance->AddPhysicsExtension("_LE","G4 << 
 80                                                << 
 81     theInstance->AddPhysicsExtension("HPT","G4 << 
 82   }                                            << 
 83                                                    72 
 84   return theInstance;                              73   return theInstance;
 85 }                                                  74 }
 86                                                    75 
 87 G4PhysListRegistry::G4PhysListRegistry()           76 G4PhysListRegistry::G4PhysListRegistry()
 88   : verbose(1)                                     77   : verbose(1)
 89   , unknownFatal(0)                                78   , unknownFatal(0)
 90   , systemDefault("FTFP_BERT")                     79   , systemDefault("FTFP_BERT")
 91 {                                                  80 {
 92   SetUserDefaultPhysList();                        81   SetUserDefaultPhysList();
 93 }                                                  82 }
 94                                                    83 
 95 G4PhysListRegistry::~G4PhysListRegistry()          84 G4PhysListRegistry::~G4PhysListRegistry()
 96 {                                                  85 {
 97 }                                                  86 }
 98                                                    87 
 99 void G4PhysListRegistry::SetUserDefaultPhysLis     88 void G4PhysListRegistry::SetUserDefaultPhysList(const G4String& name)
100 {                                                  89 {
101   if ( name == "" ) userDefault = systemDefaul     90   if ( name == "" ) userDefault = systemDefault;
102   else              userDefault = name;            91   else              userDefault = name;
103 }                                                  92 }
104                                                    93 
105 void G4PhysListRegistry::AddFactory(G4String n     94 void G4PhysListRegistry::AddFactory(G4String name, G4VBasePhysListStamper* factory)
106 {                                                  95 {
107   factories[name] = factory;                       96   factories[name] = factory;
108 }                                                  97 }
109                                                    98 
110 void G4PhysListRegistry::AddPhysicsExtension(G     99 void G4PhysListRegistry::AddPhysicsExtension(G4String name, G4String procname)
111 {                                                 100 {
112   // a mapping from short extension names to a    101   // a mapping from short extension names to actual physics process constructors
113   physicsExtensions[name] = procname;             102   physicsExtensions[name] = procname;
114 }                                                 103 }
115                                                   104 
116 G4VModularPhysicsList*                         << 105 G4VModularPhysicsList* 
117 G4PhysListRegistry::GetModularPhysicsList(cons    106 G4PhysListRegistry::GetModularPhysicsList(const G4String& name)
118 {                                                 107 {
119   //                                           << 108   // 
120   //                                              109   //
121   G4String plBase = "";                           110   G4String plBase = "";
122   std::vector<G4String> physExt;                  111   std::vector<G4String> physExt;
123   std::vector<G4int>    physReplace;              112   std::vector<G4int>    physReplace;
124   G4bool allKnown =                            << 113   G4bool allKnown = 
125     DeconstructPhysListName(name,plBase,physEx    114     DeconstructPhysListName(name,plBase,physExt,physReplace,verbose);
126                                                   115 
127   std::size_t npc = physExt.size();            << 116   size_t npc = physExt.size();
128   if ( verbose > 0 ) {                            117   if ( verbose > 0 ) {
129     G4cout << "G4PhysListRegistry::GetModularP    118     G4cout << "G4PhysListRegistry::GetModularPhysicsList <"
130            << name << ">"                         119            << name << ">"
131            << ", as \"" << plBase << "\" with     120            << ", as \"" << plBase << "\" with extensions \"";
132     for ( std::size_t ipc = 0; ipc < npc; ++ip << 121     for ( size_t ipc = 0; ipc < npc; ++ipc ) 
133       G4cout << ((physReplace[ipc]&doReplace)? << 122       G4cout << ((physReplace[ipc]>0)?"_":"+") << physExt[ipc];
134     G4cout << "\"" << G4endl;                     123     G4cout << "\"" << G4endl;
135   }                                               124   }
136                                                   125 
137   if ( ! allKnown ) {                             126   if ( ! allKnown ) {
138     // couldn't match what the user wanted ... << 127     // couldn't match what the user wanted ... 
139     G4cout << "### G4PhysListRegistry WARNING:    128     G4cout << "### G4PhysListRegistry WARNING: " << name
140            << " is not known" << G4endl << G4e    129            << " is not known" << G4endl << G4endl;
141     if ( ! unknownFatal ) return nullptr;      << 130     if ( ! unknownFatal ) return 0;
142                                                   131 
143     G4ExceptionDescription ED;                    132     G4ExceptionDescription ED;
144     ED << "The factory for the physicslist ["<    133     ED << "The factory for the physicslist ["<< name << "] does not exist!"
145        << G4endl;                                 134        << G4endl;
146     if ( plBase == "" ) {                         135     if ( plBase == "" ) {
147       ED << "Could determine no sensible base     136       ED << "Could determine no sensible base physics list" << G4endl;
148     } else {                                      137     } else {
149       ED << "One or more of the extensions doe    138       ED << "One or more of the extensions does not exist [ ";
150       for ( std::size_t ipc = 0; ipc < physExt << 139       for ( size_t ipc = 0; ipc < physExt.size(); ++ipc ) {
151         ED << physExt[ipc] << " ";                140         ED << physExt[ipc] << " ";
152       }                                           141       }
153       ED << "]" << G4endl;                        142       ED << "]" << G4endl;
154     }                                             143     }
155     G4Exception("G4PhysListRegistry::GetModula << 144     G4Exception("G4PhysListRegistry::GetModularPhysicsList", 
156                 "PhysicsList002", FatalExcepti << 145                 "PhysicsList001", FatalException, ED);
157     return nullptr;                            << 146     return 0;
158   }                                               147   }
159                                                   148 
160   // if we want this method "const" then the n    149   // if we want this method "const" then the next line becomes more complex
161   // because there is no const version of [] ( << 150   // because there is no const version of [] (which adds an entry if the 
162   // key doesn't exist)                           151   // key doesn't exist)
163   G4VModularPhysicsList* pl = factories[plBase    152   G4VModularPhysicsList* pl = factories[plBase]->Instantiate(verbose);
164   G4PhysicsConstructorRegistry* pcRegistry =   << 153   G4PhysicsConstructorRegistry* pcRegistry = 
165     G4PhysicsConstructorRegistry::Instance();     154     G4PhysicsConstructorRegistry::Instance();
166   G4int ver = pl->GetVerboseLevel();              155   G4int ver = pl->GetVerboseLevel();
167   pl->SetVerboseLevel(0);                         156   pl->SetVerboseLevel(0);
168   for ( std::size_t ipc = 0; ipc < npc; ++ipc  << 157   for ( size_t ipc = 0; ipc < npc; ++ipc ) {
169     // got back a list of short names, need to << 158     // got back a list of short names, need to use the map to get the 
170     // full physics constructor name              159     // full physics constructor name
171     G4String extName = physExt[ipc];              160     G4String extName = physExt[ipc];
172     G4String pcname  =                         << 161     G4String pcname = physicsExtensions[extName];
173       ((physReplace[ipc]&isCtorName)) ? extNam << 
174     // this doesn't have a verbose option ...     162     // this doesn't have a verbose option ... it should
175     // but G4PhysicsConstructorFactory doesn't    163     // but G4PhysicsConstructorFactory doesn't support it
176     G4VPhysicsConstructor* pctor = pcRegistry- << 164     G4VPhysicsConstructor* pc = pcRegistry->GetPhysicsConstructor(pcname);
177     G4String reporreg = "";                       165     G4String reporreg = "";
178     if (( physReplace[ipc] & doReplace)) {     << 166     if ( physReplace[ipc] > 0 ) {
179       pl->ReplacePhysics(pctor);               << 167       pl->ReplacePhysics(pc);
180       reporreg = "ReplacePhysics ";               168       reporreg = "ReplacePhysics ";
181     } else {                                      169     } else {
182       pl->RegisterPhysics(pctor);              << 170       pl->RegisterPhysics(pc);
183       reporreg = "RegisterPhysics";               171       reporreg = "RegisterPhysics";
184     }                                             172     }
185     if ( verbose > 0 ) G4cout << "<<< " << rep << 173     if ( verbose > 0 ) G4cout << "<<< " << reporreg << " with " << pcname 
186                               << " \"" << extN    174                               << " \"" << extName << "\"" << G4endl;
187   }                                               175   }
188   pl->SetVerboseLevel(ver);                       176   pl->SetVerboseLevel(ver);
189   G4cout << "<<< Reference Physics List " << n    177   G4cout << "<<< Reference Physics List " << name << " is built" << G4endl;
190   G4cout << G4endl; // old factory has this       178   G4cout << G4endl; // old factory has this
191                                                   179 
192   return pl;                                      180   return pl;
193 }                                                 181 }
194                                                   182 
195 G4VModularPhysicsList*                         << 183 G4VModularPhysicsList* 
196 G4PhysListRegistry::GetModularPhysicsListFromE    184 G4PhysListRegistry::GetModularPhysicsListFromEnv()
197 {                                                 185 {
198   //                                           << 186   // 
199   // instantiate PhysList by environment varia    187   // instantiate PhysList by environment variable "PHYSLIST"
200   // if not set use default                       188   // if not set use default
201   G4String name = "";                             189   G4String name = "";
202   char* path = std::getenv("PHYSLIST");        << 190   char* path = getenv("PHYSLIST");
203   if (path) {                                     191   if (path) {
204     name = G4String(path);                        192     name = G4String(path);
205   } else {                                        193   } else {
206     name = userDefault;                           194     name = userDefault;
207     G4cout << "### G4PhysListRegistry WARNING:    195     G4cout << "### G4PhysListRegistry WARNING: "
208            << " environment variable PHYSLIST  << 196      << " environment variable PHYSLIST is not defined"
209            << G4endl                           << 197      << G4endl
210            << "    Default Physics Lists " <<  << 198      << "    Default Physics Lists " << name 
211            << " is instantiated"               << 199      << " is instantiated" 
212            << G4endl;                          << 200      << G4endl;
213   }                                               201   }
214   return GetModularPhysicsList(name);             202   return GetModularPhysicsList(name);
215 }                                                 203 }
216                                                   204 
217 G4bool G4PhysListRegistry::IsReferencePhysList    205 G4bool G4PhysListRegistry::IsReferencePhysList(G4String name) const
218 {                                                 206 {
219   G4String plBase = "";                           207   G4String plBase = "";
220   std::vector<G4String> physExt;                  208   std::vector<G4String> physExt;
221   std::vector<G4int>    physReplace;              209   std::vector<G4int>    physReplace;
222   G4bool allKnown = DeconstructPhysListName(na    210   G4bool allKnown = DeconstructPhysListName(name,plBase,physExt,physReplace,1);
223   return allKnown;                                211   return allKnown;
224 }                                                 212 }
225                                                   213 
226 G4bool G4PhysListRegistry::DeconstructPhysList    214 G4bool G4PhysListRegistry::DeconstructPhysListName(const G4String& name,
227                                                << 215                                                    G4String& plBase, 
228                                                   216                                                    std::vector<G4String>& physExt,
229                                                   217                                                    std::vector<G4int>& replace,
230                                                   218                                                    G4int verb) const
231 {                                                 219 {
232   // Take apart a name given to us by the user    220   // Take apart a name given to us by the user
233   // this name might be a base PhysList + unkn    221   // this name might be a base PhysList + unknown number of extensions
234   // Extensions preceeded with a "_" should us << 222   // Extensions preceeded with a "_" should use 
235   //    ReplacePhysics()                          223   //    ReplacePhysics()
236   // those proceeded with a "+" should use        224   // those proceeded with a "+" should use
237   //    RegisterPhysics()                         225   //    RegisterPhysics()
238   // the former is in line with previous behav << 226   // the former is in line with previous behaviour, while the second allows 
239   // additional flexibility                       227   // additional flexibility
240   plBase = "";                                    228   plBase = "";
241   physExt.clear();                                229   physExt.clear();
242   replace.clear();                                230   replace.clear();
243   G4bool allKnown = false;                     << 231   bool allKnown = false;
244                                                << 232   
245   G4String workingName = name;                    233   G4String workingName = name;
246                                                   234 
247   const std::vector<G4String>& availBases  = A << 235   const std::vector<G4String>& availBases = AvailablePhysLists();
248   const std::vector<G4String>& availExtras = A    236   const std::vector<G4String>& availExtras = AvailablePhysicsExtensions();
249                                                   237 
250   G4PhysicsConstructorRegistry* physConstRegis << 238   G4PhysicsConstructorRegistry* physConstRegistry = 
251     G4PhysicsConstructorRegistry::Instance();     239     G4PhysicsConstructorRegistry::Instance();
252                                                   240 
253   const std::vector<G4String>& availPhysCtors  << 
254     physConstRegistry->AvailablePhysicsConstru << 
255                                                << 
256   // find the longest base list that is contai    241   // find the longest base list that is contained in the user supplied name
257   // and starts at the beginning                  242   // and starts at the beginning
258   G4String bestBase = "";                      << 243   size_t nb = availBases.size();
259   allKnown = FindLongestMatch(workingName,"bas << 244   for (size_t ib=0;  ib<nb; ++ib) {
260   if ( verb > 2 ) {                            << 245     const G4String& testBase = availBases[ib];
261     G4cout << "  " << name << ", base known="  << 246     size_t ipos = workingName.find(testBase);
262            << " chosen plBase \"" << plBase << << 247     if ( ipos == 0 ) {
                                                   >> 248       if ( testBase.size() > plBase.size() )  {
                                                   >> 249         plBase = testBase;
                                                   >> 250         allKnown = true;
                                                   >> 251         if ( verb > 3 ) { G4cout << "  physlist current best guess: " << testBase << G4endl; }
                                                   >> 252       } else {
                                                   >> 253         if ( verb > 3 ) { G4cout << "  physlist match but shorter: " << testBase << G4endl; }
                                                   >> 254       }
                                                   >> 255     } else {
                                                   >> 256       if ( verb > 3 ) { G4cout << "  physlist reject: " << testBase << G4endl; }
                                                   >> 257     }
                                                   >> 258   }
                                                   >> 259   if ( verb > 2 ) { 
                                                   >> 260     G4cout << "  physlist " << name << ", base known " << allKnown 
                                                   >> 261            << " chosen plBase \"" << plBase << "\"" << G4endl; 
263   }                                               262   }
264   if ( ! allKnown ) {                             263   if ( ! allKnown ) {
265     // didn't find any matching base physics l    264     // didn't find any matching base physics list
266     // no point of going on to the extensions     265     // no point of going on to the extensions
267     return allKnown;                              266     return allKnown;
268   }                                               267   }
269   // remove base name for working name            268   // remove base name for working name
270   workingName.erase(0,plBase.size());             269   workingName.erase(0,plBase.size());
271                                                   270 
272   // now start trying to match up extensions a << 271   // now start trying to match up extensions
273   // each should be preceeded by at "_" (repla    272   // each should be preceeded by at "_" (replace) or "+" (register)
274   // but don't freak if it isn't, just assume     273   // but don't freak if it isn't, just assume "_"
                                                   >> 274   size_t ne = availExtras.size();
275   while ( ! workingName.empty() ) {               275   while ( ! workingName.empty() ) {
276     char c = workingName.data()[0];  // leadin    276     char c = workingName.data()[0];  // leading character
277     if ( '_' == c || '+' == c ) workingName.er    277     if ( '_' == c || '+' == c ) workingName.erase(0,1);  // and remove it
278     G4int    replaceExtra = (( c != '+' ) ? do << 278     G4int    replaceExtra = ( c != '+' );
279     G4String extraName = "";                      279     G4String extraName = "";
280     G4bool   extraKnown = false;                  280     G4bool   extraKnown = false;
281                                                << 281     for (size_t ie=0;  ie<ne; ++ie) {
282     extraKnown = FindLongestMatch(workingName, << 282       const G4String& testExtra = availExtras[ie];
                                                   >> 283       size_t ipos = workingName.find(testExtra);
                                                   >> 284       if ( ipos == 0 ) {
                                                   >> 285         if ( testExtra.size() > extraName.size() )  {
                                                   >> 286           extraName = testExtra;
                                                   >> 287           extraKnown = true;
                                                   >> 288 #ifdef G4VERBOSE
                                                   >> 289           if ( verb > 3 ) { G4cout << "  physextra current best guess: " << testExtra << G4endl; }
                                                   >> 290         } else {
                                                   >> 291           if ( verb > 3 ) { G4cout << "  physextra match but shorter: " << testExtra << G4endl; }
                                                   >> 292 #endif
                                                   >> 293         }
                                                   >> 294       } else {
                                                   >> 295 #ifdef G4VERBOSE
                                                   >> 296         if ( verb > 3 ) { G4cout << "  physextra reject: " << testExtra << G4endl; }
                                                   >> 297 #endif
                                                   >> 298       }
                                                   >> 299     }
                                                   >> 300 #ifdef G4VERBOSE
                                                   >> 301     if ( verb > 2 ) { 
                                                   >> 302       G4cout << "  physextra " << name << " [" << workingName << "]"
                                                   >> 303              <<", extra known " << extraKnown 
                                                   >> 304              << " chosen extra \"" << extraName << "\"" 
                                                   >> 305              << " replace " << replaceExtra << G4endl; 
                                                   >> 306     }
                                                   >> 307 #endif
283     if ( extraKnown ) {                           308     if ( extraKnown ) {
284       // physics mapping name is known, but is    309       // physics mapping name is known, but is it actually linked to physics?
285       //const issue// G4String pcname = physic << 310       //const issue// G4String pcname = physicsExtensions[extraName]; 
286       std::map<G4String,G4String>::const_itera << 311       std::map<G4String,G4String>::const_iterator itr = 
287         physicsExtensions.find(extraName);        312         physicsExtensions.find(extraName);
288       G4String pcname = "";                       313       G4String pcname = "";
289       if ( itr != physicsExtensions.end() ) pc    314       if ( itr != physicsExtensions.end() ) pcname = itr->second;
290       G4bool realknown = physConstRegistry->Is << 315       bool realknown = physConstRegistry->IsKnownPhysicsConstructor(pcname);
291       if ( ! realknown ) allKnown = false;     << 
292 #ifdef G4VERBOSE                                  316 #ifdef G4VERBOSE
293       if ( verb > 2 ) {                        << 317       if ( verb > 2 ) { 
294         G4cout << "  extraName \"" << extraNam    318         G4cout << "  extraName \"" << extraName << "\" maps to physics ctor \""
295                << pcname << "\" which is itsel    319                << pcname << "\" which is itself realknown " << realknown
296                << G4endl;                         320                << G4endl;
297       }                                           321       }
298 #endif                                            322 #endif
299     } else {                                   << 323       if ( ! realknown ) allKnown = false;
300       // perhaps it's an explicit physCtor nam << 
301       extraKnown =                             << 
302         FindLongestMatch(workingName,"physCtor << 
303       if ( extraKnown ) replaceExtra |= isCtor << 
304     }                                          << 
305 #ifdef G4VERBOSE                               << 
306     if ( verb > 2 ) {                          << 
307       G4cout << "  physextra " << name << " [" << 
308              <<", extra known " << extraKnown  << 
309              << " chosen extra \"" << extraNam << 
310              << " replace " << replaceExtra << << 
311     }                                          << 
312 #endif                                         << 
313     if ( extraKnown ) {                        << 
314       physExt.push_back(extraName);               324       physExt.push_back(extraName);
315       replace.push_back(replaceExtra);            325       replace.push_back(replaceExtra);
316       // and remove it so we can look for the     326       // and remove it so we can look for the next bit
317       workingName.erase(0,extraName.size());      327       workingName.erase(0,extraName.size());
318                                                << 
319     } else {                                      328     } else {
320 #ifdef G4VERBOSE                               << 
321       if ( verb > 2 ) {                        << 
322         G4cout << "  workingName \"" << workin << 
323                << " couldn't be found in the e << 
324                << G4endl;                      << 
325       }                                        << 
326 #endif                                         << 
327       allKnown = false;                           329       allKnown = false;
328       // found a pattern that we can't map     << 
329       return allKnown;                         << 
330     }                                             330     }
331   } // workingName not empty                      331   } // workingName not empty
332                                                   332 
333   return allKnown;                                333   return allKnown;
334 }                                                 334 }
335                                                   335 
336 G4bool G4PhysListRegistry::FindLongestMatch(co << 
337                                             co << 
338                                             co << 
339                                             G4 << 
340                                             G4 << 
341 {                                              << 
342   bestMatch = "";                              << 
343   G4bool found = false;                        << 
344                                                << 
345   std::size_t n = validNames.size();           << 
346   for (std::size_t i=0;  i<n; ++i) {           << 
347     const G4String& testName = validNames[i];  << 
348     std::size_t ipos = workingName.find(testNa << 
349     if ( ipos == 0 ) {                         << 
350       std::size_t testNameSize = testName.size << 
351       std::size_t workNameSize = workingName.s << 
352       G4bool match = true;                     << 
353       if ( searchName == "base" ) {            << 
354         // if searching for a valid base impos << 
355         // either must exactly match or the ne << 
356         // one of the standard delimiters of " << 
357         if (workNameSize > testNameSize) {     << 
358           char nextChar = workingName[(G4int)t << 
359           if ( nextChar != '_' && nextChar !=  << 
360           if ( verb > 3 ) {                    << 
361             G4cout << "  " << searchName << "  << 
362                    << testName << " nextChar " << 
363           }                                    << 
364         }                                      << 
365       }                                        << 
366       if ( verb > 3 ) {                        << 
367         G4cout << "  " << searchName << " matc << 
368                << " " << testName << G4endl;   << 
369       }                                        << 
370       if ( match ) {                           << 
371         if ( testName.size() > bestMatch.size( << 
372           bestMatch = testName;                << 
373           found     = true;                    << 
374           if ( verb > 3 ) {                    << 
375             G4cout << "  " << searchName << "  << 
376                    << testName << G4endl;      << 
377           }                                    << 
378         } else {                               << 
379           if ( verb > 3 ) {                    << 
380             G4cout << "  " << searchName << "  << 
381                    << testName << G4endl;      << 
382           }                                    << 
383         }                                      << 
384       } else {                                 << 
385           if ( verb > 3 ) {                    << 
386             G4cout << "  " << searchName << "  << 
387                    << testName << G4endl;      << 
388           }                                    << 
389       }                                        << 
390     } else {                                   << 
391       if ( verb > 3 ) {                        << 
392         G4cout << "  " << searchName << " reje << 
393       }                                        << 
394     }                                          << 
395   }                                            << 
396   return found;                                << 
397 }                                              << 
398                                                << 
399                                                << 
400 const std::vector<G4String>& G4PhysListRegistr    336 const std::vector<G4String>& G4PhysListRegistry::AvailablePhysLists() const
401 {                                                 337 {
402   availBasePhysLists.clear();                     338   availBasePhysLists.clear();
403   std::map<G4String,G4VBasePhysListStamper*>::    339   std::map<G4String,G4VBasePhysListStamper*>::const_iterator itr;
404   for ( itr = factories.begin(); itr != factor    340   for ( itr = factories.begin(); itr != factories.end(); ++itr ) {
405     availBasePhysLists.push_back(itr->first);     341     availBasePhysLists.push_back(itr->first);
406   }                                               342   }
407                                                   343 
408   return availBasePhysLists;                      344   return availBasePhysLists;
409 }                                                 345 }
410                                                   346 
411 const std::vector<G4String>& G4PhysListRegistr    347 const std::vector<G4String>& G4PhysListRegistry::AvailablePhysicsExtensions() const
412 {                                                 348 {
413   availExtensions.clear();                        349   availExtensions.clear();
414   std::map<G4String,G4String>::const_iterator     350   std::map<G4String,G4String>::const_iterator itr;
415   for ( itr = physicsExtensions.begin(); itr !    351   for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
416     availExtensions.push_back(itr->first);        352     availExtensions.push_back(itr->first);
417   }                                               353   }
418                                                   354 
419   return availExtensions;                         355   return availExtensions;
420 }                                                 356 }
421                                                   357 
422 const std::vector<G4String>& G4PhysListRegistr    358 const std::vector<G4String>& G4PhysListRegistry::AvailablePhysListsEM() const
423 {                                                 359 {
424   // in principle this method could weed out a    360   // in principle this method could weed out all the extensions that aren't
425   // EM replacements ... but for now just use  << 361   // EM replacements ... but for now just use it as a synonym for 
426   // AvailablePhysicsExtensions()                 362   // AvailablePhysicsExtensions()
427   return AvailablePhysicsExtensions();            363   return AvailablePhysicsExtensions();
428 }                                                 364 }
429                                                   365 
430 void G4PhysListRegistry::PrintAvailablePhysLis    366 void G4PhysListRegistry::PrintAvailablePhysLists() const
431 {                                                 367 {
432   std::vector<G4String> avail = AvailablePhysL    368   std::vector<G4String> avail = AvailablePhysLists();
433   G4cout << "Base G4VModularPhysicsLists in G4    369   G4cout << "Base G4VModularPhysicsLists in G4PhysListRegistry are:"
434          << G4endl;                               370          << G4endl;
435   if ( avail.empty() ) G4cout << "... no regis    371   if ( avail.empty() ) G4cout << "... no registered lists" << G4endl;
436   else {                                          372   else {
437     std::size_t n = avail.size();              << 373     size_t n = avail.size();
438     for (std::size_t i=0; i<n; ++i ) {         << 374     for (size_t i=0; i<n; ++i ) {
439       G4cout << " [" << std::setw(3) << i << "    375       G4cout << " [" << std::setw(3) << i << "] "
440              << " \"" << avail[i] << "\"" << G    376              << " \"" << avail[i] << "\"" << G4endl;
441     }                                             377     }
442   }                                               378   }
443                                                   379 
444   G4PhysicsConstructorRegistry* physConstRegis    380   G4PhysicsConstructorRegistry* physConstRegistry = G4PhysicsConstructorRegistry::Instance();
445                                                   381 
446   std::map<G4String,G4String>::const_iterator     382   std::map<G4String,G4String>::const_iterator itr;
447   G4cout << "Replacement mappings in G4PhysLis    383   G4cout << "Replacement mappings in G4PhysListRegistry are:"
448          << G4endl;                               384          << G4endl;
449   for ( itr = physicsExtensions.begin(); itr !    385   for ( itr = physicsExtensions.begin(); itr != physicsExtensions.end(); ++itr ) {
450     G4bool known = physConstRegistry->IsKnownP << 386     bool known = physConstRegistry->IsKnownPhysicsConstructor(itr->second);
451                                                   387 
452     G4cout << "    " << std::setw(10) << itr->    388     G4cout << "    " << std::setw(10) << itr->first << " => "
453            << std::setw(30) << itr->second <<     389            << std::setw(30) << itr->second << " "
454            << ( (known)?"":"[unregistered phys    390            << ( (known)?"":"[unregistered physics]")
455            << G4endl;                             391            << G4endl;
456   }                                               392   }
457   G4cout << "Use these mapping to extend physi    393   G4cout << "Use these mapping to extend physics list; append with _EXT or +EXT" << G4endl
458          << "   to use ReplacePhysics() (\"_\"    394          << "   to use ReplacePhysics() (\"_\") or RegisterPhysics() (\"+\")."
459          << G4endl;                               395          << G4endl;
460 }                                                 396 }
                                                   >> 397 
461                                                   398