Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examplePar01.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 // $Id: examplePar01.cc 110256 2018-05-17 14:16:33Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // Geant4 - examplePar01
35 // --------------------------------------------------------------
36 // Comments
37 //
38 // Example of a main program making use of parameterisation
39 // i.e. "Fast Simulation"
40 //-------------------------------------------------------------------
41 
42 #include "G4Types.hh"
43 
44 //---------------
45 // -- Geometries:
46 //---------------
49 
50 //---------------------------------------------------------------------
51 // -- Physics list, and tool to modify it and activate fast simulation:
52 //---------------------------------------------------------------------
53 #include "FTFP_BERT.hh"
55 
56 #include "G4UImanager.hh"
57 #ifdef G4MULTITHREADED
58 #include "G4MTRunManager.hh"
59 #else
60 #include "G4RunManager.hh"
61 #endif
62 
63 // ----------------------------------------------------------------
64 // -- Action initialization (includes the primary generator action:
65 // ----------------------------------------------------------------
67 
68 #include "G4VisExecutive.hh"
69 #include "G4UIExecutive.hh"
70 
71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
72 
73 int main(int argc, char** argv)
74 {
75  // Instantiate G4UIExecutive if interactive mode
76  G4UIExecutive* ui = nullptr;
77  if ( argc == 1 ) {
78  ui = new G4UIExecutive(argc, argv);
79  }
80 
81  //-------------------------------
82  // Initialization of Run manager
83  //-------------------------------
84 #ifdef G4MULTITHREADED
85  G4MTRunManager * runManager = new G4MTRunManager;
86  runManager->SetNumberOfThreads(4);
87  G4cout<<"+-------------------------------------------------------+"<<G4endl;
88  G4cout<<"| Constructing MT run manager |"<<G4endl;
89  G4cout<<"+-------------------------------------------------------+"<<G4endl;
90 #else
91  G4RunManager * runManager = new G4RunManager;
92  G4cout<<"+-------------------------------------------------------+"<<G4endl;
93  G4cout<<"| Constructing sequential run manager |"<<G4endl;
94  G4cout<<"+-------------------------------------------------------+"<<G4endl;
95 #endif
96 
97  // -----------------------------------------------------
98  // -- Detector/mass geometry and parallel geometry(ies):
99  // -----------------------------------------------------
100  // -- Mass geometry (ie : standard geometry):
102  // -- Parallel geometry for pion parameterisation
103  detector->RegisterParallelWorld(new Par01ParallelWorldForPion("pionGhostWorld"));
104  // -- Passed to the run manager:
105  runManager->SetUserInitialization(detector);
106 
107  // ----------------------------------------------
108  // -- PhysicsList and fast simulation activation:
109  // ----------------------------------------------
110  // -- Create a physics list (note : FTFP_BERT is a G4VModularPhysicsList
111  // -- which allows to use the subsequent G4FastSimulationPhysics tool to
112  // -- activate the fast simulation):
113  FTFP_BERT* physicsList = new FTFP_BERT;
114  // -- Create helper tool, used to activate the fast simulation:
115  G4FastSimulationPhysics* fastSimulationPhysics = new G4FastSimulationPhysics();
116  fastSimulationPhysics->BeVerbose();
117  // -- activation of fast simulation for particles having fast simulation models
118  // -- attached in the mass geometry:
119  fastSimulationPhysics->ActivateFastSimulation("e-");
120  fastSimulationPhysics->ActivateFastSimulation("e+");
121  fastSimulationPhysics->ActivateFastSimulation("gamma");
122  // -- activation of fast simulation for particles having fast simulation models
123  // -- attached in the parallel geometry:
124  fastSimulationPhysics->ActivateFastSimulation("pi+","pionGhostWorld");
125  fastSimulationPhysics->ActivateFastSimulation("pi-","pionGhostWorld");
126  // -- Attach the fast simulation physics constructor to the physics list:
127  physicsList->RegisterPhysics( fastSimulationPhysics );
128  // -- Finally passes the physics list to the run manager:
129  runManager->SetUserInitialization(physicsList);
130 
131  //-------------------------------
132  // UserAction classes
133  //-------------------------------
135 
136  // Initialize Run manager
137  runManager->Initialize();
138 
139  //----------------
140  // Visualization:
141  //----------------
142  G4cout << "Instantiating Visualization Manager......." << G4endl;
143  G4VisManager* visManager = new G4VisExecutive;
144  visManager -> Initialize ();
145 
146  if(ui)
147  {
148  //--------------------------
149  // Define (G)UI
150  //--------------------------
151  ui->SessionStart();
152  delete ui;
153  }
154  else
155  {
156  G4String command = "/control/execute ";
157  G4String fileName = argv[1];
158  G4UImanager * UImanager = G4UImanager::GetUIpointer();
159  UImanager->ApplyCommand(command+fileName);
160  }
161 
162  // Free the store: user actions, physics_list and detector_description are
163  // owned and deleted by the run manager, so they should not
164  // be deleted in the main() program !
165 
166  delete visManager;
167  delete runManager;
168 
169  return 0;
170 }
void SetNumberOfThreads(G4int n)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
void Initialize()
Definition: errprop.cc:101
void ActivateFastSimulation(const G4String &particleName)
Definition of the Par01DetectorConstruction class.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: genwindef.cc:359
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
G4GLOB_DLL std::ostream G4cout
Definition of the Par01ParallelWorldForPion class.
Definition of the Par01ActionInitialization class.
void RegisterParallelWorld(G4VUserParallelWorld *)
virtual void Initialize()