Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -27,7 +27,7 @@
/// \brief Implementation of the B02ImportanceDetectorConstruction class
//
//
// $Id$
// $Id: B02ImportanceDetectorConstruction.cc 77336 2013-11-22 15:04:18Z ahoward$
//
#include "globals.hh"
@@ -52,44 +52,48 @@
#include "G4PSTrackCounter.hh"
#include "G4PSTrackLength.hh"
// for importance biasing
#include "G4IStore.hh"
// for weight window technique
#include "G4WeightWindowStore.hh"
B02ImportanceDetectorConstruction::B02ImportanceDetectorConstruction(G4String worldName)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02ImportanceDetectorConstruction::
B02ImportanceDetectorConstruction(G4String worldName)
:G4VUserParallelWorld(worldName),fLogicalVolumeVector()
{
// Construct();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B02ImportanceDetectorConstruction::~B02ImportanceDetectorConstruction()
{
fLogicalVolumeVector.clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02ImportanceDetectorConstruction::Construct()
{
G4cout << " constructing parallel world " << G4endl;
G4Material* dummyMat = 0;
//GetWorld methods create a clone of the mass world to the parallel world (!)
// via the transportation manager
ghostWorld = GetWorld();
G4LogicalVolume* worldLogical = ghostWorld->GetLogicalVolume();
fGhostWorld = GetWorld();
G4cout << " B02ImportanceDetectorConstruction:: ghostWorldName = "
<< fGhostWorld->GetName() << G4endl;
G4LogicalVolume* worldLogical = fGhostWorld->GetLogicalVolume();
fLogicalVolumeVector.push_back(worldLogical);
G4String name("none");
G4double density(universe_mean_density), temperature(0), pressure(0);
name = "Galactic";
density = universe_mean_density; //from PhysicalConstants.h
pressure = 3.e-18*pascal;
temperature = 2.73*kelvin;
G4cout << density << " " << kStateGas << G4endl;
G4Material *Galactic =
new G4Material(name, 1., 1.01*g/mole, density,
kStateGas,temperature,pressure);
// fPVolumeStore.AddPVolume(G4GeometryCell(*pWorldVolume, 0));
fPVolumeStore.AddPVolume(G4GeometryCell(*ghostWorld, 0));
fPVolumeStore.AddPVolume(G4GeometryCell(*fGhostWorld, 0));
@@ -98,25 +102,25 @@ void B02ImportanceDetectorConstruction::Construct()
G4double innerRadiusShield = 0*cm;
G4double outerRadiusShield = 100*cm;
G4double hightShield = 5*cm;
G4double heightShield = 5*cm;
G4double startAngleShield = 0*deg;
G4double spanningAngleShield = 360*deg;
G4Tubs *aShield = new G4Tubs("aShield",
innerRadiusShield,
outerRadiusShield,
hightShield,
heightShield,
startAngleShield,
spanningAngleShield);
// logical parallel cells
G4LogicalVolume *aShield_log =
new G4LogicalVolume(aShield, Galactic, "aShield_log");
fLogicalVolumeVector.push_back(aShield_log);
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;
// for (i=1; i<=18; ++i) {
@@ -126,11 +130,11 @@ void B02ImportanceDetectorConstruction::Construct()
G4double pos_x = 0*cm;
G4double pos_y = 0*cm;
G4double pos_z = startz + (i-1) * (2*hightShield);
G4double pos_z = startz + (i-1) * (2*heightShield);
G4VPhysicalVolume *pvol =
new G4PVPlacement(0,
G4ThreeVector(pos_x, pos_y, pos_z),
aShield_log,
aShield_log_imp,
name,
worldLogical,
false,
@@ -146,21 +150,21 @@ void B02ImportanceDetectorConstruction::Construct()
// last slob
innerRadiusShield = 0*cm;
// outerRadiusShield = 110*cm; exceeds world volume!!!!
outerRadiusShield = 101*cm;
// hightShield = 10*cm;
hightShield = 5*cm;
outerRadiusShield = 100*cm;
// heightShield = 10*cm;
heightShield = 5*cm;
startAngleShield = 0*deg;
spanningAngleShield = 360*deg;
G4Tubs *aRest = new G4Tubs("Rest",
innerRadiusShield,
outerRadiusShield,
hightShield,
heightShield,
startAngleShield,
spanningAngleShield);
G4LogicalVolume *aRest_log =
new G4LogicalVolume(aRest, Galactic, "aRest_log");
new G4LogicalVolume(aRest, dummyMat, "aRest_log");
fLogicalVolumeVector.push_back(aRest_log);
@@ -187,17 +191,21 @@ void B02ImportanceDetectorConstruction::Construct()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const G4VPhysicalVolume &B02ImportanceDetectorConstruction::
GetPhysicalVolumeByName(const G4String& name) const {
return *fPVolumeStore.GetPVolume(name);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4String B02ImportanceDetectorConstruction::ListPhysNamesAsG4String(){
G4String names(fPVolumeStore.GetPNames());
return names;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4String B02ImportanceDetectorConstruction::GetCellName(G4int i) {
std::ostringstream os;
@@ -210,6 +218,8 @@ G4String B02ImportanceDetectorConstruction::GetCellName(G4int i) {
return name;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4GeometryCell B02ImportanceDetectorConstruction::GetGeometryCell(G4int i){
G4String name(GetCellName(i));
const G4VPhysicalVolume *p=0;
@@ -218,20 +228,26 @@ G4GeometryCell B02ImportanceDetectorConstruction::GetGeometryCell(G4int i){
return G4GeometryCell(*p,0);
}
else {
G4cout << "B02ImportanceDetectorConstruction::GetGeometryCell: couldn't get G4GeometryCell" << G4endl;
return G4GeometryCell(*ghostWorld,-2);
G4cout << "B02ImportanceDetectorConstruction::GetGeometryCell: " << G4endl
<< " couldn't get G4GeometryCell" << G4endl;
return G4GeometryCell(*fGhostWorld,-2);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume &B02ImportanceDetectorConstruction::GetWorldVolumeAddress() const{
return *ghostWorld;
G4VPhysicalVolume &B02ImportanceDetectorConstruction::
GetWorldVolumeAddress() const{
return *fGhostWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume *B02ImportanceDetectorConstruction::GetWorldVolume() {
return ghostWorld;
return fGhostWorld;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02ImportanceDetectorConstruction::SetSensitive(){
@@ -248,12 +264,13 @@ void B02ImportanceDetectorConstruction::SetSensitive(){
// 8 ConcreteSD/SLWE_V
// -------------------------------------------------
// moved to ConstructSD() for MT compliance
//================================================
// Sensitive detectors : MultiFunctionalDetector
//================================================
//
// Sensitive Detector Manager.
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B02ImportanceDetectorConstruction::ConstructSD()
{
G4SDManager* SDman = G4SDManager::GetSDMpointer();
//
@@ -265,7 +282,8 @@ void B02ImportanceDetectorConstruction::SetSensitive(){
//------------------------
//
// Define MultiFunctionalDetector with name.
G4MultiFunctionalDetector* MFDet = new G4MultiFunctionalDetector(concreteSDname);
G4MultiFunctionalDetector* MFDet =
new G4MultiFunctionalDetector(concreteSDname);
SDman->AddNewDetector( MFDet ); // Register SD to SDManager
@@ -276,9 +294,11 @@ void B02ImportanceDetectorConstruction::SetSensitive(){
MFDet->SetFilter(neutronFilter);
for (std::vector<G4LogicalVolume *>::iterator it = fLogicalVolumeVector.begin();
for (std::vector<G4LogicalVolume *>::iterator it =
fLogicalVolumeVector.begin();
it != fLogicalVolumeVector.end(); it++){
(*it)->SetSensitiveDetector(MFDet);
// (*it)->SetSensitiveDetector(MFDet);
SetSensitiveDetector((*it)->GetName(), MFDet);
}
G4String psName;
@@ -294,7 +314,8 @@ void B02ImportanceDetectorConstruction::SetSensitive(){
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");
@@ -319,5 +340,124 @@ void B02ImportanceDetectorConstruction::SetSensitive(){
scorer8->MultiplyKineticEnergy(true);
scorer8->DivideByVelocity(true);
MFDet->RegisterPrimitive(scorer8);
}
//....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!");
}
// creating and filling the importance store
// G4IStore *istore = new G4IStore(*fWorldVolume);
G4IStore *istore = G4IStore::GetInstance(GetName());
G4GeometryCell gWorldVolumeCell(GetWorldVolumeAddress(), 0);
G4double imp =1;
istore->AddImportanceGeometryCell(1, gWorldVolumeCell);
// set importance values and create scorers
G4int cell(1);
for (cell=1; cell<=18; cell++) {
G4GeometryCell gCell = GetGeometryCell(cell);
G4cout << " adding cell: " << cell
<< " replica: " << gCell.GetReplicaNumber()
<< " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
imp = std::pow(2.0,cell-1);
G4cout << "Going to assign importance: " << imp << ", to volume: "
<< gCell.GetPhysicalVolume().GetName() << G4endl;
//x aIstore.AddImportanceGeometryCell(imp, gCell);
istore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
}
// creating the geometry cell and add both to the store
// G4GeometryCell gCell = GetGeometryCell(18);
// create importance geometry cell pair for the "rest"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);
istore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
return istore;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VWeightWindowStore *B02ImportanceDetectorConstruction::
CreateWeightWindowStore()
{
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());
// create one energy region covering the energies of the problem
//
std::set<G4double, std::less<G4double> > enBounds;
enBounds.insert(1 * GeV);
wwstore->SetGeneralUpperEnergyBounds(enBounds);
G4int n = 0;
G4double lowerWeight =1;
std::vector<G4double> lowerWeights;
lowerWeights.push_back(1);
G4GeometryCell gWorldCell(GetWorldVolumeAddress(),0);
wwstore->AddLowerWeights(gWorldCell, lowerWeights);
G4int cell(1);
for (cell=1; cell<=18; cell++) {
G4GeometryCell gCell = GetGeometryCell(cell);
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);
}
// the remaining part pf the geometry (rest) gets the same
// lower weight bound as the last conrete cell
//
// create importance geometry cell pair for the "rest"cell
// with the same importance as the last concrete cell
G4GeometryCell gCell = GetGeometryCell(19);
wwstore->AddLowerWeights(gCell, lowerWeights);
return wwstore;
}