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