ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE03.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file RE03.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 //
31 
32 #include "G4Types.hh"
33 
34 #ifdef G4MULTITHREADED
35 #include "G4MTRunManager.hh"
36 #else
37 #include "G4RunManager.hh"
38 #endif
39 #include "G4UImanager.hh"
40 #include "G4ScoringManager.hh"
41 
43 #include "FTFP_BERT.hh"
45 
46 #include "G4VisExecutive.hh"
47 #include "G4UIExecutive.hh"
48 
49 //====================================================================
50 // Un-comment this line for user defined score writer
51 // #include "RE03UserScoreWriter.hh"
52 //====================================================================
53 
54 int main(int argc,char** argv)
55 {
56  // Instantiate G4UIExecutive if there are no arguments (interactive mode)
57  G4UIExecutive* ui = nullptr;
58  if ( argc == 1 ) {
59  ui = new G4UIExecutive(argc, argv);
60  }
61 
62  // Construct the run manager
63  //
64 #ifdef G4MULTITHREADED
65  G4MTRunManager * runManager = new G4MTRunManager;
66  runManager->SetNumberOfThreads(4);
67 #else
68  G4RunManager * runManager = new G4RunManager;
69 #endif
70 
71  // Activate UI-command base scorer
73  scManager->SetVerboseLevel(1);
74 
75 //====================================================================
76 // Un-comment this line for user defined score writer
77 // scManager->SetScoreWriter(new RE03UserScoreWriter());
78 //====================================================================
79 
80  // Set mandatory initialization classes
81  //
83  runManager->SetUserInitialization(detector);
84  //
85  G4VUserPhysicsList* physics = new FTFP_BERT;
86  runManager->SetUserInitialization(physics);
87 
88  // Set user action classes through Worker Initialization
89  //
91  runManager->SetUserInitialization(actions);
92 
93  // Visualization manager
94  G4VisManager* visManager = new G4VisExecutive;
95  visManager->Initialize();
96 
97  // Initialize G4 kernel
98  //
99  runManager->Initialize();
100 
101  // Get the pointer to the User Interface manager
102  //
103  G4UImanager* UImanager = G4UImanager::GetUIpointer();
104 
105  if (ui) // Define UI session for interactive mode
106  {
107  UImanager->ApplyCommand("/control/execute vis.mac");
108  ui->SessionStart();
109  delete ui;
110  }
111  else // Batch mode
112  {
113  G4String command = "/control/execute ";
114  G4String fileName = argv[1];
115  UImanager->ApplyCommand(command+fileName);
116  }
117 
118  // Job termination
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 }