LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
examplePar02.cc
Go to the documentation of this file.
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 "G4UImanager.hh"
44 #ifdef G4MULTITHREADED
45 #include "G4MTRunManager.hh"
46 #else
47 #include "G4RunManager.hh"
48 #endif
49 
50 #include "Par02DetectorConstruction.hh"
51 #include "Par02PhysicsList.hh"
52 #include "Par02ActionInitialization.hh"
53 
54 #ifdef G4VIS_USE
55 #include "G4VisExecutive.hh"
56 #endif
57 
58 #ifdef G4UI_USE
59 #include "G4UIExecutive.hh"
60 #endif
61 
62 
63 int main( int argc, char** argv ) {
64 
65  //-------------------------------
66  // Initialization of Run manager
67  //-------------------------------
68  #ifdef G4MULTITHREADED
69  G4MTRunManager* runManager = new G4MTRunManager;
70  runManager->SetNumberOfThreads(4);
71  G4cout<<"+-------------------------------------------------------+"<<G4endl;
72  G4cout<<"| Constructing MT run manager |"<<G4endl;
73  G4cout<<"+-------------------------------------------------------+"<<G4endl;
74  #else
75  G4RunManager* runManager = new G4RunManager;
76  G4cout<<"+-------------------------------------------------------+"<<G4endl;
77  G4cout<<"| Constructing sequential run manager |"<<G4endl;
78  G4cout<<"+-------------------------------------------------------+"<<G4endl;
79  #endif
80 
81  // Detector/mass geometry:
82  G4VUserDetectorConstruction* detector = new Par02DetectorConstruction();
83  runManager->SetUserInitialization( detector );
84 
85  // PhysicsList (including G4FastSimulationManagerProcess)
86  G4VUserPhysicsList* physicsList = new Par02PhysicsList;
87  runManager->SetUserInitialization( physicsList );
88 
89  //-------------------------------
90  // UserAction classes
91  //-------------------------------
92  runManager->SetUserInitialization( new Par02ActionInitialization );
93 
94  // Initialize Run manager
95  runManager->Initialize();
96 
97  //----------------
98  // Visualization:
99  //----------------
100  #ifdef G4VIS_USE
101  G4cout << "Instantiating Visualization Manager......." << G4endl;
102  G4VisManager* visManager = new G4VisExecutive;
103  visManager->Initialize();
104  #endif
105 
106  if ( argc == 1 ) {
107  //--------------------------
108  // Define (G)UI
109  //--------------------------
110  #ifdef G4UI_USE
111  G4UIExecutive * ui = new G4UIExecutive( argc, argv );
112  ui->SessionStart();
113  delete ui;
114  #endif
115  } else {
116  G4String command = "/control/execute ";
117  G4String fileName = argv[1];
118  G4UImanager * UImanager = G4UImanager::GetUIpointer();
119  UImanager->ApplyCommand( command+fileName );
120  }
121 
122  // Free the store: user actions, physics_list and detector_description are
123  // owned and deleted by the run manager, so they should not
124  // be deleted in the main() program !
125 
126  #ifdef G4VIS_USE
127  delete visManager;
128  #endif
129  delete runManager;
130 
131  return 0;
132 }
int main(int argc, char **argv)
Definition: examplePar02.cc:63