File indexing completed on 2025-02-22 09:40:13
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 #include "CCalDetectorConstruction.hh"
0032 #include "CCalActionInitializer.hh"
0033
0034 #include "G4AnalysisManager.hh"
0035
0036 #include "G4PhysListFactory.hh"
0037
0038 #include "G4RunManagerFactory.hh"
0039 #include "G4UImanager.hh"
0040
0041 #include "G4VisExecutive.hh"
0042
0043 #include "G4UIExecutive.hh"
0044
0045 int main(int argc,char** argv) {
0046
0047 G4VisManager *visManager = nullptr;
0048
0049 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
0050 runManager->SetUserInitialization(new CCalDetectorConstruction);
0051
0052 G4PhysListFactory factory;
0053 runManager->SetUserInitialization(factory.ReferencePhysList());
0054
0055 runManager->SetUserInitialization(new CCalActionInitializer());
0056
0057 G4UImanager * UImanager = G4UImanager::GetUIpointer();
0058 UImanager->ApplyCommand("/CCal/generator/verbose 2");
0059 UImanager->ApplyCommand("/gun/position -1380. 0. 0. mm");
0060 UImanager->ApplyCommand("/gun/direction 1. 0. 0.");
0061 UImanager->ApplyCommand("/gun/energy 100 GeV");
0062
0063
0064 if (argc==1) {
0065
0066 visManager = new G4VisExecutive;
0067 visManager->Initialize();
0068
0069 G4UIExecutive* ui = new G4UIExecutive(argc, argv);
0070 if (ui->IsGUI()) {
0071
0072 UImanager->ApplyCommand("/control/execute gui.mac");
0073 }
0074 G4cout <<" Run initializing ..."<<G4endl;
0075 UImanager->ApplyCommand("/process/verbose 0");
0076 UImanager->ApplyCommand("/run/verbose 2");
0077 UImanager->ApplyCommand("/run/initialize");
0078
0079
0080 G4String visCommand = "/vis/scene/create";
0081 UImanager->ApplyCommand(visCommand);
0082
0083
0084
0085
0086
0087 visCommand = "/vis/open OGL";
0088 UImanager->ApplyCommand(visCommand);
0089
0090 visCommand = "/vis/viewer/flush";
0091 UImanager->ApplyCommand(visCommand);
0092 visCommand = "/tracking/storeTrajectory 1";
0093 UImanager->ApplyCommand(visCommand);
0094
0095 G4cout <<"Now, please, apply beamOn command..."<<G4endl;
0096 ui->SessionStart();
0097 delete ui;
0098
0099 } else {
0100
0101
0102 G4String command = "/control/execute ";
0103 G4String fileName = argv[1];
0104 UImanager->ApplyCommand(command+fileName);
0105 }
0106
0107
0108 delete runManager;
0109 delete visManager;
0110 return 0;
0111 }