LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ParN04.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 //
28 //
29 //
30 //
31 //
32 // --------------------------------------------------------------
33 // GEANT 4 - ParN04
34 // --------------------------------------------------------------
35 
36 
37 #include "ExN04DetectorConstruction.hh"
38 #include "ExN04PrimaryGeneratorAction.hh"
39 #include "ExN04RunAction.hh"
40 #include "ExN04EventAction.hh"
41 #include "ExN04StackingAction.hh"
42 #include "ExN04TrackingAction.hh"
43 #include "ExN04SteppingAction.hh"
44 #include "ExN04SteppingVerbose.hh"
45 
46 #include "G4RunManager.hh"
47 #include "G4UImanager.hh"
48 #include "QGSP_BERT.hh"
49 #include "G4VisExecutive.hh"
50 #include "G4UIExecutive.hh"
51 
52 #include "ParTopC.icc"
53 
54 int main(int argc,char** argv)
55 {
56  // Detect interactive mode (if no arguments) and define UI session
57  //
58  G4UIExecutive* ui = 0;
59  if ( argc == 1 ) {
60  ui = new G4UIExecutive(argc, argv);
61  }
62 
63  // User Verbose output class
64  //
65  G4VSteppingVerbose* verbosity = new ExN04SteppingVerbose;
66  G4VSteppingVerbose::SetInstance(verbosity);
67 
68  // Run manager
69  //
70  G4RunManager* runManager = new G4RunManager;
71 
72  // User Initialization classes (mandatory)
73  //
74  G4VUserDetectorConstruction* detector = new ExN04DetectorConstruction;
75  runManager->SetUserInitialization(detector);
76  //
77  G4VUserPhysicsList* physics = new QGSP_BERT();
78  runManager->SetUserInitialization(physics);
79 
80  // Visualization, if you choose to have it!
81  //
82  G4VisManager* visManager = new G4VisExecutive;
83  visManager->Initialize();
84 
85  // Initialize G4 kernel
86  //
87  runManager->Initialize();
88 
89  // User Action classes
90  //
91  G4VUserPrimaryGeneratorAction* gen_action = new ExN04PrimaryGeneratorAction;
92  runManager->SetUserAction(gen_action);
93  //
94  G4UserRunAction* run_action = new ExN04RunAction;
95  runManager->SetUserAction(run_action);
96  //
97  G4UserEventAction* event_action = new ExN04EventAction;
98  runManager->SetUserAction(event_action);
99  //
100  G4UserStackingAction* stacking_action = new ExN04StackingAction;
101  runManager->SetUserAction(stacking_action);
102  //
103  G4UserTrackingAction* tracking_action = new ExN04TrackingAction;
104  runManager->SetUserAction(tracking_action);
105  //
106  G4UserSteppingAction* stepping_action = new ExN04SteppingAction;
107  runManager->SetUserAction(stepping_action);
108 
109  // Get the pointer to the User Interface manager
110  //
111  G4UImanager* UImanager = G4UImanager::GetUIpointer();
112 
113  // Process macro or start UI session
114  //
115  if ( ! ui ) {
116  // batch mode
117  G4String command = "/control/execute ";
118  G4String fileName = argv[1];
119  UImanager->ApplyCommand(command+fileName);
120  }
121  else {
122  // interactive mode
123  UImanager->ApplyCommand("/control/execute vis.mac");
124  ui->SessionStart();
125  delete ui;
126  }
127 
128  // Free the store: user actions, physics_list and detector_description are
129  // owned and deleted by the run manager, so they should not
130  // be deleted in the main() program !
131 
132  delete visManager;
133  delete runManager;
134  delete verbosity;
135 
136  return 0;
137 }
int main(int argc, char **argv)
Definition: ParN04.cc:54