Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
@@ -0,0 +1,75 @@
//
// ********************************************************************
// * 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 ActionInitialization.cc
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "TrackingAction.hh"
#include "SteppingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(DetectorConstruction* det)
: G4VUserActionInitialization(),fDetector(det)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::~ActionInitialization()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
SetUserAction(new RunAction(fDetector));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
PrimaryGeneratorAction* prim = new PrimaryGeneratorAction(fDetector);
SetUserAction(prim);
RunAction* run = new RunAction(fDetector,prim);
SetUserAction(run);
EventAction* event = new EventAction(fDetector);
SetUserAction(event);
SetUserAction(new TrackingAction(fDetector));
SetUserAction(new SteppingAction(fDetector,event));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,500 @@
//
// ********************************************************************
// * 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 DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4NistManager.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4SolidStore.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4PhysicalConstants.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:G4VUserDetectorConstruction(),
fWorldMaterial(nullptr),fSolidWorld(nullptr),fLogicWorld(nullptr),
fPhysiWorld(nullptr),fSolidCalor(nullptr),fLogicCalor(nullptr),
fPhysiCalor(nullptr),fSolidLayer(nullptr),fLogicLayer(nullptr),
fPhysiLayer(nullptr)
{
for(G4int i=0; i<kMaxAbsor; ++i) {
fAbsorMaterial[i] = nullptr;
fAbsorThickness[i] = 0.0;
fSolidAbsor[i] = nullptr;
fLogicAbsor[i] = nullptr;
fPhysiAbsor[i] = nullptr;
}
// default parameter values of the calorimeter
fNbOfAbsor = 2;
fAbsorThickness[1] = 36*mm;
fAbsorThickness[2] = 4*mm;
fNbOfLayers = 50;
fCalorSizeYZ = 1.5*m;
ComputeCalorParameters();
// materials
DefineMaterials();
SetWorldMaterial("Galactic");
SetAbsorMaterial(1,"Iron");
SetAbsorMaterial(2,"Scintillator");
// create commands for interactive definition of the calorimeter
fDetectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{
delete fDetectorMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineMaterials()
{
// This function illustrates the possible ways to define materials using
// G4 database on G4Elements
G4NistManager* manager = G4NistManager::Instance();
manager->SetVerbose(0);
//
// define Elements
//
G4Element* H = manager->FindOrBuildElement(1);
G4Element* C = manager->FindOrBuildElement(6);
G4Element* O = manager->FindOrBuildElement(8);
//
// define an Element from isotopes, by relative abundance
//
G4int iz, n; //iz=number of protons in an isotope;
// n=number of nucleons in an isotope;
G4int ncomponents;
G4double z, a;
G4double abundance;
G4Isotope* U5 = new G4Isotope("U235", iz=92, n=235, a=235.01*g/mole);
G4Isotope* U8 = new G4Isotope("U238", iz=92, n=238, a=238.03*g/mole);
G4Element* U = new G4Element("enriched Uranium", "U", ncomponents=2);
U->AddIsotope(U5, abundance= 90.*perCent);
U->AddIsotope(U8, abundance= 10.*perCent);
//
// define simple materials
//
G4double density;
new G4Material("liquidH2", z=1., a= 1.008*g/mole, density= 70.8*mg/cm3);
new G4Material("Aluminium", z=13., a= 26.98*g/mole, density= 2.700*g/cm3);
new G4Material("liquidArgon", z=18, a= 39.948*g/mole, density= 1.396*g/cm3);
new G4Material("Titanium", z=22., a= 47.867*g/mole, density= 4.54*g/cm3);
new G4Material("Iron", z=26., a= 55.85*g/mole, density= 7.870*g/cm3);
new G4Material("Copper", z=29., a= 63.55*g/mole, density= 8.960*g/cm3);
new G4Material("Tungsten", z=74., a= 183.85*g/mole, density= 19.30*g/cm3);
new G4Material("Gold", z=79., a= 196.97*g/mole, density= 19.32*g/cm3);
new G4Material("Lead", z=82., a= 207.20*g/mole, density= 11.35*g/cm3);
new G4Material("Uranium", z=92., a= 238.03*g/mole, density= 18.95*g/cm3);
//
// define a material from elements. case 1: chemical molecule
//
G4int natoms;
G4Material* H2O =
new G4Material("Water", density= 1.000*g/cm3, ncomponents=2);
H2O->AddElement(H, natoms=2);
H2O->AddElement(O, natoms=1);
H2O->GetIonisation()->SetMeanExcitationEnergy(78.0*eV);
H2O->SetChemicalFormula("H_2O");
G4Material* CH =
new G4Material("Polystyrene", density= 1.032*g/cm3, ncomponents=2);
CH->AddElement(C, natoms=1);
CH->AddElement(H, natoms=1);
G4Material* Sci =
new G4Material("Scintillator", density= 1.032*g/cm3, ncomponents=2);
Sci->AddElement(C, natoms=9);
Sci->AddElement(H, natoms=10);
Sci->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
//
// examples of gas in non STP conditions
//
G4double temperature, pressure;
G4Material* CO2 =
new G4Material("CarbonicGas", density= 27.*mg/cm3, ncomponents=2,
kStateGas, temperature= 325.*kelvin, pressure= 50.*atmosphere);
CO2->AddElement(C, natoms=1);
CO2->AddElement(O, natoms=2);
new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
kStateGas, 273.15*kelvin, 1*atmosphere);
//
// example of vacuum
//
density = universe_mean_density; //from PhysicalConstants.h
pressure = 3.e-18*pascal;
temperature = 2.73*kelvin;
new G4Material("Galactic", z=1., a=1.008*g/mole, density,
kStateGas,temperature,pressure);
// G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Material* DetectorConstruction::MaterialWithSingleIsotope( G4String name,
G4String symbol, G4double density, G4int Z, G4int A)
{
// define a material from an isotope
//
G4int ncomponents;
G4double abundance, massfraction;
G4Isotope* isotope = new G4Isotope(symbol, Z, A);
G4Element* element = new G4Element(name, symbol, ncomponents=1);
element->AddIsotope(isotope, abundance= 100.*perCent);
G4Material* material = new G4Material(name, density, ncomponents=1);
material->AddElement(element, massfraction=100.*perCent);
return material;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::ComputeCalorParameters()
{
// Compute derived parameters of the calorimeter
fLayerThickness = 0.;
for (G4int iAbs=1; iAbs<=fNbOfAbsor; iAbs++) {
fLayerThickness += fAbsorThickness[iAbs];
}
fCalorThickness = fNbOfLayers*fLayerThickness;
fWorldSizeX = 1.2*fCalorThickness;
fWorldSizeYZ = 1.2*fCalorSizeYZ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct()
{
if(fPhysiWorld) { return fPhysiWorld; }
// complete the Calor parameters definition
ComputeCalorParameters();
//
// World
//
fSolidWorld = new G4Box("World", //its name
fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
fWorldMaterial, //its material
"World"); //its name
fPhysiWorld = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fLogicWorld, //its fLogical volume
"World", //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
//
// Calorimeter
//
fSolidCalor = new G4Box("Calorimeter",
fCalorThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
fLogicCalor = new G4LogicalVolume(fSolidCalor,
fWorldMaterial,
"Calorimeter");
fPhysiCalor = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fLogicCalor, //its fLogical volume
"Calorimeter", //its name
fLogicWorld, //its mother volume
false, //no boolean operation
0); //copy number
//
// Layers
//
fSolidLayer = new G4Box("Layer",
fLayerThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
fLogicLayer = new G4LogicalVolume(fSolidLayer,
fWorldMaterial,
"Layer");
if (fNbOfLayers > 1) {
fPhysiLayer = new G4PVReplica("Layer",
fLogicLayer,
fLogicCalor,
kXAxis,
fNbOfLayers,
fLayerThickness);
} else {
fPhysiLayer = new G4PVPlacement(0,
G4ThreeVector(),
fLogicLayer,
"Layer",
fLogicCalor,
false,
0);
}
//
// Absorbers
//
G4double xfront = -0.5*fLayerThickness;
for (G4int k=1; k<=fNbOfAbsor; ++k) {
fSolidAbsor[k] = new G4Box("Absorber", //its name
fAbsorThickness[k]/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
fLogicAbsor[k] = new G4LogicalVolume(fSolidAbsor[k], //its solid
fAbsorMaterial[k], //its material
fAbsorMaterial[k]->GetName());
G4double xcenter = xfront+0.5*fAbsorThickness[k];
xfront += fAbsorThickness[k];
fPhysiAbsor[k] = new G4PVPlacement(0,
G4ThreeVector(xcenter,0.,0.),
fLogicAbsor[k],
fAbsorMaterial[k]->GetName(),
fLogicLayer,
false,
k); //copy number
}
PrintCalorParameters();
//always return the fPhysical World
//
return fPhysiWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PrintCalorParameters()
{
G4int prec = 4, wid = prec + 2;
G4int dfprec = G4cout.precision(prec);
G4double totLength(0.), totRadl(0.), totNuclear(0.);
G4cout << "\n-------------------------------------------------------------"
<< "\n ---> The calorimeter is " << fNbOfLayers << " layers of:";
for (G4int i=1; i<=fNbOfAbsor; ++i) {
G4Material* material = fAbsorMaterial[i];
G4double radl = material->GetRadlen();
G4double nuclearl = material->GetNuclearInterLength();
G4double sumThickness = fNbOfLayers*fAbsorThickness[i];
G4double nbRadl = sumThickness/radl;
G4double nbNuclearl = sumThickness/nuclearl;
totLength += sumThickness;
totRadl += nbRadl;
totNuclear += nbNuclearl;
G4cout << "\n " << std::setw(12) << fAbsorMaterial[i]->GetName() <<": "
<< std::setw(wid) << G4BestUnit(fAbsorThickness[i],"Length")
<< " ---> sum = " << std::setw(wid) << G4BestUnit(sumThickness,"Length")
<< " = " << std::setw(wid) << nbRadl << " Radl "
<< " = " << std::setw(wid) << nbNuclearl << " NuclearInteractionLength " ;
}
G4cout << "\n\n total thickness = "
<< std::setw(wid) << G4BestUnit(totLength,"Length")
<< " = " << std::setw(wid)<< totRadl << " Radl "
<< " = " << std::setw(wid)<< totNuclear << " NuclearInteractionLength "
<< G4endl;
G4cout << " transverse sizeYZ = "
<< std::setw(wid) << G4BestUnit(fCalorSizeYZ,"Length")
<< G4endl;
G4cout << "-------------------------------------------------------------\n";
G4cout << "\n" << fWorldMaterial << G4endl;
for (G4int j=1; j<=fNbOfAbsor; ++j) {
G4cout << "\n" << fAbsorMaterial[j] << G4endl;
}
G4cout << "\n-------------------------------------------------------------\n";
//restore default format
G4cout.precision(dfprec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldMaterial(const G4String& material)
{
// search the material by its name
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(material);
if(pttoMaterial) {
fWorldMaterial = pttoMaterial;
if(fLogicWorld) {
fLogicWorld->SetMaterial(fWorldMaterial);
fLogicLayer->SetMaterial(fWorldMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetNbOfLayers(G4int ival)
{
// set the number of Layers
//
if (ival < 1)
{ G4cout << "\n --->warning from SetfNbOfLayers: "
<< ival << " must be at least 1. Command refused" << G4endl;
return;
}
fNbOfLayers = ival;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetNbOfAbsor(G4int ival)
{
// set the number of Absorbers
//
if (ival < 1 || ival > (kMaxAbsor-1))
{ G4cout << "\n ---> warning from SetfNbOfAbsor: "
<< ival << " must be at least 1 and and most " << kMaxAbsor-1
<< ". Command refused" << G4endl;
return;
}
fNbOfAbsor = ival;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetAbsorMaterial(G4int ival,
const G4String& material)
{
// search the material by its name
//
if (ival > fNbOfAbsor || ival <= 0)
{ G4cout << "\n --->warning from SetAbsorMaterial: absor number "
<< ival << " out of range. Command refused" << G4endl;
return;
}
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(material);
if (pttoMaterial) {
fAbsorMaterial[ival] = pttoMaterial;
if(fLogicAbsor[ival]) {
fLogicAbsor[ival]->SetMaterial(pttoMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetAbsorThickness(G4int ival, G4double val)
{
// change Absorber thickness
//
if (ival > fNbOfAbsor || ival <= 0)
{ G4cout << "\n --->warning from SetAbsorThickness: absor number "
<< ival << " out of range. Command refused" << G4endl;
return;
}
if (val <= DBL_MIN)
{ G4cout << "\n --->warning from SetAbsorThickness: thickness "
<< val << " out of range. Command refused" << G4endl;
return;
}
fAbsorThickness[ival] = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetCalorSizeYZ(G4double val)
{
// change the transverse size
//
if (val <= DBL_MIN)
{ G4cout << "\n --->warning from SetfCalorSizeYZ: thickness "
<< val << " out of range. Command refused" << G4endl;
return;
}
fCalorSizeYZ = val;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
void DetectorConstruction::ConstructSDandField()
{
if ( fFieldMessenger.Get() == nullptr ) {
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
// the field value is not zero.
G4ThreeVector fieldValue = G4ThreeVector();
G4GlobalMagFieldMessenger* msg =
new G4GlobalMagFieldMessenger(fieldValue);
//msg->SetVerboseLevel(1);
G4AutoDelete::Register(msg);
fFieldMessenger.Put( msg );
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,195 @@
//
// ********************************************************************
// * 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 DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorMessenger.hh"
#include <sstream>
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:G4UImessenger(),fDetector(Det),
fTestemDir(nullptr),
fDetDir(nullptr),
fSizeYZCmd(nullptr),
fNbLayersCmd(nullptr),
fNbAbsorCmd(nullptr),
fAbsorCmd(nullptr),
fIsotopeCmd(nullptr)
{
fTestemDir = new G4UIdirectory("/testhadr/");
fTestemDir->SetGuidance("UI commands specific to this example");
fDetDir = new G4UIdirectory("/testhadr/det/");
fDetDir->SetGuidance("detector construction commands");
fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSizeYZ",this);
fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
fSizeYZCmd->SetParameterName("Size",false);
fSizeYZCmd->SetRange("Size>0.");
fSizeYZCmd->SetUnitCategory("Length");
fSizeYZCmd->AvailableForStates(G4State_PreInit);
fSizeYZCmd->SetToBeBroadcasted(false);
fNbLayersCmd = new G4UIcmdWithAnInteger("/testhadr/det/setNbOfLayers",this);
fNbLayersCmd->SetGuidance("Set number of layers.");
fNbLayersCmd->SetParameterName("NbLayers",false);
fNbLayersCmd->SetRange("NbLayers>0");
fNbLayersCmd->AvailableForStates(G4State_PreInit);
fNbLayersCmd->SetToBeBroadcasted(false);
fNbAbsorCmd = new G4UIcmdWithAnInteger("/testhadr/det/setNbOfAbsor",this);
fNbAbsorCmd->SetGuidance("Set number of Absorbers.");
fNbAbsorCmd->SetParameterName("NbAbsor",false);
fNbAbsorCmd->SetRange("NbAbsor>0");
fNbAbsorCmd->AvailableForStates(G4State_PreInit);
fNbAbsorCmd->SetToBeBroadcasted(false);
fAbsorCmd = new G4UIcommand("/testhadr/det/setAbsor",this);
fAbsorCmd->SetGuidance("Set the absor nb, the material, the thickness.");
fAbsorCmd->SetGuidance(" absor number : from 1 to NbOfAbsor");
fAbsorCmd->SetGuidance(" material name");
fAbsorCmd->SetGuidance(" thickness (with unit) : t>0.");
//
G4UIparameter* AbsNbPrm = new G4UIparameter("AbsorNb",'i',false);
AbsNbPrm->SetGuidance("absor number : from 1 to NbOfAbsor");
AbsNbPrm->SetParameterRange("AbsorNb>0");
fAbsorCmd->SetParameter(AbsNbPrm);
//
G4UIparameter* MatPrm = new G4UIparameter("material",'s',false);
MatPrm->SetGuidance("material name");
fAbsorCmd->SetParameter(MatPrm);
//
G4UIparameter* ThickPrm = new G4UIparameter("thickness",'d',false);
ThickPrm->SetGuidance("thickness of absorber");
ThickPrm->SetParameterRange("thickness>0.");
fAbsorCmd->SetParameter(ThickPrm);
//
G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
unitPrm->SetGuidance("unit of thickness");
G4String unitList = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("mm"));
unitPrm->SetParameterCandidates(unitList);
fAbsorCmd->SetParameter(unitPrm);
//
fAbsorCmd->AvailableForStates(G4State_PreInit);
fAbsorCmd->SetToBeBroadcasted(false);
fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
//
G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
symbPrm->SetGuidance("isotope symbol");
fIsotopeCmd->SetParameter(symbPrm);
//
G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
ZPrm->SetGuidance("Z");
ZPrm->SetParameterRange("Z>0");
fIsotopeCmd->SetParameter(ZPrm);
//
G4UIparameter* APrm = new G4UIparameter("A",'i',false);
APrm->SetGuidance("A");
APrm->SetParameterRange("A>0");
fIsotopeCmd->SetParameter(APrm);
//
G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
densityPrm->SetGuidance("density of material");
densityPrm->SetParameterRange("density>0.");
fIsotopeCmd->SetParameter(densityPrm);
//
G4UIparameter* unitPrm1 = new G4UIparameter("unit",'s',false);
unitPrm1->SetGuidance("unit of density");
G4String unitList1 = G4UIcommand::UnitsList(G4UIcommand::CategoryOf("g/cm3"));
unitPrm1->SetParameterCandidates(unitList1);
fIsotopeCmd->SetParameter(unitPrm1);
//
fIsotopeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete fSizeYZCmd;
delete fNbLayersCmd;
delete fNbAbsorCmd;
delete fAbsorCmd;
delete fIsotopeCmd;
delete fDetDir;
delete fTestemDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
{
if( command == fSizeYZCmd )
{ fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));}
if( command == fNbLayersCmd )
{ fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));}
if( command == fNbAbsorCmd )
{ fDetector->SetNbOfAbsor(fNbAbsorCmd->GetNewIntValue(newValue));}
if (command == fAbsorCmd)
{
G4int num; G4double tick;
G4String unt, mat;
std::istringstream is(newValue);
is >> num >> mat >> tick >> unt;
G4String material=mat;
tick *= G4UIcommand::ValueOf(unt);
fDetector->SetAbsorMaterial (num,material);
fDetector->SetAbsorThickness(num,tick);
}
if (command == fIsotopeCmd)
{
G4int Z; G4int A; G4double dens;
G4String name, unt;
std::istringstream is(newValue);
is >> name >> Z >> A >> dens >> unt;
dens *= G4UIcommand::ValueOf(unt);
fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,171 @@
//
// ********************************************************************
// * 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 ElectromagneticPhysics.cc
/// \brief Implementation of the ElectromagneticPhysics class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "ElectromagneticPhysics.hh"
#include "G4BuilderType.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
#include "G4PhysicsListHelper.hh"
#include "G4ComptonScattering.hh"
#include "G4GammaConversion.hh"
#include "G4PhotoElectricEffect.hh"
#include "G4RayleighScattering.hh"
#include "G4eMultipleScattering.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
#include "G4MuMultipleScattering.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4hMultipleScattering.hh"
#include "G4hIonisation.hh"
#include "G4hBremsstrahlung.hh"
#include "G4hPairProduction.hh"
#include "G4ionIonisation.hh"
#include "G4IonParametrisedLossModel.hh"
#include "G4NuclearStopping.hh"
#include "G4LossTableManager.hh"
#include "G4UAtomicDeexcitation.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ElectromagneticPhysics::ElectromagneticPhysics(const G4String& name)
: G4VPhysicsConstructor(name)
{
SetPhysicsType(bElectromagnetic);
G4EmParameters* param = G4EmParameters::Instance();
param->SetDefaults();
param->SetStepFunction(0.2, 100*um);
param->SetStepFunctionMuHad(0.1, 10*um);
param->SetStepFunctionLightIons(0.1, 10*um);
param->SetStepFunctionIons(0.1, 1*um);
param->SetDeexcitationIgnoreCut(true);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ElectromagneticPhysics::~ElectromagneticPhysics()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ElectromagneticPhysics::ConstructProcess()
{
G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
// Add standard EM Processes
//
auto particleIterator=GetParticleIterator();
particleIterator->reset();
while( (*particleIterator)() ){
G4ParticleDefinition* particle = particleIterator->value();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
ph->RegisterProcess(new G4RayleighScattering, particle);
ph->RegisterProcess(new G4PhotoElectricEffect, particle);
ph->RegisterProcess(new G4ComptonScattering, particle);
ph->RegisterProcess(new G4GammaConversion, particle);
} else if (particleName == "e-") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
ph->RegisterProcess(new G4eIonisation, particle);
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
} else if (particleName == "e+") {
ph->RegisterProcess(new G4eMultipleScattering(), particle);
ph->RegisterProcess(new G4eIonisation, particle);
ph->RegisterProcess(new G4eBremsstrahlung(), particle);
ph->RegisterProcess(new G4eplusAnnihilation(), particle);
} else if (particleName == "mu+" ||
particleName == "mu-" ) {
ph->RegisterProcess(new G4MuMultipleScattering(), particle);
ph->RegisterProcess(new G4MuIonisation, particle);
ph->RegisterProcess(new G4MuBremsstrahlung(), particle);
ph->RegisterProcess(new G4MuPairProduction(), particle);
} else if( particleName == "proton" ||
particleName == "pi-" ||
particleName == "pi+" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hIonisation, particle);
} else if( particleName == "alpha" ||
particleName == "He3" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4ionIonisation, particle);
ph->RegisterProcess(new G4NuclearStopping(), particle);
} else if( particleName == "GenericIon" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
G4ionIonisation* ionIoni = new G4ionIonisation();
ionIoni->SetEmModel(new G4IonParametrisedLossModel());
ph->RegisterProcess(ionIoni, particle);
ph->RegisterProcess(new G4NuclearStopping(), particle);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hIonisation(), particle);
}
}
// Deexcitation
//
G4VAtomDeexcitation* de = new G4UAtomicDeexcitation();
G4LossTableManager::Instance()->SetAtomDeexcitation(de);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * 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 EventAction.cc
/// \brief Implementation of the EventAction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventAction.hh"
#include "Run.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
#include "G4Event.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction(DetectorConstruction* det)
:G4UserEventAction(),fDetector(det)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::~EventAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::BeginOfEventAction(const G4Event*)
{
//initialize EnergyDeposit per event
//
for (G4int k=0; k<kMaxAbsor; k++) {
fEnergyDeposit[k] = fTrackLengthCh[k] = 0.0;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::EndOfEventAction(const G4Event*)
{
//get Run
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
for (G4int k=1; k<=fDetector->GetNbOfAbsor(); k++) {
run->FillPerEvent(k,fEnergyDeposit[k],fTrackLengthCh[k]);
if (fEnergyDeposit[k] > 0.)
G4AnalysisManager::Instance()->FillH1(k, fEnergyDeposit[k]);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * 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 GammaNuclearPhysics.cc
/// \brief Implementation of the GammaNuclearPhysics class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "GammaNuclearPhysics.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
// Processes
#include "G4HadronInelasticProcess.hh"
#include "G4LowEGammaNuclearModel.hh"
#include "G4CascadeInterface.hh"
#include "G4PhotoNuclearCrossSection.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GammaNuclearPhysics::GammaNuclearPhysics(const G4String& name)
: G4VPhysicsConstructor(name)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GammaNuclearPhysics::~GammaNuclearPhysics()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GammaNuclearPhysics::ConstructProcess()
{
G4HadronInelasticProcess* process
= new G4HadronInelasticProcess("photonNuclear", G4Gamma::Definition());
process->AddDataSet( new G4PhotoNuclearCrossSection );
// to not register a model, set Emax=0; eg. Emax1 = 0.
const G4double Emax1 = 200*MeV, Emax2 = 10*GeV;
if (Emax1 > 0.) { // model 1
G4LowEGammaNuclearModel* model1 = new G4LowEGammaNuclearModel();
model1->SetMaxEnergy(Emax1);
process->RegisterMe(model1);
}
if (Emax2 > 0.) { // model 2
G4CascadeInterface* model2 = new G4CascadeInterface();
G4double Emin2 = std::max(Emax1-1*MeV, 0.);
model2->SetMinEnergy(Emin2);
model2->SetMaxEnergy(Emax2);
process->RegisterMe(model2);
}
G4ProcessManager* pManager = G4Gamma::Gamma()->GetProcessManager();
pManager->AddDiscreteProcess(process);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * 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 GammaNuclearPhysicsLEND.cc
/// \brief Implementation of the GammaNuclearPhysicsLEND class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "GammaNuclearPhysicsLEND.hh"
#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
// Processes
#include "G4HadronInelasticProcess.hh"
#include "G4LENDorBERTModel.hh"
#include "G4LENDCombinedCrossSection.hh"
#include "G4PhotoNuclearCrossSection.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GammaNuclearPhysicsLEND::GammaNuclearPhysicsLEND(const G4String& name)
: G4VPhysicsConstructor(name)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
GammaNuclearPhysicsLEND::~GammaNuclearPhysicsLEND()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void GammaNuclearPhysicsLEND::ConstructProcess()
{
G4ProcessManager* pManager = G4Gamma::Gamma()->GetProcessManager();
//
G4HadronInelasticProcess* process
= new G4HadronInelasticProcess("photonNuclear", G4Gamma::Definition());
process->AddDataSet( new G4PhotoNuclearCrossSection );
//
G4LENDorBERTModel* lend = new G4LENDorBERTModel(G4Gamma::Gamma());
lend->SetMaxEnergy(20*MeV);
process->RegisterMe(lend);
//
G4LENDCombinedCrossSection* lendXS =
new G4LENDCombinedCrossSection(G4Gamma::Gamma());
process->AddDataSet(lendXS);
//
pManager->AddDiscreteProcess(process);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,102 @@
//
// ********************************************************************
// * 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 HadronElasticPhysicsHP.cc
/// \brief Definition of the HadronElasticPhysicsHP class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
// HP models for neutron < 20 MeV
#include "HadronElasticPhysicsHP.hh"
#include "G4GenericMessenger.hh"
#include "G4HadronicProcess.hh"
#include "G4ParticleHPElastic.hh"
#include "G4ParticleHPElasticData.hh"
#include "G4ParticleHPThermalScattering.hh"
#include "G4ParticleHPThermalScatteringData.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HadronElasticPhysicsHP::HadronElasticPhysicsHP(G4int ver)
: G4HadronElasticPhysics(ver),
fMessenger(nullptr),fThermal(false)
{
// define commands for this class
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HadronElasticPhysicsHP::~HadronElasticPhysicsHP()
{
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HadronElasticPhysicsHP::ConstructProcess()
{
G4HadronElasticPhysics::ConstructProcess();
GetNeutronModel()->SetMinEnergy(19.5*MeV);
G4HadronicProcess* process = GetNeutronProcess();
G4ParticleHPElastic* model1 = new G4ParticleHPElastic();
process->RegisterMe(model1);
process->AddDataSet(new G4ParticleHPElasticData());
if (fThermal) {
model1->SetMinEnergy(4*eV);
G4ParticleHPThermalScattering* model2 = new G4ParticleHPThermalScattering();
process->RegisterMe(model2);
process->AddDataSet(new G4ParticleHPThermalScatteringData());
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HadronElasticPhysicsHP::DefineCommands()
{
// Define /testhadr/phys command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/testhadr/phys/",
"physics list commands");
// thermal scattering command
auto& thermalCmd
= fMessenger->DeclareProperty("thermalScattering", fThermal);
thermalCmd.SetGuidance("set thermal scattering model");
thermalCmd.SetParameterName("thermal", false);
thermalCmd.SetDefaultValue("false");
thermalCmd.SetStates(G4State_PreInit);
}
//..oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -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. *
// ********************************************************************
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoManager.hh"
#include "G4UnitsTable.hh"
#include "DetectorConstruction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
: fFileName("Hadr05")
{
Book();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::Book()
{
// Create or get analysis manager
// The choice of analysis technology is done via selection of a namespace
// in HistoManager.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->SetDefaultFileType("root");
analysisManager->SetFileName(fFileName);
analysisManager->SetVerboseLevel(1);
analysisManager->SetActivation(true); // enable inactivation of histograms
// Define histograms start values
const G4String id[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10","11","12","13","14","15","16","17","18","19",
"20","21"};
G4String title;
// Default values (to be reset via /analysis/h1/set command)
G4int nbins = 100;
G4double vmin = 0.;
G4double vmax = 100.;
// Create all histograms as inactivated
// as we have not yet set nbins, vmin, vmax
for (G4int k=0; k<kMaxHisto; k++) {
if (k < kMaxAbsor) title = "Edep in absorber " + id[k];
if (k > kMaxAbsor) title = "Edep longit. profile (MeV/event) in absorber "
+ id[k-kMaxAbsor];
if (k == 2*kMaxAbsor+1) title = "energy flow (MeV/event)";
G4int ih = analysisManager->CreateH1(id[k], title, nbins, vmin, vmax);
analysisManager->SetH1Activation(ih, false);
}
}
@@ -0,0 +1,122 @@
//
// ********************************************************************
// * 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 PhysicsList.cc
/// \brief Implementation of the PhysicsList class
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsList.hh"
#include "G4SystemOfUnits.hh"
#include "G4HadronElasticPhysicsXS.hh"
#include "HadronElasticPhysicsHP.hh"
#include "G4HadronPhysicsFTFP_BERT_HP.hh"
#include "G4HadronPhysicsQGSP_BIC_HP.hh"
#include "G4HadronPhysicsQGSP_BIC_AllHP.hh"
#include "G4HadronInelasticQBBC.hh"
#include "G4HadronPhysicsINCLXX.hh"
#include "G4IonElasticPhysics.hh"
#include "G4IonPhysicsXS.hh"
#include "G4IonINCLXXPhysics.hh"
#include "G4StoppingPhysics.hh"
#include "GammaNuclearPhysics.hh"
#include "GammaNuclearPhysicsLEND.hh"
///#include "G4EmExtraPhysics.hh"
#include "ElectromagneticPhysics.hh"
#include "G4EmStandardPhysics_option3.hh"
#include "G4DecayPhysics.hh"
#include "RadioactiveDecayPhysics.hh"
#include "G4RadioactiveDecayPhysics.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList()
:G4VModularPhysicsList()
{
G4int verb = 1;
SetVerboseLevel(verb);
// Hadron Elastic scattering
RegisterPhysics( new G4HadronElasticPhysicsXS(verb) );
///RegisterPhysics( new HadronElasticPhysicsHP(verb) );
// Hadron Inelastic Physics
RegisterPhysics( new G4HadronPhysicsFTFP_BERT(verb));
////RegisterPhysics( new G4HadronPhysicsQGSP_BIC(verb));
////RegisterPhysics( new G4HadronPhysicsQGSP_BIC_HP(verb));
////RegisterPhysics( new G4HadronPhysicsQGSP_BIC_AllHP(verb));
////RegisterPhysics( new G4HadronInelasticQBBC(verb));
////RegisterPhysics( new G4HadronPhysicsINCLXX(verb));
// Ion Elastic scattering
//
RegisterPhysics( new G4IonElasticPhysics(verb));
// Ion Inelastic physics
RegisterPhysics( new G4IonPhysicsXS(verb));
////RegisterPhysics( new G4IonINCLXXPhysics(verb));
// stopping Particles
RegisterPhysics( new G4StoppingPhysics(verb));
// Gamma-Nuclear Physics
RegisterPhysics( new GammaNuclearPhysics("gamma"));
////RegisterPhysics( new GammaNuclearPhysicsLEND("gamma"));
////RegisterPhysics( new G4EmExtraPhysics());
// EM physics
RegisterPhysics(new ElectromagneticPhysics());
////RegisterPhysics(new G4EmStandardPhysics_option3());
// Decay
RegisterPhysics(new G4DecayPhysics());
// Radioactive decay
RegisterPhysics(new RadioactiveDecayPhysics());
////RegisterPhysics(new G4RadioactiveDecayPhysics());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCuts()
{
SetCutValue(0*mm, "proton");
SetCutValue(1*mm, "e-");
SetCutValue(1*mm, "e+");
SetCutValue(1*mm, "gamma");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,137 @@
//
// ********************************************************************
// * 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 PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PrimaryGeneratorAction.hh"
#include "G4GenericMessenger.hh"
#include "DetectorConstruction.hh"
#include "HistoManager.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
:G4VUserPrimaryGeneratorAction(),
fParticleGun(nullptr),
fDetector(det),
fMessenger(nullptr),
fRndmBeam(0.)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
SetDefaultKinematic();
// define commands for this class
DefineCommands();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete fParticleGun;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::SetDefaultKinematic()
{
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle
= particleTable->FindParticle(particleName="proton");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
fParticleGun->SetParticleEnergy(5.*GeV);
G4double position = -0.5*(fDetector->GetWorldSizeX());
fParticleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
//
//randomize the beam, if requested.
if (fRndmBeam > 0.)
{
G4ThreeVector oldPosition = fParticleGun->GetParticlePosition();
G4double rbeam = 0.5*(fDetector->GetCalorSizeYZ())*fRndmBeam;
G4double x0 = oldPosition.x();
G4double y0 = oldPosition.y() + (2*G4UniformRand()-1.)*rbeam;
G4double z0 = oldPosition.z() + (2*G4UniformRand()-1.)*rbeam;
fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
fParticleGun->GeneratePrimaryVertex(anEvent);
fParticleGun->SetParticlePosition(oldPosition);
}
else fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::DefineCommands()
{
// Define /testhadr/gun command directory using generic messenger class
fMessenger = new G4GenericMessenger(this,
"/testhadr/gun/",
"gun control");
// default kinematic command
auto& defaultCmd
= fMessenger->DeclareMethod("setDefault",
&PrimaryGeneratorAction::SetDefaultKinematic,
"set/reset kinematic in PrimaryGenerator");
defaultCmd.SetStates(G4State_PreInit, G4State_Idle);
// randomize beam extension command
auto& rndmCmd
= fMessenger->DeclareProperty("rndm", fRndmBeam);
rndmCmd.SetGuidance("lateral size of the beam, in fraction of sizeYZ ");
rndmCmd.SetParameterName("rBeam", false);
rndmCmd.SetRange("rBeam>=0.&&rBeam<=1.");
rndmCmd.SetDefaultValue("0.");
rndmCmd.SetStates(G4State_Idle);
}
//..oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,106 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "RadioactiveDecayPhysics.hh"
#include "G4Radioactivation.hh"
#include "G4GenericIon.hh"
#include "G4PhysicsListHelper.hh"
#include "G4EmParameters.hh"
#include "G4VAtomDeexcitation.hh"
#include "G4UAtomicDeexcitation.hh"
#include "G4LossTableManager.hh"
#include "G4NuclearLevelData.hh"
#include "G4DeexPrecoParameters.hh"
#include "G4NuclideTable.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RadioactiveDecayPhysics::RadioactiveDecayPhysics(const G4String& name)
: G4VPhysicsConstructor(name)
{
// mandatory for G4NuclideTable
//
///G4NuclideTable::GetInstance()->SetThresholdOfHalfLife(0.1*picosecond);
///G4NuclideTable::GetInstance()->SetLevelTolerance(1.0*eV);
// hadronic physics extra configuration
//
G4DeexPrecoParameters* deex =
G4NuclearLevelData::GetInstance()->GetParameters();
deex->SetStoreICLevelData(true);
deex->SetMaxLifeTime(G4NuclideTable::GetInstance()->GetThresholdOfHalfLife()
/std::log(2.));
deex->SetIsomerProduction(true);
deex->SetCorrelatedGamma(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RadioactiveDecayPhysics::~RadioactiveDecayPhysics()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RadioactiveDecayPhysics::ConstructParticle()
{
G4GenericIon::GenericIon();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RadioactiveDecayPhysics::ConstructProcess()
{
G4Radioactivation* radioactiveDecay = new G4Radioactivation();
G4bool ARMflag = false;
radioactiveDecay->SetARM(ARMflag); //Atomic Rearangement
// EM physics extra configuration
// this physics constructor should be defined after EM constructor
G4EmParameters::Instance()->SetFluo(ARMflag);
G4EmParameters::Instance()->SetAugerCascade(ARMflag);
G4EmParameters::Instance()->SetDeexcitationIgnoreCut(ARMflag);
G4LossTableManager* man = G4LossTableManager::Instance();
G4VAtomDeexcitation* ad = man->AtomDeexcitation();
// EM physics constructors are not used
if( ad == nullptr ) {
ad = new G4UAtomicDeexcitation();
man->SetAtomDeexcitation(ad);
man->ResetParameters();
}
G4PhysicsListHelper::GetPhysicsListHelper()->
RegisterProcess(radioactiveDecay, G4GenericIon::GenericIon());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,288 @@
//
// ********************************************************************
// * 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 Run.cc
/// \brief Implementation of the Run class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Run.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "HistoManager.hh"
#include "G4ParticleDefinition.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::Run(DetectorConstruction* det)
: G4Run(),
fDetector(det),
fParticle(nullptr), fEkin(0.)
{
//initialize cumulative quantities
//
for (G4int k=0; k<kMaxAbsor; k++) {
fSumEAbs[k] = fSum2EAbs[k] = fSumLAbs[k] = fSum2LAbs[k] = 0.;
}
// initialize leakage
//
fEnergyLeak[0] = fEnergyLeak[1] = 0.;
//initialize Eflow
//
G4int nbPlanes = (fDetector->GetNbOfLayers())*(fDetector->GetNbOfAbsor()) + 2;
fEnergyFlow.resize(nbPlanes);
for (G4int k=0; k<nbPlanes; k++) {fEnergyFlow[k] = 0.; }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::~Run()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
{
fParticle = particle;
fEkin = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::CountProcesses(const G4VProcess* process)
{
if (process == nullptr) return;
G4String procName = process->GetProcessName();
std::map<G4String,G4int>::iterator it = fProcCounter.find(procName);
if ( it == fProcCounter.end()) {
fProcCounter[procName] = 1;
}
else {
fProcCounter[procName]++;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::FillPerEvent(G4int kAbs, G4double EAbs, G4double LAbs)
{
//accumulate statistic with restriction
//
fSumEAbs[kAbs] += EAbs; fSum2EAbs[kAbs] += EAbs*EAbs;
fSumLAbs[kAbs] += LAbs; fSum2LAbs[kAbs] += LAbs*LAbs;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::AddEnergyLeak(G4double eleak, G4int index)
{
fEnergyLeak[index] += eleak;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::SumEnergyFlow(G4int plane, G4double Eflow)
{
fEnergyFlow[plane] += Eflow;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::Merge(const G4Run* run)
{
const Run* localRun = static_cast<const Run*>(run);
// pass information about primary particle
fParticle = localRun->fParticle;
fEkin = localRun->fEkin;
// accumulate sums
//
for (G4int k=0; k<kMaxAbsor; k++) {
fSumEAbs[k] += localRun->fSumEAbs[k];
fSum2EAbs[k] += localRun->fSum2EAbs[k];
fSumLAbs[k] += localRun->fSumLAbs[k];
fSum2LAbs[k] += localRun->fSum2LAbs[k];
}
fEnergyLeak[0] += localRun->fEnergyLeak[0];
fEnergyLeak[1] += localRun->fEnergyLeak[1];
G4int nbPlanes = (fDetector->GetNbOfLayers())*(fDetector->GetNbOfAbsor()) + 2;
for (G4int k=0; k<nbPlanes; k++) {
fEnergyFlow[k] += localRun->fEnergyFlow[k];
}
//map: processes count
std::map<G4String,G4int>::const_iterator itp;
for ( itp = localRun->fProcCounter.begin();
itp != localRun->fProcCounter.end(); ++itp ) {
G4String procName = itp->first;
G4int localCount = itp->second;
if ( fProcCounter.find(procName) == fProcCounter.end()) {
fProcCounter[procName] = localCount;
}
else {
fProcCounter[procName] += localCount;
}
}
G4Run::Merge(run);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::EndOfRun()
{
//run condition
//
G4String Particle = fParticle->GetParticleName();
G4cout << "\n ---> The run is " << numberOfEvent << " "<< Particle << " of "
<< G4BestUnit(fEkin,"Energy") << " through calorimeter" << G4endl;
//frequency of processes
//
G4cout << "\n Process calls frequency :" << G4endl;
G4int index = 0;
std::map<G4String,G4int>::iterator it;
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++) {
G4String procName = it->first;
G4int count = it->second;
G4String space = " "; if (++index%3 == 0) space = "\n";
G4cout << " " << std::setw(22) << procName << "="<< std::setw(10) << count
<< space;
}
G4cout << G4endl;
G4int nEvt = numberOfEvent;
G4double norm = G4double(nEvt);
if(norm > 0) norm = 1./norm;
G4double qnorm = std::sqrt(norm);
//compute and print statistic
//
G4double beamEnergy = fEkin;
G4double sqbeam = std::sqrt(beamEnergy/GeV);
G4double MeanEAbs,MeanEAbs2,rmsEAbs,resolution,rmsres;
G4double MeanLAbs,MeanLAbs2,rmsLAbs;
G4double EdepTot = 0.;
std::ios::fmtflags mode = G4cout.flags();
G4int prec = G4cout.precision(2);
G4cout << "\n------------------------------------------------------------\n";
G4cout << std::setw(16) << "material"
<< std::setw(22) << "Edep rmsE"
<< std::setw(31) << "sqrt(E0(GeV))*rmsE/Edep"
<< std::setw(23) << "total tracklen \n \n";
for (G4int k=1; k<=fDetector->GetNbOfAbsor(); k++)
{
MeanEAbs = fSumEAbs[k]*norm;
MeanEAbs2 = fSum2EAbs[k]*norm;
rmsEAbs = std::sqrt(std::abs(MeanEAbs2 - MeanEAbs*MeanEAbs));
EdepTot += MeanEAbs;
resolution= 100.*sqbeam*rmsEAbs/MeanEAbs;
rmsres = resolution*qnorm;
MeanLAbs = fSumLAbs[k]*norm;
MeanLAbs2 = fSum2LAbs[k]*norm;
rmsLAbs = std::sqrt(std::abs(MeanLAbs2 - MeanLAbs*MeanLAbs));
//print
//
G4cout
<< std::setw(2) << k
<< std::setw(14) << fDetector->GetAbsorMaterial(k)->GetName()
<< std::setprecision(5)
<< std::setw(10) << G4BestUnit(MeanEAbs,"Energy")
<< std::setprecision(4)
<< std::setw(8) << G4BestUnit( rmsEAbs,"Energy")
<< std::setw(10) << resolution << " +- "
<< std::setprecision(3)
<< std::setw(5) << rmsres << " %"
<< std::setprecision(4)
<< std::setw(12) << G4BestUnit(MeanLAbs,"Length") << " +- "
<< std::setprecision(3)
<< std::setw(5) << G4BestUnit( rmsLAbs,"Length")
<< G4endl;
}
G4cout << "\n Total Edep = " << std::setprecision(4)
<< G4BestUnit(EdepTot,"Energy") << G4endl;
//Energy leakage
//
fEnergyLeak[0] /= nEvt;
fEnergyLeak[1] /= nEvt;
G4double EleakTot = fEnergyLeak[0] + fEnergyLeak[1];
G4cout << " Leakage : primary = "
<< G4BestUnit(fEnergyLeak[0],"Energy")
<< " secondaries = "
<< G4BestUnit(fEnergyLeak[1],"Energy")
<< " ---> total = " << G4BestUnit(EleakTot, "Energy") << G4endl;
G4cout << " Total energy released : Edep + Eleak = "
<< G4BestUnit(EdepTot + EleakTot,"Energy") << G4endl;
G4cout << "------------------------------------------------------------\n";
//Energy flow
//
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
G4int Idmax = (fDetector->GetNbOfLayers())*(fDetector->GetNbOfAbsor());
for (G4int Id=1; Id<=Idmax+1; Id++) {
analysis->FillH1(2*kMaxAbsor+1, (G4double)Id, fEnergyFlow[Id]);
}
//normalize histograms
//
for (G4int ih = kMaxAbsor+1; ih < kMaxHisto; ih++) {
analysis->ScaleH1(ih,norm/MeV);
}
//remove all contents in fProcCounter
fProcCounter.clear();
G4cout.setf(mode,std::ios::floatfield);
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,118 @@
//
// ********************************************************************
// * 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 RunAction.cc
/// \brief Implementation of the RunAction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "RunAction.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "HistoManager.hh"
#include "Run.hh"
#include "G4Timer.hh"
#include "G4RunManager.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim)
:G4UserRunAction(), fDetector(det), fPrimary(prim), fRun(nullptr),
fTimer(nullptr)
{
fHistoManager = new HistoManager();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Run* RunAction::GenerateRun()
{
fRun = new Run(fDetector);
return fRun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run*)
{
// keep run condition
if ( fPrimary ) {
G4ParticleDefinition* particle
= fPrimary->GetParticleGun()->GetParticleDefinition();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
fRun->SetPrimary(particle, energy);
}
//histograms
//
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
if (analysis->IsActive()) analysis->OpenFile();
// save Rndm status and open the timer
if (isMaster) {
// G4Random::showEngineStatus();
fTimer = new G4Timer();
fTimer->Start();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run*)
{
// compute and print statistic
if (isMaster) {
fTimer->Stop();
if(!((G4RunManager::GetRunManager()->GetRunManagerType() ==
G4RunManager::sequentialRM))) {
G4cout << "\n" << "Total number of events: "
<< fRun->GetNumberOfEvent() << G4endl;
G4cout << "Master thread time: " << *fTimer << G4endl;
}
delete fTimer;
fRun->EndOfRun();
}
//save histograms
G4AnalysisManager* analysis = G4AnalysisManager::Instance();
if (analysis->IsActive()) {
analysis->Write();
analysis->CloseFile();
}
// show Rndm status
// if (isMaster) G4Random::showEngineStatus();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,141 @@
//
// ********************************************************************
// * 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 SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingAction.hh"
#include "DetectorConstruction.hh"
#include "Run.hh"
#include "EventAction.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
:G4UserSteppingAction(),fDetector(det),fEventAct(evt)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::~SteppingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
//count processes
//
const G4StepPoint* prePoint = aStep->GetPreStepPoint();
const G4StepPoint* endPoint = aStep->GetPostStepPoint();
const G4VProcess* process = endPoint->GetProcessDefinedStep();
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
run->CountProcesses(process);
//if World, return
//
G4VPhysicalVolume* volume = prePoint->GetTouchableHandle()->GetVolume();
//if sum of absorbers do not fill exactly a layer: check material, not volume.
const G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
if (mat == fDetector->GetWorldMaterial()) return;
const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
//here we are in an absorber. Locate it
//
G4int absorNum = prePoint->GetTouchableHandle()->GetCopyNumber(0);
G4int layerNum = prePoint->GetTouchableHandle()->GetCopyNumber(1);
// collect energy deposit (taking into account track weight)
G4double edep = aStep->GetTotalEnergyDeposit();
////edep *= (aStep->GetTrack()->GetWeight());
// collect step length of charged particles
G4double stepl = 0.;
if (particle->GetPDGCharge() != 0.) stepl = aStep->GetStepLength();
// sum up per event
fEventAct->SumEnergy(absorNum,edep,stepl);
//longitudinal profile of edep per absorber
if (edep > 0.) {
G4AnalysisManager::Instance()->FillH1(kMaxAbsor+absorNum,
G4double(layerNum+1), edep);
}
//energy flow
//
// unique identificator of layer+absorber
G4int Idnow = (fDetector->GetNbOfAbsor())*layerNum + absorNum;
G4int plane;
//
//leaving the absorber ?
if (endPoint->GetStepStatus() == fGeomBoundary) {
G4ThreeVector position = endPoint->GetPosition();
G4ThreeVector direction = endPoint->GetMomentumDirection();
G4double Eflow = endPoint->GetKineticEnergy();
if (direction.x() >= 0.) run->SumEnergyFlow(plane=Idnow+1, Eflow);
else run->SumEnergyFlow(plane=Idnow, -Eflow);
}
//// example of Birk attenuation
///G4double destep = aStep->GetTotalEnergyDeposit();
///G4double response = BirksAttenuation(aStep);
///G4cout << " Destep: " << destep/keV << " keV"
/// << " response after Birks: " << response/keV << " keV" << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double SteppingAction::BirksAttenuation(const G4Step* aStep)
{
//Example of Birk attenuation law in organic scintillators.
//adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
//
G4Material* material = aStep->GetTrack()->GetMaterial();
G4double birk1 = material->GetIonisation()->GetBirksConstant();
G4double destep = aStep->GetTotalEnergyDeposit();
G4double stepl = aStep->GetStepLength();
G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
//
G4double response = destep;
if (birk1*destep*stepl*charge != 0.)
{
response = destep/(1. + birk1*destep/stepl);
}
return response;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,98 @@
//
// ********************************************************************
// * 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 TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "TrackingAction.hh"
#include "DetectorConstruction.hh"
#include "Run.hh"
#include "G4RunManager.hh"
#include "G4StepStatus.hh"
///#include "G4Positron.hh"
///#include "G4PhysicalConstants.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction(DetectorConstruction* det)
:G4UserTrackingAction(),fDetector(det)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PreUserTrackingAction(const G4Track* track )
{
//get Run
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
// Energy flow initialisation for primary particle
//
if (track->GetTrackID() == 1) {
G4int Idnow = 1;
if (track->GetVolume() != fDetector->GetphysiWorld()) {
// unique identificator of layer+absorber
const G4VTouchable* touchable = track->GetTouchable();
G4int absorNum = touchable->GetCopyNumber();
G4int layerNum = touchable->GetReplicaNumber(1);
Idnow = (fDetector->GetNbOfAbsor())*layerNum + absorNum;
}
G4double Eflow = track->GetKineticEnergy();
///if (track->GetDefinition() == G4Positron::Positron()) {
/// Eflow += 2*electron_mass_c2;
///}
//flux artefact, if primary vertex is inside the calorimeter
for (G4int pl=1; pl<=Idnow; ++pl) {run->SumEnergyFlow(pl, Eflow);}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
{
//get Run
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
// energy leakage
G4StepStatus status = aTrack->GetStep()->GetPostStepPoint()->GetStepStatus();
if (status == fWorldBoundary) {
G4int parentID = aTrack->GetParentID();
G4int index = 0; if (parentID > 0) index = 1; //primary=0, secondaries=1
G4double eleak = aTrack->GetKineticEnergy();
run->AddEnergyLeak(eleak,index);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......