Import Geant4 11.0.0.beta source tree
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
cmake_minimum_required(VERSION 3.12...3.20)
|
||||
project(exampleVecGeomNav)
|
||||
|
||||
option(WITH_ROOT "WITH ROOT SUPPORT" OFF)
|
||||
option(BUILTIN_G4VECGEOMNAV "Build G4VecGeomNav from source (requires VecGeom)" ON)
|
||||
|
||||
find_package(Geant4 REQUIRED gdml)
|
||||
find_package(VecGeom REQUIRED)
|
||||
if(WITH_ROOT)
|
||||
find_package(ROOT REQUIRED)
|
||||
find_package(TGeo2VecGeom REQUIRED)
|
||||
endif()
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
## Option to use built-in G4VecGeomNav
|
||||
################################################################################
|
||||
# Minimum version of G4VecGeomNav we need.
|
||||
set(G4VecGeomNav_VERSION "") # 2021.06.18") # 0.1")
|
||||
|
||||
if(BUILTIN_G4VECGEOMNAV)
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
g4vecgeomnav
|
||||
GIT_REPOSITORY https://gitlab.cern.ch/VecGeom/g4vecgeomnav.git
|
||||
GIT_TAG 1a002fbf2bccd81827b6100f86e2ad82433a75e9
|
||||
)
|
||||
|
||||
FetchContent_GetProperties(g4vecgeomnav)
|
||||
|
||||
if(NOT g4vecgeomnav_POPULATED)
|
||||
FetchContent_Populate(g4vecgeomnav)
|
||||
message(STATUS "${g4vecgeomnav_SOURCE_DIR}, ${g4vecgeomnav_BINARY_DIR}")
|
||||
add_subdirectory(${g4vecgeomnav_SOURCE_DIR} ${g4vecgeomnav_BINARY_DIR})
|
||||
endif()
|
||||
else()
|
||||
find_package(G4VecGeomNav REQUIRED) ## 'Glue' code bridging Geant4-VecGeom navigation
|
||||
endif()
|
||||
|
||||
set(G4VecGeomNav_LIBRARIES G4VecGeomNav::g4vecgeomnav)
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# Locate sources for this project
|
||||
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
|
||||
|
||||
# define the main target :
|
||||
add_executable(exampleVecGeomNav exampleVecGeomNav.cc ${sources})
|
||||
|
||||
target_include_directories(exampleVecGeomNav PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
|
||||
# we depend on G4VecGeomNav / VecGeom , optionally ROOT
|
||||
target_link_libraries(exampleVecGeomNav
|
||||
PRIVATE
|
||||
${Geant4_LIBRARIES}
|
||||
G4VecGeomNav::g4vecgeomnav
|
||||
VecGeom::vecgeom
|
||||
)
|
||||
|
||||
# As used in G4VecGeomNav - to refine
|
||||
if(WITH_ROOT)
|
||||
target_link_libraries(exampleVecGeomNav
|
||||
PRIVATE
|
||||
ROOT::Geom
|
||||
${TGeo2VecGeom_LIBRARIES}
|
||||
${ROOT_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Copy all scripts to the build/OUTPUT directory. This is so that, after
|
||||
# install, we can run the executable directly because it relies on these
|
||||
# scripts being in the current working directory.
|
||||
#
|
||||
set(EXVECGEOMNAVIGATION_SCRIPTS
|
||||
TestNTST.gdml
|
||||
vecgeomNav.in
|
||||
run-ntst.mac
|
||||
)
|
||||
|
||||
foreach(_script ${EXVECGEOMNAVIGATION_SCRIPTS})
|
||||
configure_file(
|
||||
${_script}
|
||||
${CMAKE_BINARY_DIR}/${_script}
|
||||
COPYONLY
|
||||
)
|
||||
endforeach()
|
||||
@@ -0,0 +1,21 @@
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=========================================================
|
||||
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
|
||||
=========================================================
|
||||
|
||||
VecGeomNavigation History file
|
||||
-------------------------------
|
||||
This file should be used by the G4 example coordinator to briefly
|
||||
summarize all major modifications introduced in the code and keep
|
||||
track of all tags.
|
||||
|
||||
----------------------------------------------------------
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
25/06/2021 B.Morgan (VecGeomNavigation-V10-07-01)
|
||||
- Fix build of builtin G4VecGeomNav
|
||||
|
||||
24/06/2021 J.Apostolakis (VecGeomNavigation-V10-07-00)
|
||||
- First version of example interfacing VecGeom navigation with Geant4.
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
|
||||
This example demonstrates integration of the navigation elements of
|
||||
[VecGeom](https://gitlab.cern.ch/VecGeom/VecGeom), to investigate the
|
||||
performance benefits.
|
||||
|
||||
This integration is in development. Supporting Placement volumes -- other
|
||||
volumes would be handled by existing Geant4 navigation.
|
||||
|
||||
The example loads a GDML file for the geometry, and can execute a batch
|
||||
file (first) or run interactive commands or both.
|
||||
|
||||
# Installation / Configuration
|
||||
|
||||
## Dependencies
|
||||
|
||||
In addition to Geant4, two projects: are required VecGeom and G4VecGeomNav.
|
||||
VecCore is also required, but can be found through VecGeom.
|
||||
|
||||
It is optionally possible to use Root in G4VecGeomNav to store voxel
|
||||
information for safety computation. These can require significant computation
|
||||
to calculate if at least one logical volume contains many daughter volume.
|
||||
|
||||
## Configuration
|
||||
- To configure you must set:
|
||||
|
||||
setenv CMAKE_PREFIX_PATH "${VECCORE_DIR}:${VECGEOM_DIR}"
|
||||
|
||||
or if you are using Vc from Root
|
||||
setenv CMAKE_PREFIX_PATH "${ROOTSYS}:${VECGEOM_DIR}"
|
||||
where VecGeom has also been built with the same installation of Vc from Root.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,242 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Author: J. Apostolakis, S. Wenzel, 2018-2021
|
||||
//
|
||||
// Started from FullCMS Geant4 application by Mihaly Novak (2017)
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4RunManagerFactory.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"
|
||||
|
||||
// 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 G4int parThreads = 2;
|
||||
|
||||
void GetInputArguments(int argc, char** argv);
|
||||
void PrintUsage();
|
||||
|
||||
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
|
||||
#ifdef G4MULTITHREADED
|
||||
<< " Number of threads = " << parThreads << G4endl
|
||||
#endif
|
||||
<< " ===================================================== " << G4endl;
|
||||
|
||||
// Use custom stepping verbosity
|
||||
G4VSteppingVerbose::SetInstance( new VG01SteppingVerboseWithDir() );
|
||||
|
||||
// Construct the run manager
|
||||
//
|
||||
G4RunManager* runManager
|
||||
= G4RunManagerFactory::CreateRunManager( G4RunManagerType::Serial);
|
||||
// or G4RunManagerType::Default to get Task or Multithreading
|
||||
|
||||
// set mandatory initialization classes
|
||||
//
|
||||
// 1. Detector construction
|
||||
//
|
||||
VG01DetectorConstruction* detector = new VG01DetectorConstruction;
|
||||
detector->SetGDMLFileName(parGDMLFile);
|
||||
detector->SetUseVecGeom(parUseVecGeom);
|
||||
runManager->SetUserInitialization(detector);
|
||||
|
||||
// 2. Physics list
|
||||
//
|
||||
G4VModularPhysicsList* physicsList = new FTFP_BERT;
|
||||
physicsList->RegisterPhysics(new G4StepLimiterPhysics());
|
||||
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);
|
||||
|
||||
// 5. Run the simulation in Interactive mode if requested ( flag: -i )
|
||||
//
|
||||
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();
|
||||
|
||||
// UImgr->ApplyCommand("/control/execute init_vis.mac");
|
||||
|
||||
// interactive mode
|
||||
uiExec->SessionStart();
|
||||
|
||||
// Cleanup
|
||||
delete uiExec;
|
||||
delete visManager;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Print out the final random number - for batch only runs
|
||||
G4cout << G4endl
|
||||
<< " ================================================================= " << G4endl
|
||||
<< " Final random number = " << G4UniformRand() << G4endl
|
||||
<< " ================================================================= " << G4endl
|
||||
<< G4endl;
|
||||
}
|
||||
//
|
||||
|
||||
// Delete the RunManager
|
||||
delete runManager;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void horizontal_line(char c)
|
||||
{
|
||||
std::cout <<"\n " << std::setw(100) << std::setfill(c)
|
||||
<< "" << std::setfill(' ') << std::endl;
|
||||
}
|
||||
|
||||
void PrintUsage() {
|
||||
horizontal_line('=');
|
||||
std::cout << " Geant4 application to demonstrate interface to VecGeom Navigation. \n"
|
||||
<< std::endl
|
||||
<< " Two modes: \n\n"
|
||||
<< " * 1 parameter this is treated as Geant4 macro file \n"
|
||||
<< " \n"
|
||||
<< " * Multiple Parameters: \n"
|
||||
<< " at least one of the following: \n"
|
||||
<< " -m : the standard Geant4 macro file \n"
|
||||
<< " -i : interactive (after batch, if any) \n"
|
||||
<< " 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"
|
||||
<< " (and report differences.) \n"
|
||||
<< " and other(s): \n"
|
||||
<< " -g : GDML file with geometry \n"
|
||||
#ifdef G4MULTITHREADED
|
||||
<< " -t : number of threads\n"
|
||||
#endif
|
||||
<< "\n"
|
||||
<< std::endl;
|
||||
horizontal_line('=');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Adapted from examples/basic/B4/exampleB4a.cc
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
#ifdef G4MULTITHREADED
|
||||
else if ( G4String(argv[i]) == "-t" ) {
|
||||
parThreads = G4UIcommand::ConvertToInt(argv[++i]);
|
||||
}
|
||||
#endif
|
||||
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();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// check if mandatory Geant4 macro file was provided
|
||||
if (parMacroFileName=="" && !parInteractive ) {
|
||||
G4cout << " *** ERROR : either interactive mode or a Geant4 macro file is required. " << G4endl;
|
||||
PrintUsage();
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file VG01ActionInitialization.hh
|
||||
/// \brief Definition of the VG01ActionInitialization class
|
||||
|
||||
#ifndef VG01ActionInitialization_h
|
||||
#define VG01ActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
/// Action initialization class.
|
||||
|
||||
class VG01ActionInitialization : public G4VUserActionInitialization
|
||||
{
|
||||
public:
|
||||
VG01ActionInitialization();
|
||||
~VG01ActionInitialization() override;
|
||||
|
||||
void BuildForMaster() const override;
|
||||
void Build() const override;
|
||||
};
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
|
||||
#ifndef VG01DetectorConstruction_h
|
||||
#define VG01DetectorConstruction_h 1
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
|
||||
#include "G4GDMLParser.hh"
|
||||
#include "G4String.hh"
|
||||
|
||||
class G4VPhysicalVolume;
|
||||
class G4FieldManager;
|
||||
class G4UniformMagField;
|
||||
class VG01DetectorMessenger;
|
||||
|
||||
class VG01DetectorConstruction : public G4VUserDetectorConstruction {
|
||||
|
||||
public:
|
||||
|
||||
VG01DetectorConstruction();
|
||||
~VG01DetectorConstruction();
|
||||
|
||||
G4VPhysicalVolume* Construct() override;
|
||||
|
||||
void SetGDMLFileName ( const G4String& gdmlfile ) { fGDMLFileName = gdmlfile; }
|
||||
void SetUseVecGeom (bool b) { fUseVecGeom = b; }
|
||||
void SetMagFieldValue(const G4double fieldValue ) { fglobFieldValue = fieldValue; }
|
||||
|
||||
static G4double GetFieldValue() { return fglobFieldValue; }
|
||||
|
||||
private:
|
||||
void CreateMagFieldAndIntegrator();
|
||||
|
||||
private:
|
||||
// this static member is for the print out
|
||||
static G4double fglobFieldValue;
|
||||
|
||||
G4String fGDMLFileName;
|
||||
G4GDMLParser fParser;
|
||||
G4VPhysicalVolume* fWorld;
|
||||
G4FieldManager* fFieldMgr;
|
||||
G4UniformMagField* fUniformMagField;
|
||||
bool fUseVecGeom = true;
|
||||
VG01DetectorMessenger* fDetectorMessenger= nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file geometry/VecGeomNavigation/src/VG01DetectorMessenger.hh
|
||||
/// \brief Implementation of the VG01PrimaryGeneratorAction class
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef VG01DetectorMessenger_hh
|
||||
#define VG01DetectorMessenger_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class VG01DetectorConstruction;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAString;
|
||||
|
||||
class VG01DetectorMessenger: public G4UImessenger {
|
||||
|
||||
public:
|
||||
|
||||
VG01DetectorMessenger( VG01DetectorConstruction* );
|
||||
~VG01DetectorMessenger();
|
||||
|
||||
void SetNewValue( G4UIcommand*, G4String ) override;
|
||||
|
||||
private:
|
||||
VG01DetectorConstruction* fDetector;
|
||||
G4UIdirectory* fDetectorDir;
|
||||
G4UIcmdWithADoubleAndUnit* fFieldCommand;
|
||||
G4UIcmdWithAString* fGDMLCommand;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file persistency/gdml/G01/include/VG01PrimaryGeneratorAction.hh
|
||||
/// \brief Generator with multiple modes: uniform, free, axis, fixed)
|
||||
//
|
||||
// Primary generator that can be configured using modes to either:
|
||||
// - 'uniform' direction secondaries (default)
|
||||
// - 'free' which is configured by UI - initialised in con/tor
|
||||
// - 'axis' directing secondaries by rotation to x, y & z axis
|
||||
// - 'fixed' along x axis, and near it ( y = 0.1 or z = 0.1)
|
||||
//
|
||||
// Authors: J. Apostolakis & S. Wenzel (CERN) 2018-2021
|
||||
//
|
||||
// Started from FullCMS code by Mihaly Novak (CERN) 2017
|
||||
|
||||
#ifndef _G01PRIMARYGENERATORACTION_H_
|
||||
#define _G01PRIMARYGENERATORACTION_H_
|
||||
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
class G4Event;
|
||||
class G4ParticleGun;
|
||||
|
||||
/// Configurable primary generator action to demonstrate use of
|
||||
/// VecGeom Navigation
|
||||
|
||||
class VG01PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
||||
{
|
||||
|
||||
public:
|
||||
enum EGeneratorMode { kFixedMode, kUniformMode, kAxisMode, kFreeMode};
|
||||
// x Axis random dir x, y, z UI directed
|
||||
|
||||
VG01PrimaryGeneratorAction( EGeneratorMode mode = kUniformMode );
|
||||
~VG01PrimaryGeneratorAction();
|
||||
|
||||
void GeneratePrimaries(G4Event* anEvent) override;
|
||||
|
||||
void SetGeneratorMode(EGeneratorMode val) { fMode = val;}
|
||||
EGeneratorMode GetGeneratorMode() { return fMode;}
|
||||
private:
|
||||
|
||||
G4ParticleGun* fParticleGun;
|
||||
EGeneratorMode fMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Alternative Stepping Verbose method that prints out:
|
||||
// - momentum direction
|
||||
// - safety ( distance to nearest boundary at pre-step point )
|
||||
//
|
||||
// ********************************************************************
|
||||
// Code developed by:
|
||||
// J. Apostolakis, April 2021
|
||||
// ********************************************************************
|
||||
|
||||
#ifndef VG01SteppingVerboseWithDir_hh
|
||||
#define VG01SteppingVerboseWithDir_hh 1
|
||||
|
||||
#include "G4SteppingVerbose.hh"
|
||||
|
||||
class VG01SteppingVerboseWithDir : public G4SteppingVerbose {
|
||||
|
||||
public:
|
||||
|
||||
//Constructor/Destructor
|
||||
VG01SteppingVerboseWithDir();
|
||||
~VG01SteppingVerboseWithDir();
|
||||
|
||||
void StepInfo() override;
|
||||
void TrackingStarted() override;
|
||||
|
||||
// implementation methods - simplify/reduce code
|
||||
void Banner();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,46 @@
|
||||
########################################################################
|
||||
## SET ALL VERBSE LEVELS TO 0
|
||||
## ---------------------------------------------------------------------
|
||||
/control/verbose 1
|
||||
/run/verbose 1
|
||||
/event/verbose 1
|
||||
/tracking/verbose 1
|
||||
|
||||
/mydet/setGdmlFile TestNTST.gdml
|
||||
|
||||
########################################################################
|
||||
## SET NUMBER OF THREADS (will be ignored in case of sequential Geant4)
|
||||
## ---------------------------------------------------------------------
|
||||
/run/numberOfThreads 1
|
||||
/control/cout/prefixString G4-WORKER
|
||||
|
||||
########################################################################
|
||||
## DETECTOR AND MAGNETIC FIELD
|
||||
## ---------------------------------------------------------------------
|
||||
###/mydet/setGdmlFile alternative.gdml
|
||||
## ---------------------------------------------------------------------
|
||||
/mydet/setField 4.0 tesla
|
||||
|
||||
########################################################################
|
||||
## INIT
|
||||
## ---------------------------------------------------------------------
|
||||
/run/initialize
|
||||
|
||||
########################################################################
|
||||
## PRIMARY GENERATOR
|
||||
## ---------------------------------------------------------------------
|
||||
# /gun/primaryPerEvt 1
|
||||
|
||||
## ---------------------------------------------------------------------
|
||||
/gun/particle e-
|
||||
## ---------------------------------------------------------------------
|
||||
/gun/energy 5 GeV
|
||||
## ---------------------------------------------------------------------
|
||||
####/gun/direction 0 1 0
|
||||
|
||||
########################################################################
|
||||
## EXECUTE with 10 events and print the list of processes at the end
|
||||
## ---------------------------------------------------------------------
|
||||
/run/beamOn 10
|
||||
## ---------------------------------------------------------------------
|
||||
# /process/list
|
||||
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
/// \file VG01ActionInitialization.cc
|
||||
/// \brief Implementation of the VG01ActionInitialization class
|
||||
|
||||
#include "VG01ActionInitialization.hh"
|
||||
#include "VG01PrimaryGeneratorAction.hh"
|
||||
|
||||
|
||||
VG01ActionInitialization::VG01ActionInitialization()
|
||||
: G4VUserActionInitialization()
|
||||
{}
|
||||
|
||||
VG01ActionInitialization::~VG01ActionInitialization()
|
||||
{}
|
||||
|
||||
void VG01ActionInitialization::BuildForMaster() const
|
||||
{
|
||||
}
|
||||
|
||||
void VG01ActionInitialization::Build() const
|
||||
{
|
||||
SetUserAction(new VG01PrimaryGeneratorAction);
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Authors: J. Apostolakis & S. Wenzel (CERN) 2018-2021
|
||||
//
|
||||
// Derived from FullCMS code by Mihaly Novak (2017-18)
|
||||
|
||||
#include "VG01DetectorConstruction.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
#include "G4UniformMagField.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "VG01DetectorMessenger.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4PropagatorInField.hh"
|
||||
|
||||
#include "G4VecGeomConverter.h"
|
||||
#include <VecGeom/management/GeoManager.h>
|
||||
|
||||
G4double VG01DetectorConstruction::fglobFieldValue = 0.0;
|
||||
|
||||
VG01DetectorConstruction::VG01DetectorConstruction()
|
||||
: G4VUserDetectorConstruction(), fWorld(nullptr), fFieldMgr(nullptr),
|
||||
fUniformMagField(nullptr), fDetectorMessenger(nullptr)
|
||||
{
|
||||
fGDMLFileName = "TestNTST.gdml";
|
||||
fDetectorMessenger = new VG01DetectorMessenger(this);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
VG01DetectorConstruction::~VG01DetectorConstruction() {
|
||||
delete fDetectorMessenger;
|
||||
if (fUniformMagField) {
|
||||
delete fUniformMagField;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* VG01DetectorConstruction::Construct() {
|
||||
// parser.SetOverlapCheck(true);
|
||||
G4TransportationManager *trMgr =
|
||||
G4TransportationManager::GetTransportationManager();
|
||||
assert(trMgr);
|
||||
|
||||
fParser.Read(fGDMLFileName, false);
|
||||
fWorld = (G4VPhysicalVolume *)fParser.GetWorldVolume();
|
||||
|
||||
// enabling 'check' mode in G4 Navigator
|
||||
G4Navigator *nav = trMgr->GetNavigatorForTracking();
|
||||
assert(nav);
|
||||
nav->CheckMode(true);
|
||||
// nav->SetVerboseLevel(1);
|
||||
std::cout << "Enabled Check mode in G4Navigator";
|
||||
|
||||
// write back
|
||||
// fParser.Write("out.gdml", fWorld);
|
||||
|
||||
fFieldMgr = trMgr->GetFieldManager();
|
||||
fWorld->GetLogicalVolume()->SetVisAttributes(G4VisAttributes::GetInvisible());
|
||||
if (fWorld==nullptr) {
|
||||
G4ExceptionDescription ed;
|
||||
ed << "World volume not set properly check your setup selection criteria"
|
||||
<< "or GDML input!" << G4endl;
|
||||
G4Exception( "VG01DetectorConstruction::Construct()",
|
||||
"G4VecGeomNavExtExample_0001", FatalException, ed );
|
||||
|
||||
}
|
||||
CreateMagFieldAndIntegrator();
|
||||
|
||||
if (fUseVecGeom) {
|
||||
// This is converting the geometry to VecGeom and implicitely also setting
|
||||
// the navigator; We should pull this out really
|
||||
G4VecGeomConverter::Instance().SetVerbose(1);
|
||||
G4VecGeomConverter::Instance().ConvertG4Geometry(fWorld);
|
||||
G4cout << vecgeom::GeoManager::Instance().getMaxDepth() << "\n";
|
||||
}
|
||||
return fWorld;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void VG01DetectorConstruction::CreateMagFieldAndIntegrator()
|
||||
{
|
||||
delete fUniformMagField;
|
||||
|
||||
if (std::abs(fglobFieldValue)>0.0) {
|
||||
// Apply a global uniform magnetic field along the Z axis.
|
||||
// Note: only when the magnetic field (pointer) is NOT zero,
|
||||
// does the Geant4 transportion in field get activated.
|
||||
fUniformMagField =
|
||||
new G4UniformMagField(G4ThreeVector(0.0,0.0,fglobFieldValue));
|
||||
fFieldMgr->SetDetectorField(fUniformMagField);
|
||||
fFieldMgr->CreateChordFinder(fUniformMagField);
|
||||
G4cout << G4endl
|
||||
<< " *** SETTING MAGNETIC FIELD in Z direction : fieldValue = "
|
||||
<< fglobFieldValue / tesla << " tesla *** " << G4endl << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
fFieldMgr->SetDetectorField(nullptr);
|
||||
G4cout << G4endl
|
||||
<< " *** NO MAGNETIC FIELD SET *** " << G4endl
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Authors: J. Apostolakis & S. Wenzel (CERN) 2018-2021
|
||||
//
|
||||
// Started from FullCMS code by Mihaly Novak (CERN) 2017
|
||||
|
||||
#include "VG01DetectorMessenger.hh"
|
||||
|
||||
#include "VG01DetectorConstruction.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
|
||||
VG01DetectorMessenger::
|
||||
VG01DetectorMessenger( VG01DetectorConstruction* myDet )
|
||||
: G4UImessenger(), fDetector( myDet )
|
||||
{
|
||||
|
||||
fDetectorDir = new G4UIdirectory( "/mydet/" );
|
||||
fDetectorDir->SetGuidance( "Detector control." );
|
||||
|
||||
fFieldCommand = new G4UIcmdWithADoubleAndUnit( "/mydet/setField", this );
|
||||
fFieldCommand->SetGuidance( "Define uniform magnetic field along Z." );
|
||||
fFieldCommand->SetGuidance( " -> in unit of [Tesla]" );
|
||||
fFieldCommand->SetParameterName( "By", false );
|
||||
fFieldCommand->SetDefaultValue( 0.0 );
|
||||
fFieldCommand->SetUnitCategory( "Magnetic flux density" );
|
||||
fFieldCommand->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
fGDMLCommand = new G4UIcmdWithAString( "/mydet/setGdmlFile", this );
|
||||
fGDMLCommand->SetGuidance( "Set the GDML file." );
|
||||
fGDMLCommand->SetDefaultValue( "TestNTST.gdml" );
|
||||
fGDMLCommand->AvailableForStates( G4State_PreInit, G4State_Idle );
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
VG01DetectorMessenger::~VG01DetectorMessenger() {
|
||||
delete fFieldCommand;
|
||||
delete fDetectorDir;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void VG01DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if ( command == fFieldCommand ) {
|
||||
fDetector->SetMagFieldValue(fFieldCommand->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( command == fGDMLCommand ) {
|
||||
fDetector->SetGDMLFileName( newValue );
|
||||
} else {
|
||||
G4cerr << "VG01DetectorMessenger: ERROR> Unknown command " << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
/// \file geometry/VecGeomNavigation/src/VG01PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the VG01PrimaryGeneratorAction class
|
||||
//
|
||||
// Authors: J. Apostolakis & S. Wenzel (CERN) 2018-2021
|
||||
//
|
||||
// Started from FullCMS code by Mihaly Novak (CERN) 2017
|
||||
|
||||
#include "VG01PrimaryGeneratorAction.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
|
||||
#include "G4RandomDirection.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
VG01PrimaryGeneratorAction::VG01PrimaryGeneratorAction( EGeneratorMode mode )
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0),
|
||||
fMode(mode)
|
||||
{
|
||||
G4int n_particle = 1;
|
||||
fParticleGun = new G4ParticleGun(n_particle);
|
||||
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4String particleName;
|
||||
fParticleGun->SetParticleDefinition(
|
||||
particleTable->FindParticle(particleName="geantino"));
|
||||
fParticleGun->SetParticleEnergy(1.0*GeV);
|
||||
fParticleGun->SetParticlePosition(G4ThreeVector(0,0,0) ); // -1.2*m, 0.1, 0.1));
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
VG01PrimaryGeneratorAction::~VG01PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void VG01PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4ThreeVector dir(1.0,0.0,0.0);
|
||||
|
||||
// G4ThreeVector FixedMode[3] =
|
||||
// { G4ThreeVector(1,0,0), G4ThreeVector(1,0.1,0), G4ThreeVector( 1, 0, 0.1)};
|
||||
G4ThreeVector AxisModeVectors[3] =
|
||||
{ G4ThreeVector(1,0,0), G4ThreeVector(0,1,0), G4ThreeVector( 0, 0, 1.0)};
|
||||
|
||||
if( fMode == kFreeMode ){
|
||||
// Do not fix the direction
|
||||
// -- UI commands to particle mode can change it!
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
return;
|
||||
//----
|
||||
}
|
||||
else if( fMode == kFixedMode )
|
||||
{
|
||||
G4int i = anEvent->GetEventID() % 3;
|
||||
dir= G4ThreeVector(1.0,0.0,0.0);
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
dir.setY(0.1);
|
||||
break;
|
||||
case 2:
|
||||
dir.setZ(0.1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( fMode == kUniformMode )
|
||||
{
|
||||
dir = G4RandomDirection();
|
||||
}
|
||||
else if ( fMode == kAxisMode )
|
||||
{
|
||||
G4int i = anEvent->GetEventID() % 3;
|
||||
dir = AxisModeVectors[i];
|
||||
}
|
||||
|
||||
fParticleGun->SetParticleMomentumDirection(dir);
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// Author : J. Apostolakis, (EP/SFT CERN) 2019-21
|
||||
//
|
||||
// Refines the existing G4SteppingVerbose, adding:
|
||||
// - direction of particle
|
||||
// - safety (at step's start point)
|
||||
|
||||
#include "VG01SteppingVerboseWithDir.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
VG01SteppingVerboseWithDir::VG01SteppingVerboseWithDir()
|
||||
: G4SteppingVerbose()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
|
||||
VG01SteppingVerboseWithDir::~VG01SteppingVerboseWithDir()
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void VG01SteppingVerboseWithDir::Banner()
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << std::setw( 5) << "Step#" << " "
|
||||
<< std::setw( 9) << "X (mm)" << " "
|
||||
<< std::setw( 9) << "Y (mm)" << " "
|
||||
<< std::setw( 9) << "Z (mm)" << " "
|
||||
<< std::setw(11) << "Ek (MeV)" << " "
|
||||
<< std::setw( 8) << "dE (MeV)" << " "
|
||||
<< std::setw( 7) << "Step(mm)" << " "
|
||||
<< std::setw(12) << "Track(mm)" << " "
|
||||
<< std::setw( 7) << "Safety(mm)" << " | "
|
||||
<< std::setw(11) << " Dir.x " << " "
|
||||
<< std::setw(11) << " Dir.y " << " "
|
||||
<< std::setw(11) << " Dir.z " << " | "
|
||||
<< std::setw(15) << "Material"
|
||||
<< std::setw(14) << "Process"
|
||||
<< std::setw(15) << "NextVolu"
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void VG01SteppingVerboseWithDir::StepInfo()
|
||||
{
|
||||
CopyState();
|
||||
|
||||
G4int prec = G4cout.precision(6);
|
||||
|
||||
if( verboseLevel >= 1 ){
|
||||
if( verboseLevel >= 4 ) VerboseTrack();
|
||||
if( verboseLevel >= 3 ){ Banner(); }
|
||||
|
||||
G4cout << std::setw( 5)<<fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw( 9)<<fTrack->GetPosition().x() / CLHEP::mm << " "
|
||||
<< std::setw( 9)<<fTrack->GetPosition().y() / CLHEP::mm << " "
|
||||
<< std::setw( 9)<<fTrack->GetPosition().z() / CLHEP::mm << " " // << " Ek = "
|
||||
<< std::setw(11)<<fTrack->GetKineticEnergy() / CLHEP::MeV << " ";
|
||||
G4cout.precision(3);
|
||||
G4cout << std::setw( 8)<<fStep->GetTotalEnergyDeposit() / CLHEP::MeV << " "
|
||||
<< std::setw( 7)<<fStep->GetStepLength() / CLHEP::mm << " ";
|
||||
G4cout.precision(6);
|
||||
G4cout << std::setw(12)<<fTrack->GetTrackLength() / CLHEP::mm << " ";
|
||||
|
||||
G4cout.precision(5);
|
||||
G4StepPoint* preStepPt= fTrack->GetStep()->GetPreStepPoint();
|
||||
if( preStepPt != nullptr ) {
|
||||
G4double safety = preStepPt->GetSafety();
|
||||
G4cout << std::setw( 8) << ( (safety > 1.0e-9) ? safety : 0.0 ) << " ";
|
||||
} else {
|
||||
G4cout << std::setw( 8) << "-0.0_(N/A)" << " ";
|
||||
}
|
||||
|
||||
|
||||
G4cout << "| ";
|
||||
G4cout << std::setw(11)<<fTrack->GetMomentumDirection().x() << " "
|
||||
<< std::setw(11)<<fTrack->GetMomentumDirection().y() << " "
|
||||
<< std::setw(11)<<fTrack->GetMomentumDirection().z() << " | ";
|
||||
|
||||
G4cout << std::setw(15) << fTrack->GetMaterial()->GetName() << " ";
|
||||
G4VProcess const* pds= fStep->GetPostStepPoint()->GetProcessDefinedStep();
|
||||
G4cout << std::setw(14) << ( ( pds != nullptr) ? pds->GetProcessName() :
|
||||
G4String( "User Limit") ) << " ";
|
||||
// if( fStepStatus != fWorldBoundary){
|
||||
if( fTrack->GetNextVolume() != nullptr ) {
|
||||
G4cout << std::setw(10) << fTrack->GetNextVolume()->GetName();
|
||||
G4cout << std::setw( 4) << fTrack->GetNextVolume()->GetCopyNo();
|
||||
} else {
|
||||
G4cout << std::setw(10) << "OutOfWorld";
|
||||
}
|
||||
|
||||
G4cout << " ";
|
||||
|
||||
G4cout << G4endl;
|
||||
|
||||
if( verboseLevel == 2 ){
|
||||
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
|
||||
fN2ndariesAlongStepDoIt +
|
||||
fN2ndariesPostStepDoIt;
|
||||
if(tN2ndariesTot>0){
|
||||
G4cout << " :----- List of 2ndaries - "
|
||||
<< "#SpawnInStep=" << std::setw(3) << tN2ndariesTot
|
||||
<< "(Rest=" << std::setw(2) << fN2ndariesAtRestDoIt
|
||||
<< ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
|
||||
<< ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt
|
||||
<< "), "
|
||||
<< "#SpawnTotal=" << std::setw(3) << (*fSecondary).size()
|
||||
<< " ---------------"
|
||||
<< G4endl;
|
||||
|
||||
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
|
||||
lp1<(*fSecondary).size(); lp1++){
|
||||
G4cout << " : "
|
||||
<< std::setw(8)
|
||||
<< (*fSecondary)[lp1]->GetPosition().x() / CLHEP::mm << " "
|
||||
<< std::setw(8)
|
||||
<< (*fSecondary)[lp1]->GetPosition().y() / CLHEP::mm << " "
|
||||
<< std::setw(8)
|
||||
<< (*fSecondary)[lp1]->GetPosition().z() / CLHEP::mm << " "
|
||||
<< std::setw(8)
|
||||
<< (*fSecondary)[lp1]->GetKineticEnergy() / CLHEP::MeV << " "
|
||||
<< std::setw(10)
|
||||
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName() << " ";
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
G4cout << " :-----------------------------"
|
||||
<< "----------------------------------"
|
||||
<< "-- EndOf2ndaries Info ---------------"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
// G4cout<< "exit VG01SteppingVerboseWithDir::StepInfo " <<G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void VG01SteppingVerboseWithDir::TrackingStarted()
|
||||
{
|
||||
CopyState();
|
||||
G4int prec = G4cout.precision(6);
|
||||
if( verboseLevel > 0 ){
|
||||
|
||||
Banner();
|
||||
|
||||
G4cout << std::setw( 5)<<fTrack->GetCurrentStepNumber() << " "
|
||||
<< std::setw( 9)<<fTrack->GetPosition().x() / CLHEP::mm << " "
|
||||
<< std::setw( 9)<<fTrack->GetPosition().y() / CLHEP::mm << " "
|
||||
<< std::setw( 9)<<fTrack->GetPosition().z() / CLHEP::mm << " " // << " E_0 = "
|
||||
<< std::setw(11)<<fTrack->GetKineticEnergy() / CLHEP::MeV << " ";
|
||||
// << " ( = " << std::setw(8) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy") << " ) "
|
||||
G4cout.precision(3);
|
||||
G4cout << std::setw( 8) << fStep->GetTotalEnergyDeposit() / CLHEP::MeV << " "
|
||||
<< std::setw( 7) << fStep->GetStepLength() / CLHEP::mm << " ";
|
||||
G4cout.precision(6);
|
||||
G4cout << std::setw(12) << fTrack->GetTrackLength() / CLHEP::mm << " ";
|
||||
|
||||
G4Step const* step= fTrack->GetStep();
|
||||
G4StepPoint const * preStepPt= nullptr;
|
||||
if( step != nullptr )
|
||||
preStepPt =fTrack->GetStep()->GetPreStepPoint();
|
||||
if( preStepPt != nullptr ) {
|
||||
G4double safety = preStepPt->GetSafety();
|
||||
G4cout << std::setw( 8) << ( (safety > 1.0e-9) ? safety : 0.0 ) << " ";
|
||||
} else {
|
||||
G4cout << std::setw( 8) << "N/A" << " ";
|
||||
}
|
||||
G4cout << "| ";
|
||||
G4cout << std::setw(11) << fTrack->GetMomentumDirection().x() << " "
|
||||
<< std::setw(11) << fTrack->GetMomentumDirection().y() << " "
|
||||
<< std::setw(11) << fTrack->GetMomentumDirection().z() << " | ";
|
||||
|
||||
// Material and volume name
|
||||
if(fTrack->GetVolume()){
|
||||
G4Material* material = fTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
|
||||
if( material != nullptr ){
|
||||
G4cout << std::setw(15) << material->GetName() << " ";
|
||||
}
|
||||
else {
|
||||
G4cout << std::setw(15) << "No-Material" << " ";
|
||||
}
|
||||
G4cout << std::setw(14) << "initStep" << " ";
|
||||
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
|
||||
G4cout << std::setw( 4) << fTrack->GetVolume()->GetCopyNo() << " (initial Volume)";
|
||||
|
||||
} else {
|
||||
G4cout << std::setw(10) << "No-Material" << " ";
|
||||
G4cout << std::setw(14) << "initStep" << " ";
|
||||
G4cout << std::setw(10) << "OutOfWorld" << " ";
|
||||
}
|
||||
// fTrack->GetMaterial() fails at track start !!!!
|
||||
G4cout << G4endl;
|
||||
}
|
||||
G4cout.precision(prec);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
# Verbosity
|
||||
/control/verbose 1
|
||||
/run/verbose 1
|
||||
/event/verbose 0
|
||||
|
||||
/mydet/setGdmlFile TestNTST.gdml
|
||||
|
||||
# /run/numberOfThreads 1
|
||||
/control/cout/prefixString G4-WORKER
|
||||
|
||||
# Detector & Field
|
||||
/mydet/setField 2.0 tesla
|
||||
|
||||
# Init
|
||||
/run/initialize
|
||||
|
||||
# Primary Generator
|
||||
# /gun/primaryPerEvt 1
|
||||
/gun/particle e-
|
||||
/gun/energy 5 GeV
|
||||
|
||||
# Runs
|
||||
/tracking/verbose 1
|
||||
/run/beamOn 1
|
||||
|
||||
/tracking/verbose 0
|
||||
/run/beamOn 10
|
||||
Reference in New Issue
Block a user