|
| 1 | +#include "WCSimPhysicsListFactory.hh" |
| 2 | + |
| 3 | +/* This code draws upon examples/extended/fields/field04 for inspiration */ |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +WCSimPhysicsListFactory::WCSimPhysicsListFactory() : G4VModularPhysicsList() |
| 8 | +{ |
| 9 | + defaultCutValue = 1.0*mm; |
| 10 | + SetVerboseLevel(1); |
| 11 | + |
| 12 | + PhysicsListName="NULL_LIST"; // default list is set in WCSimPhysicsListFactoryMessenger to QGSP_BERT |
| 13 | + factory = new G4PhysListFactory(); |
| 14 | + // TODO create opticalPhyscics object? |
| 15 | + |
| 16 | + std::vector<G4String> ValidListsVector = factory->AvailablePhysLists(); |
| 17 | + ValidListsVector.push_back("WCSim");// add deprecated WCSimPhysicsList.cc as a selectable option |
| 18 | + G4int nlists = ValidListsVector.size(); |
| 19 | + G4cout << "There are " << nlists << " available physics lists, and they are: " << G4endl; |
| 20 | + for (G4int i=0; i<nlists; i++){ |
| 21 | + G4cout << " " << ValidListsVector[i] << G4endl; |
| 22 | + ValidListsString += ValidListsVector[i]; |
| 23 | + ValidListsString += " "; |
| 24 | + } |
| 25 | + //G4cout << "ValidListsString=" << ValidListsString << G4endl; |
| 26 | + |
| 27 | + PhysicsMessenger = new WCSimPhysicsListFactoryMessenger(this, ValidListsString); |
| 28 | + |
| 29 | +} |
| 30 | + |
| 31 | +WCSimPhysicsListFactory::~WCSimPhysicsListFactory() |
| 32 | +{ |
| 33 | + delete PhysicsMessenger; |
| 34 | + PhysicsMessenger = NULL; |
| 35 | + |
| 36 | +} |
| 37 | + |
| 38 | +void WCSimPhysicsListFactory::ConstructParticle() |
| 39 | +{ |
| 40 | + G4VModularPhysicsList::ConstructParticle(); |
| 41 | +} |
| 42 | + |
| 43 | +void WCSimPhysicsListFactory::ConstructProcess() |
| 44 | +{ |
| 45 | + G4VModularPhysicsList::ConstructProcess(); |
| 46 | +} |
| 47 | + |
| 48 | +void WCSimPhysicsListFactory::SetCuts() |
| 49 | +{ |
| 50 | + // same as WCSimPhysicsList |
| 51 | + if (verboseLevel >0){ |
| 52 | + G4cout << "WCSimPhysicsListFactory::SetCuts:"; |
| 53 | + G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl; |
| 54 | + } |
| 55 | + |
| 56 | + // set cut values for gamma at first and for e- second and next for e+, |
| 57 | + // because some processes for e+/e- need cut values for gamma |
| 58 | + // |
| 59 | + SetCutValue(defaultCutValue, "gamma"); |
| 60 | + SetCutValue(defaultCutValue, "e-"); |
| 61 | + SetCutValue(defaultCutValue, "e+"); |
| 62 | + |
| 63 | + if (verboseLevel>0) DumpCutValuesTable(); |
| 64 | + |
| 65 | +} |
| 66 | + |
| 67 | +void WCSimPhysicsListFactory::SetList(G4String newvalue){ |
| 68 | + G4cout << "Setting Physics list to " << newvalue << " and delaying initialization" << G4endl; |
| 69 | + PhysicsListName = newvalue; |
| 70 | +} |
| 71 | + |
| 72 | +void WCSimPhysicsListFactory::InitializeList(){ |
| 73 | + G4cout << "Initializing physics list " << PhysicsListName << G4endl; |
| 74 | + |
| 75 | + G4VModularPhysicsList* phys = 0; |
| 76 | + |
| 77 | + if (factory->IsReferencePhysList(PhysicsListName)) { |
| 78 | + phys=factory->GetReferencePhysList(PhysicsListName); |
| 79 | + for (G4int i = 0; ; ++i) { |
| 80 | + G4VPhysicsConstructor* elem = |
| 81 | + const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i)); |
| 82 | + if (elem == NULL) break; |
| 83 | + G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl; |
| 84 | + RegisterPhysics(elem); |
| 85 | + } |
| 86 | + G4cout << "RegisterPhysics: OpticalPhysics" << G4endl; |
| 87 | + RegisterPhysics(new G4OpticalPhysics()); |
| 88 | + } else if (PhysicsListName == "WCSim") { |
| 89 | + //G4cout << "WCSim physics list not yet implemented" << G4endl; |
| 90 | + G4cout << "RegisterPhysics: WCSim" << G4endl; |
| 91 | + RegisterPhysics(new WCSimPhysicsList()); |
| 92 | + } else { |
| 93 | + G4cout << "Physics list " << PhysicsListName << " is not understood" << G4endl; |
| 94 | + } |
| 95 | +} |
0 commit comments