Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examplePar02.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 //
26 //
27 // $Id:$
28 //
29 //
30 // --------------------------------------------------------------
31 // GEANT 4 - examplePar02
32 // --------------------------------------------------------------
33 // Comments
34 //
35 // Example of a main program making use of track smearing.
36 //
37 // Note: for the time being, the program runs only in sequential mode,
38 // because the histogram manager - i.e. the class Par02Output -
39 // is a singleton...
40 //
41 //-------------------------------------------------------------------
42 
43 #include "G4Types.hh"
44 
45 #include "G4UImanager.hh"
46 #ifdef G4MULTITHREADED
47 #include "G4MTRunManager.hh"
48 #else
49 #include "G4RunManager.hh"
50 #endif
51 
53 #include "Par02PhysicsList.hh"
55 
56 #include "G4VisExecutive.hh"
57 #include "G4UIExecutive.hh"
58 
59 int main( int argc, char** argv ) {
60 
61  // Instantiate G4UIExecutive if interactive mode
62  G4UIExecutive* ui = nullptr;
63  if ( argc == 1 ) {
64  ui = new G4UIExecutive(argc, argv);
65  }
66 
67  //-------------------------------
68  // Initialization of Run manager
69  //-------------------------------
70  #ifdef G4MULTITHREADED
71  G4MTRunManager* runManager = new G4MTRunManager;
72  runManager->SetNumberOfThreads(4);
73  G4cout<<"+-------------------------------------------------------+"<<G4endl;
74  G4cout<<"| Constructing MT run manager |"<<G4endl;
75  G4cout<<"+-------------------------------------------------------+"<<G4endl;
76  #else
77  G4RunManager* runManager = new G4RunManager;
78  G4cout<<"+-------------------------------------------------------+"<<G4endl;
79  G4cout<<"| Constructing sequential run manager |"<<G4endl;
80  G4cout<<"+-------------------------------------------------------+"<<G4endl;
81  #endif
82 
83  // Detector/mass geometry:
85  runManager->SetUserInitialization( detector );
86 
87  // PhysicsList (including G4FastSimulationManagerProcess)
88  G4VUserPhysicsList* physicsList = new Par02PhysicsList;
89  runManager->SetUserInitialization( physicsList );
90 
91  //-------------------------------
92  // UserAction classes
93  //-------------------------------
95 
96  // Initialize Run manager
97  runManager->Initialize();
98 
99  //----------------
100  // Visualization:
101  //----------------
102  G4cout << "Instantiating Visualization Manager......." << G4endl;
103  G4VisManager* visManager = new G4VisExecutive;
104  visManager->Initialize();
105 
106  if ( ui ) {
107  //--------------------------
108  // Define (G)UI
109  //--------------------------
110  ui->SessionStart();
111  delete ui;
112  } else {
113  G4String command = "/control/execute ";
114  G4String fileName = argv[1];
115  G4UImanager * UImanager = G4UImanager::GetUIpointer();
116  UImanager->ApplyCommand( command+fileName );
117  }
118 
119  // Free the store: user actions, physics_list and detector_description are
120  // owned and deleted by the run manager, so they should not
121  // be deleted in the main() program !
122 
123  delete visManager;
124  delete runManager;
125 
126  return 0;
127 }
Definition of the Par02PhysicsList class.
void SetNumberOfThreads(G4int n)
Definition of the Par02ActionInitialization class.
Definition of the Par02DetectorConstruction class.
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
int main(int argc, char **argv)
Definition: genwindef.cc:359
G4GLOB_DLL std::ostream G4cout
void Initialize()
virtual void Initialize()