LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ts_scorers.cc File Reference

Main of the ThreadsafeScorers example. More...

#include "G4Types.hh"
#include "G4RunManager.hh"
#include "Randomize.hh"
#include "TSDetectorConstruction.hh"
#include "TSPhysicsList.hh"
#include "TSActionInitialization.hh"
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4TiMemory.hh"
#include <cstdlib>

Go to the source code of this file.

Typedefs

typedef G4RunManager RunManager
 

Functions

void message (RunManager *runmanager)
 
int main (int argc, char **argv)
 

Detailed Description

Main of the ThreadsafeScorers example.

Definition in file ts_scorers.cc.

Typedef Documentation

typedef G4RunManager RunManager

ts_scorers example shows how to use global scorers. The benefit of using global scorers in memory-savings for problems with very large amounts of scoring volumes. Additionally, the global scorers are more precise w.r.t. the serial solution because of the lack of compounding round-off error from multiple threads

In this example, the global scorers are implemented as static member variables in TSRun because TSRun is thread-local. The G4atomic class is the core of the thread-safe scorers and can be uses

Definition at line 54 of file ts_scorers.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 90 of file ts_scorers.cc.

References message().

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 
115  runmanager->SetUserInitialization(new TSDetectorConstruction);
116 
117  runmanager->SetUserInitialization(new TSPhysicsList);
118 
119  runmanager->SetUserInitialization(new TSActionInitialization);
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 }
G4RunManager RunManager
Definition: ts_scorers.cc:54
void message(RunManager *runmanager)
Definition: ts_scorers.cc:74
void message ( RunManager runmanager)

Definition at line 74 of file ts_scorers.cc.

Referenced by pyG4Exception::f2_G4Exception(), art::Tracer::log_with_indent(), main(), PyG4ExceptionHandler::Notify(), art::detail::ExceptionCollector::rethrow(), G4ZMQServer::SessionStart(), and util::flags::errors::Exception::what().

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 }