Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
+1 -4
View File
@@ -1,10 +1,7 @@
#----------------------------------------------------------------------------
# Setup the project
#
cmake_minimum_required(VERSION 3.8...3.18)
if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
cmake_minimum_required(VERSION 3.12...3.20)
project(B2a)
#----------------------------------------------------------------------------
+11 -9
View File
@@ -31,7 +31,7 @@
#include "B2ActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4SteppingVerbose.hh"
#include "G4UImanager.hh"
#include "FTFP_BERT.hh"
#include "G4StepLimiterPhysics.hh"
@@ -47,14 +47,16 @@ int main(int argc,char** argv)
{
// Detect interactive mode (if no arguments) and define UI session
//
G4UIExecutive* ui = 0;
if ( argc == 1 ) {
ui = new G4UIExecutive(argc, argv);
}
G4UIExecutive* ui = nullptr;
if ( argc == 1 ) { ui = new G4UIExecutive(argc, argv); }
// Optionally: choose a different Random engine...
// G4Random::setTheEngine(new CLHEP::MTwistEngine);
//use G4SteppingVerboseWithUnits
G4int precision = 4;
G4SteppingVerbose::UseBestUnit(precision);
// Construct the default run manager
//
auto* runManager =
@@ -67,10 +69,10 @@ int main(int argc,char** argv)
G4VModularPhysicsList* physicsList = new FTFP_BERT;
physicsList->RegisterPhysics(new G4StepLimiterPhysics());
runManager->SetUserInitialization(physicsList);
// Set user action classes
runManager->SetUserInitialization(new B2ActionInitialization());
// Initialize visualization
//
G4VisManager* visManager = new G4VisExecutive;
@@ -83,13 +85,13 @@ int main(int argc,char** argv)
// Process macro or start UI session
//
if ( ! ui ) {
if ( ! ui ) {
// batch mode
G4String command = "/control/execute ";
G4String fileName = argv[1];
UImanager->ApplyCommand(command+fileName);
}
else {
else {
// interactive mode
UImanager->ApplyCommand("/control/execute init_vis.mac");
if (ui->IsGUI()) {
File diff suppressed because it is too large Load Diff
@@ -49,4 +49,4 @@ class B2ActionInitialization : public G4VUserActionInitialization
#endif
@@ -38,21 +38,21 @@ class G4Event;
/// The primary generator action class with particle gum.
///
/// It defines a single particle which hits the Tracker
/// It defines a single particle which hits the Tracker
/// perpendicular to the input face. The type of the particle
/// can be changed via the G4 build-in commands of G4ParticleGun class
/// can be changed via the G4 build-in commands of G4ParticleGun class
/// (see the macros provided with this example).
class B2PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
B2PrimaryGeneratorAction();
B2PrimaryGeneratorAction();
virtual ~B2PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event* );
G4ParticleGun* GetParticleGun() {return fParticleGun;}
// Set methods
void SetRandomFlag(G4bool );
+3 -3
View File
@@ -44,16 +44,16 @@ class G4HCofThisEvent;
/// B2Tracker sensitive detector class
///
/// The hits are accounted in hits in ProcessHits() function which is called
/// by Geant4 kernel at each step. A hit is created with each step with non zero
/// by Geant4 kernel at each step. A hit is created with each step with non zero
/// energy deposit.
class B2TrackerSD : public G4VSensitiveDetector
{
public:
B2TrackerSD(const G4String& name,
B2TrackerSD(const G4String& name,
const G4String& hitsCollectionName);
virtual ~B2TrackerSD();
// methods from base class
virtual void Initialize(G4HCofThisEvent* hitCollection);
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
@@ -65,7 +65,7 @@ class B2aDetectorConstruction : public G4VUserDetectorConstruction
// methods
void DefineMaterials();
G4VPhysicalVolume* DefineVolumes();
// data members
G4int fNbOfChambers;
@@ -79,10 +79,10 @@ class B2aDetectorConstruction : public G4VUserDetectorConstruction
B2aDetectorMessenger* fMessenger; // messenger
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
// magnetic field messenger
G4bool fCheckOverlaps; // option to activate checking of volumes overlaps
G4bool fCheckOverlaps; // option to activate checking of volumes overlaps
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -52,9 +52,9 @@ class B2aDetectorMessenger: public G4UImessenger
public:
B2aDetectorMessenger(B2aDetectorConstruction* );
virtual ~B2aDetectorMessenger();
virtual void SetNewValue(G4UIcommand*, G4String);
private:
B2aDetectorConstruction* fDetectorConstruction;
@@ -57,6 +57,6 @@ void B2ActionInitialization::Build() const
SetUserAction(new B2PrimaryGeneratorAction);
SetUserAction(new B2RunAction);
SetUserAction(new B2EventAction);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+2 -2
View File
@@ -71,9 +71,9 @@ void B2EventAction::EndOfEventAction(const G4Event* event)
<< " trajectories stored in this event." << G4endl;
}
G4VHitsCollection* hc = event->GetHCofThisEvent()->GetHC(0);
G4cout << " "
G4cout << " "
<< hc->GetSize() << " hits stored in this event" << G4endl;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -50,7 +50,7 @@ B2PrimaryGeneratorAction::B2PrimaryGeneratorAction()
// default particle kinematic
G4ParticleDefinition* particleDefinition
G4ParticleDefinition* particleDefinition
= G4ParticleTable::GetParticleTable()->FindParticle("proton");
fParticleGun->SetParticleDefinition(particleDefinition);
@@ -78,7 +78,7 @@ void B2PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
G4double worldZHalfLength = 0;
G4LogicalVolume* worldLV
= G4LogicalVolumeStore::GetInstance()->GetVolume("World");
G4Box* worldBox = NULL;
G4Box* worldBox = nullptr;
if ( worldLV ) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
if ( worldBox ) worldZHalfLength = worldBox->GetZHalfLength();
else {
+3 -3
View File
@@ -36,9 +36,9 @@
B2RunAction::B2RunAction()
: G4UserRunAction()
{
{
// set printing event number per each 100 events
G4RunManager::GetRunManager()->SetPrintProgress(1000);
G4RunManager::GetRunManager()->SetPrintProgress(1000);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -49,7 +49,7 @@ B2RunAction::~B2RunAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2RunAction::BeginOfRunAction(const G4Run*)
{
{
//inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
}
+1 -1
View File
@@ -36,7 +36,7 @@
#include <iomanip>
G4ThreadLocal G4Allocator<B2TrackerHit>* B2TrackerHitAllocator=0;
G4ThreadLocal G4Allocator<B2TrackerHit>* B2TrackerHitAllocator = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+11 -11
View File
@@ -37,16 +37,16 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerSD::B2TrackerSD(const G4String& name,
const G4String& hitsCollectionName)
const G4String& hitsCollectionName)
: G4VSensitiveDetector(name),
fHitsCollection(NULL)
fHitsCollection(nullptr)
{
collectionName.insert(hitsCollectionName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2TrackerSD::~B2TrackerSD()
B2TrackerSD::~B2TrackerSD()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,21 +55,21 @@ void B2TrackerSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new B2TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
fHitsCollection
= new B2TrackerHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
G4int hcID
G4int hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
hce->AddHitsCollection( hcID, fHitsCollection );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
G4TouchableHistory*)
{
{
// energy deposit
G4double edep = aStep->GetTotalEnergyDeposit();
@@ -94,10 +94,10 @@ G4bool B2TrackerSD::ProcessHits(G4Step* aStep,
void B2TrackerSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
if ( verboseLevel>1 ) {
G4int nofHits = fHitsCollection->entries();
G4cout << G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
<< "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
}
@@ -26,7 +26,7 @@
//
/// \file B2aDetectorConstruction.cc
/// \brief Implementation of the B2aDetectorConstruction class
#include "B2aDetectorConstruction.hh"
#include "B2aDetectorMessenger.hh"
#include "B2TrackerSD.hh"
@@ -53,16 +53,16 @@
#include "G4SystemOfUnits.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* B2aDetectorConstruction::fMagFieldMessenger = 0;
G4ThreadLocal
G4GlobalMagFieldMessenger* B2aDetectorConstruction::fMagFieldMessenger = nullptr;
B2aDetectorConstruction::B2aDetectorConstruction()
:G4VUserDetectorConstruction(),
:G4VUserDetectorConstruction(),
fNbOfChambers(0),
fLogicTarget(NULL), fLogicChamber(NULL),
fTargetMaterial(NULL), fChamberMaterial(NULL),
fStepLimit(NULL),
fLogicTarget(nullptr), fLogicChamber(nullptr),
fTargetMaterial(nullptr), fChamberMaterial(nullptr),
fStepLimit(nullptr),
fCheckOverlaps(true)
{
fMessenger = new B2aDetectorMessenger(this);
@@ -72,16 +72,16 @@ B2aDetectorConstruction::B2aDetectorConstruction()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B2aDetectorConstruction::~B2aDetectorConstruction()
{
delete [] fLogicChamber;
delete [] fLogicChamber;
delete fStepLimit;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B2aDetectorConstruction::Construct()
{
// Define materials
@@ -95,13 +95,13 @@ G4VPhysicalVolume* B2aDetectorConstruction::Construct()
void B2aDetectorConstruction::DefineMaterials()
{
// Material definition
// Material definition
G4NistManager* nistManager = G4NistManager::Instance();
// Air defined using NIST Manager
nistManager->FindOrBuildMaterial("G4_AIR");
// Lead defined using NIST Manager
fTargetMaterial = nistManager->FindOrBuildMaterial("G4_Pb");
@@ -119,18 +119,18 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
G4Material* air = G4Material::GetMaterial("G4_AIR");
// Sizes of the principal geometrical components (solids)
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 trackerLength = (fNbOfChambers+1)*chamberSpacing;
G4double worldLength = 1.2 * (2*targetLength + trackerLength);
G4double targetRadius = 0.5*targetLength; // Radius of Target
targetLength = 0.5*targetLength; // Half length of the 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
@@ -151,9 +151,9 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
worldS, //its solid
air, //its material
"World"); //its name
// Must place the World Physical volume unrotated at (0,0,0).
//
//
G4VPhysicalVolume* worldPV
= new G4PVPlacement(
0, // no rotation
@@ -163,10 +163,10 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
0, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
fCheckOverlaps); // checking overlaps
// Target
G4ThreeVector positionTarget = G4ThreeVector(0,0,-(targetLength+trackerSize));
G4Tubs* targetS
@@ -180,19 +180,19 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
fCheckOverlaps); // checking overlaps
G4cout << "Target is " << 2*targetLength/cm << " cm of "
<< fTargetMaterial->GetName() << G4endl;
// Tracker
G4ThreeVector positionTracker = G4ThreeVector(0,0,0);
G4Tubs* trackerS
= new G4Tubs("tracker",0,trackerSize,trackerSize, 0.*deg, 360.*deg);
G4LogicalVolume* trackerLV
= new G4LogicalVolume(trackerS, air, "Tracker",0,0,0);
= new G4LogicalVolume(trackerS, air, "Tracker",0,0,0);
new G4PVPlacement(0, // no rotation
positionTracker, // at (x,y,z)
trackerLV, // its logical volume
@@ -200,7 +200,7 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
worldLV, // its mother volume
false, // no boolean operations
0, // copy number
fCheckOverlaps); // checking overlaps
fCheckOverlaps); // checking overlaps
// Visualization attributes
@@ -217,9 +217,9 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
<< G4endl
<< "The chambers are " << chamberWidth/cm << " cm of "
<< fChamberMaterial->GetName() << G4endl
<< "The distance between chamber is " << chamberSpacing/cm << " cm"
<< "The distance between chamber is " << chamberSpacing/cm << " cm"
<< G4endl;
G4double firstPosition = -trackerSize + chamberSpacing;
G4double firstLength = trackerLength/10;
G4double lastLength = trackerLength;
@@ -257,7 +257,7 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
trackerLV, // its mother volume
false, // no boolean operations
copyNo, // copy number
fCheckOverlaps); // checking overlaps
fCheckOverlaps); // checking overlaps
}
@@ -271,7 +271,7 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
G4double maxStep = 0.5*chamberWidth;
fStepLimit = new G4UserLimits(maxStep);
trackerLV->SetUserLimits(fStepLimit);
/// Set additional contraints on the track, with G4UserSpecialCuts
///
/// G4double maxLength = 2*trackerLength, maxTime = 0.1*ns, minEkin = 10*MeV;
@@ -286,7 +286,7 @@ G4VPhysicalVolume* B2aDetectorConstruction::DefineVolumes()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::ConstructSDandField()
{
// Sensitive detectors
@@ -295,7 +295,7 @@ void B2aDetectorConstruction::ConstructSDandField()
B2TrackerSD* aTrackerSD = new B2TrackerSD(trackerChamberSDname,
"TrackerHitsCollection");
G4SDManager::GetSDMpointer()->AddNewDetector(aTrackerSD);
// Setting aTrackerSD to all logical volumes with the same name
// Setting aTrackerSD to all logical volumes with the same name
// of "Chamber_LV".
SetSensitiveDetector("Chamber_LV", aTrackerSD, true);
@@ -305,36 +305,36 @@ void B2aDetectorConstruction::ConstructSDandField()
G4ThreeVector fieldValue = G4ThreeVector();
fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
fMagFieldMessenger->SetVerboseLevel(1);
// Register the field messenger for deleting
G4AutoDelete::Register(fMagFieldMessenger);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::SetTargetMaterial(G4String materialName)
{
G4NistManager* nistManager = G4NistManager::Instance();
G4Material* pttoMaterial =
G4Material* pttoMaterial =
nistManager->FindOrBuildMaterial(materialName);
if (fTargetMaterial != pttoMaterial) {
if ( pttoMaterial ) {
fTargetMaterial = pttoMaterial;
if (fLogicTarget) fLogicTarget->SetMaterial(fTargetMaterial);
G4cout
<< G4endl
G4cout
<< G4endl
<< "----> The target is made of " << materialName << G4endl;
} else {
G4cout
<< G4endl
G4cout
<< G4endl
<< "--> WARNING from SetTargetMaterial : "
<< materialName << " not found" << G4endl;
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B2aDetectorConstruction::SetChamberMaterial(G4String materialName)
@@ -351,12 +351,12 @@ void B2aDetectorConstruction::SetChamberMaterial(G4String materialName)
if (fLogicChamber[copyNo]) fLogicChamber[copyNo]->
SetMaterial(fChamberMaterial);
}
G4cout
<< G4endl
G4cout
<< G4endl
<< "----> The chambers are made of " << materialName << G4endl;
} else {
G4cout
<< G4endl
G4cout
<< G4endl
<< "--> WARNING from SetChamberMaterial : "
<< materialName << " not found" << G4endl;
}
@@ -375,4 +375,4 @@ void B2aDetectorConstruction::SetMaxStep(G4double maxStep)
void B2aDetectorConstruction::SetCheckOverlaps(G4bool checkOverlaps)
{
fCheckOverlaps = checkOverlaps;
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B2aDetectorMessenger.cc
/// \brief Implementation of the B2aDetectorMessenger class
@@ -87,7 +87,7 @@ void B2aDetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
if( command == fStepMaxCmd ) {
fDetectorConstruction
->SetMaxStep(fStepMaxCmd->GetNewDoubleValue(newValue));
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......