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,9 +28,10 @@
/// \brief Implementation of the B2::ActionInitialization class
#include "ActionInitialization.hh"
#include "EventAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
namespace B2
{
@@ -53,5 +54,4 @@ void ActionInitialization::Build() const
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+113 -133
View File
@@ -28,29 +28,25 @@
/// \brief Implementation of the B2a::DetectorConstruction class
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "TrackerSD.hh"
#include "G4AutoDelete.hh"
#include "G4Box.hh"
#include "G4Colour.hh"
#include "G4GeometryManager.hh"
#include "G4GeometryTolerance.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4SDManager.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
#include "G4GeometryTolerance.hh"
#include "G4GeometryManager.hh"
#include "G4UserLimits.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4SDManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4Tubs.hh"
#include "G4UserLimits.hh"
#include "G4VisAttributes.hh"
using namespace B2;
@@ -59,8 +55,7 @@ namespace B2a
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
G4ThreadLocal G4GlobalMagFieldMessenger* DetectorConstruction::fMagFieldMessenger = nullptr;
DetectorConstruction::DetectorConstruction()
{
@@ -74,7 +69,7 @@ DetectorConstruction::DetectorConstruction()
DetectorConstruction::~DetectorConstruction()
{
delete [] fLogicChamber;
delete[] fLogicChamber;
delete fStepLimit;
delete fMessenger;
}
@@ -102,7 +97,7 @@ void DetectorConstruction::DefineMaterials()
nistManager->FindOrBuildMaterial("G4_AIR");
// Lead defined using NIST Manager
fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
// Xenon gas defined using NIST Manager
fChamberMaterial = nistManager->FindOrBuildMaterial("G4_Xe");
@@ -115,22 +110,22 @@ void DetectorConstruction::DefineMaterials()
G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
{
G4Material* air = G4Material::GetMaterial("G4_AIR");
G4Material* air = G4Material::GetMaterial("G4_AIR");
// Sizes of the principal geometrical components (solids)
G4double chamberSpacing = 80*cm; // from chamber center to center!
G4double chamberSpacing = 80 * cm; // from chamber center to center!
G4double chamberWidth = 20.0*cm; // width of the chambers
G4double targetLength = 5.0*cm; // full length of Target
G4double chamberWidth = 20.0 * cm; // width of the chambers
G4double targetLength = 5.0 * cm; // full length of Target
G4double trackerLength = (fNbOfChambers+1)*chamberSpacing;
G4double trackerLength = (fNbOfChambers + 1) * chamberSpacing;
G4double worldLength = 1.2 * (2*targetLength + trackerLength);
G4double worldLength = 1.2 * (2 * targetLength + trackerLength);
G4double targetRadius = 0.5*targetLength; // Radius of Target
targetLength = 0.5*targetLength; // Half length of the Target
G4double trackerSize = 0.5*trackerLength; // Half length of the Tracker
G4double targetRadius = 0.5 * targetLength; // Radius of Target
targetLength = 0.5 * targetLength; // Half length of the Target
G4double trackerSize = 0.5 * trackerLength; // Half length of the Tracker
// Definitions of Solids, Logical Volumes, Physical Volumes
@@ -139,114 +134,108 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
G4GeometryManager::GetInstance()->SetWorldMaximumExtent(worldLength);
G4cout << "Computed tolerance = "
<< G4GeometryTolerance::GetInstance()->GetSurfaceTolerance()/mm
<< " mm" << G4endl;
<< G4GeometryTolerance::GetInstance()->GetSurfaceTolerance() / mm << " mm" << G4endl;
auto worldS = new G4Box("world", // its name
worldLength / 2, worldLength / 2, worldLength / 2); // its size
auto worldLV = new G4LogicalVolume(worldS, // its solid
air, // its material
"World"); // its name
auto worldS = new G4Box("world", // its name
worldLength / 2, worldLength / 2, worldLength / 2); // its size
auto worldLV = new G4LogicalVolume(worldS, // its solid
air, // its material
"World"); // its name
// Must place the World Physical volume unrotated at (0,0,0).
//
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 operations
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 operations
0, // copy number
fCheckOverlaps); // checking overlaps
// Target
G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
G4ThreeVector positionTarget = G4ThreeVector(0, 0, -(targetLength + trackerSize));
auto targetS = new G4Tubs("target", 0., targetRadius, targetLength, 0. * deg, 360. * deg);
fLogicTarget = new G4LogicalVolume(targetS, fTargetMaterial, "Target", nullptr, nullptr, nullptr);
new G4PVPlacement(nullptr, // no rotation
positionTarget, // at (x,y,z)
fLogicTarget, // its logical volume
"Target", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
positionTarget, // at (x,y,z)
fLogicTarget, // its logical volume
"Target", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
G4cout << "Target is " << 2*targetLength/cm << " cm of "
<< fTargetMaterial->GetName() << G4endl;
G4cout << "Target is " << 2 * targetLength / cm << " cm of " << fTargetMaterial->GetName()
<< G4endl;
// Tracker
G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
G4ThreeVector positionTracker = G4ThreeVector(0, 0, 0);
auto trackerS = new G4Tubs("tracker", 0, trackerSize, trackerSize, 0. * deg, 360. * deg);
auto trackerLV = new G4LogicalVolume(trackerS, air, "Tracker", nullptr, nullptr, nullptr);
new G4PVPlacement(nullptr, // no rotation
positionTracker, // at (x,y,z)
trackerLV, // its logical volume
"Tracker", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
positionTracker, // at (x,y,z)
trackerLV, // its logical volume
"Tracker", // its name
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
// Visualization attributes
G4VisAttributes boxVisAtt(G4Colour::White());
G4VisAttributes chamberVisAtt(G4Colour::Yellow());
worldLV ->SetVisAttributes(boxVisAtt);
fLogicTarget ->SetVisAttributes(boxVisAtt);
trackerLV ->SetVisAttributes(boxVisAtt);
worldLV->SetVisAttributes(boxVisAtt);
fLogicTarget->SetVisAttributes(boxVisAtt);
trackerLV->SetVisAttributes(boxVisAtt);
// Tracker segments
G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. "
<< G4endl
<< "The chambers are " << chamberWidth/cm << " cm of "
<< fChamberMaterial->GetName() << G4endl
<< "The distance between chamber is " << chamberSpacing/cm << " cm"
<< G4endl;
G4cout << "There are " << fNbOfChambers << " chambers in the tracker region. " << G4endl
<< "The chambers are " << chamberWidth / cm << " cm of " << fChamberMaterial->GetName()
<< G4endl << "The distance between chamber is " << chamberSpacing / cm << " cm" << G4endl;
G4double firstPosition = -trackerSize + chamberSpacing;
G4double firstLength = trackerLength/10;
G4double lastLength = trackerLength;
G4double firstLength = trackerLength / 10;
G4double lastLength = trackerLength;
G4double halfWidth = 0.5*chamberWidth;
G4double halfWidth = 0.5 * chamberWidth;
G4double rmaxFirst = 0.5 * firstLength;
G4double rmaxIncr = 0.0;
if( fNbOfChambers > 0 ){
rmaxIncr = 0.5 * (lastLength-firstLength)/(fNbOfChambers-1);
if (chamberSpacing < chamberWidth) {
G4Exception("DetectorConstruction::DefineVolumes()",
"InvalidSetup", FatalException,
"Width>Spacing");
if (fNbOfChambers > 0) {
rmaxIncr = 0.5 * (lastLength - firstLength) / (fNbOfChambers - 1);
if (chamberSpacing < chamberWidth) {
G4Exception("DetectorConstruction::DefineVolumes()", "InvalidSetup", FatalException,
"Width>Spacing");
}
}
for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
for (G4int copyNo = 0; copyNo < fNbOfChambers; copyNo++) {
G4double Zposition = firstPosition + copyNo * chamberSpacing;
G4double rmax = rmaxFirst + copyNo * rmaxIncr;
G4double Zposition = firstPosition + copyNo * chamberSpacing;
G4double rmax = rmaxFirst + copyNo * rmaxIncr;
auto chamberS = new G4Tubs("Chamber_solid", 0, rmax, halfWidth, 0. * deg, 360. * deg);
auto chamberS = new G4Tubs("Chamber_solid", 0, rmax, halfWidth, 0. * deg, 360. * deg);
fLogicChamber[copyNo] =
new G4LogicalVolume(chamberS, fChamberMaterial, "Chamber_LV", nullptr, nullptr, nullptr);
fLogicChamber[copyNo] =
new G4LogicalVolume(chamberS, fChamberMaterial, "Chamber_LV", nullptr, nullptr, nullptr);
fLogicChamber[copyNo]->SetVisAttributes(chamberVisAtt);
fLogicChamber[copyNo]->SetVisAttributes(chamberVisAtt);
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(0, 0, Zposition), // at (x,y,z)
fLogicChamber[copyNo], // its logical volume
"Chamber_PV", // its name
trackerLV, // its mother volume
false, // no boolean operations
copyNo, // copy number
fCheckOverlaps); // checking overlaps
new G4PVPlacement(nullptr, // no rotation
G4ThreeVector(0, 0, Zposition), // at (x,y,z)
fLogicChamber[copyNo], // its logical volume
"Chamber_PV", // its name
trackerLV, // its mother volume
false, // no boolean operations
copyNo, // copy number
fCheckOverlaps); // checking overlaps
}
// Example of User Limits
@@ -256,7 +245,7 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes()
//
// Sets a max step length in the tracker region, with G4StepLimiter
G4double maxStep = 0.5*chamberWidth;
G4double maxStep = 0.5 * chamberWidth;
fStepLimit = new G4UserLimits(maxStep);
trackerLV->SetUserLimits(fStepLimit);
@@ -280,11 +269,11 @@ void DetectorConstruction::ConstructSDandField()
// Sensitive detectors
G4String trackerChamberSDname = "/TrackerChamberSD";
auto aTrackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
// Setting aTrackerSD to all logical volumes with the same name
auto trackerSD = new TrackerSD(trackerChamberSDname, "TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(trackerSD);
// Setting trackerSD to all logical volumes with the same name
// of "Chamber_LV".
SetSensitiveDetector("Chamber_LV", aTrackerSD, true);
SetSensitiveDetector("Chamber_LV", trackerSD, true);
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
@@ -303,22 +292,18 @@ void DetectorConstruction::SetTargetMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* pttoMaterial =
nistManager->FindOrBuildMaterial(materialName);
G4Material* pttoMaterial = nistManager->FindOrBuildMaterial(materialName);
if (fTargetMaterial != pttoMaterial) {
if ( pttoMaterial ) {
fTargetMaterial = pttoMaterial;
if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
G4cout
<< G4endl
<< "----> The target is made of " << materialName << G4endl;
} else {
G4cout
<< G4endl
<< "--> WARNING from SetTargetMaterial : "
<< materialName << " not found" << G4endl;
}
if (pttoMaterial) {
fTargetMaterial = pttoMaterial;
if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
G4cout << G4endl << "----> The target is made of " << materialName << G4endl;
}
else {
G4cout << G4endl << "--> WARNING from SetTargetMaterial : " << materialName << " not found"
<< G4endl;
}
}
}
@@ -328,25 +313,20 @@ void DetectorConstruction::SetChamberMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* pttoMaterial =
nistManager->FindOrBuildMaterial(materialName);
G4Material* pttoMaterial = nistManager->FindOrBuildMaterial(materialName);
if (fChamberMaterial != pttoMaterial) {
if ( pttoMaterial ) {
fChamberMaterial = pttoMaterial;
for (G4int copyNo=0; copyNo<fNbOfChambers; copyNo++) {
if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->
SetMaterial(fChamberMaterial);
}
G4cout
<< G4endl
<< "----> The chambers are made of " << materialName << G4endl;
} else {
G4cout
<< G4endl
<< "--> WARNING from SetChamberMaterial : "
<< materialName << " not found" << G4endl;
}
if (pttoMaterial) {
fChamberMaterial = pttoMaterial;
for (G4int copyNo = 0; copyNo < fNbOfChambers; copyNo++) {
if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->SetMaterial(fChamberMaterial);
}
G4cout << G4endl << "----> The chambers are made of " << materialName << G4endl;
}
else {
G4cout << G4endl << "--> WARNING from SetChamberMaterial : " << materialName << " not found"
<< G4endl;
}
}
}
@@ -354,7 +334,7 @@ void DetectorConstruction::SetChamberMaterial(G4String materialName)
void DetectorConstruction::SetMaxStep(G4double maxStep)
{
if ((fStepLimit)&&(maxStep>0.)) fStepLimit->SetMaxAllowedStep(maxStep);
if ((fStepLimit) && (maxStep > 0.)) fStepLimit->SetMaxAllowedStep(maxStep);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -366,4 +346,4 @@ void DetectorConstruction::SetCheckOverlaps(G4bool checkOverlaps)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2a
+22 -21
View File
@@ -28,19 +28,19 @@
/// \brief Implementation of the B2a::DetectorMessenger class
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIdirectory.hh"
namespace B2a
{
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
: fDetectorConstruction(det)
DetectorMessenger::DetectorMessenger(DetectorConstruction* det) : fDetectorConstruction(det)
{
fDirectory = new G4UIdirectory("/B2/");
fDirectory->SetGuidance("UI commands specific to this example.");
@@ -48,19 +48,19 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction* det)
fDetDirectory = new G4UIdirectory("/B2/det/");
fDetDirectory->SetGuidance("Detector construction control");
fTargMatCmd = new G4UIcmdWithAString("/B2/det/setTargetMaterial",this);
fTargMatCmd = new G4UIcmdWithAString("/B2/det/setTargetMaterial", this);
fTargMatCmd->SetGuidance("Select Material of the Target.");
fTargMatCmd->SetParameterName("choice",false);
fTargMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fTargMatCmd->SetParameterName("choice", false);
fTargMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fChamMatCmd = new G4UIcmdWithAString("/B2/det/setChamberMaterial",this);
fChamMatCmd = new G4UIcmdWithAString("/B2/det/setChamberMaterial", this);
fChamMatCmd->SetGuidance("Select Material of the Chamber.");
fChamMatCmd->SetParameterName("choice",false);
fChamMatCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fChamMatCmd->SetParameterName("choice", false);
fChamMatCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/B2/det/stepMax",this);
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/B2/det/stepMax", this);
fStepMaxCmd->SetGuidance("Define a step max");
fStepMaxCmd->SetParameterName("stepMax",false);
fStepMaxCmd->SetParameterName("stepMax", false);
fStepMaxCmd->SetUnitCategory("Length");
fStepMaxCmd->AvailableForStates(G4State_Idle);
}
@@ -78,20 +78,21 @@ DetectorMessenger::~DetectorMessenger()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == fTargMatCmd )
{ fDetectorConstruction->SetTargetMaterial(newValue);}
if (command == fTargMatCmd) {
fDetectorConstruction->SetTargetMaterial(newValue);
}
if( command == fChamMatCmd )
{ fDetectorConstruction->SetChamberMaterial(newValue);}
if (command == fChamMatCmd) {
fDetectorConstruction->SetChamberMaterial(newValue);
}
if( command == fStepMaxCmd ) {
fDetectorConstruction
->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
if (command == fStepMaxCmd) {
fDetectorConstruction->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2a
+7 -13
View File
@@ -30,9 +30,7 @@
#include "EventAction.hh"
#include "G4Event.hh"
#include "G4EventManager.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4ios.hh"
namespace B2
@@ -40,8 +38,7 @@ namespace B2
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::BeginOfEventAction(const G4Event*)
{}
void EventAction::BeginOfEventAction(const G4Event*) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -56,19 +53,16 @@ void EventAction::EndOfEventAction(const G4Event* event)
// periodic printing
G4int eventID = event->GetEventID();
if ( eventID < 100 || eventID % 100 == 0) {
G4cout << ">>> Event: " << eventID << G4endl;
if ( trajectoryContainer ) {
G4cout << " " << n_trajectories
<< " trajectories stored in this event." << G4endl;
if (eventID < 100 || eventID % 100 == 0) {
G4cout << ">>> Event: " << eventID << G4endl;
if (trajectoryContainer) {
G4cout << " " << n_trajectories << " trajectories stored in this event." << G4endl;
}
G4VHitsCollection* hc = event->GetHCofThisEvent()->GetHC(0);
G4cout << " "
<< hc->GetSize() << " hits stored in this event" << G4endl;
G4cout << " " << hc->GetSize() << " hits stored in this event" << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
@@ -29,15 +29,12 @@
#include "PrimaryGeneratorAction.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"
namespace B2
{
@@ -51,12 +48,12 @@ PrimaryGeneratorAction::PrimaryGeneratorAction()
// default particle kinematic
G4ParticleDefinition* particleDefinition
= G4ParticleTable::GetParticleTable()->FindParticle("proton");
G4ParticleDefinition* particleDefinition =
G4ParticleTable::GetParticleTable()->FindParticle("proton");
fParticleGun->SetParticleDefinition(particleDefinition);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
fParticleGun->SetParticleEnergy(3.0*GeV);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
fParticleGun->SetParticleEnergy(3.0 * GeV);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -68,7 +65,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
@@ -77,12 +74,12 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// from G4LogicalVolumeStore.
G4double worldZHalfLength = 0;
G4LogicalVolume* worldLV
= G4LogicalVolumeStore::GetInstance()->GetVolume("World");
G4LogicalVolume* worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
G4Box* worldBox = nullptr;
if ( worldLV ) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
if ( worldBox ) worldZHalfLength = worldBox->GetZHalfLength();
else {
if (worldLV) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
if (worldBox)
worldZHalfLength = worldBox->GetZHalfLength();
else {
G4cerr << "World volume of box not found." << G4endl;
G4cerr << "Perhaps you have changed geometry." << G4endl;
G4cerr << "The gun will be place in the center." << G4endl;
@@ -90,12 +87,11 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// Starting a primary particle close to the world boundary.
//
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength+1*um));
fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength + 1 * um));
fParticleGun->GeneratePrimaryVertex(anEvent);
fParticleGun->GeneratePrimaryVertex(event);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+3 -6
View File
@@ -29,7 +29,6 @@
#include "RunAction.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
namespace B2
@@ -47,16 +46,14 @@ RunAction::RunAction()
void RunAction::BeginOfRunAction(const G4Run*)
{
//inform the runManager to save random number seed
// inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* )
{}
void RunAction::EndOfRunAction(const G4Run*) {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+9 -13
View File
@@ -28,10 +28,11 @@
/// \brief Implementation of the B2::TrackerHit class
#include "TrackerHit.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4Circle.hh"
#include "G4Colour.hh"
#include "G4UnitsTable.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include <iomanip>
@@ -45,7 +46,7 @@ G4ThreadLocal G4Allocator<TrackerHit>* TrackerHitAllocator = nullptr;
G4bool TrackerHit::operator==(const TrackerHit& right) const
{
return ( this == &right ) ? true : false;
return (this == &right) ? true : false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,8 +54,7 @@ G4bool TrackerHit::operator==(const TrackerHit& right) const
void TrackerHit::Draw()
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager)
{
if (pVVisManager) {
G4Circle circle(fPos);
circle.SetScreenSize(4.);
circle.SetFillStyle(G4Circle::filled);
@@ -68,15 +68,11 @@ void TrackerHit::Draw()
void TrackerHit::Print()
{
G4cout
<< " trackID: " << fTrackID << " chamberNb: " << fChamberNb
<< "Edep: "
<< std::setw(7) << G4BestUnit(fEdep,"Energy")
<< " Position: "
<< std::setw(7) << G4BestUnit( fPos,"Length")
<< G4endl;
G4cout << " trackID: " << fTrackID << " chamberNb: " << fChamberNb << "Edep: " << std::setw(7)
<< G4BestUnit(fEdep, "Energy") << " Position: " << std::setw(7)
<< G4BestUnit(fPos, "Length") << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2
+22 -27
View File
@@ -28,10 +28,11 @@
/// \brief Implementation of the B2::TrackerSD class
#include "TrackerSD.hh"
#include "G4HCofThisEvent.hh"
#include "G4SDManager.hh"
#include "G4Step.hh"
#include "G4ThreeVector.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
namespace B2
@@ -39,9 +40,8 @@ namespace B2
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackerSD::TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
TrackerSD::TrackerSD(const G4String& name, const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
{
collectionName.insert(hitsCollectionName);
}
@@ -52,37 +52,33 @@ void TrackerSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
fHitsCollection = new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection(hcID, fHitsCollection);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool TrackerSD::ProcessHits(G4Step* aStep,
G4TouchableHistory*)
G4bool TrackerSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
// energy deposit
G4double edep = aStep->GetTotalEnergyDeposit();
G4double edep = step->GetTotalEnergyDeposit();
if (edep==0.) return false;
if (edep == 0.) return false;
auto newHit = new TrackerHit();
newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
newHit->SetChamberNb(aStep->GetPreStepPoint()->GetTouchableHandle()
->GetCopyNumber());
newHit->SetTrackID(step->GetTrack()->GetTrackID());
newHit->SetChamberNb(step->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber());
newHit->SetEdep(edep);
newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
newHit->SetPos(step->GetPostStepPoint()->GetPosition());
fHitsCollection->insert( newHit );
fHitsCollection->insert(newHit);
//newHit->Print();
// newHit->Print();
return true;
}
@@ -91,16 +87,15 @@ G4bool TrackerSD::ProcessHits(G4Step* aStep,
void TrackerSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
std::size_t nofHits = fHitsCollection->entries();
G4cout << G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for ( std::size_t i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
if (verboseLevel > 1) {
std::size_t nofHits = fHitsCollection->entries();
G4cout << G4endl << "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for (std::size_t i = 0; i < nofHits; i++)
(*fHitsCollection)[i]->Print();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
}
} // namespace B2