Import Geant4 7.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 11:11:55 +02:00
parent e083ffb441
commit 516dbf1a58
5914 changed files with 202605 additions and 71141 deletions
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4ASCIITreeSceneHandler.cc,v 1.13 2003/11/06 15:01:34 johna Exp $
// GEANT4 tag $Name: geant4-06-00-patch-01 $
// $Id: G4ASCIITreeSceneHandler.cc,v 1.16 2004/11/11 16:03:15 johna Exp $
// GEANT4 tag $Name: geant4-07-00-cand-01 $
//
//
// John Allison 5th April 2001
@@ -37,10 +37,21 @@
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VPVParameterisation.hh"
#include "G4Polyhedron.hh"
#include "G4UnitsTable.hh"
#include "G4Material.hh"
#include "G4Scene.hh"
#include "G4ModelingParameters.hh"
#include "G4PhysicalVolumeMassScene.hh"
G4ASCIITreeSceneHandler::G4ASCIITreeSceneHandler(G4VGraphicsSystem& system,
const G4String& name):
G4VTreeSceneHandler(system, name) {}
G4ASCIITreeSceneHandler::G4ASCIITreeSceneHandler
(G4VGraphicsSystem& system,
const G4String& name):
G4VTreeSceneHandler(system, name),
fpLastPV (0),
fPVPCount (0),
fpOutFile (0)
{}
G4ASCIITreeSceneHandler::~G4ASCIITreeSceneHandler () {}
@@ -48,33 +59,132 @@ void G4ASCIITreeSceneHandler::BeginModeling () {
G4VTreeSceneHandler::BeginModeling (); // To re-use "culling off" code.
const G4ASCIITree* pSystem = (G4ASCIITree*)GetGraphicsSystem();
const G4String& outFileName = pSystem -> GetOutFileName();
if (outFileName == "G4cout") {
fpOutFile = &G4cout;
} else {
fOutFile.open (outFileName);
fpOutFile = &fOutFile;
}
G4cout << "G4ASCIITreeSceneHandler::BeginModeling: writing to ";
if (outFileName == "G4cout") {
G4cout << "G4 standard output (G4cout)";
} else {
G4cout << "file \"" << outFileName << "\"";
}
G4cout << G4endl;
WriteHeader (G4cout); G4cout << G4endl;
if (outFileName != "G4cout") {
WriteHeader (fOutFile); fOutFile << std::endl;
}
}
void G4ASCIITreeSceneHandler::WriteHeader (std::ostream& os)
{
const G4ASCIITree* pSystem = (G4ASCIITree*)GetGraphicsSystem();
const G4int verbosity = pSystem->GetVerbosity();
G4cout << "\nG4ASCIITreeSceneHandler::BeginModeling:"
"\n set verbosity with \"/vis/ASCIITree/verbose <verbosity>\":"
"\n < 10: - does not print daughters of repeated placements."
"\n - does not repeat replicas."
"\n >= 10: prints all physical volumes."
"\n For level of detail add:"
"\n >= 0: prints physical volume name."
"\n >= 1: prints logical volume name."
"\n >= 2: prints solid name and type."
"\n Note: all culling, if any, is switched off so all volumes are seen."
"\n Now printing with verbosity " << verbosity << G4endl;
const G4int detail = verbosity % 10;
os <<
"# Set verbosity with \"/vis/ASCIITree/verbose <verbosity>\":"
"\n# < 10: - does not print daughters of repeated placements."
"\n# - does not repeat replicas."
"\n# >= 10: prints all physical volumes."
"\n# The level of detail is given by the units (verbosity%10):"
"\n# >= 0: prints physical volume name."
"\n# >= 1: prints logical volume name."
"\n# >= 2: prints solid name and type."
"\n# >= 3: prints volume and density of solid."
"\n# >= 4: calculates and prints mass(es) of volume(s) in scene."
"\n# Note: by default, culling is switched off so all volumes are seen.";
if (detail >=4) {
os <<
"\n# Note: the mass is calculated for each physical volume in the scene,"
"\n# taking into account daughters up to the depth specified. Culling "
"\n# is ignored. If you want the mass of a particular subtree:"
"\n# /vis/drawVolume <name-of-physical-volume-at-top-of-subtree>"
"\n# /vis/viewer/flush";
}
os << "\n# Now printing with verbosity " << verbosity;
os << "\n# Format is: PV:n";
if (detail >= 1) os << " / LV";
if (detail >= 2) os << " / Solid(type)";
if (detail >= 3) os << ", volume, density";
os << "\n# where PV = Physical Volume";
if (detail <2) os << " and"; else os << ",";
os << " n = copy number";
if (detail >= 2) os << " and LV = Logical Volume";
}
void G4ASCIITreeSceneHandler::EndModeling () {
const G4ASCIITree* pSystem = (G4ASCIITree*) GetGraphicsSystem();
const G4int verbosity = pSystem->GetVerbosity();
const G4int detail = verbosity % 10;
const G4String& outFileName = pSystem -> GetOutFileName();
if (detail >= 4) {
G4cout << "Calculating mass(es)..." << G4endl;
const std::vector<G4VModel*>& models = fpScene->GetRunDurationModelList();
std::vector<G4VModel*>::const_iterator i;
G4PhysicalVolumeModel* pvModel;
for (i = models.begin(); i != models.end(); ++i) {
if ((pvModel = (*i)->GetG4PhysicalVolumeModel())) {
const G4ModelingParameters* tempMP = pvModel->GetModelingParameters();
G4ModelingParameters mp; // Default - no culling.
pvModel->SetModelingParameters (&mp);
G4PhysicalVolumeMassScene massScene;
massScene.EstablishSpecials (*pvModel);
pvModel->DescribeYourselfTo (massScene);
G4double volume = massScene.GetVolume();
G4double mass = massScene.GetMass();
G4cout << "Overall volume of \""
<< pvModel->GetTopPhysicalVolume()->GetName()
<< "\":"
<< pvModel->GetTopPhysicalVolume()->GetCopyNo()
<< ", is "
<< G4BestUnit (volume, "Volume")
<< "\nMass of tree to ";
G4int requestedDepth = pvModel->GetRequestedDepth();
if (requestedDepth == G4PhysicalVolumeModel::UNLIMITED) {
G4cout << "unlimited depth";
} else {
G4cout << "depth " << requestedDepth;
}
G4cout << " is " << G4BestUnit (mass, "Mass")
<< G4endl;
pvModel->SetModelingParameters (tempMP);
}
}
}
if (outFileName != "G4cout") {
fOutFile.close();
G4cout << "Output file \"" << outFileName << "\" closed." << G4endl;
}
fpLastPV = 0;
fPVPCount = 0;
fLVSet.clear();
fReplicaSet.clear();
G4cout << "G4ASCIITreeSceneHandler::EndModeling" << G4endl;
G4VTreeSceneHandler::EndModeling (); // To re-use "culling off" code.
}
void G4ASCIITreeSceneHandler::RequestPrimitives(const G4VSolid&) {
void G4ASCIITreeSceneHandler::RequestPrimitives(const G4VSolid& solid) {
const G4ASCIITree* pSystem = (G4ASCIITree*)GetGraphicsSystem();
const G4int verbosity = pSystem->GetVerbosity();
const G4int detail = verbosity % 10;
const G4String& outFileName = pSystem -> GetOutFileName();
if (fpCurrentPV != fpLastPV) {
fpLastPV = fpCurrentPV;
fPVPCount = 0;
}
if (verbosity < 10 && fReplicaSet.find(fpCurrentPV) != fReplicaSet.end()) {
// Ignore if an already treated replica.
@@ -82,26 +192,20 @@ void G4ASCIITreeSceneHandler::RequestPrimitives(const G4VSolid&) {
if (pPVM) {
pPVM->CurtailDescent();
return;
} else {
G4Exception
("G4ASCIITreeSceneHandler::RequestPrimitives:"
"not a physical volume model"); // Shouldn't happen.
}
}
// Print indented text...
for (G4int i = 0; i < fCurrentDepth; i++ ) G4cout << " ";
G4cout << "\"" << fpCurrentPV->GetName()
<< "\", copy no. " << fpCurrentPV->GetCopyNo();
if (detail >= 1) {
G4cout << ", belongs to logical volume \""
<< fpCurrentLV->GetName() << "\"";
}
if (detail >= 2) {
G4cout << " and is composed of solid \""
<< fpCurrentLV->GetSolid()->GetName()
<< "\" of type \""
<< fpCurrentLV->GetSolid()->GetEntityType() << "\"";
}
for (G4int i = 0; i < fCurrentDepth; i++ ) *fpOutFile << " ";
*fpOutFile << "\"" << fpCurrentPV->GetName()
<< "\":" << fpCurrentPV->GetCopyNo();
if (fpCurrentPV->IsReplicated()) {
fReplicaSet.insert(fpCurrentPV); // Record new replica volume.
if (verbosity < 10) {
// Add printing for replicas (when replicas are ignored)...
EAxis axis;
@@ -111,12 +215,15 @@ void G4ASCIITreeSceneHandler::RequestPrimitives(const G4VSolid&) {
G4bool consuming;
fpCurrentPV->GetReplicationData(axis,nReplicas,width,offset,consuming);
G4VPVParameterisation* pP = fpCurrentPV->GetParameterisation();
G4cout << " (" << nReplicas;
if (pP) {
G4cout << " parametrised volumes)";
if (detail < 3) {
fReplicaSet.insert(fpCurrentPV);
*fpOutFile << " (" << nReplicas << " parametrised volumes)";
}
}
else {
G4cout << " replicas)";
fReplicaSet.insert(fpCurrentPV);
*fpOutFile << " (" << nReplicas << " replicas)";
}
}
}
@@ -124,21 +231,53 @@ void G4ASCIITreeSceneHandler::RequestPrimitives(const G4VSolid&) {
if (fLVSet.find(fpCurrentLV) != fLVSet.end()) {
if (verbosity < 10) {
// Add printing for repeated placement...
G4cout << " (repeated placement)";
// Ignore if an already treated logical volume.
if (fpCurrentPV) {
((G4PhysicalVolumeModel*)fpModel)->CurtailDescent();
G4cout << G4endl;
return;
}
*fpOutFile << " (repeated placement)";
// ...and curtail descent.
((G4PhysicalVolumeModel*)fpModel)->CurtailDescent();
}
}
}
if (detail >= 1) {
*fpOutFile << " / \""
<< fpCurrentLV->GetName() << "\"";
}
if (detail >= 2) {
*fpOutFile << " / \""
<< solid.GetName()
<< "\"("
<< solid.GetEntityType() << ")";
}
if (detail >= 3) {
G4Polyhedron* pPolyhedron = solid.GetPolyhedron();
if (pPolyhedron) {
G4Material* pMaterial;
G4VPVParameterisation* pP = fpCurrentPV->GetParameterisation();
if (pP) {
pMaterial = pP -> ComputeMaterial (fPVPCount++, fpCurrentPV);
} else {
pMaterial = fpCurrentLV->GetMaterial();
}
*fpOutFile << ", "
<< G4BestUnit(pPolyhedron->GetVolume(),"Volume")
<< ", "
<< G4BestUnit(pMaterial->GetDensity(), "Volumic Mass");
} else {
*fpOutFile << " (volume not available)";
}
}
if (fLVSet.find(fpCurrentLV) == fLVSet.end()) {
fLVSet.insert(fpCurrentLV); // Record new logical volume.
}
G4cout << G4endl;
if (outFileName == "G4cout") {
G4cout << G4endl;
} else {
*fpOutFile << std::endl;
}
return;
}