Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ArrowModel.cc 76285 2013-11-08 13:01:44Z gcosmo $
// $Id: G4ArrowModel.cc 100807 2016-11-02 15:00:41Z gcosmo $
//
//
// John Allison 15th July 2012
@@ -52,7 +52,8 @@ G4ArrowModel::G4ArrowModel
(G4double x1, G4double y1, G4double z1,
G4double x2, G4double y2, G4double z2,
G4double width, const G4Colour& colour,
const G4String& description)
const G4String& description,
G4int lineSegmentsPerCircle)
{
fType = "G4ArrowModel";
fGlobalTag = fType;
@@ -65,6 +66,10 @@ G4ArrowModel::G4ArrowModel
std::min(z1,z2),
std::max(z1,z2));
// Force number of line segments per circle (aka number of rotation steps)
G4int tempN = G4Polyhedron::GetNumberOfRotationSteps();
G4Polyhedron::SetNumberOfRotationSteps(lineSegmentsPerCircle);
// Make a cylinder slightly shorter than the arrow length so that it
// doesn't stick out of the head.
const G4double shaftLength = std::sqrt
@@ -106,6 +111,9 @@ G4ArrowModel::G4ArrowModel
va.SetForceSolid(true);
fpShaftPolyhedron->SetVisAttributes(va);
fpHeadPolyhedron->SetVisAttributes(va);
// Restore number of line segments per circle
G4Polyhedron::SetNumberOfRotationSteps(tempN);
}
void G4ArrowModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ModelingParameters.cc 85020 2014-10-23 09:52:52Z gcosmo $
// $Id: G4ModelingParameters.cc 101035 2016-11-04 08:48:17Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -50,7 +50,7 @@ G4ModelingParameters::G4ModelingParameters ():
fVisibleDensity (0.01 * g / cm3),
fCullCovered (false),
fExplodeFactor (1.),
fNoOfSides (24),
fNoOfSides (72),
fpSectionSolid (0),
fpCutawaySolid (0),
fpEvent (0)
@@ -211,13 +211,13 @@ std::ostream& operator << (std::ostream& os, const G4ModelingParameters& mp)
os << "\n Vis attributes modifiers: ";
const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
mp.fVisAttributesModifiers;
mp.fVisAttributesModifiers;
if (vams.empty()) {
os << "None";
} else {
os << vams;
}
return os;
}
@@ -296,7 +296,9 @@ G4bool G4ModelingParameters::VisAttributesModifier::operator!=
break;
case G4ModelingParameters::VASForceAuxEdgeVisible:
if (fVisAtts.IsForceAuxEdgeVisible() !=
rhs.fVisAtts.IsForceAuxEdgeVisible())
rhs.fVisAtts.IsForceAuxEdgeVisible() ||
fVisAtts.IsForcedAuxEdgeVisible() !=
rhs.fVisAtts.IsForcedAuxEdgeVisible())
return true;
break;
case G4ModelingParameters::VASForceLineSegmentsPerCircle:
@@ -311,11 +313,11 @@ G4bool G4ModelingParameters::VisAttributesModifier::operator!=
std::ostream& operator <<
(std::ostream& os, const G4ModelingParameters::PVNameCopyNoPath& path)
{
// os << "Touchable path: physical-volume-name:copy-number pairs:\n ";
os << "Touchable path: physical-volume-name:copy-number pairs:\n ";
G4ModelingParameters::PVNameCopyNoPathConstIterator i;
for (i = path.begin(); i != path.end(); ++i) {
if (i != path.begin()) {
os << ", ";
os << ',';
}
os << i->GetName() << ':' << i->GetCopyNo();
}
@@ -327,12 +329,12 @@ std::ostream& operator <<
const std::vector<G4ModelingParameters::VisAttributesModifier>& vams)
{
std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
iModifier;
iModifier;
for (iModifier = vams.begin();
iModifier != vams.end();
++iModifier) {
const G4ModelingParameters::PVNameCopyNoPath& vamPath =
iModifier->GetPVNameCopyNoPath();
iModifier->GetPVNameCopyNoPath();
os << '\n' << vamPath;
const G4VisAttributes& vamVisAtts = iModifier->GetVisAttributes();
const G4Colour& c = vamVisAtts.GetColour();
@@ -394,11 +396,18 @@ std::ostream& operator <<
}
break;
case G4ModelingParameters::VASForceAuxEdgeVisible:
os << " forceAuxEdgeVisible ";
os << " forceAuxEdgeVisible: ";
if (!vamVisAtts.IsForceDrawingStyle()) {
os << "not ";
}
os << " forced";
if (vamVisAtts.IsForceAuxEdgeVisible()) {
os << "true";
} else {
os << "false";
os << ": ";
if (vamVisAtts.IsForcedAuxEdgeVisible()) {
os << "true";
} else {
os << "false";
}
}
break;
case G4ModelingParameters::VASForceLineSegmentsPerCircle:
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PSHitsModel.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4PSHitsModel.cc 99152 2016-09-07 08:04:30Z gcosmo $
//
//
// Created: Mar. 31, 2009 Akinori Kimura
@@ -41,10 +41,10 @@
G4PSHitsModel::~G4PSHitsModel () {}
G4PSHitsModel::G4PSHitsModel (const G4String& requestedMapName):
fRequestedMapName(requestedMapName), fpCurrentHits(0)
fRequestedMapName(requestedMapName)
{
fType = "G4PSHitsModel";
fGlobalTag = "G4PSHitsModel for G4THitsMap<G4double> hits.";
fGlobalTag = "G4PSHitsModel for G4THitsMap<G4StatDouble> hits.";
fGlobalDescription = fGlobalTag;
}
@@ -62,7 +62,7 @@ void G4PSHitsModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
i != scoreMap.end(); ++i) {
const G4String& name = i->first;
if (fRequestedMapName == "all" || name == fRequestedMapName) {
fpCurrentHits = i->second;
RunScore* fpCurrentHits = i->second;
//G4cout << name << ": " << fpCurrentHits << G4endl;
if (fpCurrentHits) sceneHandler.AddCompound(*fpCurrentHits);
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeMassScene.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4PhysicalVolumeMassScene.cc 99076 2016-09-01 12:40:47Z gcosmo $
//
//
// John Allison 10th August 1998.
@@ -65,7 +65,7 @@ void G4PhysicalVolumeMassScene::Reset ()
fDensityStack.clear();
}
void G4PhysicalVolumeMassScene::AccrueMass (const G4VSolid& solid)
void G4PhysicalVolumeMassScene::ProcessVolume (const G4VSolid& solid)
{
G4int currentDepth = fpPVModel->GetCurrentDepth();
G4VPhysicalVolume* pCurrentPV = fpPVModel->GetCurrentPV();
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeModel.cc 96733 2016-05-02 11:52:48Z gcosmo $
// $Id: G4PhysicalVolumeModel.cc 101035 2016-11-04 08:48:17Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -134,7 +134,7 @@ void G4PhysicalVolumeModel::CalculateExtent ()
false, // Density culling.
0., // Density (not relevant if density culling false).
true, // Cull daughters of opaque mothers.
24); // No of sides (not relevant for this operation).
72); // No of sides (not relevant for this operation).
fpMP = &mParams;
DescribeYourselfTo (bsScene);
G4double radius = bsScene.GetRadius();
@@ -385,14 +385,15 @@ void G4PhysicalVolumeModel::DescribeAndDescend
const G4VisAttributes* pVisAttribs = pLV->GetVisAttributes();
if (!pVisAttribs) pVisAttribs = fpMP->GetDefaultVisAttributes();
// Beware - pVisAttribs might still be zero - create a temporary default one...
G4bool visAttsCreated = false;
// Beware - pVisAttribs might still be zero - probably will, since that's
// the default for G4ModelingParameters. So create one if necessary...
if (!pVisAttribs) {
pVisAttribs = new G4VisAttributes;
visAttsCreated = true;
static G4VisAttributes defaultVisAttribs;
pVisAttribs = &defaultVisAttribs;
}
// From here, can assume pVisAttribs is a valid pointer.
// From here, can assume pVisAttribs is a valid pointer. This is necessary
// because PreAddSolid needs a vis attributes object.
// Make decision to draw...
G4bool thisToBeDrawn = true;
@@ -402,91 +403,81 @@ void G4PhysicalVolumeModel::DescribeAndDescend
(G4PhysicalVolumeNodeID
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
// In case we need to copy the vis atts for modification...
G4bool copyForVAM = false;
const G4VisAttributes* pUnmodifiedVisAtts = pVisAttribs;
G4VisAttributes* pModifiedVisAtts = 0;
// Check if vis attributes are to be modified by a /vis/touchable/set/ command.
const std::vector<G4ModelingParameters::VisAttributesModifier>& vams =
fpMP->GetVisAttributesModifiers();
std::vector<G4ModelingParameters::VisAttributesModifier>::const_iterator
iModifier;
for (iModifier = vams.begin();
iModifier != vams.end();
++iModifier) {
const G4ModelingParameters::PVNameCopyNoPath& vamPath =
iModifier->GetPVNameCopyNoPath();
if (vamPath.size() == fFullPVPath.size()) {
// OK - there's a size match. Check it out.
// G4cout << "Size match" << G4endl;
G4ModelingParameters::PVNameCopyNoPathConstIterator iVAMNameCopyNo;
std::vector<G4PhysicalVolumeNodeID>::const_iterator iPVNodeId;
for (iVAMNameCopyNo = vamPath.begin(), iPVNodeId = fFullPVPath.begin();
iVAMNameCopyNo != vamPath.end();
++iVAMNameCopyNo, ++iPVNodeId) {
// G4cout
// << iVAMNameCopyNo->fName
// << ',' << iVAMNameCopyNo->fCopyNo
// << "; " << iPVNodeId->GetPhysicalVolume()->GetName()
// << ',' << iPVNodeId->GetPhysicalVolume()->GetCopyNo()
// << G4endl;
if (!(
iVAMNameCopyNo->GetName() ==
iPVNodeId->GetPhysicalVolume()->GetName() &&
iVAMNameCopyNo->GetCopyNo() ==
iPVNodeId->GetPhysicalVolume()->GetCopyNo()
)) {
break;
const auto& vams = fpMP->GetVisAttributesModifiers();
if (vams.size()) {
// OK, we have some VAMs (Vis Attributes Modifiers).
for (const auto& vam: vams) {
const auto& vamPath = vam.GetPVNameCopyNoPath();
if (vamPath.size() == fFullPVPath.size()) {
// OK, we have a size match.
// Check the volume name/copy number path.
auto iVAMNameCopyNo = vamPath.begin();
auto iPVNodeId = fFullPVPath.begin();
for (; iVAMNameCopyNo != vamPath.end(); ++iVAMNameCopyNo, ++iPVNodeId) {
if (!(
iVAMNameCopyNo->GetName() ==
iPVNodeId->GetPhysicalVolume()->GetName() &&
iVAMNameCopyNo->GetCopyNo() ==
iPVNodeId->GetPhysicalVolume()->GetCopyNo()
)) {
// This path element does NOT match.
break;
}
}
}
if (iVAMNameCopyNo == vamPath.end()) {
// G4cout << "Match found" << G4endl;
if (!copyForVAM) {
pModifiedVisAtts = new G4VisAttributes(*pUnmodifiedVisAtts);
pVisAttribs = pModifiedVisAtts;
copyForVAM = true;
}
const G4VisAttributes& transVisAtts = iModifier->GetVisAttributes();
switch (iModifier->GetVisAttributesSignifier()) {
case G4ModelingParameters::VASVisibility:
pModifiedVisAtts->SetVisibility(transVisAtts.IsVisible());
break;
case G4ModelingParameters::VASDaughtersInvisible:
pModifiedVisAtts->SetDaughtersInvisible
(transVisAtts.IsDaughtersInvisible());
break;
case G4ModelingParameters::VASColour:
pModifiedVisAtts->SetColour(transVisAtts.GetColour());
break;
case G4ModelingParameters::VASLineStyle:
pModifiedVisAtts->SetLineStyle(transVisAtts.GetLineStyle());
break;
case G4ModelingParameters::VASLineWidth:
pModifiedVisAtts->SetLineWidth(transVisAtts.GetLineWidth());
break;
case G4ModelingParameters::VASForceWireframe:
if (transVisAtts.GetForcedDrawingStyle() ==
G4VisAttributes::wireframe) {
pModifiedVisAtts->SetForceWireframe
(transVisAtts.IsForceDrawingStyle());
}
break;
case G4ModelingParameters::VASForceSolid:
if (transVisAtts.GetForcedDrawingStyle() ==
G4VisAttributes::solid) {
pModifiedVisAtts->SetForceSolid
(transVisAtts.IsForceDrawingStyle());
}
break;
case G4ModelingParameters::VASForceAuxEdgeVisible:
pModifiedVisAtts->SetForceAuxEdgeVisible
(transVisAtts.IsForceAuxEdgeVisible());
break;
case G4ModelingParameters::VASForceLineSegmentsPerCircle:
pModifiedVisAtts->SetForceLineSegmentsPerCircle
(transVisAtts.GetForcedLineSegmentsPerCircle());
break;
if (iVAMNameCopyNo == vamPath.end()) {
// OK, the paths match (the above loop terminated normally).
// Create a vis atts object for the modified vis atts.
// It is static so that we may return a reliable pointer to it.
static G4VisAttributes modifiedVisAtts;
// Initialise it with the current vis atts and reset the pointer.
modifiedVisAtts = *pVisAttribs;
pVisAttribs = &modifiedVisAtts;
const G4VisAttributes& transVisAtts = vam.GetVisAttributes();
switch (vam.GetVisAttributesSignifier()) {
case G4ModelingParameters::VASVisibility:
modifiedVisAtts.SetVisibility(transVisAtts.IsVisible());
break;
case G4ModelingParameters::VASDaughtersInvisible:
modifiedVisAtts.SetDaughtersInvisible
(transVisAtts.IsDaughtersInvisible());
break;
case G4ModelingParameters::VASColour:
modifiedVisAtts.SetColour(transVisAtts.GetColour());
break;
case G4ModelingParameters::VASLineStyle:
modifiedVisAtts.SetLineStyle(transVisAtts.GetLineStyle());
break;
case G4ModelingParameters::VASLineWidth:
modifiedVisAtts.SetLineWidth(transVisAtts.GetLineWidth());
break;
case G4ModelingParameters::VASForceWireframe:
if (transVisAtts.IsForceDrawingStyle()) {
if (transVisAtts.GetForcedDrawingStyle() ==
G4VisAttributes::wireframe) {
modifiedVisAtts.SetForceWireframe(true);
}
}
break;
case G4ModelingParameters::VASForceSolid:
if (transVisAtts.IsForceDrawingStyle()) {
if (transVisAtts.GetForcedDrawingStyle() ==
G4VisAttributes::solid) {
modifiedVisAtts.SetForceSolid(true);
}
}
break;
case G4ModelingParameters::VASForceAuxEdgeVisible:
if (transVisAtts.IsForceAuxEdgeVisible()) {
modifiedVisAtts.SetForceAuxEdgeVisible
(transVisAtts.IsForcedAuxEdgeVisible());
}
break;
case G4ModelingParameters::VASForceLineSegmentsPerCircle:
modifiedVisAtts.SetForceLineSegmentsPerCircle
(transVisAtts.GetForcedLineSegmentsPerCircle());
break;
}
}
}
}
@@ -601,16 +592,6 @@ void G4PhysicalVolumeModel::DescribeAndDescend
}
}
// Delete modified vis atts if created...
if (copyForVAM) {
delete pModifiedVisAtts;
pVisAttribs = pUnmodifiedVisAtts;
copyForVAM = false;
}
// Vis atts for this volume no longer needed if created...
if (visAttsCreated) delete pVisAttribs;
if (daughtersToBeDrawn) {
for (G4int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
// Store daughter pVPV in local variable ready for recursion...
@@ -919,18 +900,29 @@ G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
}
std::ostream& operator<<
(std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID node)
(std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& node)
{
G4VPhysicalVolume* pPV = node.GetPhysicalVolume();
if (pPV) {
os << pPV->GetName()
<< ':' << node.GetCopyNo()
<< '[' << node.GetNonCulledDepth() << ']'
<< ':' << node.GetTransform();
if (!node.GetDrawn()) os << " Not ";
os << "drawn";
<< ' ' << node.GetCopyNo()
// << '[' << node.GetNonCulledDepth() << ']'
// << ':' << node.GetTransform()
;
// os << " (";
// if (!node.GetDrawn()) os << "not ";
// os << "drawn)";
} else {
os << "Null node";
os << " (Null node)";
}
return os;
}
std::ostream& operator<<
(std::ostream& os, const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path)
{
for (const auto& nodeID: path) {
os << nodeID << ' ';
}
return os;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4TrajectoriesModel.cc 87360 2014-12-01 16:07:16Z gcosmo $
// $Id: G4TrajectoriesModel.cc 98852 2016-08-15 07:03:35Z gcosmo $
//
//
// John Allison 26th August 1998.
@@ -73,6 +73,7 @@ void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
fRunID = currentRun->GetRunID();
} else {
fRunID = -1;
return;
}
const G4Event* event = fpMP->GetEvent();
@@ -80,6 +81,7 @@ void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
fEventID = event->GetEventID();
} else {
fEventID = -1;
return;
}
G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
@@ -0,0 +1,153 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByEncounteredVolume.cc 95107 2016-01-26 12:41:11Z allison $
//
// John Allison February 2016, based on
// G4TrajectoryDrawByVolume.hh Jane Tinslay March 2006
#include "G4TrajectoryDrawByEncounteredVolume.hh"
#include "G4TrajectoryDrawerUtils.hh"
#include "G4VTrajectory.hh"
#include "G4VisTrajContext.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttValue.hh"
#include "G4RichTrajectory.hh"
G4TrajectoryDrawByEncounteredVolume::G4TrajectoryDrawByEncounteredVolume
(const G4String& name, G4VisTrajContext* context)
:G4VTrajectoryModel(name, context)
,fDefault(G4Colour::Grey())
{}
G4TrajectoryDrawByEncounteredVolume::~G4TrajectoryDrawByEncounteredVolume() {}
void
G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj, const G4bool& visible) const
{
try
{
const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
G4Colour colour(fDefault);
G4String soughtPVName("none");
for (const auto& item: fMap.GetBasicMap()) {
soughtPVName = item.first;
for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
if (!point) continue;
std::vector<G4AttValue>* attValues = point->CreateAttValues();
std::vector<G4AttValue>::const_iterator iAtt;
for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
if (iAtt->GetName() == "PostVPath" &&
iAtt->GetValue().contains(soughtPVName)) break;
}
if (iAtt != attValues->end()) { // Required value found
fMap.GetColour(soughtPVName, colour);
break; // First found pvname determines colour.
}
}
}
G4VisTrajContext myContext(GetContext());
myContext.SetLineColour(colour);
myContext.SetVisible(visible);
if (GetVerbose()) {
G4cout
<< "G4TrajectoryDrawByEncounteredVolume drawer named " << Name()
<< ", drawing trajectory touching physical volume " << soughtPVName
<< ", with configuration:" << G4endl;
myContext.Print(G4cout);
}
G4TrajectoryDrawerUtils::DrawLineAndPoints(richTrajectory, myContext);
}
catch (std::bad_cast)
{
G4ExceptionDescription ed;
ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
G4Exception
("G4TrajectoryDrawByEncounteredVolume::Draw(const G4VTrajectory& traj,...",
"modeling0125",
JustWarning, ed);
return;
}
}
void
G4TrajectoryDrawByEncounteredVolume::SetDefault(const G4String& colour)
{
G4Colour myColour;
// Will not modify default colour if colour key does not exist
if (!G4Colour::GetColour(colour, myColour)) {
G4ExceptionDescription ed;
ed << "G4Colour with key "<<colour<<" does not exist ";
G4Exception
("G4TrajectoryDrawByEncounteredParticleID::SetDefault(const G4String& colour)",
"modeling0123", JustWarning, ed);
return;
}
SetDefault(myColour);
}
void
G4TrajectoryDrawByEncounteredVolume::SetDefault(const G4Colour& colour)
{
fDefault = colour;
}
void
G4TrajectoryDrawByEncounteredVolume::Set(const G4String& pvname, const G4String& colour)
{
fMap.Set(pvname, colour);
}
void
G4TrajectoryDrawByEncounteredVolume::Set(const G4String& pvname, const G4Colour& colour)
{
fMap[pvname] = colour;
}
void
G4TrajectoryDrawByEncounteredVolume::Print(std::ostream& ostr) const
{
ostr
<< "G4TrajectoryDrawByEncounteredVolume model "<< Name()
<< ", colour scheme: "
<< ", Default " << fDefault
<< std::endl;
fMap.Print(ostr);
ostr << "Default configuration:" << std::endl;
GetContext().Print(ostr);
}
@@ -0,0 +1,105 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $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.
//
// John Allison, Feb 2016
//
#include "G4TrajectoryEncounteredVolumeFilter.hh"
#include "G4TransportationManager.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttValue.hh"
#include "G4RichTrajectory.hh"
G4TrajectoryEncounteredVolumeFilter::G4TrajectoryEncounteredVolumeFilter(const G4String& name)
:G4SmartFilter<G4VTrajectory>(name)
{}
G4TrajectoryEncounteredVolumeFilter::~G4TrajectoryEncounteredVolumeFilter() {}
bool
G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj) const
{
try
{
const G4RichTrajectory& richTrajectory = dynamic_cast<const G4RichTrajectory&>(traj);
for (const auto& pvname: fVolumes) {
for (G4int iPoint = 0; iPoint < richTrajectory.GetPointEntries(); iPoint++) {
G4VTrajectoryPoint* point = richTrajectory.GetPoint(iPoint);
if (!point) continue;
std::vector<G4AttValue>* attValues = point->CreateAttValues();
std::vector<G4AttValue>::const_iterator iAtt;
for (iAtt = attValues->begin(); iAtt != attValues->end(); ++iAtt) {
if (iAtt->GetName() == "PostVPath" &&
iAtt->GetValue().contains(pvname)) break;
}
if (iAtt != attValues->end()) { // Required value found
return true; // First found pvname determines selection.
}
}
}
return false;
}
catch (std::bad_cast)
{
G4ExceptionDescription ed;
ed << "Requires G4RichTrajectory - \"/vis/scene/add/trajectories rich\"";
G4Exception
("G4TrajectoryEncounteredVolumeFilter::Evaluate(const G4VTrajectory& traj)",
"modeling0126",
JustWarning, ed);
return false;
}
}
void
G4TrajectoryEncounteredVolumeFilter::Add(const G4String& volume)
{
fVolumes.push_back(volume);
}
void
G4TrajectoryEncounteredVolumeFilter::Print(std::ostream& ostr) const
{
ostr<<"Volume names registered: "<<G4endl;
std::vector<G4String>::const_iterator iter = fVolumes.begin();
while (iter != fVolumes.end()) {
ostr<<*iter<<G4endl;
iter++;
}
}
void
G4TrajectoryEncounteredVolumeFilter::Clear()
{
// Clear volume vector
fVolumes.clear();
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// $Id: G4TrajectoryFilterFactories.cc 95593 2016-02-16 10:48:50Z gcosmo $
/// $Id: G4TrajectoryFilterFactories.cc 98766 2016-08-09 14:17:17Z gcosmo $
//
//
// Trajectory filter model factories creating filters
@@ -37,7 +37,7 @@
#include "G4TrajectoryChargeFilter.hh"
#include "G4TrajectoryParticleFilter.hh"
#include "G4TrajectoryOriginVolumeFilter.hh"
#include "G4TrajectoryTouchedVolumeFilter.hh"
#include "G4TrajectoryEncounteredVolumeFilter.hh"
// Attribute filter
G4TrajectoryAttributeFilterFactory::G4TrajectoryAttributeFilterFactory()
@@ -142,27 +142,27 @@ G4TrajectoryOriginVolumeFilterFactory::Create(const G4String& placement, const G
return ModelAndMessengers(model, messengers);
}
// Touched volume filter
G4TrajectoryTouchedVolumeFilterFactory::G4TrajectoryTouchedVolumeFilterFactory()
:G4VModelFactory< G4VFilter<G4VTrajectory> >("touchedVolumeFilter")
// Encountered volume filter
G4TrajectoryEncounteredVolumeFilterFactory::G4TrajectoryEncounteredVolumeFilterFactory()
:G4VModelFactory< G4VFilter<G4VTrajectory> >("encounteredVolumeFilter")
{}
G4TrajectoryTouchedVolumeFilterFactory::~G4TrajectoryTouchedVolumeFilterFactory() {}
G4TrajectoryEncounteredVolumeFilterFactory::~G4TrajectoryEncounteredVolumeFilterFactory() {}
G4TrajectoryTouchedVolumeFilterFactory::ModelAndMessengers
G4TrajectoryTouchedVolumeFilterFactory::Create(const G4String& placement, const G4String& name)
G4TrajectoryEncounteredVolumeFilterFactory::ModelAndMessengers
G4TrajectoryEncounteredVolumeFilterFactory::Create(const G4String& placement, const G4String& name)
{
// Create model
G4TrajectoryTouchedVolumeFilter* model = new G4TrajectoryTouchedVolumeFilter(name);
G4TrajectoryEncounteredVolumeFilter* model = new G4TrajectoryEncounteredVolumeFilter(name);
// Create associated messengers
Messengers messengers;
messengers.push_back(new G4ModelCmdAddString<G4TrajectoryTouchedVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdInvert<G4TrajectoryTouchedVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdActive<G4TrajectoryTouchedVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdVerbose<G4TrajectoryTouchedVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdReset<G4TrajectoryTouchedVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdAddString<G4TrajectoryEncounteredVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdInvert<G4TrajectoryEncounteredVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdActive<G4TrajectoryEncounteredVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdVerbose<G4TrajectoryEncounteredVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdReset<G4TrajectoryEncounteredVolumeFilter>(model, placement));
return ModelAndMessengers(model, messengers);
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryModelFactories.cc 95593 2016-02-16 10:48:50Z gcosmo $
// $Id: G4TrajectoryModelFactories.cc 98766 2016-08-09 14:17:17Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl October 2005
@@ -34,7 +34,7 @@
#include "G4TrajectoryDrawByCharge.hh"
#include "G4TrajectoryDrawByOriginVolume.hh"
#include "G4TrajectoryDrawByParticleID.hh"
#include "G4TrajectoryDrawByTouchedVolume.hh"
#include "G4TrajectoryDrawByEncounteredVolume.hh"
#include "G4TrajectoryGenericDrawer.hh"
#include "G4TrajectoryModelFactories.hh"
#include "G4VisTrajContext.hh"
@@ -171,29 +171,29 @@ G4TrajectoryDrawByOriginVolumeFactory::Create(const G4String& placement, const G
return ModelAndMessengers(model, messengers);
}
//Draw by touched volume
G4TrajectoryDrawByTouchedVolumeFactory::G4TrajectoryDrawByTouchedVolumeFactory()
:G4VModelFactory<G4VTrajectoryModel>("drawByTouchedVolume")
//Draw by encountered volume
G4TrajectoryDrawByEncounteredVolumeFactory::G4TrajectoryDrawByEncounteredVolumeFactory()
:G4VModelFactory<G4VTrajectoryModel>("drawByEncounteredVolume")
{}
G4TrajectoryDrawByTouchedVolumeFactory::~G4TrajectoryDrawByTouchedVolumeFactory() {}
G4TrajectoryDrawByEncounteredVolumeFactory::~G4TrajectoryDrawByEncounteredVolumeFactory() {}
ModelAndMessengers
G4TrajectoryDrawByTouchedVolumeFactory::Create(const G4String& placement, const G4String& name)
G4TrajectoryDrawByEncounteredVolumeFactory::Create(const G4String& placement, const G4String& name)
{
Messengers messengers;
// Create default context and model
G4VisTrajContext* context = new G4VisTrajContext("default");
G4TrajectoryDrawByTouchedVolume* model = new G4TrajectoryDrawByTouchedVolume(name, context);
G4TrajectoryDrawByEncounteredVolume* model = new G4TrajectoryDrawByEncounteredVolume(name, context);
// Create messengers for default context configuration
G4ModelCommandUtils::AddContextMsgrs(context, messengers, placement+"/"+name);
// Create messengers for drawer
messengers.push_back(new G4ModelCmdSetStringColour<G4TrajectoryDrawByTouchedVolume>(model, placement));
messengers.push_back(new G4ModelCmdSetDefaultColour<G4TrajectoryDrawByTouchedVolume>(model, placement));
messengers.push_back(new G4ModelCmdVerbose<G4TrajectoryDrawByTouchedVolume>(model, placement));
messengers.push_back(new G4ModelCmdSetStringColour<G4TrajectoryDrawByEncounteredVolume>(model, placement));
messengers.push_back(new G4ModelCmdSetDefaultColour<G4TrajectoryDrawByEncounteredVolume>(model, placement));
messengers.push_back(new G4ModelCmdVerbose<G4TrajectoryDrawByEncounteredVolume>(model, placement));
return ModelAndMessengers(model, messengers);
}