ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ts_scorers.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ts_scorers.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 //
41 //
42 //
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
46 #include "G4Types.hh"
47 
48 #ifdef G4MULTITHREADED
49  #include "G4MTRunManager.hh"
50  #include "G4Threading.hh"
51  typedef G4MTRunManager RunManager;
52 #else
53  #include "G4RunManager.hh"
55 #endif
56 
57 #include "Randomize.hh"
58 
59 // User Defined Classes
61 #include "TSPhysicsList.hh"
63 
64 #include "G4UImanager.hh"
65 #include "G4VisExecutive.hh"
66 #include "G4UIExecutive.hh"
67 #include "G4TiMemory.hh"
68 
69 // for std::system(const char*)
70 #include <cstdlib>
71 
72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
73 
74 void message(RunManager* runmanager)
75 {
76 #ifdef G4MULTITHREADED
77  runmanager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
78  G4cout << "\n\n\t--> Running in multithreaded mode with "
79  << runmanager->GetNumberOfThreads()
80  << " threads\n\n" << G4endl;
81 #else
82  // get rid of unused variable warning
83  runmanager->SetVerboseLevel(runmanager->GetVerboseLevel());
84  G4cout << "\n\n\t--> Running in serial mode\n\n" << G4endl;
85 #endif
86 }
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89 
90 int main(int argc, char** argv)
91 {
92  TIMEMORY_INIT(argc, argv);
93 
94 #if defined(GEANT4_USE_TIMEMORY)
95  // override environment settings
96  tim::settings::json_output() = true;
97  tim::settings::dart_output() = true;
98  tim::settings::dart_type() = "peak_rss";
99  tim::settings::dart_count() = 1;
100 #endif
101 
102  // Detect interactive mode (if no arguments) and define UI session
103  //
104  G4UIExecutive* ui = 0;
105  if(argc == 1)
106  ui = new G4UIExecutive(argc, argv);
107 
108  // Set the random seed
109  CLHEP::HepRandom::setTheSeed(1245214UL);
110 
111  RunManager* runmanager = new RunManager();
112 
113  message(runmanager);
114 
116 
117  runmanager->SetUserInitialization(new TSPhysicsList);
118 
120 
121  runmanager->Initialize();
122 
123 
124  // Initialize visualization
125  //
126  G4VisManager* visManager = new G4VisExecutive;
127  // G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
128  // G4VisManager* visManager = new G4VisExecutive("Quiet");
129  visManager->Initialize();
130 
131  // Get the pointer to the User Interface manager
132  G4UImanager* UImanager = G4UImanager::GetUIpointer();
133 
134  // Process macro or start UI session
135  //
136  if (!ui)
137  {
138  // batch mode
139  G4String command = "/control/execute ";
140  G4String fileName = argv[argc-1];
141  UImanager->ApplyCommand(command+fileName);
142  } else
143  {
144  // interactive mode
145  UImanager->ApplyCommand("/control/execute vis.mac");
146  ui->SessionStart();
147  delete ui;
148  }
149 
150  // Job termination
151  // Free the store: user actions, physics_list and detector_description are
152  // owned and deleted by the run manager, so they should not be deleted
153  // in the main() program !
154  delete visManager;
155  delete runmanager;
156 
157  return 0;
158 }