Import Geant4 11.3.0.beta source tree
This commit is contained in:
@@ -28,12 +28,11 @@
|
||||
/// \brief Implementation of the B4b::ActionInitialization class
|
||||
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#include "EventAction.hh"
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
#include "RunAction.hh"
|
||||
#include "EventAction.hh"
|
||||
#include "SteppingAction.hh"
|
||||
#include "G4MTRunManager.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
using namespace B4;
|
||||
|
||||
@@ -43,7 +42,7 @@ namespace B4b
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
ActionInitialization::ActionInitialization(DetectorConstruction* detConstruction)
|
||||
: fDetConstruction(detConstruction)
|
||||
: fDetConstruction(detConstruction)
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -65,4 +64,4 @@ void ActionInitialization::Build() const
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B4b
|
||||
|
||||
@@ -25,38 +25,29 @@
|
||||
//
|
||||
//
|
||||
/// \file B4/B4b/src/DetectorConstruction.cc
|
||||
/// \brief Implementation of the B4:DetectorConstruction class
|
||||
/// \brief Implementation of the B4::DetectorConstruction class
|
||||
|
||||
#include "DetectorConstruction.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 "G4PVReplica.hh"
|
||||
#include "G4GlobalMagFieldMessenger.hh"
|
||||
#include "G4AutoDelete.hh"
|
||||
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
namespace B4
|
||||
{
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4ThreadLocal
|
||||
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
|
||||
G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -81,12 +72,12 @@ void DetectorConstruction::DefineMaterials()
|
||||
G4double a; // mass of a mole;
|
||||
G4double z; // z=mean number of protons;
|
||||
G4double density;
|
||||
new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
|
||||
// The argon by NIST Manager is a gas with a different density
|
||||
new G4Material("liquidArgon", z = 18., a = 39.95 * g / mole, density = 1.390 * g / cm3);
|
||||
// The argon by NIST Manager is a gas with a different density
|
||||
|
||||
// Vacuum
|
||||
new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
|
||||
kStateGas, 2.73*kelvin, 3.e-18*pascal);
|
||||
new G4Material("Galactic", z = 1., a = 1.01 * g / mole, density = universe_mean_density,
|
||||
kStateGas, 2.73 * kelvin, 3.e-18 * pascal);
|
||||
|
||||
// Print materials
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
@@ -98,147 +89,127 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
|
||||
{
|
||||
// Geometry parameters
|
||||
G4int nofLayers = 10;
|
||||
G4double absoThickness = 10.*mm;
|
||||
G4double gapThickness = 5.*mm;
|
||||
G4double calorSizeXY = 10.*cm;
|
||||
G4double absoThickness = 10. * mm;
|
||||
G4double gapThickness = 5. * mm;
|
||||
G4double calorSizeXY = 10. * cm;
|
||||
|
||||
auto layerThickness = absoThickness + gapThickness;
|
||||
auto calorThickness = nofLayers * layerThickness;
|
||||
auto worldSizeXY = 1.2 * calorSizeXY;
|
||||
auto worldSizeZ = 1.2 * calorThickness;
|
||||
auto worldSizeZ = 1.2 * calorThickness;
|
||||
|
||||
// Get materials
|
||||
auto defaultMaterial = G4Material::GetMaterial("Galactic");
|
||||
auto absorberMaterial = G4Material::GetMaterial("G4_Pb");
|
||||
auto gapMaterial = G4Material::GetMaterial("liquidArgon");
|
||||
|
||||
if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
|
||||
if (!defaultMaterial || !absorberMaterial || !gapMaterial) {
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Cannot retrieve materials already defined.";
|
||||
G4Exception("DetectorConstruction::DefineVolumes()",
|
||||
"MyCode0001", FatalException, msg);
|
||||
G4Exception("DetectorConstruction::DefineVolumes()", "MyCode0001", FatalException, msg);
|
||||
}
|
||||
|
||||
//
|
||||
// World
|
||||
//
|
||||
auto worldS
|
||||
= new G4Box("World", // its name
|
||||
worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
|
||||
auto worldS = new G4Box("World", // its name
|
||||
worldSizeXY / 2, worldSizeXY / 2, worldSizeZ / 2); // its size
|
||||
|
||||
auto worldLV
|
||||
= new G4LogicalVolume(
|
||||
worldS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"World"); // its name
|
||||
auto worldLV = new G4LogicalVolume(worldS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"World"); // its name
|
||||
|
||||
auto worldPV = new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
worldLV, // its logical volume
|
||||
"World", // its name
|
||||
nullptr, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
worldLV, // its logical volume
|
||||
"World", // its name
|
||||
nullptr, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// Calorimeter
|
||||
//
|
||||
auto calorimeterS
|
||||
= new G4Box("Calorimeter", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
|
||||
auto calorimeterS = new G4Box("Calorimeter", // its name
|
||||
calorSizeXY / 2, calorSizeXY / 2, calorThickness / 2); // its size
|
||||
|
||||
auto calorLV
|
||||
= new G4LogicalVolume(
|
||||
calorimeterS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"Calorimeter"); // its name
|
||||
auto calorLV = new G4LogicalVolume(calorimeterS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"Calorimeter"); // its name
|
||||
|
||||
new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
calorLV, // its logical volume
|
||||
"Calorimeter", // its name
|
||||
worldLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
calorLV, // its logical volume
|
||||
"Calorimeter", // its name
|
||||
worldLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// Layer
|
||||
//
|
||||
auto layerS
|
||||
= new G4Box("Layer", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, layerThickness/2); // its size
|
||||
auto layerS = new G4Box("Layer", // its name
|
||||
calorSizeXY / 2, calorSizeXY / 2, layerThickness / 2); // its size
|
||||
|
||||
auto layerLV
|
||||
= new G4LogicalVolume(
|
||||
layerS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"Layer"); // its name
|
||||
auto layerLV = new G4LogicalVolume(layerS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"Layer"); // its name
|
||||
|
||||
new G4PVReplica(
|
||||
"Layer", // its name
|
||||
layerLV, // its logical volume
|
||||
calorLV, // its mother
|
||||
kZAxis, // axis of replication
|
||||
nofLayers, // number of replica
|
||||
layerThickness); // witdth of replica
|
||||
new G4PVReplica("Layer", // its name
|
||||
layerLV, // its logical volume
|
||||
calorLV, // its mother
|
||||
kZAxis, // axis of replication
|
||||
nofLayers, // number of replica
|
||||
layerThickness); // witdth of replica
|
||||
|
||||
//
|
||||
// Absorber
|
||||
//
|
||||
auto absorberS
|
||||
= new G4Box("Abso", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
|
||||
auto absorberS = new G4Box("Abso", // its name
|
||||
calorSizeXY / 2, calorSizeXY / 2, absoThickness / 2); // its size
|
||||
|
||||
auto absorberLV
|
||||
= new G4LogicalVolume(
|
||||
absorberS, // its solid
|
||||
absorberMaterial, // its material
|
||||
"Abso"); // its name
|
||||
auto absorberLV = new G4LogicalVolume(absorberS, // its solid
|
||||
absorberMaterial, // its material
|
||||
"Abso"); // its name
|
||||
|
||||
fAbsorberPV = new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(0., 0., -gapThickness / 2), // its position
|
||||
absorberLV, // its logical volume
|
||||
"Abso", // its name
|
||||
layerLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
fAbsorberPV = new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(0., 0., -gapThickness / 2), // its position
|
||||
absorberLV, // its logical volume
|
||||
"Abso", // its name
|
||||
layerLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// Gap
|
||||
//
|
||||
auto gapS
|
||||
= new G4Box("Gap", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
|
||||
auto gapS = new G4Box("Gap", // its name
|
||||
calorSizeXY / 2, calorSizeXY / 2, gapThickness / 2); // its size
|
||||
|
||||
auto gapLV
|
||||
= new G4LogicalVolume(
|
||||
gapS, // its solid
|
||||
gapMaterial, // its material
|
||||
"Gap"); // its name
|
||||
auto gapLV = new G4LogicalVolume(gapS, // its solid
|
||||
gapMaterial, // its material
|
||||
"Gap"); // its name
|
||||
|
||||
fGapPV = new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(0., 0., absoThickness / 2), // its position
|
||||
gapLV, // its logical volume
|
||||
"Gap", // its name
|
||||
layerLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
fGapPV = new G4PVPlacement(nullptr, // no rotation
|
||||
G4ThreeVector(0., 0., absoThickness / 2), // its position
|
||||
gapLV, // its logical volume
|
||||
"Gap", // its name
|
||||
layerLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// print parameters
|
||||
//
|
||||
G4cout
|
||||
<< G4endl
|
||||
<< "------------------------------------------------------------" << G4endl
|
||||
<< "---> The calorimeter is " << nofLayers << " layers of: [ "
|
||||
<< absoThickness/mm << "mm of " << absorberMaterial->GetName()
|
||||
<< " + "
|
||||
<< gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] " << G4endl
|
||||
<< "------------------------------------------------------------" << G4endl;
|
||||
G4cout << G4endl << "------------------------------------------------------------" << G4endl
|
||||
<< "---> The calorimeter is " << nofLayers << " layers of: [ " << absoThickness / mm
|
||||
<< "mm of " << absorberMaterial->GetName() << " + " << gapThickness / mm << "mm of "
|
||||
<< gapMaterial->GetName() << " ] " << G4endl
|
||||
<< "------------------------------------------------------------" << G4endl;
|
||||
|
||||
//
|
||||
// Visualization attributes
|
||||
@@ -269,5 +240,4 @@ void DetectorConstruction::ConstructSDandField()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
|
||||
} // namespace B4
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
/// \brief Implementation of the B4b::EventAction class
|
||||
|
||||
#include "EventAction.hh"
|
||||
|
||||
#include "RunData.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
#include <iomanip>
|
||||
|
||||
namespace B4b
|
||||
@@ -42,31 +42,22 @@ namespace B4b
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EventAction::PrintEventStatistics(
|
||||
G4double absoEdep, G4double absoTrackLength,
|
||||
G4double gapEdep, G4double gapTrackLength) const
|
||||
{
|
||||
void EventAction::PrintEventStatistics(G4double absoEdep, G4double absoTrackLength,
|
||||
G4double gapEdep, G4double gapTrackLength) const
|
||||
{
|
||||
// print event statistics
|
||||
G4cout
|
||||
<< " Absorber: total energy: "
|
||||
<< std::setw(7) << G4BestUnit(absoEdep, "Energy")
|
||||
<< " total track length: "
|
||||
<< std::setw(7) << G4BestUnit(absoTrackLength, "Length")
|
||||
<< G4endl
|
||||
<< " Gap: total energy: "
|
||||
<< std::setw(7) << G4BestUnit(gapEdep, "Energy")
|
||||
<< " total track length: "
|
||||
<< std::setw(7) << G4BestUnit(gapTrackLength, "Length")
|
||||
<< G4endl;
|
||||
G4cout << " Absorber: total energy: " << std::setw(7) << G4BestUnit(absoEdep, "Energy")
|
||||
<< " total track length: " << std::setw(7) << G4BestUnit(absoTrackLength, "Length")
|
||||
<< G4endl << " Gap: total energy: " << std::setw(7) << G4BestUnit(gapEdep, "Energy")
|
||||
<< " total track length: " << std::setw(7) << G4BestUnit(gapTrackLength, "Length")
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void EventAction::BeginOfEventAction(const G4Event* /*event*/)
|
||||
{
|
||||
auto runData
|
||||
= static_cast<RunData*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
auto runData = static_cast<RunData*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
runData->Reset();
|
||||
}
|
||||
|
||||
@@ -74,25 +65,20 @@ void EventAction::BeginOfEventAction(const G4Event* /*event*/)
|
||||
|
||||
void EventAction::EndOfEventAction(const G4Event* event)
|
||||
{
|
||||
auto runData
|
||||
= static_cast<RunData*>(
|
||||
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
auto runData = static_cast<RunData*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
runData->FillPerEvent();
|
||||
|
||||
//print per event (modulo n)
|
||||
// print per event (modulo n)
|
||||
//
|
||||
auto eventID = event->GetEventID();
|
||||
auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
|
||||
if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
|
||||
PrintEventStatistics(
|
||||
runData->GetEdep(kAbs),
|
||||
runData->GetTrackLength(kAbs),
|
||||
runData->GetEdep(kGap),
|
||||
runData->GetTrackLength(kGap));
|
||||
G4cout << "--> End of event " << eventID << "\n" << G4endl;
|
||||
if ((printModulo > 0) && (eventID % printModulo == 0)) {
|
||||
PrintEventStatistics(runData->GetEdep(kAbs), runData->GetTrackLength(kAbs),
|
||||
runData->GetEdep(kGap), runData->GetTrackLength(kGap));
|
||||
G4cout << "--> End of event " << eventID << "\n" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B4b
|
||||
|
||||
@@ -29,16 +29,13 @@
|
||||
|
||||
#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 "G4ParticleDefinition.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "Randomize.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
namespace B4
|
||||
{
|
||||
@@ -52,11 +49,10 @@ PrimaryGeneratorAction::PrimaryGeneratorAction()
|
||||
|
||||
// default particle kinematic
|
||||
//
|
||||
auto particleDefinition
|
||||
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
|
||||
auto particleDefinition = G4ParticleTable::GetParticleTable()->FindParticle("e-");
|
||||
fParticleGun->SetParticleDefinition(particleDefinition);
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
fParticleGun->SetParticleEnergy(300.*MeV);
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
|
||||
fParticleGun->SetParticleEnergy(300. * MeV);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -68,7 +64,7 @@ PrimaryGeneratorAction::~PrimaryGeneratorAction()
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* event)
|
||||
{
|
||||
// This function is called at the begining of event
|
||||
|
||||
@@ -81,29 +77,27 @@ 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);
|
||||
fParticleGun->GeneratePrimaryVertex(event);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B4
|
||||
|
||||
@@ -28,13 +28,15 @@
|
||||
/// \brief Implementation of the B4b::RunAction class
|
||||
|
||||
#include "RunAction.hh"
|
||||
|
||||
#include "RunData.hh"
|
||||
|
||||
#include "G4AnalysisManager.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
namespace B4b
|
||||
{
|
||||
@@ -52,21 +54,21 @@ RunAction::RunAction()
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
// Create directories
|
||||
//analysisManager->SetHistoDirectoryName("histograms");
|
||||
//analysisManager->SetNtupleDirectoryName("ntuple");
|
||||
// analysisManager->SetHistoDirectoryName("histograms");
|
||||
// analysisManager->SetNtupleDirectoryName("ntuple");
|
||||
analysisManager->SetVerboseLevel(1);
|
||||
analysisManager->SetNtupleMerging(true);
|
||||
// Note: merging ntuples is available only with Root output
|
||||
// Note: merging ntuples is available only with Root output
|
||||
|
||||
// Book histograms, ntuple
|
||||
//
|
||||
|
||||
// Creating histograms
|
||||
analysisManager->CreateH1("Eabs" ,"Edep in absorber", 110, 0., 330*MeV);
|
||||
analysisManager->CreateH1("Egap" ,"Edep in gap", 100, 0., 30*MeV);
|
||||
analysisManager->CreateH1("Labs" ,"trackL in absorber", 100, 0., 50*cm);
|
||||
analysisManager->CreateH1("Lgap" ,"trackL in gap", 100, 0., 50*cm);
|
||||
|
||||
analysisManager->CreateH1("Eabs", "Edep in absorber", 110, 0., 330 * MeV);
|
||||
analysisManager->CreateH1("Egap", "Edep in gap", 100, 0., 30 * MeV);
|
||||
analysisManager->CreateH1("Labs", "trackL in absorber", 100, 0., 50 * cm);
|
||||
analysisManager->CreateH1("Lgap", "trackL in gap", 100, 0., 50 * cm);
|
||||
|
||||
// Creating ntuple
|
||||
//
|
||||
analysisManager->CreateNtuple("B4", "Edep and TrackL");
|
||||
@@ -90,8 +92,8 @@ void RunAction::BeginOfRunAction(const G4Run* run)
|
||||
{
|
||||
G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
|
||||
|
||||
//inform the runManager to save random number seed
|
||||
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
|
||||
// inform the runManager to save random number seed
|
||||
// G4RunManager::GetRunManager()->SetRandomNumberStore(true);
|
||||
|
||||
// Get analysis manager
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
@@ -109,48 +111,39 @@ void RunAction::BeginOfRunAction(const G4Run* run)
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void RunAction::EndOfRunAction(const G4Run* /*aRun*/)
|
||||
void RunAction::EndOfRunAction(const G4Run* /*run*/)
|
||||
{
|
||||
// print histogram statistics
|
||||
//
|
||||
auto analysisManager = G4AnalysisManager::Instance();
|
||||
if ( analysisManager->GetH1(1) ) {
|
||||
if (analysisManager->GetH1(1)) {
|
||||
G4cout << G4endl << " ----> print histograms statistic ";
|
||||
if(isMaster) {
|
||||
if (isMaster) {
|
||||
G4cout << "for the entire run " << G4endl << G4endl;
|
||||
}
|
||||
else {
|
||||
G4cout << "for the local thread " << G4endl << G4endl;
|
||||
}
|
||||
|
||||
G4cout << " EAbs : mean = "
|
||||
<< G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
|
||||
<< " rms = "
|
||||
<< G4BestUnit(analysisManager->GetH1(0)->rms(), "Energy") << G4endl;
|
||||
G4cout << " EAbs : mean = " << G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
|
||||
<< " rms = " << G4BestUnit(analysisManager->GetH1(0)->rms(), "Energy") << G4endl;
|
||||
|
||||
G4cout << " EGap : mean = "
|
||||
<< G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
|
||||
<< " rms = "
|
||||
<< G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
|
||||
G4cout << " EGap : mean = " << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
|
||||
<< " rms = " << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
|
||||
|
||||
G4cout << " LAbs : mean = "
|
||||
<< G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
|
||||
<< " rms = "
|
||||
<< G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
|
||||
G4cout << " LAbs : mean = " << G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
|
||||
<< " rms = " << G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
|
||||
|
||||
G4cout << " LGap : mean = "
|
||||
<< G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
|
||||
<< " rms = "
|
||||
<< G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
|
||||
G4cout << " LGap : mean = " << G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
|
||||
<< " rms = " << G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
|
||||
}
|
||||
|
||||
// save histograms & ntuple
|
||||
//
|
||||
analysisManager->Write();
|
||||
analysisManager->CloseFile();
|
||||
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B4b
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
#include "RunData.hh"
|
||||
|
||||
#include "G4AnalysisManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
namespace B4b
|
||||
{
|
||||
@@ -46,15 +44,15 @@ void RunData::FillPerEvent()
|
||||
// accumulate statistic
|
||||
// in the order of the histograms, ntuple columns declarations
|
||||
G4int counter = 0;
|
||||
for ( auto edep : fEdep ) {
|
||||
for (auto edep : fEdep) {
|
||||
analysisManager->FillH1(counter, edep);
|
||||
analysisManager->FillNtupleDColumn(counter++, edep);
|
||||
}
|
||||
for ( auto trackLength : fTrackLength ) {
|
||||
for (auto trackLength : fTrackLength) {
|
||||
analysisManager->FillH1(counter, trackLength);
|
||||
analysisManager->FillNtupleDColumn(counter++, trackLength);
|
||||
}
|
||||
|
||||
|
||||
analysisManager->AddNtupleRow();
|
||||
}
|
||||
|
||||
@@ -62,14 +60,14 @@ void RunData::FillPerEvent()
|
||||
|
||||
void RunData::Reset()
|
||||
{
|
||||
for ( auto& edep : fEdep ) {
|
||||
for (auto& edep : fEdep) {
|
||||
edep = 0.;
|
||||
}
|
||||
for ( auto& trackLength : fTrackLength ) {
|
||||
for (auto& trackLength : fTrackLength) {
|
||||
trackLength = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B4b
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
/// \brief Implementation of the B4b::SteppingAction class
|
||||
|
||||
#include "SteppingAction.hh"
|
||||
#include "RunData.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
|
||||
#include "G4Step.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "RunData.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Step.hh"
|
||||
|
||||
using namespace B4;
|
||||
|
||||
@@ -43,14 +44,13 @@ namespace B4b
|
||||
|
||||
SteppingAction::SteppingAction(const DetectorConstruction* detConstruction)
|
||||
: fDetConstruction(detConstruction)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
{
|
||||
// Collect energy and track length step by step
|
||||
// Collect energy and track length step by step
|
||||
|
||||
// get volume of the current step
|
||||
auto volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
|
||||
@@ -60,22 +60,21 @@ void SteppingAction::UserSteppingAction(const G4Step* step)
|
||||
|
||||
// step length
|
||||
G4double stepLength = 0.;
|
||||
if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
|
||||
if (step->GetTrack()->GetDefinition()->GetPDGCharge() != 0.) {
|
||||
stepLength = step->GetStepLength();
|
||||
}
|
||||
|
||||
auto runData = static_cast<RunData*>
|
||||
(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
auto runData = static_cast<RunData*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
|
||||
|
||||
if ( volume == fDetConstruction->GetAbsorberPV() ) {
|
||||
if (volume == fDetConstruction->GetAbsorberPV()) {
|
||||
runData->Add(kAbs, edep, stepLength);
|
||||
}
|
||||
|
||||
if ( volume == fDetConstruction->GetGapPV() ) {
|
||||
if (volume == fDetConstruction->GetGapPV()) {
|
||||
runData->Add(kGap, edep, stepLength);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
}
|
||||
} // namespace B4b
|
||||
|
||||
Reference in New Issue
Block a user