Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -0,0 +1,78 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "SteppingAction.hh"
#include "G4RunManager.hh"
#include "AnalysisManager.hh"
#include "RunAction.hh"
#include "G4GeneralParticleSource.hh"
ActionInitialization::ActionInitialization(AnalysisManager* analysisMan, DetectorMessenger* detectorMess):
G4VUserActionInitialization()
{
analysis = analysisMan;
detector = detectorMess;
}
ActionInitialization::~ActionInitialization()
{
}
void ActionInitialization::BuildForMaster() const
{
// In MT mode, to be clearer, the RunAction class for the master thread might be
// different than the one used for the workers.
// This RunAction will be called before and after starting the
// workers.
}
void ActionInitialization::Build() const
{
// Initialize the primary particles
PrimaryGeneratorAction* primary = new PrimaryGeneratorAction(analysis);
SetUserAction(primary);
#ifdef ANALYSIS_USE
RunAction* run = new RunAction(analysis, detector);
#else
RunAction* run = new RunAction(detector);
#endif
SetUserAction(run);
SteppingAction* stepping = new SteppingAction(analysis);
SetUserAction(stepping);
}
@@ -0,0 +1,178 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
#include <stdlib.h>
#include "AnalysisManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "AnalysisMessenger.hh"
AnalysisManager::AnalysisManager(AnalysisMessenger* analysisMessenger)
{
factoryOn = false;
// Initialization
// histograms
//for (G4int k=0; k<MaxHisto; k++) fHistId[k] = 0;
// Initialization ntuple
for (G4int k=0; k<MaxNtCol; k++) fNtColId[k] = 0;
//h10 = 0;
//h20 = 0;
messenger = analysisMessenger;
}
AnalysisManager::~AnalysisManager()
{
}
void AnalysisManager::book(G4bool addExtraNt)
{
G4AnalysisManager* manager = G4AnalysisManager::Instance();
manager->SetVerboseLevel(2);
extraNt = addExtraNt;
usingRoot = messenger -> IsRootOutput();
// Create an output file
G4String fileName;
if( usingRoot == true ) fileName = "experimental_microdosimetry.root";
else fileName = "experimental_microdosimetry.csv";
// Create directories (not supported by csv)
if( usingRoot == true ) manager->SetNtupleDirectoryName("experimental_microdosimetry_ntuple");
G4bool fileOpen = manager->OpenFile(fileName);
if (!fileOpen) {
G4cout << "\n---> HistoManager::book(): cannot open "
<< fileName << G4endl;
return;
}
manager->SetFirstNtupleId(1);
//Create Primary Energy Ntuple
manager -> CreateNtuple("101", "Primary Energy");
fNtColId[0] = manager -> CreateNtupleDColumn("Ek");
manager -> FinishNtuple();
//Create Energy Deposition and Path Length within SV Ntuple
manager -> CreateNtuple("102", "Edep");
fNtColId[1] = manager -> CreateNtupleDColumn("edep");
fNtColId[2] = manager -> CreateNtupleDColumn("len");
if( extraNt == true ) fNtColId[3] = manager -> CreateNtupleIColumn("eventID");
manager -> FinishNtuple();
//creating a ntuple, containing the information about secondary particles
manager -> CreateNtuple("103", "secondary");
fNtColId[4] = manager -> CreateNtupleDColumn("AA");
fNtColId[5] = manager -> CreateNtupleDColumn("ZZ");
fNtColId[6] = manager -> CreateNtupleDColumn("KE");
manager -> FinishNtuple();
// if the telescope is in use, add an exta ntuple for its information
if( extraNt == true)
{
manager -> CreateNtuple("104", "secondStageE");
fNtColId[7] = manager -> CreateNtupleDColumn("edep");
fNtColId[8] = manager -> CreateNtupleIColumn("eventID");
manager -> FinishNtuple();
}
factoryOn = true;
}
void AnalysisManager::SetPrimaryEnergy(G4double energy)
{
G4AnalysisManager* manager = G4AnalysisManager::Instance();
manager -> FillNtupleDColumn(1, fNtColId[0], energy);
manager -> AddNtupleRow(1);
}
void AnalysisManager::StoreEnergyDeposition(G4double edep, G4double len, G4int eid)
{
G4AnalysisManager* manager = G4AnalysisManager::Instance();
manager -> FillNtupleDColumn(2, fNtColId[1], edep);
manager -> FillNtupleDColumn(2, fNtColId[2], len);
if( extraNt == true ) manager -> FillNtupleIColumn(2, fNtColId[3], eid);
// the event ID is only useful when the 4th ntuple is enabled
manager -> AddNtupleRow(2);
}
void AnalysisManager::FillSecondaries(G4int AA, G4double charge, G4double energy)
{
G4AnalysisManager* manager = G4AnalysisManager::Instance();
manager -> FillNtupleDColumn(3, fNtColId[4], AA);
manager -> FillNtupleDColumn(3, fNtColId[5], charge);
manager -> FillNtupleDColumn(3, fNtColId[6], energy);
manager -> AddNtupleRow(3);
}
void AnalysisManager::StoreSecondStageEnergyDeposition(G4double edep, G4int eid)
{
if( extraNt == true )
{
G4AnalysisManager* manager = G4AnalysisManager::Instance();
manager -> FillNtupleDColumn(4, fNtColId[7], edep);
manager -> FillNtupleIColumn(4, fNtColId[8], eid);
manager -> AddNtupleRow(4);
}
}
void AnalysisManager::finish()
{
if (factoryOn)
{
G4AnalysisManager* manager = G4AnalysisManager::Instance();
manager -> Write();
manager -> CloseFile();
factoryOn = false;
}
}
@@ -0,0 +1,61 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "AnalysisMessenger.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithABool.hh"
AnalysisMessenger::AnalysisMessenger()
{
analysisDir = new G4UIdirectory("/analysis/");
analysisDir -> SetGuidance("Customize data analysis output");
useRootForOutput = new G4UIcmdWithABool("/analysis/useRoot", this);
useRootForOutput -> SetGuidance("If true, a ROOT file is used for the output. If false, a plaintext csv file is used");
useRootForOutput -> SetParameterName("Root", true);
useRootForOutput -> AvailableForStates(G4State_PreInit);
//default
rootOutput = true;
}
AnalysisMessenger::~AnalysisMessenger()
{
delete useRootForOutput;
delete analysisDir;
}
void AnalysisMessenger::SetNewValue(G4UIcommand* command, G4String commandContent)
{
if( command == useRootForOutput )
{
rootOutput = G4UIcmdWithABool::GetNewBoolValue(commandContent);
if( rootOutput == true ) G4cout << "Outputting to a ROOT file" << G4endl;
else G4cout << "Outputting to a csv file" << G4endl;
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,251 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
// Created by Jacopo Magini: j.magini@surrey.ac.uk
#include "DetectorMessenger.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4SystemOfUnits.hh"
#include "DetectorConstruction.hh"
#include "G4RunManager.hh"
DetectorMessenger::DetectorMessenger(AnalysisManager* analysis_manager)
: geometryHasChanged(false)
{
changeTheGeometryDir = new G4UIdirectory("/geometrySetup/");
changeTheGeometryDir -> SetGuidance("Geometry setup");
changeTheDetectorCmd = new G4UIcmdWithAString("/geometrySetup/selectDetector",this);
changeTheDetectorCmd -> SetGuidance("Select the type of detector you wish to use");
changeTheDetectorCmd -> SetParameterName("Material",false);
changeTheDetectorCmd -> AvailableForStates(G4State_PreInit);
changeDetectorDimensionDir = new G4UIdirectory("/geometrySetup/detectorDimension/");
changeDetectorDimensionDir -> SetGuidance("Modify the dimensions of the detector");
changeDetectorSizeWidthCmd = new G4UIcmdWithADoubleAndUnit("/geometrySetup/detectorDimension/setWidth", this);
changeDetectorSizeWidthCmd -> SetGuidance("Set the width of the detector");
changeDetectorSizeWidthCmd -> SetParameterName("Width", false);
changeDetectorSizeWidthCmd -> SetRange("Width >= 0.1 && Width <= 150.");
changeDetectorSizeWidthCmd -> SetUnitCategory("Length");
changeDetectorSizeWidthCmd -> SetDefaultUnit("um");
changeDetectorSizeWidthCmd -> AvailableForStates(G4State_PreInit);
changeDetectorSizeThicknessCmd = new G4UIcmdWithADoubleAndUnit("/geometrySetup/detectorDimension/setThickness", this);
changeDetectorSizeThicknessCmd -> SetGuidance("Set the thickness of the detector");
changeDetectorSizeThicknessCmd -> SetParameterName("Thickness", false);
changeDetectorSizeThicknessCmd -> SetRange("Thickness >= 0.1 && Thickness <= 50.");
changeDetectorSizeThicknessCmd -> SetUnitCategory("Length");
changeDetectorSizeThicknessCmd -> SetDefaultUnit("um");
changeDetectorSizeThicknessCmd -> AvailableForStates(G4State_PreInit);
changeSecondStageDimensionDir = new G4UIdirectory("/geometrySetup/detectorDimension/secondStage/");
changeSecondStageDimensionDir -> SetGuidance("Modify the dimensions of the E stage for the telescope detector");
changeSecondStageSizeWidthCmd = new G4UIcmdWithADoubleAndUnit("/geometrySetup/detectorDimension/secondStage/setWidth", this);
changeSecondStageSizeWidthCmd -> SetGuidance("Set the width of the E-stage for telescope detector");
changeSecondStageSizeWidthCmd -> SetParameterName("Width", false);
changeSecondStageSizeWidthCmd -> SetRange("Width >= 10 && Width <= 1000.");
changeSecondStageSizeWidthCmd -> SetUnitCategory("Length");
changeSecondStageSizeWidthCmd -> SetDefaultUnit("um");
changeSecondStageSizeWidthCmd -> AvailableForStates(G4State_PreInit);
changeSecondStageSizeThicknessCmd = new G4UIcmdWithADoubleAndUnit("/geometrySetup/detectorDimension/secondStage/setThickness", this);
changeSecondStageSizeThicknessCmd -> SetGuidance("Set the thickness of the E-stage for telescope detector");
changeSecondStageSizeThicknessCmd -> SetParameterName("Thickness", false);
changeSecondStageSizeThicknessCmd -> SetRange("Thickness >= 10 && Thickness <= 1000.");
changeSecondStageSizeThicknessCmd -> SetUnitCategory("Length");
changeSecondStageSizeThicknessCmd -> SetDefaultUnit("um");
changeSecondStageSizeThicknessCmd -> AvailableForStates(G4State_PreInit);
enableWaterPhantomCmd = new G4UIcmdWithABool("/geometrySetup/enableWaterPhantom", this);
enableWaterPhantomCmd -> SetGuidance("If true, the detector is placed inside a water phantom");
enableWaterPhantomCmd -> SetParameterName("Phantom", false);
enableWaterPhantomCmd -> AvailableForStates(G4State_PreInit);
changeDetectorPositionDir = new G4UIdirectory("/geometrySetup/detectorPosition/");
changeDetectorPositionDir -> SetGuidance("Modify the placement of the detector");
changeDetectorPositionDepthCmd = new G4UIcmdWithADoubleAndUnit("/geometrySetup/detectorPosition/setDepth", this);
changeDetectorPositionDepthCmd -> SetGuidance("Set the detector depth inside the water phantom");
changeDetectorPositionDepthCmd -> SetParameterName("Depth", false);
changeDetectorPositionDepthCmd -> SetRange("Depth >= 1. && Depth <= 250.");
changeDetectorPositionDepthCmd -> SetUnitCategory("Length");
changeDetectorPositionDepthCmd -> SetDefaultUnit("mm");
changeDetectorPositionDepthCmd -> AvailableForStates(G4State_PreInit);
applyChangesToGeometryCmd = new G4UIcmdWithoutParameter("/geometrySetup/applyChanges",this);
applyChangesToGeometryCmd -> SetGuidance("Apply selected changes to the geometry");
applyChangesToGeometryCmd -> AvailableForStates(G4State_PreInit);
// default values
detectorType = "Diamond";
detectorWidth = 30.*um;
detectorThickness = 10.*um;
phantomEnabled = false;
detectorDepth = 50*mm;
secondStageWidth = 800.*um;
secondStageThickness = 500.*um;
analysis = analysis_manager;
}
DetectorMessenger::~DetectorMessenger()
{
delete changeTheDetectorCmd;
delete changeDetectorSizeWidthCmd;
delete changeDetectorSizeThicknessCmd;
delete changeSecondStageSizeWidthCmd;
delete changeSecondStageSizeThicknessCmd;
delete enableWaterPhantomCmd;
delete changeDetectorPositionDepthCmd;
delete applyChangesToGeometryCmd;
delete changeSecondStageDimensionDir;
delete changeDetectorDimensionDir;
delete changeDetectorPositionDir;
delete changeTheGeometryDir;
}
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String commandContent)
{
if( command == changeTheDetectorCmd )
{
if( commandContent == "Diamond" || commandContent == "MicroDiamond" || commandContent == "Silicon" || commandContent == "SiliconBridge" || commandContent == "DiamondTelescope")
{
detectorType = commandContent;
geometryHasChanged = true;
G4cout << "Detector type changed to " << commandContent << G4endl;
G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else
{
G4cout <<"Unknown detector type: " << commandContent << ". Geometry not changed." << G4endl;
}
}
else if( command == changeDetectorSizeWidthCmd )
{
detectorWidth = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(commandContent);
geometryHasChanged = true;
G4cout << "Detector width changed to " << commandContent << G4endl;
G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else if( command == changeDetectorSizeThicknessCmd )
{
detectorThickness = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(commandContent);
geometryHasChanged = true;
G4cout << "Detector thickness changed to " << commandContent << G4endl;
G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else if( command == changeSecondStageSizeWidthCmd )
{
secondStageWidth = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(commandContent);
geometryHasChanged = true;
G4cout << "Telescope E-stage width changed to " << commandContent << G4endl;
if ( detectorType != "DiamondTelescope" )
{
G4cout << "However this setting only takes effect when using the telescope detector.";
G4cout << "Select it with '/geometrySetup/selectDetector DiamondTelescope' or this command will be ignored" << G4endl;
}
else G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else if( command == changeSecondStageSizeThicknessCmd )
{
secondStageThickness = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(commandContent);
geometryHasChanged = true;
G4cout << "Telescope E-stage thickness changed to " << commandContent << G4endl;
if ( detectorType != "DiamondTelescope" )
{
G4cout << "However this setting only takes effect when using the telescope detector.";
G4cout << "Select it with '/geometrySetup/selectDetector DiamondTelescope' or this command will be ignored" << G4endl;
}
else G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else if( command == enableWaterPhantomCmd )
{
phantomEnabled = G4UIcmdWithABool::GetNewBoolValue(commandContent);
geometryHasChanged = true;
if( phantomEnabled == true ) G4cout << "Water phantom enabled" << G4endl;
else G4cout << "Water phantom disabled" << G4endl;
G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else if( command == changeDetectorPositionDepthCmd )
{
detectorDepth = G4UIcmdWithADoubleAndUnit::GetNewDoubleValue(commandContent);
geometryHasChanged = true;
G4cout << "Detector depth in water changed to " << commandContent << G4endl;
if( phantomEnabled == false )
{
G4cout << "However the water phantom is not enabled.";
G4cout << "Enable it with '/geometrySetup/enableWaterPhantom true' or this command will be ignored" << G4endl;
}
else G4cout << "Run /geometrySetup/applyChanges to apply" << G4endl;
}
else if( command == applyChangesToGeometryCmd )
{
if( geometryHasChanged == true )
{
G4RunManager* runManager = G4RunManager::GetRunManager();
DetectorConstruction* newDetector = new DetectorConstruction(analysis, this);
runManager -> SetUserInitialization(newDetector);
runManager -> GeometryHasBeenModified();
geometryHasChanged = false;
G4cout << "All pending changes to geometry have been applied" << G4endl;
}
else
{
G4cout << "No pending changes to geometry. This command will be ignored" << G4endl;
}
}
}
@@ -0,0 +1,256 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
// Code based on the hadrontherapy advanced example
#include "PhysicsList.hh"
#include "PhysicsListMessenger.hh"
#include "G4PhysListFactory.hh"
#include "G4VPhysicsConstructor.hh"
// Physic lists (contained inside the Geant4 distribution)
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmLivermorePhysics.hh"
#include "G4EmPenelopePhysics.hh"
#include "G4DecayPhysics.hh"
#include "G4HadronElasticPhysics.hh"
#include "G4HadronDElasticPhysics.hh"
#include "G4HadronElasticPhysicsHP.hh"
#include "G4IonBinaryCascadePhysics.hh"
#include "G4Decay.hh"
#include "G4StepLimiter.hh"
#include "G4LossTableManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4ProcessManager.hh"
#include "G4IonFluctuations.hh"
#include "G4IonParametrisedLossModel.hh"
#include "G4HadronPhysicsQGSP_BIC_HP.hh"
#include "G4RadioactiveDecayPhysics.hh"
/////////////////////////////////////////////////////////////////////////////
PhysicsList::PhysicsList() : G4VModularPhysicsList()
{
G4LossTableManager::Instance();
defaultCutValue = 0.01*micrometer;
cutForGamma = defaultCutValue;
cutForElectron = defaultCutValue;
cutForPositron = defaultCutValue;
G4double lowLimit = 250. * eV;
G4double highLimit = 100. * GeV;
G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(lowLimit, highLimit);
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForPositron, "e+");
DumpCutValuesTable();
helIsRegisted = false;
bicIsRegisted = false;
biciIsRegisted = false;
locIonIonInelasticIsRegistered = false;
radioactiveDecayIsRegisted = false;
pMessenger = new PhysicsListMessenger(this);
SetVerboseLevel(1);
// EM physics
emPhysicsList = new G4EmStandardPhysics_option3(1);
emName = G4String("emstandard_opt3");
// Decay physics and all particles
decPhysicsList = new G4DecayPhysics();
}
/////////////////////////////////////////////////////////////////////////////
PhysicsList::~PhysicsList()
{
delete pMessenger;
delete emPhysicsList;
delete decPhysicsList;
for(size_t i=0; i<hadronPhys.size(); i++) {delete hadronPhys[i];}
}
/////////////////////////////////////////////////////////////////////////////
void PhysicsList::AddPackage(const G4String& name)
{
G4PhysListFactory factory;
G4VModularPhysicsList* phys =factory.GetReferencePhysList(name);
G4int i=0;
const G4VPhysicsConstructor* elem= phys->GetPhysics(i);
G4VPhysicsConstructor* tmp = const_cast<G4VPhysicsConstructor*> (elem);
while (elem !=0)
{
RegisterPhysics(tmp);
elem= phys->GetPhysics(++i) ;
tmp = const_cast<G4VPhysicsConstructor*> (elem);
}
}
/////////////////////////////////////////////////////////////////////////////
void PhysicsList::ConstructParticle()
{
decPhysicsList->ConstructParticle();
}
/////////////////////////////////////////////////////////////////////////////
void PhysicsList::ConstructProcess()
{
// transportation
//
AddTransportation();
// electromagnetic physics list
//
emPhysicsList->ConstructProcess();
em_config.AddModels();
// decay physics list
//
decPhysicsList->ConstructProcess();
// hadronic physics lists
for(size_t i=0; i<hadronPhys.size(); i++) {
hadronPhys[i]->ConstructProcess();
}
// step limitation (as a full process)
//
// AddStepMax();
}
/////////////////////////////////////////////////////////////////////////////
void PhysicsList::AddPhysicsList(const G4String& name)
{
if (verboseLevel>1) {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
}
if (name == emName) return;
/////////////////////////////////////////////////////////////////////////////
// ELECTROMAGNETIC MODELS
/////////////////////////////////////////////////////////////////////////////
if (name == "standard_opt3") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmStandardPhysics_option3();
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmStandardPhysics_option3" << G4endl;
} else if (name == "LowE_Livermore") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmLivermorePhysics();
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmLivermorePhysics" << G4endl;
} else if (name == "LowE_Penelope") {
emName = name;
delete emPhysicsList;
emPhysicsList = new G4EmPenelopePhysics();
G4cout << "THE FOLLOWING ELECTROMAGNETIC PHYSICS LIST HAS BEEN ACTIVATED: G4EmLivermorePhysics" << G4endl;
/////////////////////////////////////////////////////////////////////////////
// HADRONIC MODELS
/////////////////////////////////////////////////////////////////////////////
} else if (name == "elastic" && !helIsRegisted) {
G4cout << "THE FOLLOWING HADRONIC ELASTIC PHYSICS LIST HAS BEEN ACTIVATED: G4HadronElasticPhysics()" << G4endl;
hadronPhys.push_back( new G4HadronElasticPhysics());
helIsRegisted = true;
} else if (name == "DElastic" && !helIsRegisted) {
hadronPhys.push_back( new G4HadronDElasticPhysics());
helIsRegisted = true;
} else if (name == "HPElastic" && !helIsRegisted) {
hadronPhys.push_back( new G4HadronElasticPhysicsHP());
helIsRegisted = true;
} else if (name == "binary" && !bicIsRegisted) {
hadronPhys.push_back(new G4HadronPhysicsQGSP_BIC_HP());
bicIsRegisted = true;
G4cout << "THE FOLLOWING HADRONIC INELASTIC PHYSICS LIST HAS BEEN ACTIVATED: HadronPhysicsQGSP_BIC_HP()" << G4endl;
} else if (name == "binary_ion" && !biciIsRegisted) {
hadronPhys.push_back(new G4IonBinaryCascadePhysics());
biciIsRegisted = true;
G4cout << "THE FOLLOWING HADRONIC INELASTIC PHYSICS LIST HAS BEEN ACTIVATED: G4IonBinaryCascadePhysics()" << G4endl;
} else if (name == "radioactive_decay" && !radioactiveDecayIsRegisted ) {
hadronPhys.push_back(new G4RadioactiveDecayPhysics());
radioactiveDecayIsRegisted = true;
G4cout << "THE FOLLOWING HADRONIC INELASTIC PHYSICS LIST HAS BEEN ACTIVATED: G4RadioactiveDecayPhysics()" << G4endl;
} else {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
<< " is not defined"
<< G4endl;
}
}
void PhysicsList::AddStepMax()
{
// Step limitation seen as a process
auto particleIterator=GetParticleIterator();
particleIterator->reset();
while ((*particleIterator)())
{
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
pmanager -> AddProcess(new G4StepLimiter(), -1,-1,3);
}
}
void PhysicsList::SetCutForGamma(G4double cut)
{
cutForGamma = cut;
SetParticleCuts(cutForGamma, G4Gamma::Gamma());
}
void PhysicsList::SetCutForElectron(G4double cut)
{
cutForElectron = cut;
SetParticleCuts(cutForElectron, G4Electron::Electron());
}
void PhysicsList::SetCutForPositron(G4double cut)
{
cutForPositron = cut;
SetParticleCuts(cutForPositron, G4Positron::Positron());
}
@@ -0,0 +1,121 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
// Code based on the hadrontherapy advanced example
#include "PhysicsListMessenger.hh"
#include "PhysicsList.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
/////////////////////////////////////////////////////////////////////////////
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:pPhysicsList(pPhys)
{
physDir = new G4UIdirectory("/physic/");
physDir->SetGuidance("Commands to activate physics models and set cuts");
gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setGCut",this);
gammaCutCmd->SetGuidance("Set gamma cut.");
gammaCutCmd->SetParameterName("Gcut",false);
gammaCutCmd->SetUnitCategory("Length");
gammaCutCmd->SetRange("Gcut>0.0");
gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
electCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setECut",this);
electCutCmd->SetGuidance("Set electron cut.");
electCutCmd->SetParameterName("Ecut",false);
electCutCmd->SetUnitCategory("Length");
electCutCmd->SetRange("Ecut>0.0");
electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
protoCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setPCut",this);
protoCutCmd->SetGuidance("Set positron cut.");
protoCutCmd->SetParameterName("Pcut",false);
protoCutCmd->SetUnitCategory("Length");
protoCutCmd->SetRange("Pcut>0.0");
protoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
allCutCmd = new G4UIcmdWithADoubleAndUnit("/physic/setCuts",this);
allCutCmd->SetGuidance("Set cut for all.");
allCutCmd->SetParameterName("cut",false);
allCutCmd->SetUnitCategory("Length");
allCutCmd->SetRange("cut>0.0");
allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
pListCmd = new G4UIcmdWithAString("/physic/addPhysics",this);
pListCmd->SetGuidance("Add physics list.");
pListCmd->SetParameterName("PList",false);
pListCmd->AvailableForStates(G4State_PreInit);
packageListCmd = new G4UIcmdWithAString("/physic/addPackage",this);
packageListCmd->SetGuidance("Add physics package.");
packageListCmd->SetParameterName("package",false);
packageListCmd->AvailableForStates(G4State_PreInit);
}
PhysicsListMessenger::~PhysicsListMessenger()
{
delete gammaCutCmd;
delete electCutCmd;
delete protoCutCmd;
delete allCutCmd;
delete pListCmd;
delete physDir;
delete packageListCmd;
}
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if( command == gammaCutCmd )
{ pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));}
if( command == electCutCmd )
{ pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));}
if( command == protoCutCmd )
{ pPhysicsList->SetCutForPositron(protoCutCmd->GetNewDoubleValue(newValue));}
if( command == allCutCmd )
{
G4double cut = allCutCmd->GetNewDoubleValue(newValue);
pPhysicsList->SetCutForGamma(cut);
pPhysicsList->SetCutForElectron(cut);
pPhysicsList->SetCutForPositron(cut);
}
if( command == pListCmd )
{ pPhysicsList->AddPhysicsList(newValue);}
if( command == packageListCmd )
{ pPhysicsList->AddPackage(newValue);}
}
@@ -0,0 +1,56 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
#include "PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4GeneralParticleSource.hh"
PrimaryGeneratorAction::PrimaryGeneratorAction(AnalysisManager* pAnalysis)
{
gun = new G4GeneralParticleSource();
analysis = pAnalysis;
}
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete gun;
}
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
gun -> GeneratePrimaryVertex(anEvent);
#ifdef ANALYSIS_USE
G4double energy = gun -> GetParticleEnergy();
analysis -> SetPrimaryEnergy(energy);
#endif
}
@@ -0,0 +1,96 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
#include "RunAction.hh"
#include "AnalysisManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4ios.hh"
#include "G4Run.hh"
#ifdef ANALYSIS_USE
RunAction::RunAction(AnalysisManager* analysis, DetectorMessenger* detector)
{
analysisMan = analysis;
detectorMess = detector;
}
#else
RunAction::RunAction(DetectorMessenger* detector)
{
detectorMess = detector;
}
#endif
RunAction::~RunAction()
{ }
void RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4int run_number = aRun->GetRunID();
G4cout << "### Run " << run_number << " start." << G4endl;
#ifdef ANALYSIS_USE
G4bool additionalOutput;
G4String detectorType = detectorMess -> GetDetectorType();
if( detectorType == "DiamondTelescope" ) additionalOutput = true;
else additionalOutput = false;
// Create ROOT file, histograms and ntuple
analysisMan -> book(additionalOutput);
#else
G4cout << "Output to file disabled: no file will be generated. "
<< "To enable it, re-run cmake with the -DWITH_ANALYSIS_USE=ON flag." << G4endl;
#endif
// check if there are pending changes in the geometry
if( detectorMess -> AreTherePendingChanges() )
{
G4cout << "WARNING: pending changes to the geometry found during BeginOfRunAction. "
<< "These will be ignored during the current run. "
<< "Use /geometrySetup/applyChanges if you want to apply them in your next run." << G4endl;
}
// print the current geometry setup
G4cout << "Simulating the " << detectorMess->GetDetectorType() << " detector "
<< "with dimensions: " << detectorMess->GetDetectorSizeWidth()/um << " um width, "
<< detectorMess->GetDetectorSizeThickness()/um << " um thickness." << G4endl;
}
void RunAction::EndOfRunAction(const G4Run* aRun)
{
G4cout << "Number of events = " << aRun->GetNumberOfEvent() << G4endl;
#ifdef ANALYSIS_USE
// Close the output ROOT file with the results
analysisMan -> finish();
#endif
}
@@ -0,0 +1,138 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
// code based on the basic example B2
//
#include "SensitiveDetector.hh"
#include "G4HCofThisEvent.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
#include "G4RunManager.hh"
SensitiveDetector::SensitiveDetector(const G4String& name,
const G4String& hitsCollectionName,
G4bool isThisAMicrodosimeter,
AnalysisManager* analysis_manager)
: G4VSensitiveDetector(name),
fHitsCollection(NULL)
{
collectionName.insert(hitsCollectionName);
analysis = analysis_manager;
isMicrod = isThisAMicrodosimeter; // only false for the E-stage of the telescope
}
SensitiveDetector::~SensitiveDetector()
{}
void SensitiveDetector::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new SensitiveDetectorHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
}
G4bool SensitiveDetector::ProcessHits(G4Step* aStep,
G4TouchableHistory*)
{
// energy deposit
G4double edep = aStep->GetTotalEnergyDeposit();
if (edep==0.) return false;
// Uncomment the following lines to only score specific physical volumes
/*
G4String volumeName = aStep -> GetPreStepPoint() -> GetPhysicalVolume()-> GetName();
if(volumeName != "SV_phys1" && volumeName != "sen_bridge" && volumeName != "physSensitiveBridgeVolume" )
return false;
*/
SensitiveDetectorHit* newHit = new SensitiveDetectorHit();
newHit -> SetEdep(edep);
// step length
G4double len = aStep->GetStepLength();
// only consider ions, protons, and neutrons for path length
const G4ParticleDefinition* thisParticle = aStep ->
GetTrack() -> GetParticleDefinition() ;
G4String particleName = thisParticle -> GetParticleName();
G4int particleZ = thisParticle -> GetAtomicNumber();
if ( (particleZ < 1) && (particleName != "neutron"))
len = 0.;
newHit->SetPath(len);
fHitsCollection -> insert( newHit );
return true;
}
void SensitiveDetector::EndOfEvent(G4HCofThisEvent*)
{
#ifdef ANALYSIS_USE
// Initialisation of total energy deposition per event to zero
G4double totalEdepInOneEvent=0;
G4double totalPathLengthInOneEvent=0;
G4int NbHits = fHitsCollection->entries();
//G4cout << "number of hits " <<NbHits << G4endl;
G4double edep, len;
for (G4int i=0;i<NbHits;i++)
{
edep = (*fHitsCollection)[i]->GetEdep();
totalEdepInOneEvent = totalEdepInOneEvent + edep;
len = (*fHitsCollection)[i]->GetPath();
totalPathLengthInOneEvent = totalPathLengthInOneEvent + len;
}
G4int eventID = G4RunManager::GetRunManager() ->
GetCurrentEvent() -> GetEventID();
if (totalEdepInOneEvent!=0)
{
if (isMicrod==true) analysis -> StoreEnergyDeposition(totalEdepInOneEvent/keV, totalPathLengthInOneEvent/um, eventID);
else analysis -> StoreSecondStageEnergyDeposition(totalEdepInOneEvent/keV, eventID);
}
#endif
}
@@ -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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
// Code based on basic example B02
//
#include "SensitiveDetectorHit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4VisAttributes.hh"
#include <iomanip>
// THIS IS NECESSARY FOR MT MODE
G4ThreadLocal G4Allocator<SensitiveDetectorHit>* SensitiveDetectorHitAllocator=0;
SensitiveDetectorHit::SensitiveDetectorHit()
: G4VHit(),
fEdep(0.), fPath(0.)
{}
SensitiveDetectorHit::~SensitiveDetectorHit() {}
SensitiveDetectorHit::SensitiveDetectorHit(const SensitiveDetectorHit& right)
: G4VHit()
{
fEdep = right.fEdep;
fPath = right.fPath;
}
const SensitiveDetectorHit& SensitiveDetectorHit::operator=(const SensitiveDetectorHit& right)
{
fEdep = right.fEdep;
fPath = right.fPath;
return *this;
}
G4bool SensitiveDetectorHit::operator==(const SensitiveDetectorHit& right) const
{
return ( this == &right ) ? true : false;
}
void SensitiveDetectorHit::Draw()
{
}
void SensitiveDetectorHit::Print()
{
G4cout
<< "HIT: Edep: "
<< std::setw(7) << G4BestUnit(fEdep,"Energy")
<< "HIT: Path: "
<< std::setw(7) << G4BestUnit(fPath,"Length")
<< G4endl;
}
@@ -0,0 +1,91 @@
//
// ********************************************************************
// * 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: Susanna Guatelli and Francesco Romano
// susanna@uow.edu.au, francesco.romano@ct.infn.it
//
#include "G4ios.hh"
#include "G4SteppingManager.hh"
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4StepPoint.hh"
#include "G4VPhysicalVolume.hh"
#include "SteppingAction.hh"
#include "AnalysisManager.hh"
#include "G4SystemOfUnits.hh"
SteppingAction::SteppingAction(AnalysisManager* pAnalysis)
{
analysis = pAnalysis;
fSecondary = 0;
}
SteppingAction::~SteppingAction()
{
}
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
G4SteppingManager* steppingManager = fpSteppingManager;
G4Track* theTrack = aStep -> GetTrack();
// check if it is alive
if(theTrack-> GetTrackStatus() == fAlive) { return; }
// Retrieve the secondary particles
fSecondary = steppingManager -> GetfSecondary();
#ifdef ANALYSIS_USE
for(size_t lp1=0;lp1<(*fSecondary).size(); lp1++)
{
// Retrieve the info about the generation of secondary particles
G4String volumeName = (*fSecondary)[lp1] -> GetVolume() -> GetName(); // volume where secondary was generated
G4String secondaryParticleName = (*fSecondary)[lp1]->GetDefinition() -> GetParticleName(); // name of the secondary
G4double secondaryParticleKineticEnergy = (*fSecondary)[lp1] -> GetKineticEnergy(); // kinetic energy
// G4String process = (*fSecondary)[lp1]-> GetCreatorProcess()-> GetProcessName(); // process creating it
G4double charge = (*fSecondary)[lp1] -> GetDynamicParticle() -> GetDefinition() -> GetPDGCharge();
G4int AA = (*fSecondary)[lp1] -> GetDynamicParticle() -> GetDefinition() -> GetBaryonNumber();
if (G4StrUtil::contains(volumeName, "SV_phys") || volumeName == "sen_bridge" || volumeName == "physSensitiveBridgeVolume")
//Testing with larger volume!
//if (volumeName == "DiaVol_phys")
{
// G4cout << "Particle in = " << volumeName << G4endl;
if ((secondaryParticleName == "proton") ||
(secondaryParticleName == "neutron")||
(secondaryParticleName == "alpha") ||
(secondaryParticleName == "deuton") ||
(secondaryParticleName == "triton") ||
(secondaryParticleName == "He3") ||
(secondaryParticleName =="GenericIon"))
analysis -> FillSecondaries(AA, charge, secondaryParticleKineticEnergy/MeV);
}
}
#endif
}