Import Geant4 11.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2022-12-09 14:43:28 +01:00
parent c07cea1fe0
commit 9f34590941
3810 changed files with 200490 additions and 182326 deletions
@@ -38,7 +38,7 @@
G4DigiModel::~G4DigiModel () {}
G4DigiModel::G4DigiModel ():
fpCurrentDigi(0)
fpCurrentDigi(nullptr)
{
fType = "G4DigiModel";
fGlobalTag = "G4DigiModel for all digis.";
@@ -49,17 +49,17 @@ void G4DigiModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
const G4Event* event = fpMP->GetEvent();
if (event) {
G4DCofThisEvent* DCE = event -> GetDCofThisEvent ();
G4DCofThisEvent* DCE = event->GetDCofThisEvent();
if (DCE) {
G4int nDC = DCE -> GetCapacity ();
for (int iDC = 0; iDC < nDC; iDC++) {
G4VDigiCollection* DC = DCE -> GetDC (iDC);
if (DC) {
for(size_t iDigi = 0; iDigi < DC->GetSize(); ++iDigi) {
fpCurrentDigi = DC -> GetDigi (iDigi);
if (fpCurrentDigi) sceneHandler.AddCompound (*fpCurrentDigi);
}
}
G4int nDC = (G4int)DCE->GetCapacity();
for (G4int iDC = 0; iDC < nDC; ++iDC) {
G4VDigiCollection* DC = DCE->GetDC(iDC);
if (DC) {
for(std::size_t iDigi = 0; iDigi < DC->GetSize(); ++iDigi) {
fpCurrentDigi = DC->GetDigi(iDigi);
if (fpCurrentDigi) sceneHandler.AddCompound(*fpCurrentDigi);
}
}
}
}
}
@@ -38,7 +38,7 @@
G4HitsModel::~G4HitsModel () {}
G4HitsModel::G4HitsModel ():
fpCurrentHit(0)
fpCurrentHit(nullptr)
{
fType = "G4HitsModel";
fGlobalTag = "G4HitsModel for all hits.";
@@ -49,17 +49,17 @@ void G4HitsModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
const G4Event* event = fpMP->GetEvent();
if (event) {
G4HCofThisEvent* HCE = event -> GetHCofThisEvent ();
G4HCofThisEvent* HCE = event->GetHCofThisEvent();
if (HCE) {
G4int nHC = HCE -> GetCapacity ();
for (int iHC = 0; iHC < nHC; iHC++) {
G4VHitsCollection* HC = HCE -> GetHC (iHC);
if (HC) {
for(size_t iHit = 0; iHit < HC->GetSize(); ++iHit) {
fpCurrentHit = HC -> GetHit (iHit);
if (fpCurrentHit) sceneHandler.AddCompound (*fpCurrentHit);
}
}
G4int nHC = (G4int)HCE->GetCapacity();
for (G4int iHC = 0; iHC < nHC; ++iHC) {
G4VHitsCollection* HC = HCE -> GetHC (iHC);
if (HC) {
for(std::size_t iHit = 0; iHit < HC->GetSize(); ++iHit) {
fpCurrentHit = HC->GetHit(iHit);
if (fpCurrentHit) sceneHandler.AddCompound(*fpCurrentHit);
}
}
}
}
}
@@ -165,10 +165,10 @@ void G4LogicalVolumeModel::DescribeYourselfTo
G4VReadOutGeometry* roGeom = sd->GetROgeometry();
if (roGeom) {
G4VPhysicalVolume* roWorld = roGeom->GetROWorld();
G4cout << "Readout geometry \"" << roGeom->GetName()
<< "\" with top physical volume \""
<< roWorld->GetName()
<< "\"" << G4endl;
// G4cout << "Readout geometry \"" << roGeom->GetName()
// << "\" with top physical volume \""
// << roWorld->GetName()
// << "\"" << G4endl;
G4PhysicalVolumeModel pvModel(roWorld);
pvModel.SetModelingParameters(fpMP);
pvModel.DescribeYourselfTo(sceneHandler);
@@ -179,7 +179,7 @@ void G4LogicalVolumeModel::DescribeYourselfTo
if (fCheckOverlaps) {
G4LogicalVolume* motherLog = fpTopPV->GetLogicalVolume();
G4VSolid* motherSolid = motherLog->GetSolid();
G4int nDaughters = motherLog->GetNoDaughters();
G4int nDaughters = (G4int)motherLog->GetNoDaughters();
// Models are called repeatedly by the scene handler so be careful...
// Print overlaps - but only the first time for a given instantiation of G4LogicalVolume
+7 -3
View File
@@ -93,7 +93,9 @@ G4Mesh::G4Mesh (G4VPhysicalVolume* containerVolume,const G4Transform3D& transfor
G4LogicalVolume* lv1 = nullptr;
G4LogicalVolume* lv2 = nullptr;
// Check if this is a container for a parameterisation
// Check if this is a container for a parameterisation.
// A simple parameterisation may only be one level.
// Nested parameterisations may be 2- or 3-level.
G4bool isContainer = false;
if (lv0->GetNoDaughters()) {
fMeshDepth++;
@@ -106,13 +108,15 @@ G4Mesh::G4Mesh (G4VPhysicalVolume* containerVolume,const G4Transform3D& transfor
fMeshDepth++;
pv2 = lv1->GetDaughter(0);
lv2 = pv2->GetLogicalVolume();
if (dynamic_cast<G4PVParameterised*>(pv2)) {
if (dynamic_cast<G4PVParameterised*>(pv2) &&
dynamic_cast<G4VNestedParameterisation*>(pv2->GetParameterisation())) {
isContainer = true;
fpParameterisedVolume = pv2;
} else if (lv2->GetNoDaughters()) {
fMeshDepth++;
pv3 = lv2->GetDaughter(0);
if (dynamic_cast<G4PVParameterised*>(pv3)) {
if (dynamic_cast<G4PVParameterised*>(pv3) &&
dynamic_cast<G4VNestedParameterisation*>(pv3->GetParameterisation())) {
isContainer = true;
fpParameterisedVolume = pv3;
}
@@ -41,6 +41,8 @@
#include "G4PhysicalVolumeModel.hh"
#include "G4UnitsTable.hh"
#define G4warn G4cout
G4ModelingParameters::G4ModelingParameters ():
fWarning (true),
fpDefaultVisAttributes (0),
@@ -117,12 +119,12 @@ G4ModelingParameters::~G4ModelingParameters ()
void G4ModelingParameters::SetVisibleDensity (G4double visibleDensity) {
const G4double reasonableMaximum = 10.0 * g / cm3;
if (visibleDensity < 0 && fWarning) {
G4cout << "G4ModelingParameters::SetVisibleDensity: attempt to set negative "
G4warn << "G4ModelingParameters::SetVisibleDensity: attempt to set negative "
"density - ignored." << G4endl;
}
else {
if (fVisibleDensity > reasonableMaximum && fWarning) {
G4cout << "G4ModelingParameters::SetVisibleDensity: density > "
G4warn << "G4ModelingParameters::SetVisibleDensity: density > "
<< reasonableMaximum
<< " g / cm3 - did you mean this?"
<< G4endl;
@@ -136,7 +138,7 @@ G4int G4ModelingParameters::SetNoOfSides (G4int nSides) {
if (nSides < nSidesMin) {
nSides = nSidesMin;
if (fWarning)
G4cout << "G4ModelingParameters::SetNoOfSides: attempt to set the"
G4warn << "G4ModelingParameters::SetNoOfSides: attempt to set the"
"\nnumber of sides per circle < " << nSidesMin
<< "; forced to" << nSides << G4endl;
}
@@ -52,23 +52,21 @@ void G4PSHitsModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
using MeshScoreMap = G4VScoringMesh::MeshScoreMap;
using RunScore = G4VScoringMesh::RunScore;
G4ScoringManager* scoringManager =
G4ScoringManager::GetScoringManagerIfExist();
G4ScoringManager* scoringManager= G4ScoringManager::GetScoringManagerIfExist();
if (scoringManager) {
size_t nMeshes = scoringManager->GetNumberOfMesh();
for (size_t iMesh = 0; iMesh < nMeshes; ++iMesh) {
G4int nMeshes = (G4int)scoringManager->GetNumberOfMesh();
for (G4int iMesh = 0; iMesh < nMeshes; ++iMesh) {
G4VScoringMesh* mesh = scoringManager->GetMesh(iMesh);
if (mesh && mesh->IsActive()) {
MeshScoreMap scoreMap = mesh->GetScoreMap();
for(MeshScoreMap::const_iterator i = scoreMap.begin();
i != scoreMap.end(); ++i) {
const G4String& name = i->first;
if (fRequestedMapName == "all" || name == fRequestedMapName) {
RunScore* fpCurrentHits = i->second;
//G4cout << name << ": " << fpCurrentHits << G4endl;
if (fpCurrentHits) sceneHandler.AddCompound(*fpCurrentHits);
}
}
MeshScoreMap scoreMap = mesh->GetScoreMap();
for(MeshScoreMap::const_iterator i = scoreMap.cbegin();
i != scoreMap.cend(); ++i) {
const G4String& name = i->first;
if (fRequestedMapName == "all" || name == fRequestedMapName) {
RunScore* fpCurrentHits = i->second;
if (fpCurrentHits) sceneHandler.AddCompound(*fpCurrentHits);
}
}
}
}
}
@@ -40,6 +40,8 @@
#include "G4VPVParameterisation.hh"
#include "G4UnitsTable.hh"
#define G4warn G4cout
G4PhysicalVolumeMassScene::G4PhysicalVolumeMassScene
(G4PhysicalVolumeModel* pPVModel):
fpPVModel (pPVModel),
@@ -123,7 +125,7 @@ void G4PhysicalVolumeMassScene::ProcessVolume (const G4VSolid& solid)
<< G4endl;
*/
if (fMass < 0.) {
G4cout <<
G4warn <<
"G4PhysicalVolumeMassScene::AccrueMass: WARNING:"
"\n Mass going negative for \""
<< pCurrentPV->GetName() <<
@@ -55,6 +55,8 @@
#include <sstream>
#include <iomanip>
#define G4warn G4cout
namespace {
G4int volumeCount = 0;
}
@@ -340,7 +342,7 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
((G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
} else {
if (fpMP->IsWarning())
G4cout <<
G4warn <<
"G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
"\n built-in replicated volumes replicated in radius for "
<< pSol->GetEntityType() <<
@@ -659,7 +661,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
// reasons why daughters might not be drawn...
// First, reasons that do not depend on culling policy...
G4int nDaughters = pLV->GetNoDaughters();
G4int nDaughters = (G4int)pLV->GetNoDaughters();
G4bool daughtersToBeDrawn = true;
// 1) There are no daughters...
if (!nDaughters) daughtersToBeDrawn = false;
@@ -751,89 +753,37 @@ void G4PhysicalVolumeModel::DescribeSolid
} else {
// Clipping, etc., performed by Boolean operations.
G4VSolid* pResultantSolid = nullptr;
// First, get polyhedron for current solid...
if (pVisAttribs->IsForceLineSegmentsPerCircle())
G4Polyhedron::SetNumberOfRotationSteps
(pVisAttribs->GetForcedLineSegmentsPerCircle());
else
G4Polyhedron::SetNumberOfRotationSteps(fpMP->GetNoOfSides());
const G4Polyhedron* pOriginalPolyhedron = pSol->GetPolyhedron();
G4Polyhedron::ResetNumberOfRotationSteps();
if (!pOriginalPolyhedron) {
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
<< pSol->GetName() <<
"\" has no polyhedron. Cannot by clipped."
<< G4endl;
pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment.
} else {
G4VSolid* pResultantSolid = 0;
if (fpClippingSolid) {
switch (fClippingMode) {
default:
case subtraction:
pResultantSolid = new G4SubtractionSolid
("subtracted_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
break;
case intersection:
pResultantSolid = new G4IntersectionSolid
("intersected_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
break;
}
if (fpClippingSolid) {
switch (fClippingMode) {
default:
case subtraction:
pResultantSolid = new G4SubtractionSolid
("subtracted_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
break;
case intersection:
pResultantSolid = new G4IntersectionSolid
("intersected_clipped_solid", pSol, fpClippingSolid, theAT.inverse());
break;
}
if (pSectionSolid) {
pResultantSolid = new G4IntersectionSolid
("sectioned_solid", pSol, pSectionSolid, theAT.inverse());
}
if (pCutawaySolid) {
// Follow above...
pResultantSolid = new G4SubtractionSolid
("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
}
G4Polyhedron* pResultantPolyhedron = pResultantSolid->GetPolyhedron();
if (!pResultantPolyhedron) {
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: resultant polyhedron for"
"\n solid \"" << pSol->GetName() <<
"\" not defined due to error during Boolean processing."
<< G4endl;
} else {
// It seems that if the sectioning solid does not intersect the
// original solid the Boolean Processor returns the original
// polyhedron, or a copy thereof. We do not want it.
// Check the number of facets, etc. If same, ignore.
// What we need from the Boolean Processor is a null pointer or a
// null polyhedron. It seems to return the original or a copy of it.
if (pResultantPolyhedron->GetNoFacets() == pOriginalPolyhedron->GetNoFacets())
// This works in most cases but I still get a box in test202 with
// /vis/viewer/set/sectionPlane on 0 0 0 m 0.1 0.1 1
{
pResultantPolyhedron = nullptr;
}
}
if (pResultantPolyhedron) {
// Finally, draw polyhedron...
sceneHandler.BeginPrimitives(theAT);
pResultantPolyhedron->SetVisAttributes(pVisAttribs);
sceneHandler.AddPrimitive(*pResultantPolyhedron);
sceneHandler.EndPrimitives();
}
delete pResultantSolid;
}
if (pSectionSolid) {
pResultantSolid = new G4IntersectionSolid
("sectioned_solid", pSol, pSectionSolid, theAT.inverse());
}
if (pCutawaySolid) {
pResultantSolid = new G4SubtractionSolid
("cutaway_solid", pSol, pCutawaySolid, theAT.inverse());
}
sceneHandler.PreAddSolid (theAT, *pVisAttribs);
pResultantSolid -> DescribeYourselfTo (sceneHandler);
sceneHandler.PostAddSolid ();
delete pResultantSolid;
}
}
@@ -77,10 +77,10 @@ G4PhysicalVolumesSearchScene::Matcher::Matcher(const G4String& requiredMatch)
: fRegexFlag(false)
{
if (requiredMatch.size()) {
size_t last = requiredMatch.size() - 1;
std::size_t last = requiredMatch.size() - 1;
// If required name begins and ends with '/', treat as a regular expression.
// 0 causes a conversion ambiguity that upsets the Windows compiler, so use 0U.
if (requiredMatch[0U] == '/' && requiredMatch[last] == '/') {
if (requiredMatch[0U] == '/' && requiredMatch[(G4int)last] == '/') {
if (last > 1) { // Non-null regexp
// regex match required
fRegexFlag = true;
@@ -89,12 +89,12 @@ G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object,
static G4bool warnedUnableToExtract = false;
if (!warnedUnableToExtract) {
G4ExceptionDescription ed;
ed <<"Unable to extract attribute definition named "<<fAttName;
ed <<"Unable to extract attribute definition named "<<fAttName << '\n'
<< "Available attributes:\n"
<< *object.GetAttDefs();
G4Exception
("G4TrajectoryDrawByAttribute::Draw",
"modeling0117", JustWarning, ed, ". Invalid attribute name");
G4cout << "Available attributes:\n"
<< *object.GetAttDefs();
warnedUnableToExtract = true;
}
return;
@@ -127,12 +127,12 @@ G4TrajectoryDrawByAttribute::Draw(const G4VTrajectory& object,
static G4bool warnedUnableToExtract = false;
if (!warnedUnableToExtract) {
G4ExceptionDescription ed;
ed <<"Unable to extract attribute value named "<<fAttName;
ed <<"Unable to extract attribute definition named "<<fAttName << '\n'
<< "Available attributes:\n"
<< *object.GetAttDefs();
G4Exception
("G4TrajectoryDrawByAttribute::Draw",
"modeling0118", JustWarning, ed, ". Invalid attribute name");
G4cout << "Available attributes:\n"
<< *object.GetAttDefs();
warnedUnableToExtract = true;
}
return;
@@ -38,6 +38,8 @@
#include "G4UIcommand.hh"
#include "G4AttValue.hh"
#define G4warn G4cout
namespace G4TrajectoryDrawerUtils {
enum TimesValidity {InvalidTimes, ValidTimes};
@@ -85,7 +87,7 @@ namespace G4TrajectoryDrawerUtils {
if (!trajectoryPointAttValues) {
static G4bool warnedNoAttValues = false;
if (!warnedNoAttValues) {
G4cout <<
G4warn <<
"*************************************************************************"
"\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
"\n*************************************************************************"
@@ -112,7 +114,7 @@ namespace G4TrajectoryDrawerUtils {
if (!foundPreTime || !foundPostTime) {
static G4bool warnedTimesNotFound = false;
if (!warnedTimesNotFound) {
G4cout <<
G4warn <<
"*************************************************************************"
"\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
"\n You need to specify \"/vis/scene/add/trajectories rich\""
@@ -52,6 +52,7 @@
#include <limits>
#include <vector>
#define G4warn G4cout
// Constructor and destructor
@@ -124,7 +125,7 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
if (!globalField) {
static G4bool warned = false;
if (!warned) {
G4cout << intro << "Null global field pointer." << G4endl;
G4warn << intro << "Null global field pointer." << G4endl;
warned = true;
}
}
@@ -132,7 +133,7 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
} else {
static G4bool warned = false;
if (!warned) {
G4cout << intro << "No global field manager." << G4endl;
G4warn << intro << "No global field manager." << G4endl;
warned = true;
}
}
@@ -158,7 +159,7 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
const G4double maxHalfScene =
std::max(xHalfScene,std::max(yHalfScene,zHalfScene));
if (maxHalfScene <= 0.) {
G4cout << "Scene extent non-positive." << G4endl;
G4warn << "Scene extent non-positive." << G4endl;
return;
}
@@ -259,7 +260,7 @@ void G4VFieldModel::DescribeYourselfTo(G4VGraphicsScene& sceneHandler) {
} // for (i, x
if (FieldMagnitudeMax <= 0.) {
G4cout << "No " << fTypeOfField << " field in this extent." << G4endl;
G4warn << "No " << fTypeOfField << " field in this extent." << G4endl;
return;
}