Newer
Older
/// \file CherProto/CherProto.cc
/// \brief Main program of the CherProto
//
// Description: Process of G4Cerenkov for JLab Cherekov Phototype
// -- Generation Cerenkov Photons --
// Version: 1.0
// Created: 1996-04-30
// Author:
// mail:
//
#include "PhysicsList.hh"
#include "DetectorConstruction.hh"
#include "ActionInitialization.hh"
#include "G4RunManager.hh"
#include "G4UImanager.hh"
#include "TFile.h"
#include <random>
void PrintUsage() {
G4cerr << " Usage: " << G4endl;
G4cerr << " CherProto [-m macro ] [-u UIsession] [-r seed] [-c config] "
<< G4endl;
}
// Evaluate arguments
//
if ( argc > 9 ) {
PrintUsage();
return 1;
G4String macro, session, config = "cher_proto_det.mac";
G4int myseed = -1;
for ( G4int i = 1; i < argc; i = i+2 ) {
if ( G4String(argv[i]) == "-m" ) macro = argv[i+1];
else if ( G4String(argv[i]) == "-u" ) session = argv[i+1];
else if ( G4String(argv[i]) == "-r" ) myseed = atoi(argv[i+1]);
else if ( G4String(argv[i]) == "-c" ) config = argv[i+1];
else {
PrintUsage();
return 1;
}
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Choose the Random engine
G4Random::setTheEngine(new CLHEP::RanecuEngine);
// Construct the default run manager
G4RunManager * runManager = new G4RunManager;
// Seed the random number generator manually
std::random_device rd;
G4Random::setTheSeed((myseed < 0) ? rd() : myseed);
// Get the pointer to the User Interface manager
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// Set mandatory initialization classes
// Detector construction
runManager->SetUserInitialization(new DetectorConstruction());
// Physics list
runManager->SetUserInitialization(new PhysicsList());
// User action initialization
runManager->SetUserInitialization(new ActionInitialization());
G4String command = "/control/execute ";
UImanager->ApplyCommand(command + config);
// Initialize G4 kernel
runManager->Initialize();
// Initialize visualization
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
if ( macro.size() ) {
// Batch mode
UImanager->ApplyCommand(command+macro);
// Define UI session for interactive mode
} else {
G4UIExecutive * ui = new G4UIExecutive(argc,argv,session);
UImanager->ApplyCommand("/control/execute vis.mac");
if (ui->IsGUI()) { UImanager->ApplyCommand("/control/execute gui.mac"); }
ui->SessionStart();
delete ui;
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not
// be deleted in the main() program !
delete visManager;
delete runManager;