Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: ActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $
//
/// \file optical/OpNovice2/src/ActionInitialization.cc
/// \brief Implementation of the ActionInitialization class
@@ -56,12 +56,23 @@ DetectorConstruction::DetectorConstruction()
fTank_x = fTank_y = fTank_z = 1.0*m;
fTank = nullptr;
fSurface = nullptr;
fBoxMPT = new G4MaterialPropertiesTable();
fWorldMPT = new G4MaterialPropertiesTable();
fTankMPT = new G4MaterialPropertiesTable();
fWorldMPT = new G4MaterialPropertiesTable();
fSurfaceMPT = new G4MaterialPropertiesTable();
fSurface = new G4OpticalSurface("Surface");
fSurface->SetType(dielectric_dielectric);
fSurface->SetFinish(ground);
fSurface->SetModel(unified);
fSurface->SetMaterialPropertiesTable(fSurfaceMPT);
fTank_LV = nullptr;
fWorld_LV = nullptr;
fTankMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_WATER");
fWorldMaterial = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
fDetectorMessenger = new DetectorMessenger(this);
}
@@ -76,61 +87,42 @@ DetectorConstruction::~DetectorConstruction()
G4VPhysicalVolume* DetectorConstruction::Construct()
{
fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
fTankMaterial->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
// ------------- Materials -------------
G4NistManager* man = G4NistManager::Instance();
G4Material* air = man->FindOrBuildMaterial("G4_AIR");
G4Material* water = man->FindOrBuildMaterial("G4_WATER");
//
// ------------ Generate & Add Material Properties Table ------------
//
water->SetMaterialPropertiesTable(fBoxMPT);
water->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
air->SetMaterialPropertiesTable(fWorldMPT);
fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
// ------------- Volumes --------------
// The experimental Hall
G4Box* world_box = new G4Box("World", fExpHall_x, fExpHall_y, fExpHall_z);
G4LogicalVolume* world_LV
= new G4LogicalVolume(world_box,air, "World", 0, 0, 0);
fWorld_LV
= new G4LogicalVolume(world_box, fWorldMaterial, "World", 0, 0, 0);
G4VPhysicalVolume* world_PV
= new G4PVPlacement(0, G4ThreeVector(), world_LV, "World", 0, false, 0);
= new G4PVPlacement(0, G4ThreeVector(), fWorld_LV, "World", 0, false, 0);
// The Water Tank
G4Box* waterTank_box = new G4Box("Tank",fTank_x,fTank_y,fTank_z);
// The tank
G4Box* tank_box = new G4Box("Tank", fTank_x, fTank_y, fTank_z);
G4LogicalVolume* waterTank_log
= new G4LogicalVolume(waterTank_box,water,"Tank",0,0,0);
fTank_LV
= new G4LogicalVolume(tank_box, fTankMaterial, "Tank", 0, 0, 0);
fTank
= new G4PVPlacement(0, G4ThreeVector(), waterTank_log, "Tank",
world_LV, false, 0);
= new G4PVPlacement(0, G4ThreeVector(), fTank_LV, "Tank",
fWorld_LV, false, 0);
// ------------- Surface --------------
fSurface = new G4OpticalSurface("Surface");
fSurface->SetType(dielectric_dielectric);
fSurface->SetFinish(polished);
fSurface->SetModel(unified);
fSurface->SetMaterialPropertiesTable(fSurfaceMPT);
G4LogicalBorderSurface* surface =
new G4LogicalBorderSurface("Surface",
fTank, world_PV, fSurface);
G4OpticalSurface* opticalSurface = dynamic_cast <G4OpticalSurface*>
(surface->GetSurface(fTank,world_PV)->GetSurfaceProperty());
G4cout << "opticalSurface->DumpInfo" << G4endl;
if (opticalSurface) opticalSurface->DumpInfo();
G4cout << "****** opticalSurface->DumpInfo:" << G4endl;
if (opticalSurface) { opticalSurface->DumpInfo(); }
G4cout << "****** end of opticalSurface->DumpInfo" << G4endl;
return world_PV;
}
@@ -145,12 +137,12 @@ void DetectorConstruction::SetSurfaceSigmaAlpha(G4double v) {
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddBoxMPV(const char* c,
void DetectorConstruction::AddTankMPV(const char* c,
G4MaterialPropertyVector* mpv) {
mpv->SetSpline(true);
fBoxMPT->AddProperty(c, mpv);
fTankMPT->AddProperty(c, mpv);
G4cout << "The MPT for the box is now: " << G4endl;
fBoxMPT->DumpTable();
fTankMPT->DumpTable();
G4cout << "............." << G4endl;
}
@@ -175,10 +167,10 @@ void DetectorConstruction::AddSurfaceMPV(const char* c,
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::AddBoxMPCV(const char* c, G4double v) {
fBoxMPT->AddConstProperty(c, v);
void DetectorConstruction::AddTankMPCV(const char* c, G4double v) {
fTankMPT->AddConstProperty(c, v);
G4cout << "The MPT for the box is now: " << G4endl;
fBoxMPT->DumpTable();
fTankMPT->DumpTable();
G4cout << "............." << G4endl;
}
@@ -188,5 +180,35 @@ void DetectorConstruction::AddWorldMPCV(const char* c, G4double v) {
G4cout << "The MPT for the world is now: " << G4endl;
fWorldMPT->DumpTable();
G4cout << "............." << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetWorldMaterial(const G4String& mat) {
G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
if (pmat && fWorldMaterial != pmat) {
fWorldMaterial = pmat;
if (fWorld_LV) {
fWorld_LV->SetMaterial(fWorldMaterial);
fWorldMaterial->SetMaterialPropertiesTable(fWorldMPT);
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
G4cout << "World material set to " << fWorldMaterial->GetName()
<< G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetTankMaterial(const G4String& mat) {
G4Material* pmat = G4NistManager::Instance()->FindOrBuildMaterial(mat);
if (pmat && fTankMaterial != pmat) {
fTankMaterial = pmat;
if (fTank_LV) {
fTank_LV->SetMaterial(fTankMaterial);
fTankMaterial->SetMaterialPropertiesTable(fTankMPT);
fTankMaterial->GetIonisation()->SetBirksConstant(0.126*mm/MeV);
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
G4cout << "Tank material set to " << fTankMaterial->GetName()
<< G4endl;
}
}
@@ -26,7 +26,6 @@
/// \file optical/OpNovice2/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id: DetectorMessenger.cc 77288 2013-11-22 10:52:58Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -86,18 +85,24 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fSurfaceMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fSurfaceMatPropVectorCmd->SetToBeBroadcasted(false);
fBoxMatPropVectorCmd = new G4UIcmdWithAString("/opnovice2/boxProperty", this);
fBoxMatPropVectorCmd->SetGuidance("Set material property vector for ");
fBoxMatPropVectorCmd->SetGuidance("the box.");
fBoxMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fBoxMatPropVectorCmd->SetToBeBroadcasted(false);
fTankMatPropVectorCmd =
new G4UIcmdWithAString("/opnovice2/boxProperty", this);
fTankMatPropVectorCmd->SetGuidance("Set material property vector for ");
fTankMatPropVectorCmd->SetGuidance("the box.");
fTankMatPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fTankMatPropVectorCmd->SetToBeBroadcasted(false);
fBoxMatConstPropVectorCmd =
fTankMatConstPropVectorCmd =
new G4UIcmdWithAString("/opnovice2/boxConstProperty", this);
fBoxMatConstPropVectorCmd->SetGuidance("Set material constant property ");
fBoxMatConstPropVectorCmd->SetGuidance("for the box.");
fBoxMatConstPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fBoxMatConstPropVectorCmd->SetToBeBroadcasted(false);
fTankMatConstPropVectorCmd->SetGuidance("Set material constant property ");
fTankMatConstPropVectorCmd->SetGuidance("for the box.");
fTankMatConstPropVectorCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fTankMatConstPropVectorCmd->SetToBeBroadcasted(false);
fTankMaterialCmd = new G4UIcmdWithAString("/opnovice2/boxMaterial", this);
fTankMaterialCmd->SetGuidance("Set material of box.");
fTankMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fTankMaterialCmd->SetToBeBroadcasted(false);
fWorldMatPropVectorCmd =
new G4UIcmdWithAString("/opnovice2/worldProperty", this);
@@ -114,6 +119,11 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
AvailableForStates(G4State_PreInit, G4State_Idle);
fWorldMatConstPropVectorCmd->SetToBeBroadcasted(false);
fWorldMaterialCmd = new G4UIcmdWithAString("/opnovice2/worldMaterial", this);
fWorldMaterialCmd->SetGuidance("Set material of world.");
fWorldMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fWorldMaterialCmd->SetToBeBroadcasted(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -125,10 +135,12 @@ DetectorMessenger::~DetectorMessenger()
delete fSurfaceModelCmd;
delete fSurfaceSigmaAlphaCmd;
delete fSurfaceMatPropVectorCmd;
delete fBoxMatPropVectorCmd;
delete fBoxMatConstPropVectorCmd;
delete fTankMatPropVectorCmd;
delete fTankMatConstPropVectorCmd;
delete fTankMaterialCmd;
delete fWorldMatPropVectorCmd;
delete fWorldMatConstPropVectorCmd;
delete fWorldMaterialCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -311,7 +323,7 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
fDetector->SetSurfaceSigmaAlpha(
G4UIcmdWithADouble::GetNewDoubleValue(newValue));
}
else if (command == fBoxMatPropVectorCmd) {
else if (command == fTankMatPropVectorCmd) {
// got a string. need to convert it to physics vector.
// string format is property name, then pairs of energy, value
// specify units for each value, eg 3.0*eV
@@ -333,7 +345,7 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
}
const char* c = prop.c_str();
fDetector->AddBoxMPV(c, mpv);
fDetector->AddTankMPV(c, mpv);
}
else if (command == fWorldMatPropVectorCmd) {
// Convert string to physics vector
@@ -378,7 +390,7 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
fDetector->AddSurfaceMPV(c, mpv);
}
else if (command == fBoxMatConstPropVectorCmd) {
else if (command == fTankMatConstPropVectorCmd) {
// Convert string to physics vector
// string format is property name, then value
// space delimited
@@ -389,7 +401,7 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
instring >> tmp;
G4double val = G4UIcommand::ConvertToDouble(tmp);
const char* c = prop.c_str();
fDetector->AddBoxMPCV(c, val);
fDetector->AddTankMPCV(c, val);
}
else if (command == fWorldMatConstPropVectorCmd) {
// Convert string to physics vector
@@ -402,7 +414,13 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
instring >> tmp;
G4double val = G4UIcommand::ConvertToDouble(tmp);
const char* c = prop.c_str();
fDetector->AddBoxMPCV(c, val);
fDetector->AddTankMPCV(c, val);
}
else if (command == fWorldMaterialCmd) {
fDetector->SetWorldMaterial(newValue);
}
else if (command == fTankMaterialCmd) {
fDetector->SetTankMaterial(newValue);
}
}
@@ -27,7 +27,6 @@
/// \brief Implementation of the HistoManager class
//
//
// $Id: HistoManager.cc 104417 2017-05-30 08:30:48Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+15 -6
View File
@@ -26,7 +26,6 @@
/// \file optical/OpNovice2/src/Run.cc
/// \brief Implementation of the Run class
//
// $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -34,6 +33,7 @@
#include <numeric>
#include "Run.hh"
#include "DetectorConstruction.hh"
#include "G4OpBoundaryProcess.hh"
#include "G4SystemOfUnits.hh"
@@ -110,6 +110,9 @@ void Run::EndOfRun()
G4int TotNbofEvents = numberOfEvent;
if (TotNbofEvents == 0) return;
const DetectorConstruction* det = (const DetectorConstruction*)
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
std::ios::fmtflags mode = G4cout.flags();
G4int prec = G4cout.precision(2);
@@ -118,6 +121,11 @@ void Run::EndOfRun()
G4cout << "Primary particle was: " << fParticle->GetParticleName()
<< " with energy " << G4BestUnit(fEkin, "Energy") << "." << G4endl;
G4cout << "Material of world: " << det->GetWorldMaterial()->GetName()
<< G4endl;
G4cout << "Material of tank: " << det->GetTankMaterial()->GetName()
<< G4endl << G4endl;
if (fParticle->GetParticleName() != "opticalphoton") {
G4cout << "Average energy of Cerenkov photons created per event: "
<< (fCerenkovEnergy/eV)/TotNbofEvents << " eV." << G4endl;
@@ -135,13 +143,14 @@ void Run::EndOfRun()
G4cout << " Average energy: " << (fScintEnergy/eV)/fScintCount << " eV."
<< G4endl;
}
G4cout << "Average number of OpRayleigh scatters per event: "
<< fRayleighCount/TotNbofEvents << G4endl;
G4cout << "\n";
}
G4cout << "OpAbsorption per event: " << fOpAbsorption/TotNbofEvents
G4cout << "Average number of OpRayleigh per event: "
<< fRayleighCount/TotNbofEvents << G4endl;
G4cout << "Average number of OpAbsorption per event: "
<< fOpAbsorption/TotNbofEvents << G4endl;
G4cout <<
"\nSurface events (on +X surface, maximum one per photon) this run:"
<< G4endl;
G4cout << "\nSurface events (on +X surface) this run:" << G4endl;
G4cout << "# of primary particles: " << std::setw(8) << TotNbofEvents
<< G4endl;
G4cout << "OpAbsorption before surface: " << std::setw(8)
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: SteppingAction.cc 71007 2013-06-09 16:14:59Z maire $
//
/// \file optical/OpNovice2/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
@@ -53,7 +52,8 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction()
: G4UserSteppingAction()
: G4UserSteppingAction(),
fVerbose(0)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -65,7 +65,7 @@ void SteppingAction::UserSteppingAction(const G4Step* step)
{
static G4ParticleDefinition* opticalphoton =
G4OpticalPhoton::OpticalPhotonDefinition();
static G4AnalysisManager* analysisMan = G4AnalysisManager::Instance();
G4AnalysisManager* analysisMan = G4AnalysisManager::Instance();
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
@@ -269,9 +269,37 @@ void SteppingAction::UserSteppingAction(const G4Step* step)
}
else { // particle != opticalphoton
// print how many Cerenkov and scint photons produced this step
// this demonstrates use of GetNumPhotons()
auto proc_man = track->GetDynamicParticle()->GetParticleDefinition()
->GetProcessManager();
G4int n_proc = proc_man->GetPostStepProcessVector()->entries();
G4ProcessVector* proc_vec = proc_man->GetPostStepProcessVector(typeDoIt);
G4int n_scint = 0;
G4int n_cer = 0;
for (G4int i = 0; i < n_proc; ++i) {
if ((*proc_vec)[i]->GetProcessName().compare("Cerenkov") == 0) {
auto cer = (G4Cerenkov*)(*proc_vec)[i];
n_cer = cer->GetNumPhotons();
}
else if ((*proc_vec)[i]->GetProcessName().compare("Scintillation") == 0) {
auto scint = (G4Scintillation*)(*proc_vec)[i];
n_scint = scint->GetNumPhotons();
}
}
if (fVerbose > 0) {
if (n_cer > 0 || n_scint > 0) {
G4cout << "In this step, " << n_cer
<< " Cerenkov and " << n_scint
<< " scintillation photons were produced." << G4endl;
}
}
// loop over secondaries, create statistics
const std::vector<const G4Track*>* secondaries =
step->GetSecondaryInCurrentStep();
for (auto sec : *secondaries) {
if (sec->GetDynamicParticle()->GetParticleDefinition() == opticalphoton){
if (sec->GetCreatorProcess()->GetProcessName().compare("Cerenkov")==0){
@@ -27,7 +27,6 @@
/// \brief Implementation of the TrackInformation class
//
//
// $Id: TrackInformation.cc 97671 2016-06-07 08:25:00Z gcosmo $
//
#include "TrackInformation.hh"
@@ -26,7 +26,6 @@
/// \file optical/OpNovice2/src/TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
// $Id: TrackingAction.cc 66379 2012-12-18 09:46:33Z gcosmo $
//
#include "TrackingAction.hh"