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