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


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