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(B4c)
#----------------------------------------------------------------------------
+29 -20
View File
@@ -31,22 +31,21 @@
#include "B4cActionInitialization.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4SteppingVerbose.hh"
#include "G4UIcommand.hh"
#include "FTFP_BERT.hh"
#include "Randomize.hh"
#include "G4VisExecutive.hh"
#include "G4UImanager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "FTFP_BERT.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace {
void PrintUsage() {
G4cerr << " Usage: " << G4endl;
G4cerr << " exampleB4c [-m macro ] [-u UIsession] [-t nThreads]" << G4endl;
G4cerr << " exampleB4a [-m macro ] [-u UIsession] [-t nThreads] [-vDefault]"
<< G4endl;
G4cerr << " note: -t option is available only for multi-threaded mode."
<< G4endl;
}
@@ -62,9 +61,10 @@ int main(int argc,char** argv)
PrintUsage();
return 1;
}
G4String macro;
G4String session;
G4bool verboseBestUnits = true;
#ifdef G4MULTITHREADED
G4int nThreads = 0;
#endif
@@ -76,31 +76,40 @@ int main(int argc,char** argv)
nThreads = G4UIcommand::ConvertToInt(argv[i+1]);
}
#endif
else if ( G4String(argv[i]) == "-vDefault" ) {
verboseBestUnits = false;
--i; // this option is not followed with a parameter
}
else {
PrintUsage();
return 1;
}
}
}
// Detect interactive mode (if no macro provided) and define UI session
//
G4UIExecutive* ui = 0;
G4UIExecutive* ui = nullptr;
if ( ! macro.size() ) {
ui = new G4UIExecutive(argc, argv, session);
}
// Optionally: choose a different Random engine...
//
// G4Random::setTheEngine(new CLHEP::MTwistEngine);
// Use G4SteppingVerboseWithUnits
if ( verboseBestUnits ) {
G4int precision = 4;
G4SteppingVerbose::UseBestUnit(precision);
}
// Construct the default run manager
//
auto* runManager =
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
#ifdef G4MULTITHREADED
if ( nThreads > 0 ) {
if ( nThreads > 0 ) {
runManager->SetNumberOfThreads(nThreads);
}
}
#endif
// Set mandatory initialization classes
@@ -110,10 +119,10 @@ int main(int argc,char** argv)
auto physicsList = new FTFP_BERT;
runManager->SetUserInitialization(physicsList);
auto actionInitialization = new B4cActionInitialization();
runManager->SetUserInitialization(actionInitialization);
// Initialize visualization
auto visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
@@ -130,7 +139,7 @@ int main(int argc,char** argv)
G4String command = "/control/execute ";
UImanager->ApplyCommand(command+macro);
}
else {
else {
// interactive mode : define UI session
UImanager->ApplyCommand("/control/execute init_vis.mac");
if (ui->IsGUI()) {
@@ -142,7 +151,7 @@ int main(int argc,char** argv)
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
File diff suppressed because it is too large Load Diff
-7
View File
@@ -23,13 +23,6 @@
/gui/addButton gun "neutron" "/gun/particle neutron"
/gui/addButton gun "proton" "/gun/particle proton"
#
# Vis menu :
/gui/addMenu vis Vis
/gui/addButton vis DAWNFILE "/control/execute visTutor/exN03Vis0.mac"
/gui/addButton vis OpenInventor "/control/execute visTutor/exN03Vis5.mac"
/gui/addButton vis TimeSlicing "/control/execute visTutor/exN03Vis12.mac"
/gui/addButton vis EmShower "/control/execute visTutor/exN03Vis13.mac"
#
# Viewer menu :
/gui/addMenu viewer Viewer
/gui/addButton viewer "Set style surface" "/vis/viewer/set/style surface"
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4PrimaryGeneratorAction.hh
/// \brief Definition of the B4PrimaryGeneratorAction class
@@ -38,19 +38,19 @@ class G4Event;
/// The primary generator action class with particle gum.
///
/// It defines a single particle which hits the calorimeter
/// It defines a single particle which hits the calorimeter
/// 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 B4PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
B4PrimaryGeneratorAction();
B4PrimaryGeneratorAction();
virtual ~B4PrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event* event);
// set methods
void SetRandomFlag(G4bool value);
+4 -4
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4RunAction.hh
/// \brief Definition of the B4RunAction class
@@ -37,9 +37,9 @@ class G4Run;
/// Run action class
///
/// It accumulates statistic and computes dispersion of the energy deposit
/// It accumulates statistic and computes dispersion of the energy deposit
/// and track lengths of charged particles with use of analysis tools:
/// H1D histograms are created in BeginOfRunAction() for the following
/// H1D histograms are created in BeginOfRunAction() for the following
/// physics quantities:
/// - Edep in absorber
/// - Edep in gap
@@ -49,7 +49,7 @@ class G4Run;
/// The histograms and ntuple are saved in the output file in a format
/// accoring to a selected technology in B4Analysis.hh.
///
/// In EndOfRunAction(), the accumulated statistic and computed
/// In EndOfRunAction(), the accumulated statistic and computed
/// dispersion is printed.
///
@@ -47,4 +47,4 @@ class B4cActionInitialization : public G4VUserActionInitialization
#endif
+6 -6
View File
@@ -66,7 +66,7 @@ class B4cCalorHit : public G4VHit
// get methods
G4double GetEdep() const;
G4double GetTrackLength() const;
private:
G4double fEdep; ///< Energy deposit in the sensitive volume
G4double fTrackLength; ///< Track length in the sensitive volume
@@ -99,16 +99,16 @@ inline void B4cCalorHit::operator delete(void *hit)
}
inline void B4cCalorHit::Add(G4double de, G4double dl) {
fEdep += de;
fEdep += de;
fTrackLength += dl;
}
inline G4double B4cCalorHit::GetEdep() const {
return fEdep;
inline G4double B4cCalorHit::GetEdep() const {
return fEdep;
}
inline G4double B4cCalorHit::GetTrackLength() const {
return fTrackLength;
inline G4double B4cCalorHit::GetTrackLength() const {
return fTrackLength;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -50,11 +50,11 @@ class G4HCofThisEvent;
class B4cCalorimeterSD : public G4VSensitiveDetector
{
public:
B4cCalorimeterSD(const G4String& name,
const G4String& hitsCollectionName,
B4cCalorimeterSD(const G4String& name,
const G4String& hitsCollectionName,
G4int nofCells);
virtual ~B4cCalorimeterSD();
// methods from base class
virtual void Initialize(G4HCofThisEvent* hitCollection);
virtual G4bool ProcessHits(G4Step* step, G4TouchableHistory* history);
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4cDetectorConstruction.hh
/// \brief Definition of the B4cDetectorConstruction class
@@ -49,7 +49,7 @@ class G4GlobalMagFieldMessenger;
///
/// In ConstructSDandField() sensitive detectors of B4cCalorimeterSD type
/// are created and associated with the Absorber and Gap volumes.
/// In addition a transverse uniform magnetic field is defined
/// In addition a transverse uniform magnetic field is defined
/// via G4GlobalMagFieldMessenger class.
class B4cDetectorConstruction : public G4VUserDetectorConstruction
@@ -61,16 +61,16 @@ class B4cDetectorConstruction : public G4VUserDetectorConstruction
public:
virtual G4VPhysicalVolume* Construct();
virtual void ConstructSDandField();
private:
// methods
//
void DefineMaterials();
G4VPhysicalVolume* DefineVolumes();
// data members
//
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
static G4ThreadLocal G4GlobalMagFieldMessenger* fMagFieldMessenger;
// magnetic field messenger
G4bool fCheckOverlaps; // option to activate checking of volumes overlaps
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4cEventAction.hh
/// \brief Definition of the B4cEventAction class
@@ -38,8 +38,8 @@
/// Event action class
///
/// In EndOfEventAction(), it prints the accumulated quantities of the energy
/// deposit and track lengths of charged particles in Absober and Gap layers
/// In EndOfEventAction(), it prints the accumulated quantities of the energy
/// deposit and track lengths of charged particles in Absober and Gap layers
/// stored in the hits collections.
class B4cEventAction : public G4UserEventAction
@@ -50,21 +50,21 @@ public:
virtual void BeginOfEventAction(const G4Event* event);
virtual void EndOfEventAction(const G4Event* event);
private:
// methods
B4cCalorHitsCollection* GetHitsCollection(G4int hcID,
const G4Event* event) const;
void PrintEventStatistics(G4double absoEdep, G4double absoTrackLength,
G4double gapEdep, G4double gapTrackLength) const;
// data members
// data members
G4int fAbsHCID;
G4int fGapHCID;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
+11 -11
View File
@@ -1,43 +1,43 @@
// ROOT macro file for plotting example B4 histograms
//
// ROOT macro file for plotting example B4 histograms
//
// Can be run from ROOT session:
// root[0] .x plotHisto.C
{
gROOT->Reset();
gROOT->SetStyle("Plain");
// Draw histos filled by Geant4 simulation
//
// Open file filled by Geant4 simulation
// Draw histos filled by Geant4 simulation
//
// Open file filled by Geant4 simulation
TFile f("B4.root");
// Create a canvas and divide it into 2x2 pads
TCanvas* c1 = new TCanvas("c1", "", 20, 20, 1000, 1000);
c1->Divide(2,2);
// Draw Eabs histogram in the pad 1
c1->cd(1);
TH1D* hist1 = (TH1D*)f.Get("Eabs");
hist1->Draw("HIST");
// Draw Labs histogram in the pad 2
c1->cd(2);
TH1D* hist2 = (TH1D*)f.Get("Labs");
hist2->Draw("HIST");
// Draw Egap histogram in the pad 3
// with logaritmic scale for y
TH1D* hist3 = (TH1D*)f.Get("Egap");
c1->cd(3);
gPad->SetLogy(1);
hist3->Draw("HIST");
// Draw Lgap histogram in the pad 4
// with logaritmic scale for y
c1->cd(4);
gPad->SetLogy(1);
TH1D* hist4 = (TH1D*)f.Get("Lgap");
hist4->Draw("HIST");
}
}
+10 -10
View File
@@ -1,42 +1,42 @@
// ROOT macro file for plotting example B4 ntuple
//
//
// Can be run from ROOT session:
// root[0] .x plotNtuple.C
{
gROOT->Reset();
gROOT->SetStyle("Plain");
// Draw histos filled by Geant4 simulation
//
// Open file filled by Geant4 simulation
// Draw histos filled by Geant4 simulation
//
// Open file filled by Geant4 simulation
TFile f("B4.root");
// Create a canvas and divide it into 2x2 pads
TCanvas* c1 = new TCanvas("c1", "", 20, 20, 1000, 1000);
c1->Divide(2,2);
// Get ntuple
TNtuple* ntuple = (TNtuple*)f.Get("B4");
// Draw Eabs histogram in the pad 1
c1->cd(1);
ntuple->Draw("Eabs");
// Draw Labs histogram in the pad 2
c1->cd(2);
ntuple->Draw("Labs");
// Draw Egap histogram in the pad 3
// with logaritmic scale for y ?? how to do this?
c1->cd(3);
gPad->SetLogy(1);
ntuple->Draw("Egap");
// Draw Lgap histogram in the pad 4
// with logaritmic scale for y ?? how to do this?
c1->cd(4);
gPad->SetLogy(1);
ntuple->Draw("Egap");
}
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4PrimaryGeneratorAction.cc
/// \brief Implementation of the B4PrimaryGeneratorAction class
@@ -51,7 +51,7 @@ B4PrimaryGeneratorAction::B4PrimaryGeneratorAction()
// default particle kinematic
//
auto particleDefinition
auto particleDefinition
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
fParticleGun->SetParticleDefinition(particleDefinition);
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
@@ -72,7 +72,7 @@ void B4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
// This function is called at the begining of event
// In order to avoid dependence of PrimaryGeneratorAction
// on DetectorConstruction class we get world volume
// on DetectorConstruction class we get world volume
// from G4LogicalVolumeStore
//
G4double worldZHalfLength = 0.;
@@ -85,7 +85,7 @@ void B4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
}
if ( worldBox ) {
worldZHalfLength = worldBox->GetZHalfLength();
worldZHalfLength = worldBox->GetZHalfLength();
}
else {
G4ExceptionDescription msg;
@@ -94,8 +94,8 @@ void B4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
msg << "The gun will be place in the center.";
G4Exception("B4PrimaryGeneratorAction::GeneratePrimaries()",
"MyCode0002", JustWarning, msg);
}
}
// Set gun position
fParticleGun
->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
+24 -24
View File
@@ -39,9 +39,9 @@
B4RunAction::B4RunAction()
: G4UserRunAction()
{
{
// set printing event number per each event
G4RunManager::GetRunManager()->SetPrintProgress(1);
G4RunManager::GetRunManager()->SetPrintProgress(1);
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
@@ -49,7 +49,7 @@ B4RunAction::B4RunAction()
auto analysisManager = G4AnalysisManager::Instance();
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Create directories
// Create directories
//analysisManager->SetHistoDirectoryName("histograms");
//analysisManager->SetNtupleDirectoryName("ntuple");
analysisManager->SetVerboseLevel(1);
@@ -58,7 +58,7 @@ B4RunAction::B4RunAction()
// Book histograms, ntuple
//
// Creating histograms
analysisManager->CreateH1("Eabs","Edep in absorber", 100, 0., 800*MeV);
analysisManager->CreateH1("Egap","Edep in gap", 100, 0., 100*MeV);
@@ -79,16 +79,16 @@ B4RunAction::B4RunAction()
B4RunAction::~B4RunAction()
{
delete G4AnalysisManager::Instance();
delete G4AnalysisManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4RunAction::BeginOfRunAction(const G4Run* /*run*/)
{
{
//inform the runManager to save random number seed
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Get analysis manager
auto analysisManager = G4AnalysisManager::Instance();
@@ -108,30 +108,30 @@ void B4RunAction::EndOfRunAction(const G4Run* /*run*/)
if ( analysisManager->GetH1(1) ) {
G4cout << G4endl << " ----> print histograms statistic ";
if(isMaster) {
G4cout << "for the entire run " << G4endl << G4endl;
G4cout << "for the entire run " << G4endl << G4endl;
}
else {
G4cout << "for the local thread " << G4endl << G4endl;
G4cout << "for the local thread " << G4endl << G4endl;
}
G4cout << " EAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(0)->mean(), "Energy")
<< " rms = "
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 = "
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 = "
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 = "
G4cout << " LGap : mean = "
<< G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
}
@@ -57,6 +57,6 @@ void B4cActionInitialization::Build() const
SetUserAction(new B4PrimaryGeneratorAction);
SetUserAction(new B4RunAction);
SetUserAction(new B4cEventAction);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+3 -3
View File
@@ -36,7 +36,7 @@
#include <iomanip>
G4ThreadLocal G4Allocator<B4cCalorHit>* B4cCalorHitAllocator = 0;
G4ThreadLocal G4Allocator<B4cCalorHit>* B4cCalorHitAllocator = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -81,9 +81,9 @@ G4bool B4cCalorHit::operator==(const B4cCalorHit& right) const
void B4cCalorHit::Print()
{
G4cout
<< "Edep: "
<< "Edep: "
<< std::setw(7) << G4BestUnit(fEdep,"Energy")
<< " track length: "
<< " track length: "
<< std::setw(7) << G4BestUnit( fTrackLength,"Length")
<< G4endl;
}
+24 -24
View File
@@ -37,7 +37,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4cCalorimeterSD::B4cCalorimeterSD(
const G4String& name,
const G4String& name,
const G4String& hitsCollectionName,
G4int nofCells)
: G4VSensitiveDetector(name),
@@ -49,8 +49,8 @@ B4cCalorimeterSD::B4cCalorimeterSD(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4cCalorimeterSD::~B4cCalorimeterSD()
{
B4cCalorimeterSD::~B4cCalorimeterSD()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -58,16 +58,16 @@ B4cCalorimeterSD::~B4cCalorimeterSD()
void B4cCalorimeterSD::Initialize(G4HCofThisEvent* hce)
{
// Create hits collection
fHitsCollection
= new B4cCalorHitsCollection(SensitiveDetectorName, collectionName[0]);
fHitsCollection
= new B4cCalorHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
auto hcID
auto hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
hce->AddHitsCollection( hcID, fHitsCollection );
hce->AddHitsCollection( hcID, fHitsCollection );
// Create hits
// fNofCells for cells + one more for total sums
// fNofCells for cells + one more for total sums
for (G4int i=0; i<fNofCells+1; i++ ) {
fHitsCollection->insert(new B4cCalorHit());
}
@@ -75,42 +75,42 @@ void B4cCalorimeterSD::Initialize(G4HCofThisEvent* hce)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
G4TouchableHistory*)
{
{
// energy deposit
auto edep = step->GetTotalEnergyDeposit();
// step length
G4double stepLength = 0.;
if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
stepLength = step->GetStepLength();
}
if ( edep==0. && stepLength == 0. ) return false;
if ( edep==0. && stepLength == 0. ) return false;
auto touchable = (step->GetPreStepPoint()->GetTouchable());
// Get calorimeter cell id
// Get calorimeter cell id
auto layerNumber = touchable->GetReplicaNumber(1);
// Get hit accounting data for this cell
auto hit = (*fHitsCollection)[layerNumber];
if ( ! hit ) {
G4ExceptionDescription msg;
msg << "Cannot access hit " << layerNumber;
msg << "Cannot access hit " << layerNumber;
G4Exception("B4cCalorimeterSD::ProcessHits()",
"MyCode0004", FatalException, msg);
}
}
// Get hit for total accounting
auto hitTotal
auto hitTotal
= (*fHitsCollection)[fHitsCollection->entries()-1];
// Add values
hit->Add(edep, stepLength);
hitTotal->Add(edep, stepLength);
hitTotal->Add(edep, stepLength);
return true;
}
@@ -118,11 +118,11 @@ G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
void B4cCalorimeterSD::EndOfEvent(G4HCofThisEvent*)
{
if ( verboseLevel>1 ) {
if ( verboseLevel>1 ) {
auto nofHits = fHitsCollection->entries();
G4cout
<< G4endl
<< "-------->Hits Collection: in this event they are " << nofHits
<< 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();
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4cDetectorConstruction.cc
/// \brief Implementation of the B4cDetectorConstruction class
@@ -49,8 +49,8 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* B4cDetectorConstruction::fMagFieldMessenger = 0;
G4ThreadLocal
G4GlobalMagFieldMessenger* B4cDetectorConstruction::fMagFieldMessenger = nullptr;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -64,16 +64,16 @@ B4cDetectorConstruction::B4cDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4cDetectorConstruction::~B4cDetectorConstruction()
{
}
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* B4cDetectorConstruction::Construct()
{
// Define materials
// Define materials
DefineMaterials();
// Define volumes
return DefineVolumes();
}
@@ -81,15 +81,15 @@ G4VPhysicalVolume* B4cDetectorConstruction::Construct()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4cDetectorConstruction::DefineMaterials()
{
{
// Lead material defined using NIST Manager
auto nistManager = G4NistManager::Instance();
nistManager->FindOrBuildMaterial("G4_Pb");
// Liquid argon material
G4double a; // mass of a mole;
G4double z; // z=mean number of protons;
G4double density;
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
@@ -114,74 +114,74 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
auto layerThickness = absoThickness + gapThickness;
auto calorThickness = fNofLayers * 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 ) {
G4ExceptionDescription msg;
msg << "Cannot retrieve materials already defined.";
msg << "Cannot retrieve materials already defined.";
G4Exception("B4DetectorConstruction::DefineVolumes()",
"MyCode0001", FatalException, msg);
}
//
}
//
// World
//
auto worldS
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 worldPV
= new G4PVPlacement(
0, // no rotation
G4ThreeVector(), // at (0,0,0)
worldLV, // its logical volume
worldLV, // its logical volume
"World", // its name
0, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
//
fCheckOverlaps); // checking overlaps
//
// Calorimeter
//
//
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
new G4PVPlacement(
0, // no rotation
G4ThreeVector(), // at (0,0,0)
calorLV, // its logical volume
calorLV, // its logical volume
"Calorimeter", // its name
worldLV, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
//
fCheckOverlaps); // checking overlaps
//
// Layer
//
auto layerS
auto layerS
= new G4Box("Layer", // its name
calorSizeXY/2, calorSizeXY/2, layerThickness/2); //its size
auto layerLV
= new G4LogicalVolume(
layerS, // its solid
@@ -195,66 +195,66 @@ G4VPhysicalVolume* B4cDetectorConstruction::DefineVolumes()
kZAxis, // axis of replication
fNofLayers, // number of replica
layerThickness); // witdth of replica
//
//
// Absorber
//
auto absorberS
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
"AbsoLV"); // its name
new G4PVPlacement(
0, // no rotation
G4ThreeVector(0., 0., -gapThickness/2), // its position
absorberLV, // its logical volume
absorberLV, // its logical volume
"Abso", // its name
layerLV, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
fCheckOverlaps); // checking overlaps
//
//
// Gap
//
auto gapS
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
"GapLV"); // its name
new G4PVPlacement(
0, // no rotation
G4ThreeVector(0., 0., absoThickness/2), // its position
gapLV, // its logical volume
gapLV, // its logical volume
"Gap", // its name
layerLV, // its mother volume
false, // no boolean operation
0, // copy number
fCheckOverlaps); // checking overlaps
fCheckOverlaps); // checking overlaps
//
// print parameters
//
G4cout
<< G4endl
<< G4endl
<< "------------------------------------------------------------" << G4endl
<< "---> The calorimeter is " << fNofLayers << " layers of: [ "
<< absoThickness/mm << "mm of " << absorberMaterial->GetName()
<< absoThickness/mm << "mm of " << absorberMaterial->GetName()
<< " + "
<< gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] " << G4endl
<< "------------------------------------------------------------" << G4endl;
//
//
// Visualization attributes
//
worldLV->SetVisAttributes (G4VisAttributes::GetInvisible());
@@ -275,20 +275,20 @@ void B4cDetectorConstruction::ConstructSDandField()
{
// G4SDManager::GetSDMpointer()->SetVerboseLevel(1);
//
//
// Sensitive detectors
//
auto absoSD
auto absoSD
= new B4cCalorimeterSD("AbsorberSD", "AbsorberHitsCollection", fNofLayers);
G4SDManager::GetSDMpointer()->AddNewDetector(absoSD);
SetSensitiveDetector("AbsoLV",absoSD);
auto gapSD
auto gapSD
= new B4cCalorimeterSD("GapSD", "GapHitsCollection", fNofLayers);
G4SDManager::GetSDMpointer()->AddNewDetector(gapSD);
SetSensitiveDetector("GapLV",gapSD);
//
//
// Magnetic field
//
// Create global magnetic field messenger.
@@ -297,7 +297,7 @@ void B4cDetectorConstruction::ConstructSDandField()
G4ThreeVector fieldValue;
fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
fMagFieldMessenger->SetVerboseLevel(1);
// Register the field messenger for deleting
G4AutoDelete::Register(fMagFieldMessenger);
}
+22 -22
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
/// \file B4cEventAction.cc
/// \brief Implementation of the B4cEventAction class
@@ -56,23 +56,23 @@ B4cEventAction::~B4cEventAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4cCalorHitsCollection*
B4cCalorHitsCollection*
B4cEventAction::GetHitsCollection(G4int hcID,
const G4Event* event) const
{
auto hitsCollection
auto hitsCollection
= static_cast<B4cCalorHitsCollection*>(
event->GetHCofThisEvent()->GetHC(hcID));
if ( ! hitsCollection ) {
G4ExceptionDescription msg;
msg << "Cannot access hitsCollection ID " << hcID;
msg << "Cannot access hitsCollection ID " << hcID;
G4Exception("B4cEventAction::GetHitsCollection()",
"MyCode0003", FatalException, msg);
}
}
return hitsCollection;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -82,14 +82,14 @@ void B4cEventAction::PrintEventStatistics(
{
// print event statistics
G4cout
<< " Absorber: total energy: "
<< " Absorber: total energy: "
<< std::setw(7) << G4BestUnit(absoEdep, "Energy")
<< " total track length: "
<< " total track length: "
<< std::setw(7) << G4BestUnit(absoTrackLength, "Length")
<< G4endl
<< " Gap: total energy: "
<< " Gap: total energy: "
<< std::setw(7) << G4BestUnit(gapEdep, "Energy")
<< " total track length: "
<< " total track length: "
<< std::setw(7) << G4BestUnit(gapTrackLength, "Length")
<< G4endl;
}
@@ -102,12 +102,12 @@ void B4cEventAction::BeginOfEventAction(const G4Event* /*event*/)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4cEventAction::EndOfEventAction(const G4Event* event)
{
{
// Get hits collections IDs (only once)
if ( fAbsHCID == -1 ) {
fAbsHCID
fAbsHCID
= G4SDManager::GetSDMpointer()->GetCollectionID("AbsorberHitsCollection");
fGapHCID
fGapHCID
= G4SDManager::GetSDMpointer()->GetCollectionID("GapHitsCollection");
}
@@ -118,37 +118,37 @@ void B4cEventAction::EndOfEventAction(const G4Event* event)
// Get hit with total values
auto absoHit = (*absoHC)[absoHC->entries()-1];
auto gapHit = (*gapHC)[gapHC->entries()-1];
// Print per event (modulo n)
//
auto eventID = event->GetEventID();
auto printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
G4cout << "---> End of event: " << eventID << G4endl;
G4cout << "---> End of event: " << eventID << G4endl;
PrintEventStatistics(
absoHit->GetEdep(), absoHit->GetTrackLength(),
gapHit->GetEdep(), gapHit->GetTrackLength());
}
}
// Fill histograms, ntuple
//
// get analysis manager
auto analysisManager = G4AnalysisManager::Instance();
// fill histograms
analysisManager->FillH1(0, absoHit->GetEdep());
analysisManager->FillH1(1, gapHit->GetEdep());
analysisManager->FillH1(2, absoHit->GetTrackLength());
analysisManager->FillH1(3, gapHit->GetTrackLength());
// fill ntuple
analysisManager->FillNtupleDColumn(0, absoHit->GetEdep());
analysisManager->FillNtupleDColumn(1, gapHit->GetEdep());
analysisManager->FillNtupleDColumn(2, absoHit->GetTrackLength());
analysisManager->FillNtupleDColumn(3, gapHit->GetTrackLength());
analysisManager->AddNtupleRow();
}
analysisManager->AddNtupleRow();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......