File indexing completed on 2025-01-18 09:17:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 #include "G4Types.hh"
0039 #include "G4RunManagerFactory.hh"
0040 #include "G4UImanager.hh"
0041 #include "Randomize.hh"
0042 #include "G4VisExecutive.hh"
0043 #include "G4UIExecutive.hh"
0044 #include "XrayFluoDetectorConstruction.hh"
0045 #include "XrayFluoPlaneDetectorConstruction.hh"
0046 #include "XrayFluoMercuryDetectorConstruction.hh"
0047 #include "XrayFluoPhysicsList.hh"
0048 #include "XrayFluoSimulation.hh"
0049
0050 #include "XrayFluoActionInitializer.hh"
0051 #include "XrayFluoAnalysisManager.hh"
0052
0053 void XrayFluoSimulation::RunSimulation(int argc,char* argv[])
0054 {
0055 auto* runManager = G4RunManagerFactory::CreateRunManager();
0056 G4int nThreads = 4;
0057 runManager->SetNumberOfThreads(nThreads);
0058
0059
0060 G4int geometryNumber = 0;
0061
0062 if (argc == 3){
0063 geometryNumber = atoi(argv[2]);
0064
0065 }
0066 while ( (geometryNumber < 1) || (geometryNumber >4)) {
0067 G4cout << "Please Select Simulation Geometrical Set-Up: "<< G4endl;
0068 G4cout << "1 - Test Beam" << G4endl;
0069 G4cout << "2 - Infinite Plane" << G4endl;
0070 G4cout << "3 - Planet and Sun"<< G4endl;
0071 G4cout << "4 - Phase-Space Production"<< G4endl;
0072
0073 G4cin >> geometryNumber;
0074 }
0075
0076
0077 XrayFluoAnalysisManager* analysis =
0078 XrayFluoAnalysisManager::getInstance();
0079
0080
0081
0082
0083 if (geometryNumber == 1 || geometryNumber == 4) {
0084 XrayFluoDetectorConstruction* testBeamDetector
0085 = XrayFluoDetectorConstruction::GetInstance();
0086 if (geometryNumber == 4) {
0087 testBeamDetector->PhaseSpaceOn();
0088 analysis->PhaseSpaceOn();
0089 }
0090 runManager->SetUserInitialization(testBeamDetector);
0091 }
0092 else if (geometryNumber == 2) {
0093 XrayFluoPlaneDetectorConstruction*
0094 planeDetector = XrayFluoPlaneDetectorConstruction::GetInstance();
0095 runManager->SetUserInitialization(planeDetector);
0096 }
0097 else if (geometryNumber == 3) {
0098 XrayFluoMercuryDetectorConstruction* mercuryDetector =
0099 XrayFluoMercuryDetectorConstruction::GetInstance();
0100 runManager->SetUserInitialization(mercuryDetector);
0101 }
0102
0103
0104
0105 runManager->SetUserInitialization(new XrayFluoPhysicsList());
0106
0107
0108 runManager->SetUserInitialization
0109 (new XrayFluoActionInitializer(geometryNumber));
0110
0111
0112 G4VisManager* visManager = new G4VisExecutive;
0113 visManager->Initialize();
0114
0115
0116 G4UImanager* UImanager = G4UImanager::GetUIpointer();
0117
0118 if (argc == 1)
0119 {
0120 UImanager->ApplyCommand("/control/execute initInter.mac");
0121 UImanager->ApplyCommand("/control/execute vis.mac");
0122 G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0123 ui->SessionStart();
0124 delete ui;
0125 }
0126 else
0127 {
0128 G4String command = "/control/execute ";
0129 G4String fileName = argv[1];
0130 UImanager->ApplyCommand(command+fileName);
0131 }
0132
0133
0134 delete visManager;
0135 G4cout << "visManager deleted"<< G4endl;
0136
0137 delete runManager;
0138 }