00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4VModularPhysicsList.hh"
00037 #include "G4StateManager.hh"
00038
00039
00040 G4VModularPhysicsList::G4VModularPhysicsList()
00041 : G4VUserPhysicsList(),
00042 verboseLevel(0)
00043 {
00044 physicsVector = new G4PhysConstVector();
00045 }
00046
00047 G4VModularPhysicsList::~G4VModularPhysicsList()
00048 {
00049 G4PhysConstVector::iterator itr;
00050 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00051 delete (*itr);
00052 }
00053 physicsVector->clear();
00054 delete physicsVector;
00055 }
00056
00057 G4VModularPhysicsList::G4VModularPhysicsList(const G4VModularPhysicsList& right) : G4VUserPhysicsList(right),
00058 verboseLevel(0)
00059 {
00060 physicsVector = new G4PhysConstVector();
00061 }
00062
00063 G4VModularPhysicsList & G4VModularPhysicsList::operator=(const G4VModularPhysicsList& right)
00064 {
00065 if (this != &right) {
00066 defaultCutValue = right.defaultCutValue;
00067 isSetDefaultCutValue = right.isSetDefaultCutValue;
00068 fRetrievePhysicsTable = right.fRetrievePhysicsTable;
00069 fStoredInAscii = right.fStoredInAscii;
00070 fIsCheckedForRetrievePhysicsTable = right.fIsCheckedForRetrievePhysicsTable;
00071 fIsRestoredCutValues = right.fIsRestoredCutValues;
00072 directoryPhysicsTable = right.directoryPhysicsTable;
00073 fDisplayThreshold = right.fDisplayThreshold;
00074 fIsPhysicsTableBuilt = right.fIsPhysicsTableBuilt;
00075 fDisableCheckParticleList = right.fDisableCheckParticleList;
00076 verboseLevel = right.verboseLevel;
00077
00078 if(physicsVector !=0) {
00079 G4PhysConstVector::iterator itr;
00080 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00081 delete (*itr);
00082 }
00083 physicsVector->clear();
00084 delete physicsVector;
00085 }
00086 physicsVector = new G4PhysConstVector();
00087 }
00088 return *this;
00089 }
00090
00091 void G4VModularPhysicsList::ConstructParticle()
00092 {
00093
00094 G4PhysConstVector::iterator itr;
00095 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00096 (*itr)->ConstructParticle();;
00097 }
00098 }
00099
00100
00101 void G4VModularPhysicsList::ConstructProcess()
00102 {
00103 AddTransportation();
00104
00105 G4PhysConstVector::iterator itr;
00106 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00107 (*itr)->ConstructProcess();
00108 }
00109 }
00110
00111
00112
00113 void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
00114 {
00115 G4StateManager* stateManager = G4StateManager::GetStateManager();
00116 G4ApplicationState currentState = stateManager->GetCurrentState();
00117 if(!(currentState==G4State_PreInit)){
00118 G4Exception("G4VModularPhysicsList::RegisterPhysics",
00119 "Run0201", JustWarning,
00120 "Geant4 kernel is not PreInit state : Method ignored.");
00121 return;
00122 }
00123
00124 G4String pName = fPhysics->GetPhysicsName();
00125 G4int pType = fPhysics->GetPhysicsType();
00126
00127
00128
00129 if (pType == 0) {
00130 physicsVector->push_back(fPhysics);
00131 #ifdef G4VERBOSE
00132 if (verboseLevel >1){
00133 G4cout << "G4VModularPhysicsList::RegisterPhysics: "
00134 << pName << "with type : " << pType
00135 << " is added"
00136 << G4endl;
00137 }
00138 #endif
00139 return;
00140 }
00141
00142
00143 G4PhysConstVector::iterator itr;
00144 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00145 if ( pType == (*itr)->GetPhysicsType()) break;
00146 }
00147 if (itr!= physicsVector->end()) {
00148 #ifdef G4VERBOSE
00149 if (verboseLevel >0){
00150 G4cout << "G4VModularPhysicsList::RegisterPhysics: "
00151 << "a physics with given type already exists "
00152 << G4endl;
00153 G4cout << " Type = " << pType << " : "
00154 << " existing physics is " << (*itr)->GetPhysicsName()
00155 << G4endl;
00156 G4cout << pName << " can not be registered "<<G4endl;
00157 }
00158 #endif
00159 G4String comment ="Duplicate type for ";
00160 comment += pName;
00161 G4Exception("G4VModularPhysicsList::RegisterPhysics",
00162 "Run0202", JustWarning, comment);
00163 return;
00164 }
00165
00166
00167 physicsVector->push_back(fPhysics);
00168
00169 }
00170
00171 void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
00172 {
00173 G4StateManager* stateManager = G4StateManager::GetStateManager();
00174 G4ApplicationState currentState = stateManager->GetCurrentState();
00175 if(!(currentState==G4State_PreInit)){
00176 G4Exception("G4VModularPhysicsList::ReplacePhysics",
00177 "Run0203", JustWarning,
00178 "Geant4 kernel is not PreInit state : Method ignored.");
00179 return;
00180 }
00181
00182 G4String pName = fPhysics->GetPhysicsName();
00183 G4int pType = fPhysics->GetPhysicsType();
00184
00185
00186
00187 if (pType == 0) {
00188
00189 physicsVector->push_back(fPhysics);
00190 #ifdef G4VERBOSE
00191 if (verboseLevel >0){
00192 G4cout << "G4VModularPhysicsList::ReplacePhysics: "
00193 << pName << "with type : " << pType
00194 << " is added"
00195 << G4endl;
00196 }
00197 #endif
00198 return;
00199 }
00200
00201
00202 G4PhysConstVector::iterator itr= physicsVector->begin();
00203 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00204 if ( pType == (*itr)->GetPhysicsType()) break;
00205 }
00206 if (itr == physicsVector->end()) {
00207
00208 physicsVector->push_back(fPhysics);
00209 } else {
00210 #ifdef G4VERBOSE
00211 if (verboseLevel >0){
00212 G4cout << "G4VModularPhysicsList::ReplacePhysics: "
00213 << (*itr)->GetPhysicsName() << "with type : " << pType
00214 << " is replaces with " << pName
00215 << G4endl;
00216 }
00217 #endif
00218
00219
00220 delete (*itr);
00221
00222 (*itr) = fPhysics;
00223
00224 }
00225
00226 return;
00227 }
00228
00229 void G4VModularPhysicsList::RemovePhysics(G4int pType)
00230 {
00231 G4StateManager* stateManager = G4StateManager::GetStateManager();
00232 G4ApplicationState currentState = stateManager->GetCurrentState();
00233 if(!(currentState==G4State_PreInit)){
00234 G4Exception("G4VModularPhysicsList::RemovePhysics",
00235 "Run0204", JustWarning,
00236 "Geant4 kernel is not PreInit state : Method ignored.");
00237 return;
00238 }
00239
00240 for (G4PhysConstVector::iterator itr = physicsVector->begin();
00241 itr!= physicsVector->end();) {
00242 if ( pType == (*itr)->GetPhysicsType()) {
00243 G4String pName = (*itr)->GetPhysicsName();
00244 #ifdef G4VERBOSE
00245 if (verboseLevel > 0){
00246 G4cout << "G4VModularPhysicsList::RemovePhysics: "
00247 << pName << " is removed"
00248 << G4endl;
00249 }
00250 #endif
00251 physicsVector->erase(itr);
00252 break;
00253 } else {
00254 itr++;
00255 }
00256 }
00257 }
00258
00259 void G4VModularPhysicsList::RemovePhysics(G4VPhysicsConstructor* fPhysics)
00260 {
00261 G4StateManager* stateManager = G4StateManager::GetStateManager();
00262 G4ApplicationState currentState = stateManager->GetCurrentState();
00263 if(!(currentState==G4State_PreInit)){
00264 G4Exception("G4VModularPhysicsList::RemovePhysics",
00265 "Run0205", JustWarning,
00266 "Geant4 kernel is not PreInit state : Method ignored.");
00267 return;
00268 }
00269
00270 for (G4PhysConstVector::iterator itr = physicsVector->begin();
00271 itr!= physicsVector->end();) {
00272 if ( fPhysics == (*itr)) {
00273 G4String pName = (*itr)->GetPhysicsName();
00274 #ifdef G4VERBOSE
00275 if (verboseLevel > 0 ){
00276 G4cout << "G4VModularPhysicsList::RemovePhysics: "
00277 << pName << " is removed"
00278 << G4endl;
00279 }
00280 #endif
00281 physicsVector->erase(itr);
00282 break;
00283 } else {
00284 itr++;
00285 }
00286 }
00287 }
00288 void G4VModularPhysicsList::RemovePhysics(const G4String& name)
00289 {
00290 G4StateManager* stateManager = G4StateManager::GetStateManager();
00291 G4ApplicationState currentState = stateManager->GetCurrentState();
00292 if(!(currentState==G4State_PreInit)){
00293 G4Exception("G4VModularPhysicsList::RemovePhysics",
00294 "Run0206", JustWarning,
00295 "Geant4 kernel is not PreInit state : Method ignored.");
00296 return;
00297 }
00298
00299 for (G4PhysConstVector::iterator itr = physicsVector->begin();
00300 itr!= physicsVector->end();) {
00301 G4String pName = (*itr)->GetPhysicsName();
00302 if ( name == pName) {
00303 #ifdef G4VERBOSE
00304 if (verboseLevel > 0){
00305 G4cout << "G4VModularPhysicsList::RemovePhysics: "
00306 << pName << " is removed"
00307 << G4endl;
00308 }
00309 #endif
00310 physicsVector->erase(itr);
00311 break;
00312 } else {
00313 itr++;
00314 }
00315 }
00316 }
00317
00318 const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(G4int idx) const
00319 {
00320 G4int i;
00321 G4PhysConstVector::iterator itr= physicsVector->begin();
00322 for (i=0; i<idx && itr!= physicsVector->end() ; ++i) ++itr;
00323 if (itr!= physicsVector->end()) return (*itr);
00324 else return 0;
00325 }
00326
00327 const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(const G4String& name) const
00328 {
00329 G4PhysConstVector::iterator itr;
00330 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00331 if ( name == (*itr)->GetPhysicsName()) break;
00332 }
00333 if (itr!= physicsVector->end()) return (*itr);
00334 else return 0;
00335 }
00336
00337 const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysicsWithType(G4int pType) const
00338 {
00339 G4PhysConstVector::iterator itr;
00340 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00341 if ( pType == (*itr)->GetPhysicsType()) break;
00342 }
00343 if (itr!= physicsVector->end()) return (*itr);
00344 else return 0;
00345 }
00346
00347
00348 void G4VModularPhysicsList::SetVerboseLevel(G4int value)
00349 {
00350 verboseLevel = value;
00351
00352
00353 G4PhysConstVector::iterator itr;
00354 for (itr = physicsVector->begin(); itr!= physicsVector->end(); ++itr) {
00355 (*itr)->SetVerboseLevel(verboseLevel);
00356 }
00357
00358 }