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.4.p2)


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