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