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,14 +28,13 @@
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::ActionInitialization(const G4String& fileName)
: fFileName(fileName)
{}
ActionInitialization::ActionInitialization(const G4String& fileName) : fFileName(fileName) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,25 +28,24 @@
/// \brief Implementation of the DetectorConstruction class
#include "DetectorConstruction.hh"
#include "ScreenSD.hh"
#include "G4AutoDelete.hh"
#include "G4Box.hh"
#include "G4Colour.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4SDManager.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SystemOfUnits.hh"
#include "G4AutoDelete.hh"
#include "G4VisAttributes.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -58,9 +57,9 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
// Build materials
G4Material* air = nistManager->FindOrBuildMaterial("G4_AIR");
G4Material* csi = nistManager->FindOrBuildMaterial("G4_CESIUM_IODIDE");
// There is no need to test if materials were built/found
// as G4NistManager would issue an error otherwise
// Try the code with "XYZ".
// There is no need to test if materials were built/found
// as G4NistManager would issue an error otherwise
// Try the code with "XYZ".
// Print all materials
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
@@ -73,62 +72,59 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
//
// The world dimensions
G4double worldHxyz = 2.*m;
G4double worldHxyz = 2. * m;
// world volume
auto worldS = new G4Box("World", worldHxyz, worldHxyz, worldHxyz);
auto worldS = new G4Box("World", worldHxyz, worldHxyz, worldHxyz);
auto worldLV = new G4LogicalVolume(worldS, air, "World");
auto worldLV = new G4LogicalVolume(worldS, air, "World");
G4VPhysicalVolume* worldPV
= new G4PVPlacement(
nullptr, G4ThreeVector(), worldLV, "World", nullptr, false, 0, checkOverlaps);
G4VPhysicalVolume* worldPV =
new G4PVPlacement(nullptr, G4ThreeVector(), worldLV, "World", nullptr, false, 0, checkOverlaps);
//
// Box
//
// The box dimensions
G4double boxHxy = 1.*m;
G4double boxHz = 10.*cm;
G4double boxHxy = 1. * m;
G4double boxHz = 10. * cm;
// box volume
auto boxS = new G4Box("World", boxHxy, boxHxy, boxHz);
auto boxS = new G4Box("World", boxHxy, boxHxy, boxHz);
auto boxLV = new G4LogicalVolume(boxS, csi, "Box");
auto boxLV = new G4LogicalVolume(boxS, csi, "Box");
// The box position
G4double posz = 0.*m;
G4double posz = 0. * m;
new G4PVPlacement(
nullptr, G4ThreeVector(0, 0, posz),
boxLV, "Box", worldLV, false, 0, checkOverlaps);
new G4PVPlacement(nullptr, G4ThreeVector(0, 0, posz), boxLV, "Box", worldLV, false, 0,
checkOverlaps);
//
// Scoring screen
//
// The screen dimensions
G4double screenHxy = 1.999*m;
G4double screenHz = 1.*mm;
G4double screenHxy = 1.999 * m;
G4double screenHz = 1. * mm;
// Screen volume
auto screenS = new G4Box("World", screenHxy, screenHxy, screenHz);
auto screenS = new G4Box("World", screenHxy, screenHxy, screenHz);
auto screenLV = new G4LogicalVolume(screenS, air, "Screen");
auto screenLV = new G4LogicalVolume(screenS, air, "Screen");
// The screen position
posz += boxHz + screenHz;
new G4PVPlacement(
nullptr, G4ThreeVector(0, 0, posz),
screenLV, "Screen", worldLV, false, 0, checkOverlaps);
new G4PVPlacement(nullptr, G4ThreeVector(0, 0, posz), screenLV, "Screen", worldLV, false, 0,
checkOverlaps);
//
// Visualization attributes
//
worldLV->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);
boxLV->SetVisAttributes(simpleBoxVisAtt);
screenLV->SetVisAttributes(simpleBoxVisAtt);
@@ -29,14 +29,14 @@
#include "PrimaryGeneratorAction.hh"
#include "G4RunManager.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4LogicalVolume.hh"
#include "G4Box.hh"
#include "G4Event.hh"
#include "G4LogicalVolume.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4Proton.hh"
#include "G4RunManager.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
@@ -48,8 +48,8 @@ PrimaryGeneratorAction::PrimaryGeneratorAction()
fParticleGun = new G4ParticleGun(nofParticles);
// default particle kinematic
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(1.*GeV);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
fParticleGun->SetParticleEnergy(1. * GeV);
fParticleGun->SetParticleDefinition(G4Proton::Proton());
}
@@ -75,28 +75,25 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// Check that the world volume has box shape
G4Box* worldBox = nullptr;
if ( worldLV ) {
if (worldLV) {
worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
}
if ( worldBox ) {
if (worldBox) {
worldZHalfLength = worldBox->GetZHalfLength();
}
else {
else {
G4ExceptionDescription msg;
msg << "World volume of box shape not found." << G4endl;
msg << "Perhaps you have changed geometry." << G4endl;
msg << "The gun will be place in the center.";
G4Exception("PrimaryGeneratorAction::GeneratePrimaries()",
"MyCode0002", JustWarning, msg);
G4Exception("PrimaryGeneratorAction::GeneratePrimaries()", "MyCode0002", JustWarning, msg);
}
// Set gun position
fParticleGun
->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
fParticleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -29,16 +29,15 @@
#include "RunAction.hh"
#include "G4AnalysisManager.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4AnalysisManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(const G4String& fileName)
: fFileName(fileName)
RunAction::RunAction(const G4String& fileName) : fFileName(fileName)
{
// Create analysis manager
auto analysisManager = G4AnalysisManager::Instance();
@@ -46,7 +45,7 @@ RunAction::RunAction(const G4String& fileName)
analysisManager->SetVerboseLevel(1);
analysisManager->SetNtupleMerging(true);
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Note: merging ntuples is available only with Root output
// Note: merging ntuples is available only with Root output
// Set default fileName
analysisManager->SetFileName(fFileName);
@@ -54,12 +53,12 @@ RunAction::RunAction(const G4String& fileName)
// Create ntuple
//
analysisManager->CreateNtuple("Screen", "Screen hits");
analysisManager->CreateNtupleIColumn("ID"); // column id = 0
analysisManager->CreateNtupleIColumn("PDG"); // column id = 1
analysisManager->CreateNtupleDColumn("Ekin"); // column id = 2
analysisManager->CreateNtupleDColumn("Xpos"); // column id = 3
analysisManager->CreateNtupleDColumn("Ypos"); // column id = 4
analysisManager->CreateNtupleDColumn("time"); // column id = 5
analysisManager->CreateNtupleIColumn("ID"); // column id = 0
analysisManager->CreateNtupleIColumn("PDG"); // column id = 1
analysisManager->CreateNtupleDColumn("Ekin"); // column id = 2
analysisManager->CreateNtupleDColumn("Xpos"); // column id = 3
analysisManager->CreateNtupleDColumn("Ypos"); // column id = 4
analysisManager->CreateNtupleDColumn("time"); // column id = 5
analysisManager->FinishNtuple();
}
@@ -30,24 +30,20 @@
#include "ScreenSD.hh"
#include "G4VTouchable.hh"
#include "G4Step.hh"
#include "G4ios.hh"
#include "G4SystemOfUnits.hh"
#include "G4AnalysisManager.hh"
#include "G4Step.hh"
#include "G4SystemOfUnits.hh"
#include "G4VProcess.hh"
#include "G4VTouchable.hh"
#include "G4ios.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ScreenSD::ScreenSD(const G4String& name)
: G4VSensitiveDetector(name)
{}
ScreenSD::ScreenSD(const G4String& name) : G4VSensitiveDetector(name) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ScreenSD::Initialize(G4HCofThisEvent* /*hce*/)
{}
void ScreenSD::Initialize(G4HCofThisEvent* /*hce*/) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -66,13 +62,13 @@ G4bool ScreenSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
G4StepPoint* preStepPoint = step->GetPreStepPoint();
// Ekin:
G4double Ekin = preStepPoint->GetKineticEnergy();
G4double Ekin = preStepPoint->GetKineticEnergy();
// Obtain local coordinates:
const G4VTouchable* touchable = preStepPoint->GetTouchable();
G4ThreeVector globalPosition = preStepPoint->GetPosition();
G4ThreeVector localPosition
= touchable->GetHistory()->GetTopTransform().TransformPoint(globalPosition);
G4ThreeVector localPosition =
touchable->GetHistory()->GetTopTransform().TransformPoint(globalPosition);
// // Example for obtaining the local direction:
// G4ThreeVector globalDirection = preStepPoint->GetMomentumDirection();
// G4ThreeVector localDirection
@@ -85,10 +81,10 @@ G4bool ScreenSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillNtupleIColumn(0, ID);
analysisManager->FillNtupleIColumn(1, pdgCode);
analysisManager->FillNtupleDColumn(2, Ekin/MeV);
analysisManager->FillNtupleDColumn(3, localPosition.x()/cm);
analysisManager->FillNtupleDColumn(4, localPosition.y()/cm);
analysisManager->FillNtupleDColumn(5, time/ns);
analysisManager->FillNtupleDColumn(2, Ekin / MeV);
analysisManager->FillNtupleDColumn(3, localPosition.x() / cm);
analysisManager->FillNtupleDColumn(4, localPosition.y() / cm);
analysisManager->FillNtupleDColumn(5, time / ns);
analysisManager->AddNtupleRow();
return true;
@@ -96,7 +92,6 @@ G4bool ScreenSD::ProcessHits(G4Step* step, G4TouchableHistory* /*history*/)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ScreenSD::EndOfEvent(G4HCofThisEvent* /*hce*/)
{}
void ScreenSD::EndOfEvent(G4HCofThisEvent* /*hce*/) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......