Import Geant4 10.5.0 source tree

This commit is contained in:
Gabriele Cosmo
2018-12-07 15:15:39 +01:00
parent 6aa23be517
commit db49709b53
11370 changed files with 187480 additions and 160142 deletions
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4ArrowModel.cc 100807 2016-11-02 15:00:41Z gcosmo $
//
//
// John Allison 15th July 2012
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AttFilterUtils.cc 66870 2013-01-14 23:38:59Z adotti $
//
// Visualisation attribute filter utility functions.
//
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4AxesModel.cc 83403 2014-08-21 15:07:30Z gcosmo $
//
//
// John Allison 3rd April 2001
@@ -86,7 +85,7 @@ G4AxesModel::G4AxesModel
<< "\" not found. Defaulting to white and opaque.";
G4Exception
("G4AxesModel::G4AxesModel",
"modeling0012", JustWarning, ed);
"modeling0011", JustWarning, ed);
}
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4BoundingSphereScene.cc 81056 2014-05-20 09:02:16Z gcosmo $
//
//
// John Allison 7th June 1997
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// $Id: G4DigiFilterFactories.cc 68043 2013-03-13 14:27:49Z gcosmo $
//
//
// Digi filter model factories creating filters
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4DigiModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
// John Allison 26th August 1998.
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4GPSModel.cc 100959 2016-11-03 14:13:37Z allison $
//
//
// John Allison 26th April 2017.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// $Id: G4HitFilterFactories.cc 68043 2013-03-13 14:27:49Z gcosmo $
//
//
// Hits filter model factories creating filters
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4HitsModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
// John Allison 26th August 1998.
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4LogicalVolumeModel.cc 110480 2018-05-25 07:25:18Z gcosmo $
//
//
// John Allison 26th July 1999.
@@ -40,6 +39,10 @@
#include "G4DrawVoxels.hh"
#include "G4VSensitiveDetector.hh"
#include "G4VReadOutGeometry.hh"
#include "G4Circle.hh"
#include <vector>
#include <utility>
G4LogicalVolumeModel::G4LogicalVolumeModel
(G4LogicalVolume* pLV,
@@ -72,7 +75,8 @@ G4LogicalVolumeModel::G4LogicalVolumeModel
fBooleans (booleans),
fVoxels (voxels),
fReadout (readout),
fCheckOverlaps(checkOverlaps)
fCheckOverlaps(checkOverlaps),
fOverlapsPrinted(false)
{
fType = "G4LogicalVolumeModel";
fGlobalTag = fpLV -> GetName ();
@@ -81,6 +85,66 @@ G4LogicalVolumeModel::G4LogicalVolumeModel
G4LogicalVolumeModel::~G4LogicalVolumeModel () {}
namespace {
// Keep a vector of solid-transform pairs to avoid duplication.
typedef std::pair<G4VSolid*,G4Transform3D> solidTransformPair;
std::vector<solidTransformPair> solidTransformVector;
void drawSolidsAndPoint
(G4VGraphicsScene& sceneHandler,
const G4ThreeVector& point,
G4VSolid* sol1, const G4Transform3D& t1,
G4VSolid* sol2, const G4Transform3D& t2)
{
const G4Colour highlightSolidColour(1.0,0.8,0.8);
const G4double highlightSolidLineWidth(10./*pixels*/);
const G4Colour highlightPointColour(0.5,0.5,1.0);
const G4double highlightPointDiameter(20./*pixels*/);
// Draw first solid. Avoid duplication.
std::pair<G4VSolid*,G4Transform3D> pair1(sol1,t1);
auto iter1 = solidTransformVector.begin();
for ( ; iter1 != solidTransformVector.end(); ++iter1) {
if (iter1->first == pair1.first &&
iter1->second == pair1.second) break;
}
if (iter1 == solidTransformVector.end()) {
solidTransformVector.push_back(pair1);
G4VisAttributes highlightSolidVisAtts(highlightSolidColour);
highlightSolidVisAtts.SetLineWidth(highlightSolidLineWidth);
sceneHandler.PreAddSolid(t1,highlightSolidVisAtts);
sceneHandler.AddSolid(*sol1);
sceneHandler.PostAddSolid();
}
// Draw second solid. Avoid duplication.
std::pair<G4VSolid*,G4Transform3D> pair2(sol2,t2);
auto iter2 = solidTransformVector.begin();
for ( ; iter2 != solidTransformVector.end(); ++iter2) {
if (iter2->first == pair2.first &&
iter2->second == pair2.second) break;
}
if (iter2 == solidTransformVector.end()) {
solidTransformVector.push_back(pair2);
G4VisAttributes highlightSolidVisAtts(highlightSolidColour);
highlightSolidVisAtts.SetLineWidth(highlightSolidLineWidth);
sceneHandler.PreAddSolid(t2,highlightSolidVisAtts);
sceneHandler.AddSolid(*sol2);
sceneHandler.PostAddSolid();
}
// Draw points. Draw them all.
G4VisAttributes highlightPointVisAtts(highlightPointColour);
G4Circle overlapPoint;
overlapPoint.SetVisAttributes(highlightPointVisAtts);
overlapPoint.SetPosition(point);
overlapPoint.SetDiameter(G4VMarker::SizeType::screen,highlightPointDiameter);
overlapPoint.SetFillStyle(G4VMarker::FillStyle::filled);
sceneHandler.BeginPrimitives();
sceneHandler.AddPrimitive(overlapPoint);
sceneHandler.EndPrimitives();
}
}
void G4LogicalVolumeModel::DescribeYourselfTo
(G4VGraphicsScene& sceneHandler) {
@@ -129,11 +193,55 @@ void G4LogicalVolumeModel::DescribeYourselfTo
}
if (fCheckOverlaps) {
G4LogicalVolume* lv = fpTopPV->GetLogicalVolume();
G4int nSisters = lv->GetNoDaughters();
for (G4int iSister = 0; iSister < nSisters; ++iSister) {
G4PVPlacement* placement = dynamic_cast<G4PVPlacement*>(lv->GetDaughter(iSister));
if (placement) placement->CheckOverlaps();
G4LogicalVolume* motherLog = fpTopPV->GetLogicalVolume();
G4VSolid* motherSolid = motherLog->GetSolid();
G4int nDaughters = 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
if (!fOverlapsPrinted) {
for (G4int iDaughter = 0; iDaughter < nDaughters; ++iDaughter) {
G4VPhysicalVolume* daughterPhys = motherLog->GetDaughter(iDaughter);
daughterPhys->CheckOverlaps();
}
fOverlapsPrinted = true;
}
// Draw overlaps. This algorithm is based on G4PVPlacement::CheckOverlaps.
solidTransformVector.clear();
for (G4int iDaughter = 0; iDaughter < nDaughters; ++iDaughter) {
G4VPhysicalVolume* daughterPhys = motherLog->GetDaughter(iDaughter);
// Replicas and paramaterisations not presently processed
if (!dynamic_cast<G4PVPlacement*>(daughterPhys)) continue;
G4AffineTransform tDaughter(daughterPhys->GetRotation(),daughterPhys->GetTranslation());
G4VSolid* daughterSolid = daughterPhys->GetLogicalVolume()->GetSolid();
const G4int nTrials = 1000;
for (G4int i = 0; i < nTrials; ++i) {
G4ThreeVector p = daughterSolid->GetPointOnSurface();
// Transform to mother's coordinate system
G4ThreeVector pMother = tDaughter.TransformPoint(p);
// Check overlaps with the mother volume
if (motherSolid->Inside(pMother)==kOutside) {
// Draw mother and daughter and point
drawSolidsAndPoint
(sceneHandler,pMother,motherSolid,G4Transform3D(),daughterSolid,tDaughter);
}
// Check other daughters
for (G4int iSister = 0; iSister < nDaughters; ++iSister) {
if (iSister == iDaughter) continue;
G4VPhysicalVolume* sisterPhys = motherLog->GetDaughter(iSister);
G4AffineTransform tSister(sisterPhys->GetRotation(),sisterPhys->GetTranslation());
// Transform to sister's coordinate system
G4ThreeVector pSister = tSister.InverseTransformPoint(pMother);
G4LogicalVolume* sisterLog = sisterPhys->GetLogicalVolume();
G4VSolid* sisterSolid = sisterLog->GetSolid();
if (sisterSolid->Inside(pSister)==kInside) {
// Draw daughter and sister and point
drawSolidsAndPoint
(sceneHandler,pMother,daughterSolid,tDaughter,sisterSolid,tSister);
}
}
}
}
}
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4MagneticFieldModel.cc 101958 2016-12-12 08:04:35Z gcosmo $
//
//
// John Allison 17th August 2013
@@ -62,6 +61,11 @@ G4MagneticFieldModel::G4MagneticFieldModel
std::ostringstream oss;
oss << ':' << fNDataPointsPerMaxHalfScene
<< ':' << fArrow3DLineSegmentsPerCircle;
if (fRepresentation == Representation::fullArrow) {
oss << " full arrow";
} else if (fRepresentation == Representation::lightArrow) {
oss << " light arrow";
}
fGlobalDescription = fType + oss.str();
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4ModelingParameters.cc 109510 2018-04-26 07:15:57Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -90,25 +89,25 @@ G4ModelingParameters::~G4ModelingParameters ()
delete fpCutawaySolid;
}
G4ModelingParameters::VisAttributesModifier::VisAttributesModifier
(const G4VisAttributes& visAtts,
G4ModelingParameters::VisAttributesSignifier signifier,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path):
fVisAtts(visAtts), fSignifier(signifier)
{
typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
typedef std::vector<PVNodeID> PVPath;
typedef PVPath::const_iterator PVPathConstIterator;
PVPathConstIterator i;
for (i = path.begin();
i != path.end();
++i) {
fPVNameCopyNoPath.push_back
(PVNameCopyNo
(i->GetPhysicalVolume()->GetName(),
i->GetCopyNo()));
}
}
//G4ModelingParameters::VisAttributesModifier::VisAttributesModifier
//(const G4VisAttributes& visAtts,
// G4ModelingParameters::VisAttributesSignifier signifier,
// const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path):
//fVisAtts(visAtts), fSignifier(signifier)
//{
// typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
// typedef std::vector<PVNodeID> PVPath;
// typedef PVPath::const_iterator PVPathConstIterator;
// PVPathConstIterator i;
// for (i = path.begin();
// i != path.end();
// ++i) {
// fPVNameCopyNoPath.push_back
// (PVNameCopyNo
// (i->GetPhysicalVolume()->GetName(),
// i->GetCopyNo()));
// }
//}
void G4ModelingParameters::SetVisibleDensity (G4double visibleDensity) {
const G4double reasonableMaximum = 10.0 * g / cm3;
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4NullModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
// John Allison 4th April 1998.
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PSHitsModel.cc 99152 2016-09-07 08:04:30Z gcosmo $
//
//
// Created: Mar. 31, 2009 Akinori Kimura
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeMassScene.cc 108859 2018-03-12 07:44:53Z gcosmo $
//
//
// John Allison 10th August 1998.
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeModel.cc 110743 2018-06-12 06:33:37Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -32,7 +31,6 @@
#include "G4PhysicalVolumeModel.hh"
#include "G4ModelingParameters.hh"
#include "G4VGraphicsScene.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VPVParameterisation.hh"
@@ -54,23 +52,27 @@
#include "G4Vector3D.hh"
#include <sstream>
#include <iomanip>
G4PhysicalVolumeModel::G4PhysicalVolumeModel
(G4VPhysicalVolume* pVPV
(G4VPhysicalVolume* pVPV
, G4int requestedDepth
, const G4Transform3D& modelTransformation
, const G4Transform3D& modelTransformation
, const G4ModelingParameters* pMP
, G4bool useFullExtent)
: G4VModel (modelTransformation, pMP)
, G4bool useFullExtent
, const std::vector<G4PhysicalVolumeNodeID>& baseFullPVPath)
: G4VModel (modelTransformation,pMP)
, fpTopPV (pVPV)
, fTopPVCopyNo (0)
, fRequestedDepth (requestedDepth)
, fUseFullExtent (useFullExtent)
, fCurrentDepth (0)
, fpCurrentPV (0)
, fpCurrentLV (0)
, fpCurrentMaterial (0)
, fpCurrentTransform (0)
, fpCurrentPV (fpTopPV)
, fCurrentPVCopyNo (fpTopPV? fpTopPV->GetCopyNo(): 0)
, fpCurrentLV (fpTopPV? fpTopPV->GetLogicalVolume(): 0)
, fpCurrentMaterial (fpCurrentLV? fpCurrentLV->GetMaterial(): 0)
, fpCurrentTransform (const_cast<G4Transform3D*>(&modelTransformation))
, fBaseFullPVPath (baseFullPVPath)
, fAbort (false)
, fCurtailDescent (false)
, fpClippingSolid (0)
@@ -96,17 +98,11 @@ G4PhysicalVolumeModel::G4PhysicalVolumeModel
} else {
fTopPVName = fpTopPV -> GetName ();
fTopPVCopyNo = fpTopPV -> GetCopyNo ();
std::ostringstream o;
o << fpTopPV -> GetCopyNo ();
fGlobalTag = fpTopPV -> GetName () + "." + o.str();
std::ostringstream oss;
oss << fpTopPV->GetName() << ':' << fpTopPV->GetCopyNo()
<< " BasePath:" << fBaseFullPVPath;
fGlobalTag = oss.str();
fGlobalDescription = "G4PhysicalVolumeModel " + fGlobalTag;
fpCurrentPV = fpTopPV;
if (fpCurrentPV) fpCurrentLV = fpCurrentPV->GetLogicalVolume();
if (fpCurrentLV) fpCurrentMaterial = fpCurrentLV->GetMaterial();
fpCurrentTransform = const_cast<G4Transform3D*>(&modelTransformation);
CalculateExtent ();
}
}
@@ -116,6 +112,18 @@ G4PhysicalVolumeModel::~G4PhysicalVolumeModel ()
delete fpClippingSolid;
}
G4ModelingParameters::PVNameCopyNoPath G4PhysicalVolumeModel::GetPVNameCopyNoPath
(const std::vector<G4PhysicalVolumeNodeID>& path)
{
G4ModelingParameters::PVNameCopyNoPath PVNameCopyNoPath;
for (const auto& node: path) {
PVNameCopyNoPath.push_back
(G4ModelingParameters::PVNameCopyNo
(node.GetPhysicalVolume()->GetName(),node.GetCopyNo()));
}
return PVNameCopyNoPath;
}
void G4PhysicalVolumeModel::CalculateExtent ()
{
if (fUseFullExtent) {
@@ -166,9 +174,6 @@ void G4PhysicalVolumeModel::DescribeYourselfTo
("G4PhysicalVolumeModel::DescribeYourselfTo",
"modeling0003", FatalException, "No modeling parameters.");
// For safety...
fCurrentDepth = 0;
G4Transform3D startingTransformation = fTransform;
VisitGeometryAndGetVisReps
@@ -177,23 +182,16 @@ void G4PhysicalVolumeModel::DescribeYourselfTo
startingTransformation,
sceneHandler);
// Clear data...
// Reset or clear data...
fCurrentDepth = 0;
fpCurrentPV = 0;
fpCurrentLV = 0;
fpCurrentMaterial = 0;
if (fFullPVPath.size() != fBaseFullPVPath.size()) {
// They should be equal if pushing and popping is happening properly.
G4Exception
("G4PhysicalVolumeModel::DescribeYourselfTo",
"modeling0013",
FatalException,
"Path at start of modeling not equal to base path. Something badly"
"\nwrong. Please contact visualisation coordinator.");
}
fpCurrentPV = fpTopPV;
fCurrentPVCopyNo = fpTopPV->GetCopyNo();
fpCurrentLV = fpTopPV->GetLogicalVolume();
fpCurrentMaterial = fpCurrentLV? fpCurrentLV->GetMaterial(): 0;
fFullPVPath = fBaseFullPVPath;
fDrawnPVPath.clear();
fAbort = false;
fCurtailDescent = false;
fAbort = false;
fCurtailDescent = false;
}
G4String G4PhysicalVolumeModel::GetCurrentTag () const
@@ -255,6 +253,7 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
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.
@@ -338,6 +337,7 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
pVPV -> SetTranslation (translation);
pVPV -> SetRotation (pRotation);
pVPV -> SetCopyNo (n);
fCurrentPVCopyNo = n;
if (visualisable) {
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
@@ -365,6 +365,7 @@ void G4PhysicalVolumeModel::DescribeAndDescend
{
// Maintain useful data members...
fpCurrentPV = pVPV;
fCurrentPVCopyNo = pVPV->GetCopyNo();
fpCurrentLV = pLV;
fpCurrentMaterial = pMaterial;
@@ -801,7 +802,9 @@ const std::map<G4String,G4AttDef>* G4PhysicalVolumeModel::GetAttDefs() const
= G4AttDefStore::GetInstance("G4PhysicalVolumeModel", isNew);
if (isNew) {
(*store)["PVPath"] =
G4AttDef("PVPath","Physical Volume Path","Physics","","G4String");
G4AttDef("PVPath","Physical Volume Path","Physics","","G4String");
(*store)["BasePVPath"] =
G4AttDef("BasePVPath","Base Physical Volume Path","Physics","","G4String");
(*store)["LVol"] =
G4AttDef("LVol","Logical Volume","Physics","","G4String");
(*store)["Solid"] =
@@ -830,8 +833,6 @@ const std::map<G4String,G4AttDef>* G4PhysicalVolumeModel::GetAttDefs() const
return store;
}
#include <iomanip>
static std::ostream& operator<< (std::ostream& o, const G4Transform3D t)
{
using namespace std;
@@ -874,12 +875,6 @@ static std::ostream& operator<< (std::ostream& o, const G4Transform3D t)
std::vector<G4AttValue>* G4PhysicalVolumeModel::CreateCurrentAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
std::ostringstream oss;
for (size_t i = 0; i < fFullPVPath.size(); ++i) {
oss << fFullPVPath[i].GetPhysicalVolume()->GetName()
<< ':' << fFullPVPath[i].GetCopyNo();
if (i != fFullPVPath.size() - 1) oss << '/';
}
if (!fpCurrentLV) {
G4Exception
@@ -890,7 +885,10 @@ std::vector<G4AttValue>* G4PhysicalVolumeModel::CreateCurrentAttValues() const
return values;
}
std::ostringstream oss; oss << fFullPVPath;
values->push_back(G4AttValue("PVPath", oss.str(),""));
oss.str(""); oss << fBaseFullPVPath;
values->push_back(G4AttValue("BasePVPath", oss.str(),""));
values->push_back(G4AttValue("LVol", fpCurrentLV->GetName(),""));
G4VSolid* pSol = fpCurrentLV->GetSolid();
values->push_back(G4AttValue("Solid", pSol->GetName(),""));
@@ -954,8 +952,12 @@ std::ostream& operator<<
std::ostream& operator<<
(std::ostream& os, const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
{
for (const auto& nodeID: path) {
os << nodeID << ' ';
if (path.empty()) {
os << " NULL PATH";
} else {
for (const auto& nodeID: path) {
os << ' ' << nodeID;
}
}
return os;
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeSearchScene.cc 91686 2015-07-31 09:40:08Z gcosmo $
//
//
// John Allison 10th August 1998.
@@ -46,7 +45,6 @@ G4PhysicalVolumeSearchScene::G4PhysicalVolumeSearchScene
fRequiredCopyNo (requiredCopyNo),
fFoundDepth (0),
fpFoundPV (0),
fpFoundLV (0),
fVerbosity (verbosity),
fMultipleOccurrence (false)
{}
@@ -71,11 +69,7 @@ void G4PhysicalVolumeSearchScene::ProcessVolume (const G4VSolid&) {
typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
typedef std::vector<PVNodeID> PVPath;
const PVPath& fullPVPath = fpPVModel->GetFullPVPath();
G4int currentDepth = fpPVModel->GetCurrentDepth();
G4LogicalVolume* pCurrentLV = fpPVModel->GetCurrentLV();
//G4Material* pCurrentMaterial = fpPVModel->GetCurrentMaterial();
// Note: pCurrentMaterial may be zero (parallel world).
G4int currentDepth = fpPVModel->GetCurrentDepth();
if ((fRequiredCopyNo < 0 || // I.e., ignore negative request.
fRequiredCopyNo == pCurrentPV -> GetCopyNo ())) {
// Current policy - take first one found!!
@@ -83,7 +77,6 @@ void G4PhysicalVolumeSearchScene::ProcessVolume (const G4VSolid&) {
fFoundFullPVPath = fullPVPath;
fFoundDepth = currentDepth;
fpFoundPV = pCurrentPV;
fpFoundLV = pCurrentLV;
fFoundObjectTransformation = *fpCurrentObjectTransformation;
}
else {
@@ -0,0 +1,115 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// John Allison 5th September 2018, based on G4PhysicalVolumeSearchScene
// An artificial scene to find physical volumes. Instead of returning the
// first occurence (G4PhysicalVolumeSearchScene) this class (note the extra
// 's' in the name of this class) returns a vector of all occurences.
#include "G4PhysicalVolumesSearchScene.hh"
#include <regex>
G4PhysicalVolumesSearchScene::G4PhysicalVolumesSearchScene
(G4PhysicalVolumeModel* pSearchVolumesModel, // usually a world
const G4String& requiredPhysicalVolumeName,
G4int requiredCopyNo)
: fpSearchVolumesModel (pSearchVolumesModel)
, fMatcher (requiredPhysicalVolumeName)
, fRequiredCopyNo (requiredCopyNo)
{}
void G4PhysicalVolumesSearchScene::ProcessVolume (const G4VSolid&)
{
G4VPhysicalVolume* pCurrentPV = fpSearchVolumesModel->GetCurrentPV();
const G4String& name = pCurrentPV->GetName();
G4int copyNo = fpSearchVolumesModel->GetCurrentPVCopyNo();
// Match the name with the required physical volume name. The latter can be of
// the form "/regexp/", where regexp is a regular expression (see C++ regex),
// or a plain name, in which case there must be an exact match.
if (fMatcher.Match(name)) {
if ((fRequiredCopyNo < 0 || // I.e., ignore negative request
fRequiredCopyNo == copyNo)) {
auto path = fpSearchVolumesModel->GetFullPVPath();
path.pop_back(); // Base node is one up from found node
fFindings.push_back
(Findings
(fpSearchVolumesModel->GetTopPhysicalVolume(),
pCurrentPV,
copyNo,
fpSearchVolumesModel->GetCurrentDepth(),
path,
*fpCurrentObjectTransformation));
}
}
}
G4PhysicalVolumesSearchScene::Matcher::Matcher(const G4String& requiredMatch)
: fRegexFlag(false)
{
if (requiredMatch.size()) {
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 (last > 1) { // Non-null regexp
// regex match required
fRegexFlag = true;
// Extract the required regex
fRequiredMatch = requiredMatch.substr(1,last-1);
}
} else {
// Exact match required
fRequiredMatch = requiredMatch;
}
}
if (fRequiredMatch.isNull()) {
G4Exception
("G4PhysicalVolumesSearchScene::Matcher::Matcher",
"modeling0013", JustWarning, "Required match is null");
}
}
G4bool G4PhysicalVolumesSearchScene::Matcher::Match(const G4String& s)
// Match the string with the required match. The latter can be of the form
// "/regexp/", where regexp is a regular expression (see C++ regex),
// or a plain string, in which case there must be an exact match.
{
G4bool found = false;
if (fRequiredMatch.size()) {
if (fRegexFlag) { // Use extracted regex
std::regex requiredRegex(fRequiredMatch);
std::cmatch match;
std::regex_search(s.c_str(), match, requiredRegex);
if (match.size() > 0) found = true;
} else { // Require complete match
if (s == fRequiredMatch) found = true;
}
}
return found;
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4ScaleModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
// John Allison 21st July 2001.
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4TextModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
// John Allison 3rd April 2001
@@ -24,54 +24,36 @@
// ********************************************************************
//
//
// $Id: G4TouchableDumpScene.cc 66773 2013-01-12 14:48:08Z allison $
//
//
// John Allison 15th May 2014.
// An artificial scene to dump touchable attributes.
//
// John Allison 22nd August 2018.
// An artificial scene to find the properties of a touchable.
#include "G4TouchableDumpScene.hh"
#include "G4TouchablePropertiesScene.hh"
#include "G4VSolid.hh"
#include "G4Vector3D.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PhysicalVolumeModel.hh"
//#include "G4PhysicalVolumeModel.hh"
#include "G4AttValue.hh"
#include "G4AttCheck.hh"
G4TouchableDumpScene::G4TouchableDumpScene
(std::ostream& os,
G4PhysicalVolumeModel* pPVModel,
G4TouchablePropertiesScene::G4TouchablePropertiesScene
(G4PhysicalVolumeModel* pSearchPVModel,
const G4ModelingParameters::PVNameCopyNoPath& requiredTouchable)
:fos(os)
,fpPVModel(pPVModel)
:fpSearchPVModel(pSearchPVModel)
,fRequiredTouchable(requiredTouchable)
,fFound(false)
{}
G4TouchableDumpScene::~G4TouchableDumpScene () {}
G4TouchablePropertiesScene::~G4TouchablePropertiesScene () {}
void G4TouchableDumpScene::ProcessVolume (const G4VSolid& solid) {
void G4TouchablePropertiesScene::ProcessVolume (const G4VSolid& /*solid*/) {
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>&
fullPVPath = fpPVModel->GetFullPVPath();
fullPVPath = fpSearchPVModel->GetFullPVPath();
if (fRequiredTouchable.size() == fullPVPath.size()) {
// OK - there's a size match. Check it out.
// G4cout << "Size match" << G4endl;
G4ModelingParameters::PVNameCopyNoPathConstIterator iNameCopyNo;
std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>::const_iterator
iPVNodeId;
for (iNameCopyNo = fRequiredTouchable.begin(), iPVNodeId = fullPVPath.begin();
iNameCopyNo != fRequiredTouchable.end();
++iNameCopyNo, ++iPVNodeId) {
// G4cout
// << iNameCopyNo->GetName()
// << ',' << iNameCopyNo->GetCopyNo()
// << "; " << iPVNodeId->GetPhysicalVolume()->GetName()
// << ',' << iPVNodeId->GetPhysicalVolume()->GetCopyNo()
// << G4endl;
if (!(
iNameCopyNo->GetName() ==
iPVNodeId->GetPhysicalVolume()->GetName() &&
@@ -82,21 +64,13 @@ void G4TouchableDumpScene::ProcessVolume (const G4VSolid& solid) {
}
}
if (iNameCopyNo == fRequiredTouchable.end()) {
// G4cout << "Match found" << G4endl;
fFound = true;
const std::map<G4String,G4AttDef>* attDefs = fpPVModel->GetAttDefs();
std::vector<G4AttValue>* attValues = fpPVModel->CreateCurrentAttValues();
fos << G4AttCheck(attValues, attDefs);
delete attValues;
G4Polyhedron* polyhedron = solid.GetPolyhedron();
fos << "\nLocal polyhedron coordinates:\n" << *polyhedron;
G4Transform3D* transform = fpPVModel->GetCurrentTransform();
polyhedron->Transform(*transform);
fos << "\nGlobal polyhedron coordinates:\n" << *polyhedron;
fpPVModel->Abort(); // No need to look further.
fFoundTouchableProperties.fTouchablePath = fRequiredTouchable;
fFoundTouchableProperties.fpTouchablePV = fpSearchPVModel->GetCurrentPV();
fFoundTouchableProperties.fTouchableGlobalTransform = *fpSearchPVModel->GetCurrentTransform();
fFoundTouchableProperties.fTouchableBaseFullPVPath = fpSearchPVModel->GetFullPVPath();
// Base path is one down from found PV
fFoundTouchableProperties.fTouchableBaseFullPVPath.pop_back();
fpSearchPVModel->Abort(); // No need to look further.
}
}
}
@@ -0,0 +1,59 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// John Allison 22nd August 2018
// Touchable utilities
#include "G4TouchableUtils.hh"
#include "G4TouchablePropertiesScene.hh"
#include "G4TransportationManager.hh"
G4PhysicalVolumeModel::TouchableProperties G4TouchableUtils::FindTouchableProperties
(G4ModelingParameters::PVNameCopyNoPath path)
{
// If the search is not successful properties.fpTouchablePV will be null.
G4PhysicalVolumeModel::TouchableProperties properties;
G4TransportationManager* transportationManager =
G4TransportationManager::GetTransportationManager ();
size_t nWorlds = transportationManager->GetNoWorlds();
std::vector<G4VPhysicalVolume*>::iterator iterWorld =
transportationManager->GetWorldsIterator();
for (size_t i = 0; i < nWorlds; ++i, ++iterWorld) {
G4PhysicalVolumeModel pvModel (*iterWorld); // Unlimited depth.
G4ModelingParameters mp; // Default - no culling.
pvModel.SetModelingParameters (&mp);
G4TouchablePropertiesScene scene (&pvModel,path);
pvModel.DescribeYourselfTo (scene); // Initiate geometry tree traversal.
if (scene.GetFoundTouchableProperties().fpTouchablePV) {
properties = scene.GetFoundTouchableProperties();
break; // Found, so no need to scan more worlds.
}
}
return properties;
}
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4TrajectoriesModel.cc 98852 2016-08-15 07:03:35Z gcosmo $
//
//
// John Allison 26th August 1998.
@@ -53,7 +52,7 @@ G4TrajectoriesModel::G4TrajectoriesModel ()
,fEventID(-1)
{
fType = "G4TrajectoriesModel";
fGlobalTag = "G4TrajectoriesModel for all trajectories.";
fGlobalTag = "G4TrajectoriesModel for any type of trajectory";
fGlobalDescription = fGlobalTag;
}
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryChargeFilter.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
// Filter trajectories according to charge. Only registered
// charges will pass the filter.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByAttribute.cc 78838 2014-01-28 08:46:17Z gcosmo $
//
// Jane Tinslay August 2006
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByCharge.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
#include "G4TrajectoryDrawByCharge.hh"
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByEncounteredVolume.cc 95107 2016-01-26 12:41:11Z allison $
//
// John Allison February 2016, based on
// G4TrajectoryDrawByVolume.hh Jane Tinslay March 2006
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByOriginVolume.cc 96316 2016-04-06 07:23:44Z gcosmo $
//
// Jane Tinslay March 2006
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByParticleID.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawerUtils.cc 107920 2017-12-13 08:06:00Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
//
@@ -218,6 +217,7 @@ namespace G4TrajectoryDrawerUtils {
if (myContext.GetDrawLine()) {
G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
trajectoryLineAttribs.SetLineWidth(myContext.GetLineWidth());
trajectoryLineAttribs.SetVisibility(myContext.GetLineVisible());
trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
@@ -264,6 +264,7 @@ namespace G4TrajectoryDrawerUtils {
if (myContext.GetDrawLine()) {
G4VisAttributes trajectoryLineAttribs(myContext.GetLineColour());
trajectoryLineAttribs.SetLineWidth(myContext.GetLineWidth());
trajectoryLineAttribs.SetVisibility(myContext.GetLineVisible());
for (size_t i = 1; i < trajectoryLine.size(); ++i ) {
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryEncounteredVolumeFilter.cc 95107 2016-01-26 12:41:11Z allison $
//
// Filter trajectories according to encountered volume name. Only registered
// volumes will pass the filter.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// $Id: G4TrajectoryFilterFactories.cc 98766 2016-08-09 14:17:17Z gcosmo $
//
//
// Trajectory filter model factories creating filters
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryGenericDrawer.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
// Jane Tinslay May 2006
//
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryModelFactories.cc 98766 2016-08-09 14:17:17Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl October 2005
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryOriginVolumeFilter.cc 95115 2016-01-26 16:33:29Z gcosmo $
//
// Filter trajectories according to volume name. Only registered
// volumes will pass the filter.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryParticleFilter.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
// Filter trajectories according to particle type. Only registered
// particle types will pass the filter.
@@ -24,7 +24,6 @@
// ********************************************************************
//
//
// $Id: G4VModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -23,7 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VTrajectoryModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
//
// Jane Tinslay May 2006
//
@@ -28,6 +28,7 @@
// Default configuration
G4VisTrajContext::G4VisTrajContext(const G4String& name)
:fName(name)
,fLineWidth(1.)
,fLineColour(G4Colour::Grey())
,fLineVisible(true)
,fDrawLine(true)