Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/run/src/G4VModularPhysicsList.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 /run/src/G4VModularPhysicsList.cc (Version 11.3.0) and /run/src/G4VModularPhysicsList.cc (Version 11.1.2)


  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 // G4VModularPhysicsList implementation            26 // G4VModularPhysicsList implementation
 27 //                                                 27 //
 28 // Original author: H.Kurashige (Kobe Universi     28 // Original author: H.Kurashige (Kobe University), 12 November 2000
 29 // -------------------------------------------     29 // --------------------------------------------------------------------
 30                                                    30 
 31 #include "G4VModularPhysicsList.hh"            <<  31 #include <algorithm>
 32                                                    32 
                                                   >>  33 #include "G4VModularPhysicsList.hh"
 33 #include "G4StateManager.hh"                       34 #include "G4StateManager.hh"
 34                                                    35 
 35 #include <algorithm>                           << 
 36                                                << 
 37 // This macros change the references to fields     36 // This macros change the references to fields that are now encapsulated
 38 // in the class G4VMPLData.                        37 // in the class G4VMPLData.
 39 #define G4MT_physicsVector ((G4VMPLsubInstance <<  38 #define G4MT_physicsVector                                                     \
                                                   >>  39   ((G4VMPLsubInstanceManager.offset[g4vmplInstanceID]).physicsVector)
 40                                                    40 
 41 G4VMPLManager G4VModularPhysicsList::G4VMPLsub     41 G4VMPLManager G4VModularPhysicsList::G4VMPLsubInstanceManager;
 42                                                    42 
 43 // -------------------------------------------     43 // --------------------------------------------------------------------
 44 void G4VMPLData::initialize()                      44 void G4VMPLData::initialize()
 45 {                                                  45 {
 46   physicsVector = new G4PhysConstVectorData();     46   physicsVector = new G4PhysConstVectorData();
 47 }                                                  47 }
 48                                                    48 
 49 // -------------------------------------------     49 // --------------------------------------------------------------------
 50 G4VModularPhysicsList::G4VModularPhysicsList()     50 G4VModularPhysicsList::G4VModularPhysicsList()
                                                   >>  51   : G4VUserPhysicsList()
 51 {                                                  52 {
 52   g4vmplInstanceID = G4VMPLsubInstanceManager.     53   g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
 53 }                                                  54 }
 54                                                    55 
 55 // -------------------------------------------     56 // --------------------------------------------------------------------
 56 G4VModularPhysicsList::~G4VModularPhysicsList(     57 G4VModularPhysicsList::~G4VModularPhysicsList()
 57 {                                                  58 {
 58   if (G4MT_physicsVector != nullptr) {         <<  59   if(G4MT_physicsVector != nullptr)
 59     for (auto& ptr : *G4MT_physicsVector) {    <<  60   {  
 60       delete ptr;                              <<  61     for(auto & ptr : *G4MT_physicsVector) { delete ptr; }
 61     }                                          << 
 62     delete G4MT_physicsVector;                     62     delete G4MT_physicsVector;
 63     G4MT_physicsVector = nullptr;                  63     G4MT_physicsVector = nullptr;
 64   }                                                64   }
 65 }                                                  65 }
 66                                                    66 
 67 // -------------------------------------------     67 // --------------------------------------------------------------------
 68 G4VModularPhysicsList::G4VModularPhysicsList(c     68 G4VModularPhysicsList::G4VModularPhysicsList(const G4VModularPhysicsList& right)
 69   : G4VUserPhysicsList(right)                      69   : G4VUserPhysicsList(right)
 70 {                                                  70 {
 71   g4vmplInstanceID = G4VMPLsubInstanceManager.     71   g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
 72   G4MT_physicsVector = nullptr;                    72   G4MT_physicsVector = nullptr;
 73 }                                                  73 }
 74                                                    74 
 75 // -------------------------------------------     75 // --------------------------------------------------------------------
 76 G4VModularPhysicsList& G4VModularPhysicsList:: <<  76 G4VModularPhysicsList& G4VModularPhysicsList::operator=(
                                                   >>  77   const G4VModularPhysicsList& right)
 77 {                                                  78 {
 78   if (this != &right) {                        <<  79   if(this != &right)
 79     defaultCutValue = right.defaultCutValue;   <<  80   {
 80     isSetDefaultCutValue = right.isSetDefaultC <<  81     defaultCutValue                   = right.defaultCutValue;
 81     fRetrievePhysicsTable = right.fRetrievePhy <<  82     isSetDefaultCutValue              = right.isSetDefaultCutValue;
 82     fStoredInAscii = right.fStoredInAscii;     <<  83     fRetrievePhysicsTable             = right.fRetrievePhysicsTable;
                                                   >>  84     fStoredInAscii                    = right.fStoredInAscii;
 83     fIsCheckedForRetrievePhysicsTable = right.     85     fIsCheckedForRetrievePhysicsTable = right.fIsCheckedForRetrievePhysicsTable;
 84     fIsRestoredCutValues = right.fIsRestoredCu <<  86     fIsRestoredCutValues              = right.fIsRestoredCutValues;
 85     directoryPhysicsTable = right.directoryPhy <<  87     directoryPhysicsTable             = right.directoryPhysicsTable;
 86     (this->subInstanceManager.offset[this->g4v <<  88     (this->subInstanceManager.offset[this->g4vuplInstanceID])
 87       static_cast<const G4VUserPhysicsList&>(r <<  89       ._fDisplayThreshold = static_cast<const G4VUserPhysicsList&>(right)
 88         .GetSubInstanceManager()               <<  90                               .GetSubInstanceManager()
 89         .offset[right.GetInstanceID()]         <<  91                               .offset[right.GetInstanceID()]
 90         ._fDisplayThreshold;                   <<  92                               ._fDisplayThreshold;
 91     (this->subInstanceManager.offset[this->g4v <<  93     (this->subInstanceManager.offset[this->g4vuplInstanceID])
 92       static_cast<G4int>(static_cast<const G4V <<  94       ._fDisplayThreshold = static_cast<const G4VUserPhysicsList&>(right)
 93                            .GetSubInstanceMana <<  95                               .GetSubInstanceManager()
 94                            .offset[right.GetIn <<  96                               .offset[right.GetInstanceID()]
 95                            ._fIsPhysicsTableBu <<  97                               ._fIsPhysicsTableBuilt;
 96     fDisableCheckParticleList = right.fDisable     98     fDisableCheckParticleList = right.fDisableCheckParticleList;
 97     verboseLevel = right.verboseLevel;         <<  99     verboseLevel              = right.verboseLevel;
 98                                                   100 
 99     if (G4MT_physicsVector != nullptr) {       << 101     if(G4MT_physicsVector != nullptr)
100       for (auto& ptr : *G4MT_physicsVector) {  << 102     {  
101         delete ptr;                            << 103       for(auto & ptr : *G4MT_physicsVector) { delete ptr; }
102       }                                        << 
103       delete G4MT_physicsVector;                  104       delete G4MT_physicsVector;
104       G4MT_physicsVector = nullptr;               105       G4MT_physicsVector = nullptr;
105     }                                             106     }
106     g4vmplInstanceID = G4VMPLsubInstanceManage    107     g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
107   }                                               108   }
108   return *this;                                   109   return *this;
109 }                                                 110 }
110                                                   111 
111 // -------------------------------------------    112 // --------------------------------------------------------------------
112 void G4VModularPhysicsList::ConstructParticle(    113 void G4VModularPhysicsList::ConstructParticle()
113 {                                                 114 {
114   // create particles                             115   // create particles
115   for (auto itr = G4MT_physicsVector->cbegin() << 116   for(auto itr = G4MT_physicsVector->cbegin();
                                                   >> 117            itr != G4MT_physicsVector->cend(); ++itr)
                                                   >> 118   {
116     (*itr)->ConstructParticle();                  119     (*itr)->ConstructParticle();
117   }                                               120   }
118 }                                                 121 }
119                                                   122 
120 // -------------------------------------------    123 // --------------------------------------------------------------------
121 // Andrea Dotti: May 6 2013                       124 // Andrea Dotti: May 6 2013
122 // Current limitation being debugged: Construc    125 // Current limitation being debugged: Construction of physics processes
123 // needs to be sequential (there is at least o    126 // needs to be sequential (there is at least one HAD processes creating
124 // problems). This is not yet understood and n    127 // problems). This is not yet understood and needs to be debugged. We do not
125 // want this part to be sequential (imagine wh    128 // want this part to be sequential (imagine when one has 100 threads)
126 // TODO: Remove this lock                         129 // TODO: Remove this lock
127 #include "G4AutoLock.hh"                          130 #include "G4AutoLock.hh"
128 namespace                                         131 namespace
129 {                                                 132 {
130 G4Mutex constructProcessMutex = G4MUTEX_INITIA << 133   G4Mutex constructProcessMutex = G4MUTEX_INITIALIZER;
131 }                                                 134 }
132                                                   135 
133 // -------------------------------------------    136 // --------------------------------------------------------------------
134 void G4VModularPhysicsList::ConstructProcess()    137 void G4VModularPhysicsList::ConstructProcess()
135 {                                                 138 {
136   G4AutoLock l(&constructProcessMutex);  // Pr    139   G4AutoLock l(&constructProcessMutex);  // Protection to be removed (A.Dotti)
137   AddTransportation();                            140   AddTransportation();
138                                                   141 
139   for (auto itr = G4MT_physicsVector->cbegin() << 142   for(auto itr = G4MT_physicsVector->cbegin();
                                                   >> 143            itr != G4MT_physicsVector->cend(); ++itr)
                                                   >> 144   {
140     (*itr)->ConstructProcess();                   145     (*itr)->ConstructProcess();
141   }                                               146   }
142 }                                                 147 }
143                                                   148 
144 // -------------------------------------------    149 // --------------------------------------------------------------------
145 void G4VModularPhysicsList::RegisterPhysics(G4    150 void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
146 {                                                 151 {
147   G4StateManager* stateManager = G4StateManage << 152   G4StateManager* stateManager    = G4StateManager::GetStateManager();
148   G4ApplicationState currentState = stateManag    153   G4ApplicationState currentState = stateManager->GetCurrentState();
149   if (!(currentState == G4State_PreInit)) {    << 154   if(!(currentState == G4State_PreInit))
150     G4Exception("G4VModularPhysicsList::Regist << 155   {
                                                   >> 156     G4Exception("G4VModularPhysicsList::RegisterPhysics", "Run0201",
                                                   >> 157                 JustWarning,
151                 "Geant4 kernel is not PreInit     158                 "Geant4 kernel is not PreInit state : Method ignored.");
152     return;                                       159     return;
153   }                                               160   }
154                                                   161 
155   G4String pName = fPhysics->GetPhysicsName();    162   G4String pName = fPhysics->GetPhysicsName();
156   G4int pType = fPhysics->GetPhysicsType();    << 163   G4int pType    = fPhysics->GetPhysicsType();
157   // If physics_type is equal to 0,               164   // If physics_type is equal to 0,
158   // following duplication check is omitted       165   // following duplication check is omitted
159   // This is TEMPORAL treatment.                  166   // This is TEMPORAL treatment.
160   if (pType == 0) {                            << 167   if(pType == 0)
                                                   >> 168   {
161     G4MT_physicsVector->push_back(fPhysics);      169     G4MT_physicsVector->push_back(fPhysics);
162 #ifdef G4VERBOSE                                  170 #ifdef G4VERBOSE
163     if (verboseLevel > 1) {                    << 171     if(verboseLevel > 1)
164       G4cout << "G4VModularPhysicsList::Regist << 172     {
165              << " is added" << G4endl;         << 173       G4cout << "G4VModularPhysicsList::RegisterPhysics: " << pName
                                                   >> 174              << " with type : " << pType << " is added" << G4endl;
166     }                                             175     }
167 #endif                                            176 #endif
168     return;                                       177     return;
169   }                                               178   }
170                                                   179 
171   // Check if physics with the physics_type sa    180   // Check if physics with the physics_type same as one of given physics
172   auto itr = G4MT_physicsVector->cbegin();        181   auto itr = G4MT_physicsVector->cbegin();
173   for (; itr != G4MT_physicsVector->cend(); ++ << 182   for(; itr != G4MT_physicsVector->cend(); ++itr)
174     if (pType == (*itr)->GetPhysicsType()) bre << 183   {
                                                   >> 184     if(pType == (*itr)->GetPhysicsType())
                                                   >> 185       break;
175   }                                               186   }
176   if (itr != G4MT_physicsVector->cend()) {     << 187   if(itr != G4MT_physicsVector->cend())
                                                   >> 188   {
177 #ifdef G4VERBOSE                                  189 #ifdef G4VERBOSE
178     if (verboseLevel > 0) {                    << 190     if(verboseLevel > 0)
                                                   >> 191     {
179       G4cout << "G4VModularPhysicsList::Regist    192       G4cout << "G4VModularPhysicsList::RegisterPhysics: "
180              << "a physics with given type alr    193              << "a physics with given type already exists " << G4endl;
181       G4cout << " Type = " << pType << " : "      194       G4cout << " Type = " << pType << " : "
182              << "  existing physics is " << (*    195              << "  existing physics is " << (*itr)->GetPhysicsName() << G4endl;
183       G4cout << " New " << pName << " can not     196       G4cout << " New " << pName << " can not be registered " << G4endl;
184     }                                             197     }
185 #endif                                            198 #endif
186     G4String comment = "Duplicate type for ";     199     G4String comment = "Duplicate type for ";
187     comment += pName;                             200     comment += pName;
188     G4Exception("G4VModularPhysicsList::Regist << 201     G4Exception("G4VModularPhysicsList::RegisterPhysics", "Run0202",
                                                   >> 202                 JustWarning, comment);
189     return;                                       203     return;
190   }                                               204   }
191                                                   205 
192   // register                                     206   // register
193   G4MT_physicsVector->push_back(fPhysics);        207   G4MT_physicsVector->push_back(fPhysics);
194 }                                                 208 }
195                                                   209 
196 // -------------------------------------------    210 // --------------------------------------------------------------------
197 void G4VModularPhysicsList::ReplacePhysics(G4V    211 void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
198 {                                                 212 {
199   G4StateManager* stateManager = G4StateManage << 213   G4StateManager* stateManager    = G4StateManager::GetStateManager();
200   G4ApplicationState currentState = stateManag    214   G4ApplicationState currentState = stateManager->GetCurrentState();
201   if (!(currentState == G4State_PreInit)) {    << 215   if(!(currentState == G4State_PreInit))
                                                   >> 216   {
202     G4Exception("G4VModularPhysicsList::Replac    217     G4Exception("G4VModularPhysicsList::ReplacePhysics", "Run0203", JustWarning,
203                 "Geant4 kernel is not PreInit     218                 "Geant4 kernel is not PreInit state : Method ignored.");
204     return;                                       219     return;
205   }                                               220   }
206                                                   221 
207   G4String pName = fPhysics->GetPhysicsName();    222   G4String pName = fPhysics->GetPhysicsName();
208   G4int pType = fPhysics->GetPhysicsType();    << 223   G4int pType    = fPhysics->GetPhysicsType();
209   // If physics_type is equal to 0,               224   // If physics_type is equal to 0,
210   // duplication check is omitted and just add    225   // duplication check is omitted and just added.
211   // This is TEMPORAL treatment.                  226   // This is TEMPORAL treatment.
212   if (pType == 0) {                            << 227   if(pType == 0)
                                                   >> 228   {
213     // register                                   229     // register
214     G4MT_physicsVector->push_back(fPhysics);      230     G4MT_physicsVector->push_back(fPhysics);
215 #ifdef G4VERBOSE                                  231 #ifdef G4VERBOSE
216     if (verboseLevel > 0) {                    << 232     if(verboseLevel > 0)
217       G4cout << "G4VModularPhysicsList::Replac << 233     {
218              << " is added" << G4endl;         << 234       G4cout << "G4VModularPhysicsList::ReplacePhysics: " << pName
                                                   >> 235              << " with type : " << pType << " is added" << G4endl;
219     }                                             236     }
220 #endif                                            237 #endif
221     return;                                       238     return;
222   }                                               239   }
223                                                   240 
224   // Check if physics with the physics_type sa    241   // Check if physics with the physics_type same as one of given physics
225   auto itr = G4MT_physicsVector->begin();         242   auto itr = G4MT_physicsVector->begin();
226   for (; itr != G4MT_physicsVector->end(); ++i << 243   for(; itr != G4MT_physicsVector->end(); ++itr)
227     if (pType == (*itr)->GetPhysicsType()) bre << 244   {
                                                   >> 245     if(pType == (*itr)->GetPhysicsType())
                                                   >> 246       break;
228   }                                               247   }
229   if (itr == G4MT_physicsVector->end()) {      << 248   if(itr == G4MT_physicsVector->end())
                                                   >> 249   {
230     // register                                   250     // register
231     G4MT_physicsVector->push_back(fPhysics);      251     G4MT_physicsVector->push_back(fPhysics);
232   }                                               252   }
233   else {                                       << 253   else
                                                   >> 254   {
234 #ifdef G4VERBOSE                                  255 #ifdef G4VERBOSE
235     if (verboseLevel > 0) {                    << 256     if(verboseLevel > 0)
236       G4cout << "G4VModularPhysicsList::Replac << 257     {
237              << " with type : " << pType << "  << 258       G4cout << "G4VModularPhysicsList::ReplacePhysics: "
                                                   >> 259              << (*itr)->GetPhysicsName() << " with type : " << pType
                                                   >> 260              << " is replaced with " << pName << G4endl;
238     }                                             261     }
239 #endif                                            262 #endif
240                                                   263 
241     //  delete exsiting one                       264     //  delete exsiting one
242     delete (*itr);                             << 265     delete(*itr);
243     // replace with given one                     266     // replace with given one
244     (*itr) = fPhysics;                            267     (*itr) = fPhysics;
245   }                                               268   }
246   return;                                         269   return;
247 }                                                 270 }
248                                                   271 
249 // -------------------------------------------    272 // --------------------------------------------------------------------
250 void G4VModularPhysicsList::RemovePhysics(G4in    273 void G4VModularPhysicsList::RemovePhysics(G4int pType)
251 {                                                 274 {
252   G4StateManager* stateManager = G4StateManage << 275   G4StateManager* stateManager    = G4StateManager::GetStateManager();
253   G4ApplicationState currentState = stateManag    276   G4ApplicationState currentState = stateManager->GetCurrentState();
254   if (!(currentState == G4State_PreInit)) {    << 277   if(!(currentState == G4State_PreInit))
                                                   >> 278   {
255     G4Exception("G4VModularPhysicsList::Remove    279     G4Exception("G4VModularPhysicsList::RemovePhysics", "Run0204", JustWarning,
256                 "Geant4 kernel is not PreInit     280                 "Geant4 kernel is not PreInit state : Method ignored.");
257     return;                                       281     return;
258   }                                               282   }
259                                                   283 
260   for (auto itr = G4MT_physicsVector->cbegin() << 284   for(auto itr = G4MT_physicsVector->cbegin();
261     if (pType == (*itr)->GetPhysicsType()) {   << 285            itr != G4MT_physicsVector->cend();)
                                                   >> 286   {
                                                   >> 287     if(pType == (*itr)->GetPhysicsType())
                                                   >> 288     {
262       G4String pName = (*itr)->GetPhysicsName(    289       G4String pName = (*itr)->GetPhysicsName();
263 #ifdef G4VERBOSE                                  290 #ifdef G4VERBOSE
264       if (verboseLevel > 0) {                  << 291       if(verboseLevel > 0)
265         G4cout << "G4VModularPhysicsList::Remo << 292       {
                                                   >> 293         G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
                                                   >> 294                << " is removed" << G4endl;
266       }                                           295       }
267 #endif                                            296 #endif
268       G4MT_physicsVector->erase(itr);             297       G4MT_physicsVector->erase(itr);
269       break;                                      298       break;
270     }                                             299     }
271                                                << 300     else
272     ++itr;                                     << 301     {
                                                   >> 302       ++itr;
                                                   >> 303     }
273   }                                               304   }
274 }                                                 305 }
275                                                   306 
276 // -------------------------------------------    307 // --------------------------------------------------------------------
277 void G4VModularPhysicsList::RemovePhysics(G4VP    308 void G4VModularPhysicsList::RemovePhysics(G4VPhysicsConstructor* fPhysics)
278 {                                                 309 {
279   G4StateManager* stateManager = G4StateManage << 310   G4StateManager* stateManager    = G4StateManager::GetStateManager();
280   G4ApplicationState currentState = stateManag    311   G4ApplicationState currentState = stateManager->GetCurrentState();
281   if (!(currentState == G4State_PreInit)) {    << 312   if(!(currentState == G4State_PreInit))
                                                   >> 313   {
282     G4Exception("G4VModularPhysicsList::Remove    314     G4Exception("G4VModularPhysicsList::RemovePhysics", "Run0205", JustWarning,
283                 "Geant4 kernel is not PreInit     315                 "Geant4 kernel is not PreInit state : Method ignored.");
284     return;                                       316     return;
285   }                                               317   }
286                                                   318 
287   for (auto itr = G4MT_physicsVector->cbegin() << 319   for(auto itr = G4MT_physicsVector->cbegin();
288     if (fPhysics == (*itr)) {                  << 320            itr != G4MT_physicsVector->cend();)
                                                   >> 321   {
                                                   >> 322     if(fPhysics == (*itr))
                                                   >> 323     {
289       G4String pName = (*itr)->GetPhysicsName(    324       G4String pName = (*itr)->GetPhysicsName();
290 #ifdef G4VERBOSE                                  325 #ifdef G4VERBOSE
291       if (verboseLevel > 0) {                  << 326       if(verboseLevel > 0)
292         G4cout << "G4VModularPhysicsList::Remo << 327       {
                                                   >> 328         G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
                                                   >> 329                << " is removed" << G4endl;
293       }                                           330       }
294 #endif                                            331 #endif
295       G4MT_physicsVector->erase(itr);             332       G4MT_physicsVector->erase(itr);
296       break;                                      333       break;
297     }                                             334     }
298                                                << 335     else
299     ++itr;                                     << 336     {
                                                   >> 337       ++itr;
                                                   >> 338     }
300   }                                               339   }
301 }                                                 340 }
302                                                   341 
303 // -------------------------------------------    342 // --------------------------------------------------------------------
304 void G4VModularPhysicsList::RemovePhysics(cons    343 void G4VModularPhysicsList::RemovePhysics(const G4String& name)
305 {                                                 344 {
306   G4StateManager* stateManager = G4StateManage << 345   G4StateManager* stateManager    = G4StateManager::GetStateManager();
307   G4ApplicationState currentState = stateManag    346   G4ApplicationState currentState = stateManager->GetCurrentState();
308   if (!(currentState == G4State_PreInit)) {    << 347   if(!(currentState == G4State_PreInit))
                                                   >> 348   {
309     G4Exception("G4VModularPhysicsList::Remove    349     G4Exception("G4VModularPhysicsList::RemovePhysics", "Run0206", JustWarning,
310                 "Geant4 kernel is not PreInit     350                 "Geant4 kernel is not PreInit state : Method ignored.");
311     return;                                       351     return;
312   }                                               352   }
313                                                   353 
314   for (auto itr = G4MT_physicsVector->cbegin() << 354   for(auto itr = G4MT_physicsVector->cbegin();
                                                   >> 355            itr != G4MT_physicsVector->cend();)
                                                   >> 356   {
315     G4String pName = (*itr)->GetPhysicsName();    357     G4String pName = (*itr)->GetPhysicsName();
316     if (name == pName) {                       << 358     if(name == pName)
                                                   >> 359     {
317 #ifdef G4VERBOSE                                  360 #ifdef G4VERBOSE
318       if (verboseLevel > 0) {                  << 361       if(verboseLevel > 0)
319         G4cout << "G4VModularPhysicsList::Remo << 362       {
                                                   >> 363         G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
                                                   >> 364                << " is removed" << G4endl;
320       }                                           365       }
321 #endif                                            366 #endif
322       G4MT_physicsVector->erase(itr);             367       G4MT_physicsVector->erase(itr);
323       break;                                      368       break;
324     }                                             369     }
325                                                << 370     else
326     ++itr;                                     << 371     {
                                                   >> 372       ++itr;
                                                   >> 373     }
327   }                                               374   }
328 }                                                 375 }
329                                                   376 
330 // -------------------------------------------    377 // --------------------------------------------------------------------
331 const G4VPhysicsConstructor* G4VModularPhysics    378 const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(G4int idx) const
332 {                                                 379 {
333   auto itr = G4MT_physicsVector->cbegin();        380   auto itr = G4MT_physicsVector->cbegin();
334   for (G4int i = 0; i < idx && itr != G4MT_phy << 381   for(G4int i = 0; i < idx && itr != G4MT_physicsVector->cend(); ++i)
335     ++itr;                                        382     ++itr;
336   if (itr != G4MT_physicsVector->cend()) retur << 383   if(itr != G4MT_physicsVector->cend())
337   return nullptr;                              << 384     return (*itr);
                                                   >> 385   else
                                                   >> 386     return nullptr;
338 }                                                 387 }
339                                                   388 
340 // -------------------------------------------    389 // --------------------------------------------------------------------
341 const G4VPhysicsConstructor* G4VModularPhysics << 390 const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(
                                                   >> 391   const G4String& name) const
342 {                                                 392 {
343   auto itr = G4MT_physicsVector->cbegin();        393   auto itr = G4MT_physicsVector->cbegin();
344   for (; itr != G4MT_physicsVector->cend(); ++ << 394   for(; itr != G4MT_physicsVector->cend(); ++itr)
345     if (name == (*itr)->GetPhysicsName()) brea << 395   {
                                                   >> 396     if(name == (*itr)->GetPhysicsName())
                                                   >> 397       break;
346   }                                               398   }
347   if (itr != G4MT_physicsVector->cend()) retur << 399   if(itr != G4MT_physicsVector->cend())
348   return nullptr;                              << 400     return (*itr);
                                                   >> 401   else
                                                   >> 402     return nullptr;
349 }                                                 403 }
350                                                   404 
351 // -------------------------------------------    405 // --------------------------------------------------------------------
352 const G4VPhysicsConstructor* G4VModularPhysics << 406 const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysicsWithType(
                                                   >> 407   G4int pType) const
353 {                                                 408 {
354   auto itr = G4MT_physicsVector->cbegin();        409   auto itr = G4MT_physicsVector->cbegin();
355   for (; itr != G4MT_physicsVector->cend(); ++ << 410   for(; itr != G4MT_physicsVector->cend(); ++itr)
356     if (pType == (*itr)->GetPhysicsType()) bre << 411   {
                                                   >> 412     if(pType == (*itr)->GetPhysicsType())
                                                   >> 413       break;
357   }                                               414   }
358   if (itr != G4MT_physicsVector->cend()) retur << 415   if(itr != G4MT_physicsVector->cend())
359   return nullptr;                              << 416     return (*itr);
                                                   >> 417   else
                                                   >> 418     return nullptr;
360 }                                                 419 }
361                                                   420 
362 // -------------------------------------------    421 // --------------------------------------------------------------------
363 void G4VModularPhysicsList::SetVerboseLevel(G4    422 void G4VModularPhysicsList::SetVerboseLevel(G4int value)
364 {                                                 423 {
365   verboseLevel = value;                           424   verboseLevel = value;
366   // Loop over constructors                       425   // Loop over constructors
367   for (auto itr = G4MT_physicsVector->cbegin() << 426   for(auto itr = G4MT_physicsVector->cbegin();
                                                   >> 427            itr != G4MT_physicsVector->cend(); ++itr)
                                                   >> 428   {
368     (*itr)->SetVerboseLevel(verboseLevel);        429     (*itr)->SetVerboseLevel(verboseLevel);
369   }                                               430   }
370 }                                                 431 }
371                                                   432 
372 // -------------------------------------------    433 // --------------------------------------------------------------------
373 void G4VModularPhysicsList::TerminateWorker()     434 void G4VModularPhysicsList::TerminateWorker()
374 {                                                 435 {
375   // See https://jira-geant4.kek.jp/browse/DEV    436   // See https://jira-geant4.kek.jp/browse/DEV-284
376   std::for_each(G4MT_physicsVector->cbegin(),  << 437   std::for_each(
377                 [](G4PhysConstVector::value_ty << 438     G4MT_physicsVector->cbegin(), G4MT_physicsVector->cend(),
                                                   >> 439     [](G4PhysConstVector::value_type el) { el->TerminateWorker(); });
378   G4VUserPhysicsList::TerminateWorker();          440   G4VUserPhysicsList::TerminateWorker();
379 }                                                 441 }
380                                                   442