Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+15
View File
@@ -6,6 +6,21 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-10-22 John Allison (modeling-V11-02-05)
- G4PhysicalVolumeModel.cc:
- Fixed some ragged indentations.
## 2024-10-16 John Allison (modeling-V11-02-04)
- G4TrajectoryDrawByEncounteredVolume.cc, G4TrajectoryEncounteredVolumeFilter.cc:
- Replace check on trajectory type using dynamic_cast with a simple check
on the existence on the required G4Att.
## 2024-08-31 John Allison (modeling-V11-02-03)
- More Coverity fixes
## 2024-07-17 John Allison (modeling-V11-02-02)
- Coverity fixes
## 2024-01-22 John Allison (modeling-V11-02-01)
- Coworks with visman-V11-02-04, greps-V11-02-00 and interfaces-V11-02-01.
- G4PhysicalVolumeModel:
@@ -36,6 +36,8 @@
#include "G4ConversionFatalError.hh"
#include "G4ConversionUtils.hh"
#include <utility>
namespace {
// Helper classes
@@ -168,8 +170,7 @@ G4AttValueFilterT<T, ConversionErrorPolicy>::LoadIntervalElement(const G4String&
if (!G4ConversionUtils::Convert(input, min, max)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
std::pair<T, T> myPair(min, max);
fIntervalMap[input] = myPair;
fIntervalMap[input] = std::pair<T, T> (min, max);
}
template <typename T, typename ConversionErrorPolicy>
@@ -180,7 +181,7 @@ G4AttValueFilterT<T, ConversionErrorPolicy>::LoadSingleValueElement(const G4Stri
if (!G4ConversionUtils::Convert(input, output)) ConversionErrorPolicy::ReportError(input, "Invalid format. Was the input data formatted correctly ?");
fSingleValueMap[input] = output;
fSingleValueMap[input] = std::move(output);
}
template <typename T, typename ConversionErrorPolicy>
@@ -37,7 +37,9 @@
#include "G4AttValue.hh"
#include "G4SmartFilter.hh"
#include "G4VAttValueFilter.hh"
#include <vector>
#include <utility>
template <typename T>
class G4AttributeFilterT : public G4SmartFilter<T> {
@@ -208,7 +210,7 @@ G4AttributeFilterT<T>::AddInterval(const G4String& interval)
return;
}
fConfigVect.push_back(myPair);
fConfigVect.push_back(std::move(myPair));
}
template <typename T>
@@ -226,7 +228,7 @@ G4AttributeFilterT<T>::AddValue(const G4String& value)
("G4AttributeFilterT::AddValue", "modeling0105", JustWarning, ed);
return;
}
fConfigVect.push_back(myPair);
fConfigVect.push_back(std::move(myPair));
}
#endif
@@ -86,7 +86,7 @@ public: // With description
class PVNameCopyNo {
public:
// Normal constructor
PVNameCopyNo(G4String name, G4int copyNo)
PVNameCopyNo(const G4String& name, G4int copyNo)
: fName(name), fCopyNo(copyNo) {}
const G4String& GetName() const {return fName;}
G4int GetCopyNo() const {return fCopyNo;}
@@ -61,13 +61,11 @@ public:
G4VPhysicalVolume* pFoundPV,
G4int foundPVCopyNo = 0,
G4int foundDepth = 0,
std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
foundBasePVPath =
std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
foundFullPVPath =
std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
G4Transform3D foundObjectTransformation = G4Transform3D())
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>&
foundBasePVPath = std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>&
foundFullPVPath = std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
const G4Transform3D& foundObjectTransformation = G4Transform3D())
: fpSearchPV(pSearchPV)
, fpFoundPV(pFoundPV)
, fFoundPVCopyNo(foundPVCopyNo)
@@ -305,18 +305,18 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
G4VPVParameterisation* pP = pVPV -> GetParameterisation ();
if (pP) { // Parametrised volume.
for (int n = nBegin; n < nEnd; n++) {
pSol = pP -> ComputeSolid (n, pVPV);
pP -> ComputeTransformation (n, pVPV);
pSol -> ComputeDimensions (pP, n, pVPV);
pVPV -> SetCopyNo (n);
pSol = pP -> ComputeSolid (n, pVPV);
pP -> ComputeTransformation (n, pVPV);
pSol -> ComputeDimensions (pP, n, pVPV);
pVPV -> SetCopyNo (n);
fCurrentPVCopyNo = n;
// Create a touchable of current parent for ComputeMaterial.
// fFullPVPath has not been updated yet so at this point it
// corresponds to the parent.
G4PhysicalVolumeModelTouchable parentTouchable(fFullPVPath);
pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
// Create a touchable of current parent for ComputeMaterial.
// fFullPVPath has not been updated yet so at this point it
// corresponds to the parent.
G4PhysicalVolumeModelTouchable parentTouchable(fFullPVPath);
pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
}
}
else { // Plain replicated volume. From geometry_guide.txt...
@@ -347,64 +347,64 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
G4RotationMatrix* pOriginalRotation = pVPV -> GetRotation ();
G4double originalRMin = 0., originalRMax = 0.;
if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
originalRMin = ((G4Tubs*)pSol)->GetInnerRadius();
originalRMax = ((G4Tubs*)pSol)->GetOuterRadius();
originalRMin = ((G4Tubs*)pSol)->GetInnerRadius();
originalRMax = ((G4Tubs*)pSol)->GetOuterRadius();
}
G4bool visualisable = true;
for (int n = nBegin; n < nEnd; n++) {
G4ThreeVector translation; // Identity.
G4RotationMatrix rotation; // Identity - life enough for visualizing.
G4RotationMatrix* pRotation = 0;
switch (axis) {
default:
case kXAxis:
translation = G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
break;
case kYAxis:
translation = G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
break;
case kZAxis:
translation = G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
break;
case kRho:
if (pSol->GetEntityType() == "G4Tubs") {
((G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
((G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
} else {
if (fpMP->IsWarning())
G4warn <<
"G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
"\n built-in replicated volumes replicated in radius for "
<< pSol->GetEntityType() <<
"-type\n solids (your solid \""
<< pSol->GetName() <<
"\") are not visualisable."
<< G4endl;
visualisable = false;
}
break;
case kPhi:
rotation.rotateZ (-(offset+(n+0.5)*width));
// Minus Sign because for the physical volume we need the
// coordinate system rotation.
pRotation = &rotation;
break;
}
pVPV -> SetTranslation (translation);
pVPV -> SetRotation (pRotation);
pVPV -> SetCopyNo (n);
G4ThreeVector translation; // Identity.
G4RotationMatrix rotation; // Identity - life enough for visualizing.
G4RotationMatrix* pRotation = 0;
switch (axis) {
default:
case kXAxis:
translation = G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
break;
case kYAxis:
translation = G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
break;
case kZAxis:
translation = G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
break;
case kRho:
if (pSol->GetEntityType() == "G4Tubs") {
((G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
((G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
} else {
if (fpMP->IsWarning())
G4warn <<
"G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
"\n built-in replicated volumes replicated in radius for "
<< pSol->GetEntityType() <<
"-type\n solids (your solid \""
<< pSol->GetName() <<
"\") are not visualisable."
<< G4endl;
visualisable = false;
}
break;
case kPhi:
rotation.rotateZ (-(offset+(n+0.5)*width));
// Minus Sign because for the physical volume we need the
// coordinate system rotation.
pRotation = &rotation;
break;
}
pVPV -> SetTranslation (translation);
pVPV -> SetRotation (pRotation);
pVPV -> SetCopyNo (n);
fCurrentPVCopyNo = n;
if (visualisable) {
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
}
if (visualisable) {
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
}
}
// Restore originals...
pVPV -> SetTranslation (originalTranslation);
pVPV -> SetRotation (pOriginalRotation);
if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
((G4Tubs*)pSol)->SetInnerRadius(originalRMin);
((G4Tubs*)pSol)->SetOuterRadius(originalRMax);
((G4Tubs*)pSol)->SetInnerRadius(originalRMin);
((G4Tubs*)pSol)->SetOuterRadius(originalRMax);
}
}
}
@@ -32,8 +32,8 @@
#include "G4VTrajectory.hh"
#include "G4VisTrajContext.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttDef.hh"
#include "G4AttValue.hh"
#include "G4RichTrajectory.hh"
G4TrajectoryDrawByEncounteredVolume::G4TrajectoryDrawByEncounteredVolume
(const G4String& name, G4VisTrajContext* context)
@@ -46,9 +46,12 @@ G4TrajectoryDrawByEncounteredVolume::~G4TrajectoryDrawByEncounteredVolume() {}
void
G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj, const G4bool& /*visible*/) const
{
try
{
const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
// Check the required G4Att exists
const auto& aPointAttDefs = traj.GetPoint(0)->GetAttDefs();
if (aPointAttDefs->find("PostVPath") != aPointAttDefs->end()) {
// Must be a rich trajectory
const auto& richTrajectory = traj;
G4Colour colour(fDefault);
G4String soughtPVName("none");
@@ -82,20 +85,18 @@ G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj, const G4boo
<< ", with configuration:" << G4endl;
myContext.Print(G4cout);
}
G4TrajectoryDrawerUtils::DrawLineAndPoints(richTrajectory, myContext);
}
catch (const std::bad_cast&)
{
G4TrajectoryDrawerUtils::DrawLineAndPoints(richTrajectory, myContext);
} else {
G4ExceptionDescription ed;
ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
G4Exception
("G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj,...",
"modeling0125",
JustWarning, ed);
return;
}
}
@@ -38,6 +38,8 @@
#include "G4UIcommand.hh"
#include "G4AttValue.hh"
#include <utility>
#define G4warn G4cout
namespace G4TrajectoryDrawerUtils {
@@ -203,8 +205,8 @@ namespace G4TrajectoryDrawerUtils {
}
}
trajectoryLine = newTrajectoryLine;
trajectoryLineTimes = newTrajectoryLineTimes;
trajectoryLine = std::move(newTrajectoryLine);
trajectoryLineTimes = std::move(newTrajectoryLineTimes);
}
static void DrawWithoutTime(const G4VisTrajContext& myContext,
@@ -32,8 +32,8 @@
#include "G4TrajectoryEncounteredVolumeFilter.hh"
#include "G4TransportationManager.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttDef.hh"
#include "G4AttValue.hh"
#include "G4RichTrajectory.hh"
G4TrajectoryEncounteredVolumeFilter::G4TrajectoryEncounteredVolumeFilter(const G4String& name)
:G4SmartFilter<G4VTrajectory>(name)
@@ -44,10 +44,13 @@ G4TrajectoryEncounteredVolumeFilter::~G4TrajectoryEncounteredVolumeFilter() {}
bool
G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj) const
{
try
{
const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
// Check the required G4Att exists
const auto& aPointAttDefs = traj.GetPoint(0)->GetAttDefs();
if (aPointAttDefs->find("PostVPath") != aPointAttDefs->end()) {
// Must be a rich trajectory
const auto& richTrajectory = traj;
for (const auto& pvname: fVolumes) {
for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
@@ -64,10 +67,9 @@ G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj) const
}
}
return false;
}
catch (const std::bad_cast&)
{
} else {
G4ExceptionDescription ed;
ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
G4Exception
@@ -75,6 +77,7 @@ G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj) const
"modeling0126",
JustWarning, ed);
return false;
}
}