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
@@ -30,18 +30,23 @@
//
#include "B02ActionInitialization.hh"
#include "B02PrimaryGeneratorAction.hh"
#include "B02RunAction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02ActionInitialization::B02ActionInitialization()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02ActionInitialization::~B02ActionInitialization()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -54,10 +59,8 @@ void B02ActionInitialization::BuildForMaster() const
void B02ActionInitialization::Build() const
{
SetUserAction(new B02PrimaryGeneratorAction);
SetUserAction(new B02RunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -28,44 +28,46 @@
//
//
//
#include "G4Types.hh"
#include "globals.hh"
#include "B02DetectorConstruction.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4PVPlacement.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4LogicalVolume.hh"
#include "G4Material.hh"
#include "G4PVPlacement.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
#include "G4Tubs.hh"
#include "G4Types.hh"
#include "G4VisAttributes.hh"
#include "globals.hh"
// for importance biasing
#include "G4IStore.hh"
// For Primitive Scorers
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4PSNofCollision.hh"
#include "G4PSPopulation.hh"
#include "G4PSTrackCounter.hh"
#include "G4PSTrackLength.hh"
#include "G4SDManager.hh"
#include "G4SDParticleFilter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02DetectorConstruction::B02DetectorConstruction()
: G4VUserDetectorConstruction()
{;}
B02DetectorConstruction::B02DetectorConstruction() : G4VUserDetectorConstruction()
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02DetectorConstruction::~B02DetectorConstruction()
{;}
{
;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -73,7 +75,7 @@ G4VPhysicalVolume* B02DetectorConstruction::Construct()
{
G4double pos_x;
G4double pos_y;
G4double pos_z;
G4double pos_z;
G4double density, pressure, temperature;
G4double A;
@@ -83,109 +85,97 @@ G4VPhysicalVolume* B02DetectorConstruction::Construct()
G4double z;
G4double fractionmass;
A = 1.01*g/mole;
G4Element* elH = new G4Element(name="Hydrogen",symbol="H" , Z= 1, A);
A = 1.01 * g / mole;
G4Element* elH = new G4Element(name = "Hydrogen", symbol = "H", Z = 1, A);
A = 12.01*g/mole;
G4Element* elC = new G4Element(name="Carbon" ,symbol="C" , Z = 6, A);
A = 12.01 * g / mole;
G4Element* elC = new G4Element(name = "Carbon", symbol = "C", Z = 6, A);
A = 16.00*g/mole;
G4Element* elO = new G4Element(name="Oxygen" ,symbol="O" , Z= 8, A);
A = 16.00 * g / mole;
G4Element* elO = new G4Element(name = "Oxygen", symbol = "O", Z = 8, A);
A = 22.99*g/mole;
G4Element* elNa = new G4Element(name="Natrium" ,symbol="Na" , Z=11 , A);
A = 22.99 * g / mole;
G4Element* elNa = new G4Element(name = "Natrium", symbol = "Na", Z = 11, A);
A = 200.59*g/mole;
G4Element* elHg = new G4Element(name="Hg" ,symbol="Hg" , Z=80, A);
A = 200.59 * g / mole;
G4Element* elHg = new G4Element(name = "Hg", symbol = "Hg", Z = 80, A);
A = 26.98*g/mole;
G4Element* elAl = new G4Element(name="Aluminium" ,symbol="Al" , Z=13, A);
A = 26.98 * g / mole;
G4Element* elAl = new G4Element(name = "Aluminium", symbol = "Al", Z = 13, A);
A = 28.09*g/mole;
G4Element* elSi = new G4Element(name="Silicon", symbol="Si", Z=14, A);
A = 28.09 * g / mole;
G4Element* elSi = new G4Element(name = "Silicon", symbol = "Si", Z = 14, A);
A = 39.1*g/mole;
G4Element* elK = new G4Element(name="K" ,symbol="K" , Z=19 , A);
A = 39.1 * g / mole;
G4Element* elK = new G4Element(name = "K", symbol = "K", Z = 19, A);
A = 69.72*g/mole;
G4Element* elCa = new G4Element(name="Calzium" ,symbol="Ca" , Z=31 , A);
A = 69.72 * g / mole;
G4Element* elCa = new G4Element(name = "Calzium", symbol = "Ca", Z = 31, A);
A = 55.85*g/mole;
G4Element* elFe = new G4Element(name="Iron" ,symbol="Fe", Z=26, A);
A = 55.85 * g / mole;
G4Element* elFe = new G4Element(name = "Iron", symbol = "Fe", Z = 26, A);
density = universe_mean_density; //from PhysicalConstants.h
pressure = 3.e-18*pascal;
temperature = 2.73*kelvin;
G4Material *Galactic =
new G4Material(name="Galactic", z=1., A=1.01*g/mole, density,
kStateGas,temperature,pressure);
density = universe_mean_density; // from PhysicalConstants.h
pressure = 3.e-18 * pascal;
temperature = 2.73 * kelvin;
G4Material* Galactic = new G4Material(name = "Galactic", z = 1., A = 1.01 * g / mole, density,
kStateGas, temperature, pressure);
density = 2.03*g/cm3;
density = 2.03 * g / cm3;
G4Material* Concrete = new G4Material("Concrete", density, 10);
Concrete->AddElement(elH , fractionmass= 0.01);
Concrete->AddElement(elO , fractionmass= 0.529);
Concrete->AddElement(elNa , fractionmass= 0.016);
Concrete->AddElement(elHg , fractionmass= 0.002);
Concrete->AddElement(elAl , fractionmass= 0.034);
Concrete->AddElement(elSi , fractionmass= 0.337);
Concrete->AddElement(elK , fractionmass= 0.013);
Concrete->AddElement(elCa , fractionmass= 0.044);
Concrete->AddElement(elFe , fractionmass= 0.014);
Concrete->AddElement(elC , fractionmass= 0.001);
Concrete->AddElement(elH, fractionmass = 0.01);
Concrete->AddElement(elO, fractionmass = 0.529);
Concrete->AddElement(elNa, fractionmass = 0.016);
Concrete->AddElement(elHg, fractionmass = 0.002);
Concrete->AddElement(elAl, fractionmass = 0.034);
Concrete->AddElement(elSi, fractionmass = 0.337);
Concrete->AddElement(elK, fractionmass = 0.013);
Concrete->AddElement(elCa, fractionmass = 0.044);
Concrete->AddElement(elFe, fractionmass = 0.014);
Concrete->AddElement(elC, fractionmass = 0.001);
/////////////////////////////
// world cylinder volume
////////////////////////////
// world solid
G4double innerRadiusCylinder = 0*cm;
G4double innerRadiusCylinder = 0 * cm;
// G4double outerRadiusCylinder = 101*cm; // dont't have scoring
G4double outerRadiusCylinder = 100*cm; // dont't have scoring
// cells coinside eith world volume boundary
G4double outerRadiusCylinder = 100 * cm; // dont't have scoring
// cells coinside eith world volume boundary
// G4double heightCylinder = 105*cm;
G4double heightCylinder = 100*cm;
G4double startAngleCylinder = 0*deg;
G4double spanningAngleCylinder = 360*deg;
G4double heightCylinder = 100 * cm;
G4double startAngleCylinder = 0 * deg;
G4double spanningAngleCylinder = 360 * deg;
G4Tubs *worldCylinder = new G4Tubs("worldCylinder",
innerRadiusCylinder,
outerRadiusCylinder,
heightCylinder,
startAngleCylinder,
spanningAngleCylinder);
G4Tubs* worldCylinder = new G4Tubs("worldCylinder", innerRadiusCylinder, outerRadiusCylinder,
heightCylinder, startAngleCylinder, spanningAngleCylinder);
// logical world
G4LogicalVolume *worldCylinder_log =
G4LogicalVolume* worldCylinder_log =
new G4LogicalVolume(worldCylinder, Galactic, "worldCylinder_log");
name = "shieldWorld";
fWorldVolume = new G4PVPlacement(0, G4ThreeVector(0,0,0), worldCylinder_log
,name, 0, false, 0);
fWorldVolume = new G4PVPlacement(0, G4ThreeVector(0, 0, 0), worldCylinder_log, name, 0, false, 0);
// creating 18 slobs of 10 cm thick concrete
G4double innerRadiusShield = 0*cm;
G4double outerRadiusShield = 100*cm;
G4double heightShield = 90*cm;
G4double startAngleShield = 0*deg;
G4double spanningAngleShield = 360*deg;
G4double innerRadiusShield = 0 * cm;
G4double outerRadiusShield = 100 * cm;
G4double heightShield = 90 * cm;
G4double startAngleShield = 0 * deg;
G4double spanningAngleShield = 360 * deg;
G4Tubs* aShield = new G4Tubs("aShield", innerRadiusShield, outerRadiusShield, heightShield,
startAngleShield, spanningAngleShield);
G4Tubs *aShield = new G4Tubs("aShield",
innerRadiusShield,
outerRadiusShield,
heightShield,
startAngleShield,
spanningAngleShield);
// logical shield
G4LogicalVolume *aShield_log =
new G4LogicalVolume(aShield, Concrete, "aShield_log");
G4LogicalVolume* aShield_log = new G4LogicalVolume(aShield, Concrete, "aShield_log");
G4VisAttributes* pShieldVis = new
G4VisAttributes(G4Colour(0.0,0.0,1.0));
G4VisAttributes* pShieldVis = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
pShieldVis->SetForceSolid(true);
aShield_log->SetVisAttributes(pShieldVis);
@@ -193,25 +183,21 @@ G4VPhysicalVolume* B02DetectorConstruction::Construct()
name = "concreteShield";
pos_x = 0*cm;
pos_y = 0*cm;
pos_x = 0 * cm;
pos_y = 0 * cm;
pos_z = 0;
new G4PVPlacement(0,
G4ThreeVector(pos_x, pos_y, pos_z),
aShield_log,
name,
worldCylinder_log,
false,
0);
new G4PVPlacement(0, G4ThreeVector(pos_x, pos_y, pos_z), aShield_log, name, worldCylinder_log,
false, 0);
return fWorldVolume;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *B02DetectorConstruction::GetWorldVolume() {
return fWorldVolume;
G4VPhysicalVolume* B02DetectorConstruction::GetWorldVolume()
{
return fWorldVolume;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -29,27 +29,27 @@
//
//
#include "globals.hh"
#include <sstream>
#include "B02ImportanceDetectorConstruction.hh"
#include "G4Material.hh"
#include "G4Tubs.hh"
#include "G4LogicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4Material.hh"
#include "G4PVPlacement.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
#include "G4Tubs.hh"
#include "globals.hh"
#include <sstream>
// For Primitive Scorers
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDParticleFilter.hh"
#include "G4PSNofCollision.hh"
#include "G4PSPopulation.hh"
#include "G4PSTrackCounter.hh"
#include "G4PSTrackLength.hh"
#include "G4SDManager.hh"
#include "G4SDParticleFilter.hh"
// for importance biasing
#include "G4IStore.hh"
@@ -59,9 +59,8 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02ImportanceDetectorConstruction::
B02ImportanceDetectorConstruction(G4String worldName)
:G4VUserParallelWorld(worldName),fLogicalVolumeVector()
B02ImportanceDetectorConstruction::B02ImportanceDetectorConstruction(G4String worldName)
: G4VUserParallelWorld(worldName), fLogicalVolumeVector()
{
// Construct();
}
@@ -76,16 +75,16 @@ B02ImportanceDetectorConstruction::~B02ImportanceDetectorConstruction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02ImportanceDetectorConstruction::Construct()
{
{
G4cout << " constructing parallel world " << G4endl;
G4Material* dummyMat = 0;
G4Material* dummyMat = 0;
//GetWorld methods create a clone of the mass world to the parallel world (!)
// via the transportation manager
// GetWorld methods create a clone of the mass world to the parallel world (!)
// via the transportation manager
fGhostWorld = GetWorld();
G4cout << " B02ImportanceDetectorConstruction:: ghostWorldName = "
<< fGhostWorld->GetName() << G4endl;
G4cout << " B02ImportanceDetectorConstruction:: ghostWorldName = " << fGhostWorld->GetName()
<< G4endl;
G4LogicalVolume* worldLogical = fGhostWorld->GetLogicalVolume();
fLogicalVolumeVector.push_back(worldLogical);
@@ -94,45 +93,33 @@ void B02ImportanceDetectorConstruction::Construct()
// creating 18 slobs of 10 cm thicknes
G4double innerRadiusShield = 0*cm;
G4double outerRadiusShield = 100*cm;
G4double heightShield = 5*cm;
G4double startAngleShield = 0*deg;
G4double spanningAngleShield = 360*deg;
G4double innerRadiusShield = 0 * cm;
G4double outerRadiusShield = 100 * cm;
G4double heightShield = 5 * cm;
G4double startAngleShield = 0 * deg;
G4double spanningAngleShield = 360 * deg;
G4Tubs* aShield = new G4Tubs("aShield", innerRadiusShield, outerRadiusShield, heightShield,
startAngleShield, spanningAngleShield);
G4Tubs *aShield = new G4Tubs("aShield",
innerRadiusShield,
outerRadiusShield,
heightShield,
startAngleShield,
spanningAngleShield);
// logical parallel cells
G4LogicalVolume *aShield_log_imp =
new G4LogicalVolume(aShield, dummyMat, "aShield_log_imp");
G4LogicalVolume* aShield_log_imp = new G4LogicalVolume(aShield, dummyMat, "aShield_log_imp");
fLogicalVolumeVector.push_back(aShield_log_imp);
// physical parallel cells
G4String name = "none";
G4int i = 1;
G4double startz = -85*cm;
G4double startz = -85 * cm;
// for (i=1; i<=18; ++i) {
for (i=1; i<=18; i++) {
for (i = 1; i <= 18; i++) {
name = GetCellName(i);
G4double pos_x = 0*cm;
G4double pos_y = 0*cm;
G4double pos_z = startz + (i-1) * (2*heightShield);
G4VPhysicalVolume *pvol =
new G4PVPlacement(0,
G4ThreeVector(pos_x, pos_y, pos_z),
aShield_log_imp,
name,
worldLogical,
false,
i);
G4double pos_x = 0 * cm;
G4double pos_y = 0 * cm;
G4double pos_z = startz + (i - 1) * (2 * heightShield);
G4VPhysicalVolume* pvol = new G4PVPlacement(0, G4ThreeVector(pos_x, pos_y, pos_z),
aShield_log_imp, name, worldLogical, false, i);
// 0);
G4GeometryCell cell(*pvol, i);
// G4GeometryCell cell(*pvol, 0);
@@ -140,71 +127,62 @@ void B02ImportanceDetectorConstruction::Construct()
}
// filling the rest of the world volumr behind the concrete with
// another slob which should get the same importance value as the
// another slob which should get the same importance value as the
// last slob
innerRadiusShield = 0*cm;
innerRadiusShield = 0 * cm;
// outerRadiusShield = 110*cm; exceeds world volume!!!!
outerRadiusShield = 100*cm;
outerRadiusShield = 100 * cm;
// heightShield = 10*cm;
heightShield = 5*cm;
startAngleShield = 0*deg;
spanningAngleShield = 360*deg;
heightShield = 5 * cm;
startAngleShield = 0 * deg;
spanningAngleShield = 360 * deg;
G4Tubs *aRest = new G4Tubs("Rest",
innerRadiusShield,
outerRadiusShield,
heightShield,
startAngleShield,
spanningAngleShield);
G4LogicalVolume *aRest_log =
new G4LogicalVolume(aRest, dummyMat, "aRest_log");
G4Tubs* aRest = new G4Tubs("Rest", innerRadiusShield, outerRadiusShield, heightShield,
startAngleShield, spanningAngleShield);
G4LogicalVolume* aRest_log = new G4LogicalVolume(aRest, dummyMat, "aRest_log");
fLogicalVolumeVector.push_back(aRest_log);
name = GetCellName(19);
G4double pos_x = 0*cm;
G4double pos_y = 0*cm;
G4double pos_x = 0 * cm;
G4double pos_y = 0 * cm;
// G4double pos_z = 100*cm;
G4double pos_z = 95*cm;
G4VPhysicalVolume *pvol =
new G4PVPlacement(0,
G4ThreeVector(pos_x, pos_y, pos_z),
aRest_log,
name,
worldLogical,
false,
19);
G4double pos_z = 95 * cm;
G4VPhysicalVolume* pvol = new G4PVPlacement(0, G4ThreeVector(pos_x, pos_y, pos_z), aRest_log,
name, worldLogical, false, 19);
// 0);
G4GeometryCell cell(*pvol, 19);
// G4GeometryCell cell(*pvol, 0);
fPVolumeStore.AddPVolume(cell);
SetSensitive();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4VPhysicalVolume &B02ImportanceDetectorConstruction::
GetPhysicalVolumeByName(const G4String& name) const {
const G4VPhysicalVolume&
B02ImportanceDetectorConstruction::GetPhysicalVolumeByName(const G4String& name) const
{
return *fPVolumeStore.GetPVolume(name);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4String B02ImportanceDetectorConstruction::ListPhysNamesAsG4String(){
G4String B02ImportanceDetectorConstruction::ListPhysNamesAsG4String()
{
G4String names(fPVolumeStore.GetPNames());
return names;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4String B02ImportanceDetectorConstruction::GetCellName(G4int i) {
G4String B02ImportanceDetectorConstruction::GetCellName(G4int i)
{
std::ostringstream os;
os << "cell_";
if (i<10) {
if (i < 10) {
os << "0";
}
os << i;
@@ -214,37 +192,39 @@ G4String B02ImportanceDetectorConstruction::GetCellName(G4int i) {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4GeometryCell B02ImportanceDetectorConstruction::GetGeometryCell(G4int i){
G4GeometryCell B02ImportanceDetectorConstruction::GetGeometryCell(G4int i)
{
G4String name(GetCellName(i));
const G4VPhysicalVolume *p=0;
const G4VPhysicalVolume* p = 0;
p = fPVolumeStore.GetPVolume(name);
if (p) {
return G4GeometryCell(*p,0);
return G4GeometryCell(*p, 0);
}
else {
G4cout << "B02ImportanceDetectorConstruction::GetGeometryCell: " << G4endl
<< " couldn't get G4GeometryCell" << G4endl;
return G4GeometryCell(*fGhostWorld,-2);
return G4GeometryCell(*fGhostWorld, -2);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume &B02ImportanceDetectorConstruction::
GetWorldVolumeAddress() const{
return *fGhostWorld;
G4VPhysicalVolume& B02ImportanceDetectorConstruction::GetWorldVolumeAddress() const
{
return *fGhostWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *B02ImportanceDetectorConstruction::GetWorldVolume() {
G4VPhysicalVolume* B02ImportanceDetectorConstruction::GetWorldVolume()
{
return fGhostWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02ImportanceDetectorConstruction::SetSensitive(){
void B02ImportanceDetectorConstruction::SetSensitive()
{
// -------------------------------------------------
// The collection names of defined Primitives are
// 0 ConcreteSD/Collisions
@@ -259,13 +239,11 @@ void B02ImportanceDetectorConstruction::SetSensitive(){
// -------------------------------------------------
// moved to ConstructSD() for MT compliance
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02ImportanceDetectorConstruction::ConstructSD()
{
G4SDManager* SDman = G4SDManager::GetSDMpointer();
//
// Sensitive Detector Name
@@ -276,56 +254,54 @@ void B02ImportanceDetectorConstruction::ConstructSD()
//------------------------
//
// Define MultiFunctionalDetector with name.
G4MultiFunctionalDetector* MFDet =
new G4MultiFunctionalDetector(concreteSDname);
SDman->AddNewDetector( MFDet ); // Register SD to SDManager
G4MultiFunctionalDetector* MFDet = new G4MultiFunctionalDetector(concreteSDname);
SDman->AddNewDetector(MFDet); // Register SD to SDManager
G4String fltName,particleName;
G4SDParticleFilter* neutronFilter =
new G4SDParticleFilter(fltName="neutronFilter", particleName="neutron");
G4String fltName, particleName;
G4SDParticleFilter* neutronFilter =
new G4SDParticleFilter(fltName = "neutronFilter", particleName = "neutron");
MFDet->SetFilter(neutronFilter);
for (std::vector<G4LogicalVolume *>::iterator it =
fLogicalVolumeVector.begin();
it != fLogicalVolumeVector.end(); it++){
for (std::vector<G4LogicalVolume*>::iterator it = fLogicalVolumeVector.begin();
it != fLogicalVolumeVector.end(); it++)
{
// (*it)->SetSensitiveDetector(MFDet);
SetSensitiveDetector((*it)->GetName(), MFDet);
}
G4String psName;
G4PSNofCollision* scorer0 = new G4PSNofCollision(psName="Collisions");
G4PSNofCollision* scorer0 = new G4PSNofCollision(psName = "Collisions");
MFDet->RegisterPrimitive(scorer0);
G4PSNofCollision* scorer1 = new G4PSNofCollision(psName="CollWeight");
G4PSNofCollision* scorer1 = new G4PSNofCollision(psName = "CollWeight");
scorer1->Weighted(true);
MFDet->RegisterPrimitive(scorer1);
G4PSPopulation* scorer2 = new G4PSPopulation(psName="Population");
G4PSPopulation* scorer2 = new G4PSPopulation(psName = "Population");
MFDet->RegisterPrimitive(scorer2);
G4PSTrackCounter* scorer3 =
new G4PSTrackCounter(psName="TrackEnter",fCurrent_In);
G4PSTrackCounter* scorer3 = new G4PSTrackCounter(psName = "TrackEnter", fCurrent_In);
MFDet->RegisterPrimitive(scorer3);
G4PSTrackLength* scorer4 = new G4PSTrackLength(psName="SL");
G4PSTrackLength* scorer4 = new G4PSTrackLength(psName = "SL");
MFDet->RegisterPrimitive(scorer4);
G4PSTrackLength* scorer5 = new G4PSTrackLength(psName="SLW");
G4PSTrackLength* scorer5 = new G4PSTrackLength(psName = "SLW");
scorer5->Weighted(true);
MFDet->RegisterPrimitive(scorer5);
G4PSTrackLength* scorer6 = new G4PSTrackLength(psName="SLWE");
G4PSTrackLength* scorer6 = new G4PSTrackLength(psName = "SLWE");
scorer6->Weighted(true);
scorer6->MultiplyKineticEnergy(true);
MFDet->RegisterPrimitive(scorer6);
G4PSTrackLength* scorer7 = new G4PSTrackLength(psName="SLW_V");
G4PSTrackLength* scorer7 = new G4PSTrackLength(psName = "SLW_V");
scorer7->Weighted(true);
scorer7->DivideByVelocity(true);
MFDet->RegisterPrimitive(scorer7);
G4PSTrackLength* scorer8 = new G4PSTrackLength(psName="SLWE_V");
G4PSTrackLength* scorer8 = new G4PSTrackLength(psName = "SLWE_V");
scorer8->Weighted(true);
scorer8->MultiplyKineticEnergy(true);
scorer8->DivideByVelocity(true);
@@ -335,40 +311,35 @@ void B02ImportanceDetectorConstruction::ConstructSD()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VIStore* B02ImportanceDetectorConstruction::CreateImportanceStore()
{
G4cout << " B02ImportanceDetectorConstruction:: Creating Importance Store "
<< G4endl;
if (!fPVolumeStore.Size())
{
G4Exception("B02ImportanceDetectorConstruction::CreateImportanceStore"
,"exampleB02_0001",RunMustBeAborted
,"no physical volumes created yet!");
G4cout << " B02ImportanceDetectorConstruction:: Creating Importance Store " << G4endl;
if (!fPVolumeStore.Size()) {
G4Exception("B02ImportanceDetectorConstruction::CreateImportanceStore", "exampleB02_0001",
RunMustBeAborted, "no physical volumes created yet!");
}
// creating and filling the importance store
// G4IStore *istore = new G4IStore(*fWorldVolume);
G4IStore *istore = G4IStore::GetInstance(GetName());
G4IStore* istore = G4IStore::GetInstance(GetName());
G4GeometryCell gWorldVolumeCell(GetWorldVolumeAddress(), 0);
G4double imp =1;
G4double imp = 1;
istore->AddImportanceGeometryCell(1, gWorldVolumeCell);
// set importance values and create scorers
// set importance values and create scorers
G4int cell(1);
for (cell=1; cell<=18; cell++) {
for (cell = 1; cell <= 18; cell++) {
G4GeometryCell gCell = GetGeometryCell(cell);
G4cout << " adding cell: " << cell
<< " replica: " << gCell.GetReplicaNumber()
G4cout << " adding cell: " << cell << " replica: " << gCell.GetReplicaNumber()
<< " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
imp = std::pow(2.0,cell-1);
imp = std::pow(2.0, cell - 1);
G4cout << "Going to assign importance: " << imp << ", to volume: "
<< gCell.GetPhysicalVolume().GetName() << G4endl;
//x aIstore.AddImportanceGeometryCell(imp, gCell);
G4cout << "Going to assign importance: " << imp
<< ", to volume: " << gCell.GetPhysicalVolume().GetName() << G4endl;
// x aIstore.AddImportanceGeometryCell(imp, gCell);
istore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
}
@@ -376,64 +347,57 @@ G4VIStore* B02ImportanceDetectorConstruction::CreateImportanceStore()
// G4GeometryCell gCell = GetGeometryCell(18);
// create importance geometry cell pair for the "rest"cell
// with the same importance as the last concrete cell
// with the same importance as the last concrete cell
G4GeometryCell gCell = GetGeometryCell(19);
// G4double imp = std::pow(2.0,18);
imp = std::pow(2.0,17);
// G4double imp = std::pow(2.0,18);
imp = std::pow(2.0, 17);
istore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
return istore;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VWeightWindowStore *B02ImportanceDetectorConstruction::
CreateWeightWindowStore()
G4VWeightWindowStore* B02ImportanceDetectorConstruction::CreateWeightWindowStore()
{
G4cout << " B02ImportanceDetectorConstruction:: Creating Importance Store "
<< G4endl;
if (!fPVolumeStore.Size())
{
G4Exception("B02ImportanceDetectorConstruction::CreateWeightWindowStore"
,"exampleB02_0002",RunMustBeAborted
,"no physical volumes created yet!");
G4cout << " B02ImportanceDetectorConstruction:: Creating Importance Store " << G4endl;
if (!fPVolumeStore.Size()) {
G4Exception("B02ImportanceDetectorConstruction::CreateWeightWindowStore", "exampleB02_0002",
RunMustBeAborted, "no physical volumes created yet!");
}
// creating and filling the importance store
// G4IStore *istore = new G4IStore(*fWorldVolume);
G4WeightWindowStore *wwstore = G4WeightWindowStore::GetInstance(GetName());
G4WeightWindowStore* wwstore = G4WeightWindowStore::GetInstance(GetName());
// create one energy region covering the energies of the problem
//
std::set<G4double, std::less<G4double> > enBounds;
std::set<G4double, std::less<G4double>> enBounds;
enBounds.insert(1 * GeV);
wwstore->SetGeneralUpperEnergyBounds(enBounds);
G4int n = 0;
G4double lowerWeight =1;
G4double lowerWeight = 1;
std::vector<G4double> lowerWeights;
lowerWeights.push_back(1);
G4GeometryCell gWorldCell(GetWorldVolumeAddress(),0);
G4GeometryCell gWorldCell(GetWorldVolumeAddress(), 0);
wwstore->AddLowerWeights(gWorldCell, lowerWeights);
G4int cell(1);
for (cell=1; cell<=18; cell++) {
for (cell = 1; cell <= 18; cell++) {
G4GeometryCell gCell = GetGeometryCell(cell);
G4cout << " adding cell: " << cell
<< " replica: " << gCell.GetReplicaNumber()
G4cout << " adding cell: " << cell << " replica: " << gCell.GetReplicaNumber()
<< " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
lowerWeight = 1./std::pow(2., n++);
G4cout << "Going to assign lower weight: " << lowerWeight
<< ", to volume: "
<< gCell.GetPhysicalVolume().GetName() << G4endl;
lowerWeights.clear();
lowerWeights.push_back(lowerWeight);
wwstore->AddLowerWeights(gCell, lowerWeights);
lowerWeight = 1. / std::pow(2., n++);
G4cout << "Going to assign lower weight: " << lowerWeight
<< ", to volume: " << gCell.GetPhysicalVolume().GetName() << G4endl;
lowerWeights.clear();
lowerWeights.push_back(lowerWeight);
wwstore->AddLowerWeights(gCell, lowerWeights);
}
// the remaining part pf the geometry (rest) gets the same
@@ -441,10 +405,9 @@ CreateWeightWindowStore()
//
// create importance geometry cell pair for the "rest"cell
// with the same importance as the last concrete cell
// with the same importance as the last concrete cell
G4GeometryCell gCell = GetGeometryCell(19);
wwstore->AddLowerWeights(gCell, lowerWeights);
wwstore->AddLowerWeights(gCell, lowerWeights);
return wwstore;
}
@@ -27,7 +27,7 @@
/// \brief Implementation of the B02PVolumeStore class
//
//
// GEANT4 tag
// GEANT4 tag
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
@@ -37,65 +37,65 @@
// ----------------------------------------------------------------------
#include "B02PVolumeStore.hh"
#include <sstream>
#include "G4VPhysicalVolume.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02PVolumeStore::B02PVolumeStore(){}
#include <sstream>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02PVolumeStore::~B02PVolumeStore(){}
B02PVolumeStore::B02PVolumeStore() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02PVolumeStore::AddPVolume(const G4GeometryCell &cell){
B02SetGeometryCell::iterator it =
fSetGeometryCell.find(cell);
B02PVolumeStore::~B02PVolumeStore() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02PVolumeStore::AddPVolume(const G4GeometryCell& cell)
{
B02SetGeometryCell::iterator it = fSetGeometryCell.find(cell);
if (it != fSetGeometryCell.end()) {
G4cout << "B02PVolumeStore::AddPVolume: cell already stored"
<< G4endl;
G4cout << "B02PVolumeStore::AddPVolume: cell already stored" << G4endl;
return;
}
fSetGeometryCell.insert(cell);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4VPhysicalVolume *B02PVolumeStore::
GetPVolume(const G4String &name) const {
const G4VPhysicalVolume *pvol = 0;
const G4VPhysicalVolume* B02PVolumeStore::GetPVolume(const G4String& name) const
{
const G4VPhysicalVolume* pvol = 0;
for (B02SetGeometryCell::const_iterator it = fSetGeometryCell.begin();
it != fSetGeometryCell.end(); ++it) {
const G4VPhysicalVolume &vol = it->GetPhysicalVolume();
it != fSetGeometryCell.end(); ++it)
{
const G4VPhysicalVolume& vol = it->GetPhysicalVolume();
if (vol.GetName() == name) {
pvol = &vol;
}
pvol = &vol;
}
}
if (!pvol) {
G4cout << "B02PVolumeStore::GetPVolume: no physical volume named: "
<< name << ", found" << G4endl;
G4cout << "B02PVolumeStore::GetPVolume: no physical volume named: " << name << ", found"
<< G4endl;
}
return pvol;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4String B02PVolumeStore::GetPNames() const {
G4String B02PVolumeStore::GetPNames() const
{
G4String NameString;
for (B02SetGeometryCell::const_iterator it = fSetGeometryCell.begin();
it != fSetGeometryCell.end(); ++it) {
const G4VPhysicalVolume &vol = it->GetPhysicalVolume();
it != fSetGeometryCell.end(); ++it)
{
const G4VPhysicalVolume& vol = it->GetPhysicalVolume();
std::ostringstream os;
os << vol.GetName() << "_" << it->GetReplicaNumber()
<< "\n";
os << vol.GetName() << "_" << it->GetReplicaNumber() << "\n";
G4String cellname = os.str();
// G4String cellname(vol.GetName());
// cellname += G4String("_");
// cellname += std::str(it->GetReplicaNumber());
@@ -107,7 +107,8 @@ G4String B02PVolumeStore::GetPNames() const {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int B02PVolumeStore::Size() {
G4int B02PVolumeStore::Size()
{
return fSetGeometryCell.size();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -29,26 +29,25 @@
//
//
#include "globals.hh"
#include "B02PrimaryGeneratorAction.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4Neutron.hh"
#include "G4ThreeVector.hh"
#include "G4ParticleGun.hh"
#include "G4SystemOfUnits.hh"
#include "G4ThreeVector.hh"
#include "globals.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02PrimaryGeneratorAction::B02PrimaryGeneratorAction()
: G4VUserPrimaryGeneratorAction(), fParticleGun(0)
: G4VUserPrimaryGeneratorAction(), fParticleGun(0)
{
G4int n_particle = 1;
fParticleGun = new G4ParticleGun(n_particle);
fParticleGun->SetParticleDefinition(G4Neutron::NeutronDefinition());
fParticleGun->SetParticleEnergy(10.0*MeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, -90.0005*cm));
fParticleGun->SetParticleEnergy(10.0 * MeV);
fParticleGun->SetParticlePosition(G4ThreeVector(0.0, 0.0, -90.0005 * cm));
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, 1.0));
}
+65 -68
View File
@@ -32,7 +32,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
// (Description)
// B02Run Class is for accumulating scored quantities which is
// B02Run Class is for accumulating scored quantities which is
// scored using G4MutiFunctionalDetector and G4VPrimitiveScorer.
// Accumulation is done using G4THitsMap object.
//
@@ -41,10 +41,10 @@
// was assigned at instantiation of MultiFunctionalDetector(MFD).
// Then B02Run constructor automatically scans primitive scorers
// in the MFD, and obtains collectionIDs of all collections associated
// to those primitive scorers. Futhermore, the G4THitsMap objects
// to those primitive scorers. Futhermore, the G4THitsMap objects
// for accumulating during a RUN are automatically created too.
// (*) Collection Name is same as primitive scorer name.
//
//
// The resultant information is kept inside B02Run objects as
// data members.
// std::vector<G4String> fCollName; // Collection Name,
@@ -57,16 +57,16 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "B02Run.hh"
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4SDManager.hh"
#include "G4VPrimitiveScorer.hh"
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Constructor.
// Constructor.
// (The vector of MultiFunctionalDetector name has to given.)
B02Run::B02Run(const std::vector<G4String> mfdName): G4Run()
B02Run::B02Run(const std::vector<G4String> mfdName) : G4Run()
{
G4SDManager* SDman = G4SDManager::GetSDMpointer();
//=================================================
@@ -74,38 +74,36 @@ B02Run::B02Run(const std::vector<G4String> mfdName): G4Run()
// Get CollectionIDs for HitCollections.
//=================================================
G4int Nmfd = mfdName.size();
for ( G4int idet = 0; idet < Nmfd ; idet++){ // Loop for all MFD.
for (G4int idet = 0; idet < Nmfd; idet++) { // Loop for all MFD.
G4String detName = mfdName[idet];
//--- Seek and Obtain MFD objects from SDmanager.
G4MultiFunctionalDetector* mfd =
(G4MultiFunctionalDetector*)(SDman->FindSensitiveDetector(detName));
//
if ( mfd ){
//--- Loop over the registered primitive scorers.
for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); icol++){
// Get Primitive Scorer object.
G4VPrimitiveScorer* scorer=mfd->GetPrimitive(icol);
// collection name and collectionID for HitsCollection,
// where type of HitsCollection is G4THitsMap in case of primitive scorer.
// The collection name is given by <MFD name>/<Primitive Scorer name>.
G4String collectionName = scorer->GetName();
G4String fullCollectionName = detName+"/"+collectionName;
G4int collectionID = SDman->GetCollectionID(fullCollectionName);
if (mfd) {
//--- Loop over the registered primitive scorers.
for (G4int icol = 0; icol < mfd->GetNumberOfPrimitives(); icol++) {
// Get Primitive Scorer object.
G4VPrimitiveScorer* scorer = mfd->GetPrimitive(icol);
// collection name and collectionID for HitsCollection,
// where type of HitsCollection is G4THitsMap in case of primitive scorer.
// The collection name is given by <MFD name>/<Primitive Scorer name>.
G4String collectionName = scorer->GetName();
G4String fullCollectionName = detName + "/" + collectionName;
G4int collectionID = SDman->GetCollectionID(fullCollectionName);
if ( collectionID >= 0 ){
G4cout << "++ "<<fullCollectionName<< " id " << collectionID
<< G4endl;
// Store obtained HitsCollection information into data members.
// And, creates new G4THitsMap for accumulating quantities during RUN.
fCollName.push_back(fullCollectionName);
fCollID.push_back(collectionID);
fRunMap.push_back(new G4THitsMap<G4double>(detName
,collectionName));
}else{
G4cout << "** collection " << fullCollectionName
<< " not found. "<<G4endl;
}
if (collectionID >= 0) {
G4cout << "++ " << fullCollectionName << " id " << collectionID << G4endl;
// Store obtained HitsCollection information into data members.
// And, creates new G4THitsMap for accumulating quantities during RUN.
fCollName.push_back(fullCollectionName);
fCollID.push_back(collectionID);
fRunMap.push_back(new G4THitsMap<G4double>(detName, collectionName));
}
else {
G4cout << "** collection " << fullCollectionName << " not found. " << G4endl;
}
}
}
}
}
@@ -118,8 +116,8 @@ B02Run::~B02Run()
{
//--- Clear HitsMap for RUN
G4int Nmap = fRunMap.size();
for ( G4int i = 0; i < Nmap; i++){
if(fRunMap[i] ) fRunMap[i]->clear();
for (G4int i = 0; i < Nmap; i++) {
if (fRunMap[i]) fRunMap[i]->clear();
}
fCollName.clear();
fCollID.clear();
@@ -145,20 +143,20 @@ void B02Run::RecordEvent(const G4Event* aEvent)
// Sum up HitsMap of this Event into HitsMap of this RUN
//=======================================================
G4int Ncol = fCollID.size();
for ( G4int i = 0; i < Ncol ; i++ ){ // Loop over HitsCollection
G4THitsMap<G4double>* EvtMap=0;
if ( fCollID[i] >= 0 ){ // Collection is attached to HCE
for (G4int i = 0; i < Ncol; i++) { // Loop over HitsCollection
G4THitsMap<G4double>* EvtMap = 0;
if (fCollID[i] >= 0) { // Collection is attached to HCE
EvtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fCollID[i]));
}else{
G4cout <<" Error EvtMap Not Found "<< i << G4endl;
}
if ( EvtMap ) {
else {
G4cout << " Error EvtMap Not Found " << i << G4endl;
}
if (EvtMap) {
//=== Sum up HitsMap of this event to HitsMap of RUN.===
*fRunMap[i] += *EvtMap;
//======================================================
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -168,46 +166,45 @@ void B02Run::RecordEvent(const G4Event* aEvent)
//-----
// Access HitsMap.
// By MultiFunctionalDetector name and Collection Name.
G4THitsMap<G4double>* B02Run::GetHitsMap(const G4String& detName,
const G4String& colName){
G4String fullName = detName+"/"+colName;
return GetHitsMap(fullName);
G4THitsMap<G4double>* B02Run::GetHitsMap(const G4String& detName, const G4String& colName)
{
G4String fullName = detName + "/" + colName;
return GetHitsMap(fullName);
}
//-----
// Access HitsMap.
// By full description of collection name, that is
// <MultiFunctional Detector Name>/<Primitive Scorer Name>
G4THitsMap<G4double>* B02Run::GetHitsMap(const G4String& fullName){
G4int Ncol = fCollName.size();
for ( G4int i = 0; i < Ncol; i++){
if ( fCollName[i] == fullName ){
return fRunMap[i];
}
G4THitsMap<G4double>* B02Run::GetHitsMap(const G4String& fullName)
{
G4int Ncol = fCollName.size();
for (G4int i = 0; i < Ncol; i++) {
if (fCollName[i] == fullName) {
return fRunMap[i];
}
return NULL;
}
return NULL;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// - Dump All HitsMap of this RUN. (for debuging and monitoring of quantity).
// This method calls G4THisMap::PrintAll() for individual HitsMap.
void B02Run::DumpAllScorer(){
void B02Run::DumpAllScorer()
{
// - Number of HitsMap in this RUN.
G4int n = GetNumberOfHitsMap();
// - GetHitsMap and dump values.
for ( G4int i = 0; i < n ; i++ ){
G4THitsMap<G4double>* RunMap =GetHitsMap(i);
if ( RunMap ) {
G4cout << " PrimitiveScorer RUN "
<< RunMap->GetSDname() <<","<< RunMap->GetName() << G4endl;
for (G4int i = 0; i < n; i++) {
G4THitsMap<G4double>* RunMap = GetHitsMap(i);
if (RunMap) {
G4cout << " PrimitiveScorer RUN " << RunMap->GetSDname() << "," << RunMap->GetName()
<< G4endl;
G4cout << " Number of entries " << RunMap->entries() << G4endl;
std::map<G4int,G4double*>::iterator itr = RunMap->GetMap()->begin();
for(; itr != RunMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first
<< " Run Value : " << *(itr->second)
<< G4endl;
std::map<G4int, G4double*>::iterator itr = RunMap->GetMap()->begin();
for (; itr != RunMap->GetMap()->end(); itr++) {
G4cout << " copy no.: " << itr->first << " Run Value : " << *(itr->second) << G4endl;
}
}
}
@@ -217,18 +214,18 @@ void B02Run::DumpAllScorer(){
void B02Run::Merge(const G4Run* aRun)
{
const B02Run * localRun = static_cast<const B02Run *>(aRun);
const B02Run* localRun = static_cast<const B02Run*>(aRun);
//=======================================================
// Merge HitsMap of working threads
//=======================================================
G4int nCol = localRun->fCollID.size();
for ( G4int i = 0; i < nCol ; i++ ){ // Loop over HitsCollection
if ( localRun->fCollID[i] >= 0 ){
for (G4int i = 0; i < nCol; i++) { // Loop over HitsCollection
if (localRun->fCollID[i] >= 0) {
*fRunMap[i] += *localRun->fRunMap[i];
}
}
G4Run::Merge(aRun);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+84 -107
View File
@@ -27,31 +27,32 @@
/// \brief Implementation of the B02RunAction class
//
//
//
//
#include "B02RunAction.hh"
#include "B02Run.hh"
//-- In order to obtain detector information.
#include "G4RunManager.hh"
#include "B02DetectorConstruction.hh"
#include "B02ImportanceDetectorConstruction.hh"
#include "G4THitsMap.hh"
#include "G4RunManager.hh"
#include "G4THitsMap.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
// B02RunAction
//
//
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Constructor
B02RunAction::B02RunAction():
G4UserRunAction(),
// fFieldName(15),
fFieldValue(14)
B02RunAction::B02RunAction()
: G4UserRunAction(),
// fFieldName(15),
fFieldValue(14)
{
// - Prepare data member for B02Run.
// vector represents a list of MultiFunctionalDetector names.
@@ -87,7 +88,7 @@ void B02RunAction::BeginOfRunAction(const G4Run* aRun)
void B02RunAction::EndOfRunAction(const G4Run* aRun)
{
G4cout << " ###### EndOfRunAction " <<G4endl;
G4cout << " ###### EndOfRunAction " << G4endl;
//- B02Run object.
B02Run* b02Run = (B02Run*)aRun;
//--- Dump all socred quantities involved in B02Run.
@@ -95,14 +96,12 @@ void B02RunAction::EndOfRunAction(const G4Run* aRun)
//---
G4RunManager* mgr = G4RunManager::GetRunManager();
//
for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){
const G4VUserDetectorConstruction* vdet =
mgr->GetUserDetectorConstruction();
B02ImportanceDetectorConstruction* bdet =
(B02ImportanceDetectorConstruction*)vdet;
for (G4int i = 0; i < (G4int)fSDName.size(); i++) {
const G4VUserDetectorConstruction* vdet = mgr->GetUserDetectorConstruction();
B02ImportanceDetectorConstruction* bdet = (B02ImportanceDetectorConstruction*)vdet;
//
//---------------------------------------------
// Dump accumulated quantities for this RUN.
// (Display only central region of x-y plane)
@@ -116,94 +115,73 @@ void B02RunAction::EndOfRunAction(const G4Run* aRun)
// 7 ConcreteSD/SLW_V
// 8 ConcreteSD/SLWE_V
//---------------------------------------------
G4THitsMap<G4double>* Collisions =
b02Run->GetHitsMap(fSDName[i]+"/Collisions");
G4THitsMap<G4double>* CollWeight =
b02Run->GetHitsMap(fSDName[i]+"/CollWeight");
G4THitsMap<G4double>* Population =
b02Run->GetHitsMap(fSDName[i]+"/Population");
G4THitsMap<G4double>* TrackEnter =
b02Run->GetHitsMap(fSDName[i]+"/TrackEnter");
G4THitsMap<G4double>* SL = b02Run->GetHitsMap(fSDName[i]+"/SL");
G4THitsMap<G4double>* SLW = b02Run->GetHitsMap(fSDName[i]+"/SLW");
G4THitsMap<G4double>* SLWE = b02Run->GetHitsMap(fSDName[i]+"/SLWE");
G4THitsMap<G4double>* SLW_V = b02Run->GetHitsMap(fSDName[i]+"/SLW_V");
G4THitsMap<G4double>* SLWE_V = b02Run->GetHitsMap(fSDName[i]+"/SLWE_V");
G4THitsMap<G4double>* Collisions = b02Run->GetHitsMap(fSDName[i] + "/Collisions");
G4THitsMap<G4double>* CollWeight = b02Run->GetHitsMap(fSDName[i] + "/CollWeight");
G4THitsMap<G4double>* Population = b02Run->GetHitsMap(fSDName[i] + "/Population");
G4THitsMap<G4double>* TrackEnter = b02Run->GetHitsMap(fSDName[i] + "/TrackEnter");
G4THitsMap<G4double>* SL = b02Run->GetHitsMap(fSDName[i] + "/SL");
G4THitsMap<G4double>* SLW = b02Run->GetHitsMap(fSDName[i] + "/SLW");
G4THitsMap<G4double>* SLWE = b02Run->GetHitsMap(fSDName[i] + "/SLWE");
G4THitsMap<G4double>* SLW_V = b02Run->GetHitsMap(fSDName[i] + "/SLW_V");
G4THitsMap<G4double>* SLWE_V = b02Run->GetHitsMap(fSDName[i] + "/SLWE_V");
if (IsMaster())
{
G4cout <<
"\n--------------------End of Global Run-----------------------" <<
G4endl;
G4cout <<
" Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
}
else
{
G4cout <<
"\n--------------------End of Local Run------------------------" <<
G4endl;
G4cout <<
" Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl;
}
G4cout << "============================================================="
<<G4endl;
G4cout << "============================================================="
<<G4endl;
if (IsMaster()) {
G4cout << "\n--------------------End of Global Run-----------------------" << G4endl;
G4cout << " Number of event processed : " << aRun->GetNumberOfEvent() << G4endl;
}
else {
G4cout << "\n--------------------End of Local Run------------------------" << G4endl;
G4cout << " Number of event processed : " << aRun->GetNumberOfEvent() << G4endl;
}
std::ostream *myout = &G4cout;
G4cout << "=============================================================" << G4endl;
G4cout << "=============================================================" << G4endl;
std::ostream* myout = &G4cout;
PrintHeader(myout);
for ( G4int iz = 0; iz < 20; iz++){
for (G4int iz = 0; iz < 20; iz++) {
G4double* SumCollisions = (*Collisions)[iz];
G4double* SumCollWeight = (*CollWeight)[iz];
G4double* Populations = (*Population)[iz];
G4double* TrackEnters = (*TrackEnter)[iz];
G4double* SLs = (*SL)[iz];
G4double* SLWs = (*SLW)[iz];
G4double* SLWEs = (*SLWE)[iz];
G4double* SLW_Vs = (*SLW_V)[iz];
G4double* SLWE_Vs = (*SLWE_V)[iz];
if ( !SumCollisions ) SumCollisions = new G4double(0.0);
if ( !SumCollWeight ) SumCollWeight = new G4double(0.0);
if ( !Populations ) Populations = new G4double(0.0);
if ( !TrackEnters ) TrackEnters = new G4double(0.0);
if ( !SLs ) SLs = new G4double(0.0);
if ( !SLWs ) SLWs = new G4double(0.0);
if ( !SLWEs ) SLWEs = new G4double(0.0);
if ( !SLW_Vs ) SLW_Vs = new G4double(0.0);
if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0);
G4double NumWeightedEnergy =0.0;
G4double FluxWeightedEnergy=0.0;
G4double AverageTrackWeight=0.0;
if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs);
if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs);
if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs);
G4double* Populations = (*Population)[iz];
G4double* TrackEnters = (*TrackEnter)[iz];
G4double* SLs = (*SL)[iz];
G4double* SLWs = (*SLW)[iz];
G4double* SLWEs = (*SLWE)[iz];
G4double* SLW_Vs = (*SLW_V)[iz];
G4double* SLWE_Vs = (*SLWE_V)[iz];
if (!SumCollisions) SumCollisions = new G4double(0.0);
if (!SumCollWeight) SumCollWeight = new G4double(0.0);
if (!Populations) Populations = new G4double(0.0);
if (!TrackEnters) TrackEnters = new G4double(0.0);
if (!SLs) SLs = new G4double(0.0);
if (!SLWs) SLWs = new G4double(0.0);
if (!SLWEs) SLWEs = new G4double(0.0);
if (!SLW_Vs) SLW_Vs = new G4double(0.0);
if (!SLWE_Vs) SLWE_Vs = new G4double(0.0);
G4double NumWeightedEnergy = 0.0;
G4double FluxWeightedEnergy = 0.0;
G4double AverageTrackWeight = 0.0;
if (*SLW_Vs != 0.) NumWeightedEnergy = (*SLWE_Vs) / (*SLW_Vs);
if (*SLWs != 0.) FluxWeightedEnergy = (*SLWEs) / (*SLWs);
if (*SLs != 0.) AverageTrackWeight = (*SLWs) / (*SLs);
G4String cname = bdet->GetCellName(iz);
G4cout
<< std::setw(fFieldValue) << cname << " |"
<< std::setw(fFieldValue) << (*TrackEnters) << " |"
<< std::setw(fFieldValue) << (*Populations) << " |"
<< std::setw(fFieldValue) << (*SumCollisions) << " |"
<< std::setw(fFieldValue) << (*SumCollWeight) << " |"
<< std::setw(fFieldValue) << NumWeightedEnergy << " |"
<< std::setw(fFieldValue) << FluxWeightedEnergy << " |"
<< std::setw(fFieldValue) << AverageTrackWeight << " |"
<< std::setw(fFieldValue) << (*SLs) << " |"
<< std::setw(fFieldValue) << (*SLWs) << " |"
<< std::setw(fFieldValue) << (*SLW_Vs) << " |"
<< std::setw(fFieldValue) << (*SLWEs) << " |"
<< std::setw(fFieldValue) << (*SLWE_Vs) << " |"
<< G4endl;
G4cout << std::setw(fFieldValue) << cname << " |" << std::setw(fFieldValue) << (*TrackEnters)
<< " |" << std::setw(fFieldValue) << (*Populations) << " |" << std::setw(fFieldValue)
<< (*SumCollisions) << " |" << std::setw(fFieldValue) << (*SumCollWeight) << " |"
<< std::setw(fFieldValue) << NumWeightedEnergy << " |" << std::setw(fFieldValue)
<< FluxWeightedEnergy << " |" << std::setw(fFieldValue) << AverageTrackWeight << " |"
<< std::setw(fFieldValue) << (*SLs) << " |" << std::setw(fFieldValue) << (*SLWs)
<< " |" << std::setw(fFieldValue) << (*SLW_Vs) << " |" << std::setw(fFieldValue)
<< (*SLWEs) << " |" << std::setw(fFieldValue) << (*SLWE_Vs) << " |" << G4endl;
}
G4cout << "============================================="<<G4endl;
G4cout << "=============================================" << G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02RunAction::PrintHeader(std::ostream *out)
void B02RunAction::PrintHeader(std::ostream* out)
{
std::vector<G4String> vecScoreName;
vecScoreName.push_back("Tr.Entering");
@@ -220,36 +198,35 @@ void B02RunAction::PrintHeader(std::ostream *out)
vecScoreName.push_back("SLWE_v");
// head line
// std::string vname;
// vname = FillString("Volume", ' ', fFieldName+1);
// std::string vname;
// vname = FillString("Volume", ' ', fFieldName+1);
//*out << vname << '|';
*out << std::setw(fFieldValue) << "Volume" << " |";
for (std::vector<G4String>::iterator it = vecScoreName.begin();
it != vecScoreName.end(); it++) {
// vname = FillString((*it),
// ' ',
// fFieldValue+1,
// false);
// *out << vname << '|';
*out << std::setw(fFieldValue) << (*it) << " |";
*out << std::setw(fFieldValue) << "Volume"
<< " |";
for (std::vector<G4String>::iterator it = vecScoreName.begin(); it != vecScoreName.end(); it++) {
// vname = FillString((*it),
// ' ',
// fFieldValue+1,
// false);
// *out << vname << '|';
*out << std::setw(fFieldValue) << (*it) << " |";
}
*out << G4endl;
*out << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
std::string B02RunAction::FillString(const std::string &name,
char c, G4int n, G4bool back)
std::string B02RunAction::FillString(const std::string& name, char c, G4int n, G4bool back)
{
std::string fname("");
G4int k = n - name.size();
if (k > 0) {
if (back) {
fname = name;
fname += std::string(k,c);
fname += std::string(k, c);
}
else {
fname = std::string(k,c);
fname = std::string(k, c);
fname += name;
}
}