Import Geant4 11.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2024-06-28 13:08:51 +02:00
parent f7b23877ed
commit e58e650b32
5232 changed files with 239416 additions and 244360 deletions
@@ -28,17 +28,16 @@
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "EventAction.hh"
#include "HistoManager.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "SteppingAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(DetectorConstruction* detector)
: fDetector(detector)
{}
ActionInitialization::ActionInitialization(DetectorConstruction* detector) : fDetector(detector) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -49,7 +48,7 @@ ActionInitialization::~ActionInitialization() = default;
void ActionInitialization::BuildForMaster() const
{
// Histo manager
auto histo = new HistoManager();
auto histo = new HistoManager();
// Actions
SetUserAction(new RunAction(histo));
@@ -60,19 +59,19 @@ void ActionInitialization::BuildForMaster() const
void ActionInitialization::Build() const
{
// Histo manager
auto histo = new HistoManager();
auto histo = new HistoManager();
// Actions
//
SetUserAction(new PrimaryGeneratorAction(fDetector));
auto runAction = new RunAction(histo);
auto runAction = new RunAction(histo);
SetUserAction(runAction);
auto eventAction = new EventAction(runAction, histo);
auto eventAction = new EventAction(runAction, histo);
SetUserAction(eventAction);
auto steppingAction = new SteppingAction(fDetector, eventAction);
auto steppingAction = new SteppingAction(fDetector, eventAction);
SetUserAction(steppingAction);
}
@@ -30,26 +30,24 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4Box.hh"
#include "G4Colour.hh"
#include "G4GeometryManager.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4StateManager.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4SolidStore.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SystemOfUnits.hh"
#include "G4RunManager.hh"
#include "G4SolidStore.hh"
#include "G4StateManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4VisAttributes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -113,114 +111,118 @@ G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
//
// World
//
fSolidWorld = new G4Box("World", //its name
fWorldSizeX/2,fWorldSizeYZ/2,fWorldSizeYZ/2); //its size
fSolidWorld = new G4Box("World", // its name
fWorldSizeX / 2, fWorldSizeYZ / 2, fWorldSizeYZ / 2); // its size
fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid
fDefaultMaterial, //its material
"World"); //its name
fLogicWorld = new G4LogicalVolume(fSolidWorld, // its solid
fDefaultMaterial, // its material
"World"); // its name
fPhysiWorld = new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(), //at (0,0,0)
fLogicWorld, //its logical volume
"World", //its name
nullptr, //its mother volume
false, //no boolean operation
0); //copy number
fPhysiWorld = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
fLogicWorld, // its logical volume
"World", // its name
nullptr, // its mother volume
false, // no boolean operation
0); // copy number
//
// Calorimeter
//
fSolidCalor = nullptr; fLogicCalor = nullptr; fPhysiCalor = nullptr;
fSolidLayer = nullptr; fLogicLayer = nullptr; fPhysiLayer = nullptr;
fSolidCalor = nullptr;
fLogicCalor = nullptr;
fPhysiCalor = nullptr;
fSolidLayer = nullptr;
fLogicLayer = nullptr;
fPhysiLayer = nullptr;
if (fCalorThickness > 0.) {
fSolidCalor = new G4Box("Calorimeter", //its name
fCalorThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); //size
if (fCalorThickness > 0.) {
fSolidCalor = new G4Box("Calorimeter", // its name
fCalorThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2); // size
fLogicCalor = new G4LogicalVolume(fSolidCalor, //its solid
fDefaultMaterial, //its material
"Calorimeter"); //its name
fLogicCalor = new G4LogicalVolume(fSolidCalor, // its solid
fDefaultMaterial, // its material
"Calorimeter"); // its name
fPhysiCalor = new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(), //at (0,0,0)
fLogicCalor, //its logical volume
"Calorimeter", //its name
fLogicWorld, //its mother volume
false, //no boolean operation
0); //copy number
fPhysiCalor = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
fLogicCalor, // its logical volume
"Calorimeter", // its name
fLogicWorld, // its mother volume
false, // no boolean operation
0); // copy number
//
// Layer
//
fSolidLayer = new G4Box("Layer", //its name
fLayerThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); //size
fSolidLayer = new G4Box("Layer", // its name
fLayerThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2); // size
fLogicLayer = new G4LogicalVolume(fSolidLayer, //its solid
fDefaultMaterial, //its material
"Layer"); //its name
fLogicLayer = new G4LogicalVolume(fSolidLayer, // its solid
fDefaultMaterial, // its material
"Layer"); // its name
if (fNbOfLayers > 1) {
fPhysiLayer = new G4PVReplica("Layer", //its name
fLogicLayer, //its logical volume
fLogicCalor, //its mother
kXAxis, //axis of replication
fNbOfLayers, //number of replica
fLayerThickness); //witdth of replica
fPhysiLayer = new G4PVReplica("Layer", // its name
fLogicLayer, // its logical volume
fLogicCalor, // its mother
kXAxis, // axis of replication
fNbOfLayers, // number of replica
fLayerThickness); // witdth of replica
}
else {
fPhysiLayer = new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(), //at (0,0,0)
fLogicLayer, //its logical volume
"Layer", //its name
fLogicCalor, //its mother volume
false, //no boolean operation
0); //copy number
fPhysiLayer = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(), // at (0,0,0)
fLogicLayer, // its logical volume
"Layer", // its name
fLogicCalor, // its mother volume
false, // no boolean operation
0); // copy number
}
}
//
// Absorber
//
fSolidAbsorber = nullptr; fLogicAbsorber = nullptr; fPhysiAbsorber = nullptr;
fSolidAbsorber = nullptr;
fLogicAbsorber = nullptr;
fPhysiAbsorber = nullptr;
if (fAbsorberThickness > 0.) {
fSolidAbsorber = new G4Box("Absorber", //its name
fAbsorberThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2); //size
fSolidAbsorber = new G4Box("Absorber", // its name
fAbsorberThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2); // size
fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, //its solid
fAbsorberMaterial, //its material
fAbsorberMaterial->GetName()); //name
fPhysiAbsorber = new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(-fGapThickness/2,0.,0.), //its position
fLogicAbsorber, //its logical volume
fAbsorberMaterial->GetName(), //its name
fLogicLayer, //its mother
false, //no boulean operat
0); //copy number
fLogicAbsorber = new G4LogicalVolume(fSolidAbsorber, // its solid
fAbsorberMaterial, // its material
fAbsorberMaterial->GetName()); // name
fPhysiAbsorber = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(-fGapThickness / 2, 0., 0.), // its position
fLogicAbsorber, // its logical volume
fAbsorberMaterial->GetName(), // its name
fLogicLayer, // its mother
false, // no boulean operat
0); // copy number
}
//
// Gap
//
fSolidGap = nullptr; fLogicGap = nullptr; fPhysiGap = nullptr;
fSolidGap = nullptr;
fLogicGap = nullptr;
fPhysiGap = nullptr;
if (fGapThickness > 0.) {
fSolidGap = new G4Box("Gap",
fGapThickness/2,fCalorSizeYZ/2,fCalorSizeYZ/2);
fSolidGap = new G4Box("Gap", fGapThickness / 2, fCalorSizeYZ / 2, fCalorSizeYZ / 2);
fLogicGap = new G4LogicalVolume(fSolidGap,
fGapMaterial,
fGapMaterial->GetName());
fLogicGap = new G4LogicalVolume(fSolidGap, fGapMaterial, fGapMaterial->GetName());
fPhysiGap = new G4PVPlacement(nullptr, //no rotation
G4ThreeVector(fAbsorberThickness/2,0.,0.), //its position
fLogicGap, //its logical volume
fGapMaterial->GetName(), //its name
fLogicLayer, //its mother
false, //no boulean operat
0); //copy number
fPhysiGap = new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(fAbsorberThickness / 2, 0., 0.), // its position
fLogicGap, // its logical volume
fGapMaterial->GetName(), // its name
fLogicLayer, // its mother
false, // no boulean operat
0); // copy number
}
PrintCalorParameters();
@@ -228,14 +230,14 @@ G4VPhysicalVolume* DetectorConstruction::ConstructCalorimeter()
//
// Visualization attributes
//
fLogicWorld->SetVisAttributes (G4VisAttributes::GetInvisible());
fLogicWorld->SetVisAttributes(G4VisAttributes::GetInvisible());
auto simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
auto simpleBoxVisAtt = new G4VisAttributes(G4Colour(1.0, 1.0, 1.0));
simpleBoxVisAtt->SetVisibility(true);
fLogicCalor->SetVisAttributes(simpleBoxVisAtt);
//
//always return the physical World
// always return the physical World
//
return fPhysiWorld;
}
@@ -246,9 +248,8 @@ void DetectorConstruction::PrintCalorParameters()
{
G4cout << "\n------------------------------------------------------------"
<< "\n---> The calorimeter is " << fNbOfLayers << " layers of: [ "
<< fAbsorberThickness/mm << "mm of " << fAbsorberMaterial->GetName()
<< " + "
<< fGapThickness/mm << "mm of " << fGapMaterial->GetName() << " ] "
<< fAbsorberThickness / mm << "mm of " << fAbsorberMaterial->GetName() << " + "
<< fGapThickness / mm << "mm of " << fGapMaterial->GetName() << " ] "
<< "\n------------------------------------------------------------\n";
}
@@ -274,7 +275,7 @@ void DetectorConstruction::SetGapMaterial(const G4String& materialChoice)
auto material = G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (material != nullptr) {
fGapMaterial = material;
if ( fLogicGap != nullptr) {
if (fLogicGap != nullptr) {
fLogicGap->SetMaterial(fGapMaterial);
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
@@ -287,7 +288,7 @@ void DetectorConstruction::SetAbsorberThickness(G4double value)
{
// change Absorber thickness and recompute the calorimeter parameters
fAbsorberThickness = value;
if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
if (G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit) {
G4RunManager::GetRunManager()->ReinitializeGeometry();
}
}
@@ -298,7 +299,7 @@ void DetectorConstruction::SetGapThickness(G4double value)
{
// change Gap thickness and recompute the calorimeter parameters
fGapThickness = value;
if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
if (G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit) {
G4RunManager::GetRunManager()->ReinitializeGeometry();
}
}
@@ -309,7 +310,7 @@ void DetectorConstruction::SetCalorSizeYZ(G4double value)
{
// change the transverse size and recompute the calorimeter parameters
fCalorSizeYZ = value;
if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
if (G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit) {
G4RunManager::GetRunManager()->ReinitializeGeometry();
}
}
@@ -319,7 +320,7 @@ void DetectorConstruction::SetCalorSizeYZ(G4double value)
void DetectorConstruction::SetNbOfLayers(G4int value)
{
fNbOfLayers = value;
if ( G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit ) {
if (G4StateManager::GetStateManager()->GetCurrentState() != G4State_PreInit) {
G4RunManager::GetRunManager()->ReinitializeGeometry();
}
}
@@ -32,57 +32,57 @@
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIdirectory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger( DetectorConstruction* Det)
: fDetector(Det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* Det) : fDetector(Det)
{
G4bool broadcast = false;
fDetDir = new G4UIdirectory("/det/",broadcast);
fDetDir = new G4UIdirectory("/det/", broadcast);
fDetDir->SetGuidance("Detector control");
fAbsMaterCmd = new G4UIcmdWithAString("/det/setAbsMat",this);
fAbsMaterCmd = new G4UIcmdWithAString("/det/setAbsMat", this);
fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
fAbsMaterCmd->SetParameterName("AbsMat",false);
fAbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAbsMaterCmd->SetParameterName("AbsMat", false);
fAbsMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fGapMaterCmd = new G4UIcmdWithAString("/det/setGapMat",this);
fGapMaterCmd = new G4UIcmdWithAString("/det/setGapMat", this);
fGapMaterCmd->SetGuidance("Select Material of the Gap.");
fGapMaterCmd->SetParameterName("GapMat",false);
fGapMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fGapMaterCmd->SetParameterName("GapMat", false);
fGapMaterCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/det/setAbsThick",this);
fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/det/setAbsThick", this);
fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
fAbsThickCmd->SetParameterName("AbsThick",false);
fAbsThickCmd->SetParameterName("AbsThick", false);
fAbsThickCmd->SetRange("AbsThick>=0.");
fAbsThickCmd->SetUnitCategory("Length");
fAbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fAbsThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fGapThickCmd = new G4UIcmdWithADoubleAndUnit("/det/setGapThick",this);
fGapThickCmd = new G4UIcmdWithADoubleAndUnit("/det/setGapThick", this);
fGapThickCmd->SetGuidance("Set Thickness of the Gap");
fGapThickCmd->SetParameterName("GapThick",false);
fGapThickCmd->SetParameterName("GapThick", false);
fGapThickCmd->SetRange("GapThick>=0.");
fGapThickCmd->SetUnitCategory("Length");
fGapThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fGapThickCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/det/setSizeYZ",this);
fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/det/setSizeYZ", this);
fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
fSizeYZCmd->SetParameterName("SizeYZ",false);
fSizeYZCmd->SetParameterName("SizeYZ", false);
fSizeYZCmd->SetRange("SizeYZ>0.");
fSizeYZCmd->SetUnitCategory("Length");
fSizeYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fSizeYZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fNbLayersCmd = new G4UIcmdWithAnInteger("/det/setNbOfLayers",this);
fNbLayersCmd = new G4UIcmdWithAnInteger("/det/setNbOfLayers", this);
fNbLayersCmd->SetGuidance("Set number of layers.");
fNbLayersCmd->SetParameterName("NbLayers",false);
fNbLayersCmd->SetParameterName("NbLayers", false);
fNbLayersCmd->SetRange("NbLayers>0 && NbLayers<500");
fNbLayersCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fNbLayersCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -102,32 +102,32 @@ DetectorMessenger::~DetectorMessenger()
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == fAbsMaterCmd ) {
if (command == fAbsMaterCmd) {
fDetector->SetAbsorberMaterial(newValue);
return;
}
if( command == fGapMaterCmd ) {
if (command == fGapMaterCmd) {
fDetector->SetGapMaterial(newValue);
return;
}
if( command == fAbsThickCmd ) {
if (command == fAbsThickCmd) {
fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));
return;
}
if( command == fGapThickCmd ) {
if (command == fGapThickCmd) {
fDetector->SetGapThickness(fGapThickCmd->GetNewDoubleValue(newValue));
return;
}
if( command == fSizeYZCmd ) {
if (command == fSizeYZCmd) {
fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));
return;
}
if( command == fNbLayersCmd ) {
if (command == fNbLayersCmd) {
fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));
return;
}
@@ -35,15 +35,14 @@
#include "EventAction.hh"
#include "RunAction.hh"
#include "HistoManager.hh"
#include "RunAction.hh"
#include "G4Event.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction(RunAction* run, HistoManager* histo)
: fRunAct(run),fHistoManager(histo)
EventAction::EventAction(RunAction* run, HistoManager* histo) : fRunAct(run), fHistoManager(histo)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,7 +54,7 @@ EventAction::~EventAction() = default;
void EventAction::BeginOfEventAction(const G4Event* evt)
{
G4int evtNb = evt->GetEventID();
if (evtNb%fPrintModulo == 0) {
if (evtNb % fPrintModulo == 0) {
G4cout << "\n---> Begin of event: " << evtNb << G4endl;
}
@@ -68,18 +67,18 @@ void EventAction::BeginOfEventAction(const G4Event* evt)
void EventAction::EndOfEventAction(const G4Event*)
{
//accumulates statistic
// accumulates statistic
//
fRunAct->FillPerEvent(fEnergyAbs, fEnergyGap, fTrackLAbs, fTrackLGap);
//fill histograms
// fill histograms
//
fHistoManager->FillHisto(0, fEnergyAbs);
fHistoManager->FillHisto(1, fEnergyGap);
fHistoManager->FillHisto(2, fTrackLAbs);
fHistoManager->FillHisto(3, fTrackLGap);
//fill ntuple
// fill ntuple
//
fHistoManager->FillNtuple(fEnergyAbs, fEnergyGap, fTrackLAbs, fTrackLGap);
}
@@ -34,30 +34,28 @@
#include "DetectorConstruction.hh"
#include "G4Event.hh"
#include "G4ParticleDefinition.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* dc)
: fDetector(dc)
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* dc) : fDetector(dc)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
fParticleGun = new G4ParticleGun(n_particle);
// default particle kinematic
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
G4String particleName;
G4ParticleDefinition* particle = particleTable->FindParticle(particleName="e-");
G4ParticleDefinition* particle = particleTable->FindParticle(particleName = "e-");
fParticleGun->SetParticleDefinition(particle);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
fParticleGun->SetParticleEnergy(500.*MeV);
G4double position = -0.5*(fDetector->GetWorldSizeX());
fParticleGun->SetParticlePosition(G4ThreeVector(position,0.*cm,0.*cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1., 0., 0.));
fParticleGun->SetParticleEnergy(500. * MeV);
G4double position = -0.5 * (fDetector->GetWorldSizeX());
fParticleGun->SetParticlePosition(G4ThreeVector(position, 0. * cm, 0. * cm));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -71,10 +69,9 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
// this function is called at the begining of event
//
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -32,17 +32,17 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "RunAction.hh"
#include "HistoManager.hh"
#include "G4AccumulableManager.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4AccumulableManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(HistoManager* histo)
: fHistoManager(histo)
RunAction::RunAction(HistoManager* histo) : fHistoManager(histo)
{
// Register accumulable to the accumulable manager
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
@@ -69,23 +69,26 @@ void RunAction::BeginOfRunAction(const G4Run* aRun)
// reset accumulables to their initial values
G4AccumulableManager::Instance()->Reset();
//histograms
// histograms
//
fHistoManager->Book();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::FillPerEvent(G4double EAbs, G4double EGap,
G4double LAbs, G4double LGap)
void RunAction::FillPerEvent(G4double EAbs, G4double EGap, G4double LAbs, G4double LGap)
{
//accumulate statistic
// accumulate statistic
//
fSumEAbs += EAbs; fSum2EAbs += EAbs*EAbs;
fSumEGap += EGap; fSum2EGap += EGap*EGap;
fSumEAbs += EAbs;
fSum2EAbs += EAbs * EAbs;
fSumEGap += EGap;
fSum2EGap += EGap * EGap;
fSumLAbs += LAbs; fSum2LAbs += LAbs*LAbs;
fSumLGap += LGap; fSum2LGap += LGap*LGap;
fSumLAbs += LAbs;
fSum2LAbs += LAbs * LAbs;
fSumLGap += LGap;
fSum2LGap += LGap * LGap;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -102,67 +105,72 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
return;
}
//compute statistics: mean and rms
// compute statistics: mean and rms
//
auto sumEAbs = fSumEAbs.GetValue();
auto sum2EAbs = fSum2EAbs.GetValue();
sumEAbs /= nofEvents; sum2EAbs /= nofEvents;
auto rmsEAbs = sum2EAbs - sumEAbs*sumEAbs;
if (rmsEAbs >0.) {
sumEAbs /= nofEvents;
sum2EAbs /= nofEvents;
auto rmsEAbs = sum2EAbs - sumEAbs * sumEAbs;
if (rmsEAbs > 0.) {
rmsEAbs = std::sqrt(rmsEAbs);
} else {
}
else {
rmsEAbs = 0.;
}
auto sumEGap = fSumEGap.GetValue();
auto sum2EGap = fSum2EGap.GetValue();
sumEGap /= nofEvents; sum2EGap /= nofEvents;
auto rmsEGap = sum2EGap - sumEGap*sumEGap;
if (rmsEGap >0.) {
sumEGap /= nofEvents;
sum2EGap /= nofEvents;
auto rmsEGap = sum2EGap - sumEGap * sumEGap;
if (rmsEGap > 0.) {
rmsEGap = std::sqrt(rmsEGap);
} else {
}
else {
rmsEGap = 0.;
}
auto sumLAbs = fSumLAbs.GetValue();
auto sum2LAbs = fSum2LAbs.GetValue();
sumLAbs /= nofEvents; sum2LAbs /= nofEvents;
auto rmsLAbs = sum2LAbs - sumLAbs*sumLAbs;
if (rmsLAbs >0.) {
sumLAbs /= nofEvents;
sum2LAbs /= nofEvents;
auto rmsLAbs = sum2LAbs - sumLAbs * sumLAbs;
if (rmsLAbs > 0.) {
rmsLAbs = std::sqrt(rmsLAbs);
} else {
}
else {
rmsLAbs = 0.;
}
auto sumLGap = fSumLGap.GetValue();
auto sum2LGap = fSum2LGap.GetValue();
sumLGap /= nofEvents; sum2LGap /= nofEvents;
G4double rmsLGap = sum2LGap - sumLGap*sumLGap;
if (rmsLGap >0.) {
sumLGap /= nofEvents;
sum2LGap /= nofEvents;
G4double rmsLGap = sum2LGap - sumLGap * sumLGap;
if (rmsLGap > 0.) {
rmsLGap = std::sqrt(rmsLGap);
} else {
}
else {
rmsLGap = 0.;
}
//print
// print
//
G4cout
<< "\n--------------------End of Run------------------------------\n"
<< "\n mean Energy in Absorber : " << G4BestUnit(sumEAbs,"Energy")
<< " +- " << G4BestUnit(rmsEAbs,"Energy")
<< "\n mean Energy in Gap : " << G4BestUnit(sumEGap,"Energy")
<< " +- " << G4BestUnit(rmsEGap,"Energy")
<< G4endl;
G4cout << "\n--------------------End of Run------------------------------\n"
<< "\n mean Energy in Absorber : " << G4BestUnit(sumEAbs, "Energy") << " +- "
<< G4BestUnit(rmsEAbs, "Energy")
<< "\n mean Energy in Gap : " << G4BestUnit(sumEGap, "Energy") << " +- "
<< G4BestUnit(rmsEGap, "Energy") << G4endl;
G4cout
<< "\n mean trackLength in Absorber : " << G4BestUnit(sumLAbs,"Length")
<< " +- " << G4BestUnit(rmsLAbs,"Length")
<< "\n mean trackLength in Gap : " << G4BestUnit(sumLGap,"Length")
<< " +- " << G4BestUnit(rmsLGap,"Length")
<< "\n------------------------------------------------------------\n"
<< G4endl;
G4cout << "\n mean trackLength in Absorber : " << G4BestUnit(sumLAbs, "Length") << " +- "
<< G4BestUnit(rmsLAbs, "Length")
<< "\n mean trackLength in Gap : " << G4BestUnit(sumLGap, "Length") << " +- "
<< G4BestUnit(rmsLGap, "Length")
<< "\n------------------------------------------------------------\n"
<< G4endl;
//save histograms
// save histograms
//
fHistoManager->PrintStatistic();
fHistoManager->Save();
@@ -39,7 +39,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
: fDetector(det), fEventAction(evt)
: fDetector(det), fEventAction(evt)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -51,8 +51,7 @@ SteppingAction::~SteppingAction() = default;
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
// get volume of the current step
G4VPhysicalVolume* volume =
aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
G4VPhysicalVolume* volume = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
// collect energy and track length step by step
G4double edep = aStep->GetTotalEnergyDeposit();
@@ -62,8 +61,12 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep)
stepl = aStep->GetStepLength();
}
if (volume == fDetector->GetAbsorber()) { fEventAction->AddAbs(edep,stepl); }
if (volume == fDetector->GetGap()) { fEventAction->AddGap(edep,stepl); }
if (volume == fDetector->GetAbsorber()) {
fEventAction->AddAbs(edep, stepl);
}
if (volume == fDetector->GetGap()) {
fEventAction->AddGap(edep, stepl);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......