Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -28,57 +28,54 @@
// Started from FullCMS Geant4 application by Mihaly Novak (2017)
//---------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include "FTFP_BERT.hh"
#include "VG01ActionInitialization.hh"
#include "VG01DetectorConstruction.hh"
#include "VG01SteppingVerboseWithDir.hh"
#include "G4RunManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4StepLimiterPhysics.hh"
#include "G4UImanager.hh"
#include "G4UIsession.hh"
#include "G4UIterminal.hh"
#include "G4VModularPhysicsList.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
#include "Randomize.hh"
#include "VG01DetectorConstruction.hh"
#include "VG01ActionInitialization.hh"
#include "VG01SteppingVerboseWithDir.hh"
#include <iomanip>
#include <iostream>
// For interactivity
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
static G4bool parUseVecGeom = true;
static G4bool parCompareG4 = false;
static G4bool parInteractive = false;
static std::string parMacroFileName = "";
static std::string parGDMLFile = "TestNTST.gdml";
static G4bool parUseVecGeom = true;
static G4bool parCompareG4 = false;
static G4bool parInteractive = false;
static std::string parMacroFileName = "";
static std::string parGDMLFile = "TestNTST.gdml";
void GetInputArguments(int argc, char** argv);
void PrintUsage();
int main(int argc, char** argv) {
int main(int argc, char** argv)
{
//
// get input arguments
GetInputArguments(argc, argv);
G4cout<< " ========== Running exampleVecGeomNav ================ " << G4endl
<< " GDML geometry file = " << parGDMLFile << G4endl
<< " Geant4 macro = " << parMacroFileName << G4endl
<< " Use VecGeom (VG) navigation = " << parUseVecGeom << G4endl
<< " Compare G4 vs VG navigation = " << parCompareG4 << G4endl
<< " ===================================================== " << G4endl;
G4cout << " ========== Running exampleVecGeomNav ================ " << G4endl
<< " GDML geometry file = " << parGDMLFile << G4endl
<< " Geant4 macro = " << parMacroFileName << G4endl
<< " Use VecGeom (VG) navigation = " << parUseVecGeom << G4endl
<< " Compare G4 vs VG navigation = " << parCompareG4 << G4endl
<< " ===================================================== " << G4endl;
// Use custom stepping verbosity
G4VSteppingVerbose::SetInstance( new VG01SteppingVerboseWithDir() );
G4VSteppingVerbose::SetInstance(new VG01SteppingVerboseWithDir());
// Construct the run manager
//
G4RunManager* runManager
= G4RunManagerFactory::CreateRunManager( G4RunManagerType::Serial);
G4RunManager* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::Serial);
// or G4RunManagerType::Default to get Task or Multithreading
// set mandatory initialization classes
@@ -97,42 +94,38 @@ int main(int argc, char** argv) {
runManager->SetUserInitialization(physicsList);
// 3. User action
//
//
runManager->SetUserInitialization(new VG01ActionInitialization());
// 4. Run the simulation in batch mode, except if macroFile == "-"
//
//
G4UImanager* UImgr = G4UImanager::GetUIpointer();
G4String command = "/control/execute ";
if( parMacroFileName != "-")
UImgr->ApplyCommand(command+parMacroFileName);
if (parMacroFileName != "-") UImgr->ApplyCommand(command + parMacroFileName);
// 5. Run the simulation in Interactive mode if requested ( flag: -i )
//
if( parInteractive )
{
G4UIExecutive* uiExec = 0;
uiExec = new G4UIExecutive(argc, argv);
if (parInteractive) {
G4UIExecutive* uiExec = 0;
uiExec = new G4UIExecutive(argc, argv);
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// UImgr->ApplyCommand("/control/execute init_vis.mac");
// UImgr->ApplyCommand("/control/execute init_vis.mac");
// interactive mode
uiExec->SessionStart();
// Cleanup
delete uiExec;
delete visManager;
}
else
{
// interactive mode
uiExec->SessionStart();
// Cleanup
delete uiExec;
delete visManager;
}
else {
// Print out the final random number - for batch only runs
G4cout << G4endl
<< " ================================================================= " << G4endl
@@ -149,11 +142,11 @@ int main(int argc, char** argv) {
void horizontal_line(char c)
{
std::cout <<"\n " << std::setw(100) << std::setfill(c)
<< "" << std::setfill(' ') << std::endl;
std::cout << "\n " << std::setw(100) << std::setfill(c) << "" << std::setfill(' ') << std::endl;
}
void PrintUsage() {
void PrintUsage()
{
horizontal_line('=');
std::cout << " Geant4 application to demonstrate interface to VecGeom Navigation. \n"
<< std::endl
@@ -167,7 +160,7 @@ void PrintUsage() {
<< " optionally one of the following: \n"
<< " -v : flag ==> run using VecGeom navigation (default). \n"
<< " -o : flag ==> run using Geant4 navigation. \n"
<< " -c : flag ==> compare VecGeom and Geant4 navigation"
<< " -c : flag ==> compare VecGeom and Geant4 navigation"
<< " (and report differences.) \n"
<< " and other(s): \n"
<< " -g : GDML file with geometry \n"
@@ -176,44 +169,53 @@ void PrintUsage() {
horizontal_line('=');
}
void GetInputArguments(int argc, char** argv) {
void GetInputArguments(int argc, char** argv)
{
// process arguments
if (argc == 1) {
PrintUsage();
exit(0);
}
if (argc == 2) {
parMacroFileName = argv[1];
G4cout << " argc = 2 -- Filename = " << parMacroFileName << G4endl;
return;
parMacroFileName = argv[1];
G4cout << " argc = 2 -- Filename = " << parMacroFileName << G4endl;
return;
}
// Adapted from examples/basic/B4/exampleB4a.cc
for ( G4int i=1; i<argc; ++i ) {
if ( G4String(argv[i]) == "-m" ) {
if( ++i < argc ) {
for (G4int i = 1; i < argc; ++i) {
if (G4String(argv[i]) == "-m") {
if (++i < argc) {
parMacroFileName = argv[i];
G4cout << " arg-parsing: Macro file name= " << parMacroFileName << G4endl;
}
else{
G4cerr << " Parse Error: '-m' cannot be last argument. Use it : -m <filename>" << G4endl;
PrintUsage();
exit(1);
else {
G4cerr << " Parse Error: '-m' cannot be last argument. Use it : -m <filename>" << G4endl;
PrintUsage();
exit(1);
}
}
else if ( G4String(argv[i]) == "-g" ) {
if( ++i < argc ) { parGDMLFile = argv[i];
G4cout << " arg-parsing: GDML file name= " << parGDMLFile << G4endl;
else if (G4String(argv[i]) == "-g") {
if (++i < argc) {
parGDMLFile = argv[i];
G4cout << " arg-parsing: GDML file name= " << parGDMLFile << G4endl;
}
else{
G4cerr << " Parse Error: '-m' cannot be last argument. Use it : -m <filename>" << G4endl;
PrintUsage();
exit(1);
else {
G4cerr << " Parse Error: '-m' cannot be last argument. Use it : -m <filename>" << G4endl;
PrintUsage();
exit(1);
}
}
else if ( G4String(argv[i]) == "-v" ) { parUseVecGeom = true; }
else if ( G4String(argv[i]) == "-o" ) { parUseVecGeom = false; }
else if ( G4String(argv[i]) == "-c" ) { parCompareG4 = true; parUseVecGeom= true; }
else if (G4String(argv[i]) == "-v") {
parUseVecGeom = true;
}
else if (G4String(argv[i]) == "-o") {
parUseVecGeom = false;
}
else if (G4String(argv[i]) == "-c") {
parCompareG4 = true;
parUseVecGeom = true;
}
else {
G4cerr << " Unknown argument : " << argv[i] << G4endl;
PrintUsage();
@@ -222,10 +224,10 @@ void GetInputArguments(int argc, char** argv) {
}
// check if mandatory Geant4 macro file was provided
if (parMacroFileName=="" && !parInteractive ) {
G4cerr << " *** ERROR : either interactive mode or a Geant4 macro file is required. "
<< G4endl;
PrintUsage();
exit(-1);
if (parMacroFileName == "" && !parInteractive) {
G4cerr << " *** ERROR : either interactive mode or a Geant4 macro file is required. "
<< G4endl;
PrintUsage();
exit(-1);
}
}