Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
+49 -1
View File
@@ -1,4 +1,4 @@
$Id: History 94206 2015-11-09 08:11:59Z gcosmo $
$Id: History 96733 2016-05-02 11:52:48Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -20,6 +20,54 @@ committal in the CVS repository !
History file for visualization/modeling
---------------------------------------
2nd May 2016 John Allison (modeling-V10-02-04)
- G4PhysicalVolumeModel.cc: Fixed gcc-6.1 warning.
5th April 2016 John Allison (modeling-V10-02-03)
- G4TrajectoryDrawByOriginVolume.cc: Tidied #include statements.
15th February 2016 John Allison (modeling-V10-02-02)
- Introduced drawing and filtering by touched volume. I.e.,
/vis/modeling/trajectories/create/drawByTouchedVolume
/vis/filtering/trajectories/create/touchedVolumeFilter
and their associated commands. Note that this
selects only by a single string, the physical volume name. If there
are more than one physical volumes with that name then any trajectory
touching any one of those volumes will be selected. If the user sets
more than one physical volume name (by using the set command more than
once) the trajectory will be selected if it touches either of those
volumes and which of the attributes (e.g., colour) associated with
those volumes is chosen is undefined, but one will be chosen.
A more comprehensive facility would allow the user to select by
touched touchable, i.e., by the full path and copy numbers of the
physical volume - but that is a job for the future if a use case arises.
o G4TrajectoryModelFactories.hh/cc:
Added G4TrajectoryDrawByTouchedVolumeFactory.
o G4TrajectoryFilterFactories.hh/cc:
Added G4TrajectoryTouchedVolumeFilterFactory.
o Added new files and classes:
G4TrajectoryDrawByTouchedVolume.hh/cc
G4TrajectoryTouchedVolumeFilter.hh/cc
o G4ModelColourMap.hh: Added new access function:
const std::map<T, G4Colour>& GetBasicMap() const;
to allow access to the T objects (which are G4String objects,
physical volume name(s) in this case) that have been set.
o sources.make: Added:
G4TrajectoryDrawByTouchedVolume.hh
G4TrajectoryTouchedVolumeFilter.hh
G4TrajectoryDrawByTouchedVolume.cc
G4TrajectoryTouchedVolumeFilter.cc
- G4TrajectoryDrawByOriginVolume.cc: Tidied.
26th January 2016 John Allison (modeling-V10-02-01)
- G4ModelingParameters.hh: Added VisAttributesModifier Set commands.
26th January 2016 John Allison (modeling-V10-02-00)
- G4TrajectoryDrawByOriginVolume::Draw and
G4TrajectoryOriginVolumeFilter::Evaluate:
Added specific arguments to LocateGlobalPointAndSetup to handle
multithreading mode.
2nd October 2015 John Allison (modeling-V10-01-05)
- G4MagneticFieldModel.cc: Cosmetic improvements.
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4ModelColourMap.hh 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4ModelColourMap.hh 95593 2016-02-16 10:48:50Z gcosmo $
//
// Generic variable->G4Colour map, where "variable" is the template
// parameter.
@@ -52,6 +52,7 @@ public: // With description
G4Colour& operator[](const T& quantity);
// Access functions
const std::map<T, G4Colour>& GetBasicMap() const;
bool GetColour(const T&, G4Colour&) const;
void Print(std::ostream& ostr) const;
@@ -100,6 +101,10 @@ G4ModelColourMap<T>::Set(const T& quantity, const G4Colour& colour)
fMap[quantity] = colour;
}
template <typename T>
const std::map<T, G4Colour>& G4ModelColourMap<T>::GetBasicMap() const
{ return fMap; }
template <typename T>
bool
G4ModelColourMap<T>::GetColour(const T& quantity, G4Colour& colour) const
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ModelingParameters.hh 81056 2014-05-20 09:02:16Z gcosmo $
// $Id: G4ModelingParameters.hh 95224 2016-02-01 09:14:18Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -102,11 +102,17 @@ public: // With description
VisAttributesSignifier signifier,
const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>& path);
const G4VisAttributes& GetVisAttributes() const
{return fVisAtts;}
{return fVisAtts;}
VisAttributesSignifier GetVisAttributesSignifier() const
{return fSignifier;}
{return fSignifier;}
const PVNameCopyNoPath& GetPVNameCopyNoPath() const
{return fPVNameCopyNoPath;}
{return fPVNameCopyNoPath;}
void SetVisAttributes(const G4VisAttributes& visAtts)
{fVisAtts = visAtts;}
void SetVisAttributesSignifier(VisAttributesSignifier signifier)
{fSignifier = signifier;}
void SetPVNameCopyNoPath(const PVNameCopyNoPath& PVNameCopyNoPath)
{fPVNameCopyNoPath = PVNameCopyNoPath;}
G4bool operator!=(const VisAttributesModifier&) const;
G4bool operator==(const VisAttributesModifier& rhs) const
{return !operator!=(rhs);}
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * 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: G4TrajectoryDrawByTouchedVolume.hh 66264 2012-12-14 10:17:44Z allison $
//
// Class Description:
// Trajectory model which colours a trajectory according to
// the touched volume
// Class Description - End:
// Jane Tinslay March 2006
#ifndef G4TRAJECTORYDRAWBYTOUCHEDVOLUME
#define G4TRAJECTORYDRAWBYTOUCHEDVOLUME
#include "G4VTrajectoryModel.hh"
#include "G4Colour.hh"
#include "G4ModelColourMap.hh"
#include "G4String.hh"
#include <map>
class G4TrajectoryDrawByTouchedVolume : public G4VTrajectoryModel {
public: // With description
G4TrajectoryDrawByTouchedVolume(const G4String& name = "Unspecified", G4VisTrajContext* context=0);
virtual ~G4TrajectoryDrawByTouchedVolume();
// Draw method
virtual void Draw(const G4VTrajectory& trajectory,
const G4bool& visible = true) const;
virtual void Print(std::ostream& ostr) const;
// Print configuration
void SetDefault(const G4String&);
void SetDefault(const G4Colour&);
void Set(const G4String& pvname, const G4String& colour);
void Set(const G4String& pvname, const G4Colour& colour);
// Configuration functions
private:
// Data members
G4ModelColourMap<G4String> fMap;
G4Colour fDefault;
};
#endif
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// $Id: G4TrajectoryFilterFactories.hh 68043 2013-03-13 14:27:49Z gcosmo $
/// $Id: G4TrajectoryFilterFactories.hh 95593 2016-02-16 10:48:50Z gcosmo $
//
//
// Trajectory filter model factories creating filters
@@ -97,9 +97,25 @@ public: // With description
G4TrajectoryOriginVolumeFilterFactory();
virtual ~G4TrajectoryOriginVolumeFilterFactory();
ModelAndMessengers Create(const G4String& placement, const G4String& name);
};
// Touched volume filter
class G4TrajectoryTouchedVolumeFilterFactory : public G4VModelFactory< G4VFilter<G4VTrajectory> > {
public: // With description
typedef std::vector<G4UImessenger*> Messengers;
typedef std::pair< G4VFilter<G4VTrajectory> *, Messengers > ModelAndMessengers;
G4TrajectoryTouchedVolumeFilterFactory();
virtual ~G4TrajectoryTouchedVolumeFilterFactory();
ModelAndMessengers Create(const G4String& placement, const G4String& name);
};
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryModelFactories.hh 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4TrajectoryModelFactories.hh 95593 2016-02-16 10:48:50Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl October 2005
//
@@ -98,9 +98,21 @@ public: // With description
G4TrajectoryDrawByOriginVolumeFactory();
virtual ~G4TrajectoryDrawByOriginVolumeFactory();
ModelAndMessengers Create(const G4String& placement, const G4String& name);
};
class G4TrajectoryDrawByTouchedVolumeFactory : public G4VModelFactory<G4VTrajectoryModel> {
public: // With description
G4TrajectoryDrawByTouchedVolumeFactory();
virtual ~G4TrajectoryDrawByTouchedVolumeFactory();
ModelAndMessengers Create(const G4String& placement, const G4String& name);
};
#endif
@@ -0,0 +1,68 @@
//
// ********************************************************************
// * 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: G4TrajectoryTouchedVolumeFilter.hh 66264 2012-12-14 10:17:44Z allison $
//
// Filter trajectories according to touched volume name. Only registered
// volumes will pass the filter.
//
// John Allison, Feb 2016
//
#ifndef G4TRAJECTORYTOUCHEDVOLUMEFILTER_HH
#define G4TRAJECTORYTOUCHEDVOLUMEFILTER_HH
#include "G4SmartFilter.hh"
#include "G4VTrajectory.hh"
#include <vector>
class G4TrajectoryTouchedVolumeFilter : public G4SmartFilter<G4VTrajectory> {
public: // With description
// Construct with filter name
G4TrajectoryTouchedVolumeFilter(const G4String& name = "Unspecified");
virtual ~G4TrajectoryTouchedVolumeFilter();
// Evaluate this trajectory
virtual bool Evaluate(const G4VTrajectory&) const;
// Print configuration
virtual void Print(std::ostream& ostr) const;
// Clear filter
virtual void Clear();
// Configuration function
void Add(const G4String& volume);
private:
// Data member
std::vector<G4String> fVolumes;
};
#endif
+5 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 88190 2015-02-02 17:24:54Z gcosmo $
# $Id: sources.cmake 95593 2016-02-16 10:48:50Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -85,12 +85,14 @@ GEANT4_DEFINE_MODULE(NAME G4modeling
G4TrajectoryDrawByCharge.hh
G4TrajectoryDrawByOriginVolume.hh
G4TrajectoryDrawByParticleID.hh
G4TrajectoryDrawByTouchedVolume.hh
G4TrajectoryDrawerUtils.hh
G4TrajectoryFilterFactories.hh
G4TrajectoryGenericDrawer.hh
G4TrajectoryModelFactories.hh
G4TrajectoryOriginVolumeFilter.hh
G4TrajectoryParticleFilter.hh
G4TrajectoryTouchedVolumeFilter.hh
G4VAttValueFilter.hh
G4VModel.hh
G4VModel.icc
@@ -125,12 +127,14 @@ GEANT4_DEFINE_MODULE(NAME G4modeling
G4TrajectoryDrawByCharge.cc
G4TrajectoryDrawByOriginVolume.cc
G4TrajectoryDrawByParticleID.cc
G4TrajectoryDrawByTouchedVolume.cc
G4TrajectoryDrawerUtils.cc
G4TrajectoryFilterFactories.cc
G4TrajectoryGenericDrawer.cc
G4TrajectoryModelFactories.cc
G4TrajectoryOriginVolumeFilter.cc
G4TrajectoryParticleFilter.cc
G4TrajectoryTouchedVolumeFilter.cc
G4VModel.cc
G4VTrajectoryModel.cc
G4VisTrajContext.cc
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeModel.cc 88763 2015-03-09 12:26:23Z gcosmo $
// $Id: G4PhysicalVolumeModel.cc 96733 2016-05-02 11:52:48Z gcosmo $
//
//
// John Allison 31st December 1997.
@@ -927,7 +927,8 @@ std::ostream& operator<<
<< ':' << node.GetCopyNo()
<< '[' << node.GetNonCulledDepth() << ']'
<< ':' << node.GetTransform();
if (!node.GetDrawn()) os << " Not "; os << "drawn";
if (!node.GetDrawn()) os << " Not ";
os << "drawn";
} else {
os << "Null node";
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByOriginVolume.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4TrajectoryDrawByOriginVolume.cc 96316 2016-04-06 07:23:44Z gcosmo $
//
// Jane Tinslay March 2006
@@ -44,14 +44,16 @@ G4TrajectoryDrawByOriginVolume::~G4TrajectoryDrawByOriginVolume() {}
void
G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4bool& visible) const
{
G4Colour colour(fDefault);
G4Navigator* navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(0);
assert (0 != aTrajectoryPoint);
G4Colour colour(fDefault);
G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup(aTrajectoryPoint->GetPosition());
G4Navigator* navigator =
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup
(aTrajectoryPoint->GetPosition(), nullptr,false,true);
// Logical volumes form basis.
G4LogicalVolume* logicalVolume = volume->GetLogicalVolume();
@@ -72,7 +74,7 @@ G4TrajectoryDrawByOriginVolume::Draw(const G4VTrajectory& traj, const G4bool& vi
if (GetVerbose()) {
G4cout<<"G4TrajectoryDrawByOriginVolume drawer named "<<Name();
G4cout<<", drawing trajectory originating in logical volume, "<<logicalName;
G4cout<<", physical volumed "<<physicalName<<", with configuration:"<<G4endl;
G4cout<<", physical volume "<<physicalName<<", with configuration:"<<G4endl;
myContext.Print(G4cout);
}
@@ -117,11 +119,14 @@ G4TrajectoryDrawByOriginVolume::Set(const G4String& particle, const G4Colour& co
void
G4TrajectoryDrawByOriginVolume::Print(std::ostream& ostr) const
{
ostr<<"G4TrajectoryDrawByOriginVolume model "<< Name() <<" colour scheme: "<<std::endl;
ostr<<"Default : "<<fDefault<<G4endl;
ostr
<< "G4TrajectoryDrawByOriginVolume model "<< Name()
<< ", colour scheme: "
<< ", Default " << fDefault
<< std::endl;
fMap.Print(ostr);
ostr<<"Default configuration:"<<G4endl;
GetContext().Print(G4cout);
ostr << "Default configuration:" << std::endl;
GetContext().Print(ostr);
}
@@ -0,0 +1,150 @@
//
// ********************************************************************
// * 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: G4TrajectoryDrawByTouchedVolume.cc 95107 2016-01-26 12:41:11Z allison $
//
// Jane Tinslay March 2006
#include "G4TrajectoryDrawByTouchedVolume.hh"
#include "G4TrajectoryDrawerUtils.hh"
#include "G4VTrajectory.hh"
#include "G4VisTrajContext.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttValue.hh"
#include "G4RichTrajectory.hh"
G4TrajectoryDrawByTouchedVolume::G4TrajectoryDrawByTouchedVolume(const G4String& name, G4VisTrajContext* context)
:G4VTrajectoryModel(name, context)
,fDefault(G4Colour::Grey())
{}
G4TrajectoryDrawByTouchedVolume::~G4TrajectoryDrawByTouchedVolume() {}
void
G4TrajectoryDrawByTouchedVolume::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
<< "G4TrajectoryDrawByTouchedVolume 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
("G4TrajectoryDrawByTouchedVolume::Draw(const G4VTrajectory& traj,...",
"modeling0125",
JustWarning, ed);
return;
}
}
void
G4TrajectoryDrawByTouchedVolume::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
("G4TrajectoryDrawByTouchedParticleID::SetDefault(const G4String& colour)", "modeling0123", JustWarning, ed);
return;
}
SetDefault(myColour);
}
void
G4TrajectoryDrawByTouchedVolume::SetDefault(const G4Colour& colour)
{
fDefault = colour;
}
void
G4TrajectoryDrawByTouchedVolume::Set(const G4String& pvname, const G4String& colour)
{
fMap.Set(pvname, colour);
}
void
G4TrajectoryDrawByTouchedVolume::Set(const G4String& pvname, const G4Colour& colour)
{
fMap[pvname] = colour;
}
void
G4TrajectoryDrawByTouchedVolume::Print(std::ostream& ostr) const
{
ostr
<< "G4TrajectoryDrawByTouchedVolume model "<< Name()
<< ", colour scheme: "
<< ", Default " << fDefault
<< std::endl;
fMap.Print(ostr);
ostr << "Default configuration:" << std::endl;
GetContext().Print(ostr);
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// $Id: G4TrajectoryFilterFactories.cc 68043 2013-03-13 14:27:49Z gcosmo $
/// $Id: G4TrajectoryFilterFactories.cc 95593 2016-02-16 10:48:50Z gcosmo $
//
//
// Trajectory filter model factories creating filters
@@ -37,6 +37,7 @@
#include "G4TrajectoryChargeFilter.hh"
#include "G4TrajectoryParticleFilter.hh"
#include "G4TrajectoryOriginVolumeFilter.hh"
#include "G4TrajectoryTouchedVolumeFilter.hh"
// Attribute filter
G4TrajectoryAttributeFilterFactory::G4TrajectoryAttributeFilterFactory()
@@ -116,10 +117,9 @@ G4TrajectoryParticleFilterFactory::Create(const G4String& placement, const G4Str
return ModelAndMessengers(model, messengers);
}
// Origin volume filter
G4TrajectoryOriginVolumeFilterFactory::G4TrajectoryOriginVolumeFilterFactory()
:G4VModelFactory< G4VFilter<G4VTrajectory> >("originVolumeFilter")
:G4VModelFactory< G4VFilter<G4VTrajectory> >("originVolumeFilter")
{}
G4TrajectoryOriginVolumeFilterFactory::~G4TrajectoryOriginVolumeFilterFactory() {}
@@ -129,17 +129,40 @@ G4TrajectoryOriginVolumeFilterFactory::Create(const G4String& placement, const G
{
// Create model
G4TrajectoryOriginVolumeFilter* model = new G4TrajectoryOriginVolumeFilter(name);
// Create associated messengers
Messengers messengers;
messengers.push_back(new G4ModelCmdAddString<G4TrajectoryOriginVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdInvert<G4TrajectoryOriginVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdActive<G4TrajectoryOriginVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdVerbose<G4TrajectoryOriginVolumeFilter>(model, placement));
messengers.push_back(new G4ModelCmdReset<G4TrajectoryOriginVolumeFilter>(model, placement));
return ModelAndMessengers(model, messengers);
}
// Touched volume filter
G4TrajectoryTouchedVolumeFilterFactory::G4TrajectoryTouchedVolumeFilterFactory()
:G4VModelFactory< G4VFilter<G4VTrajectory> >("touchedVolumeFilter")
{}
G4TrajectoryTouchedVolumeFilterFactory::~G4TrajectoryTouchedVolumeFilterFactory() {}
G4TrajectoryTouchedVolumeFilterFactory::ModelAndMessengers
G4TrajectoryTouchedVolumeFilterFactory::Create(const G4String& placement, const G4String& name)
{
// Create model
G4TrajectoryTouchedVolumeFilter* model = new G4TrajectoryTouchedVolumeFilter(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));
return ModelAndMessengers(model, messengers);
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryModelFactories.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4TrajectoryModelFactories.cc 95593 2016-02-16 10:48:50Z gcosmo $
//
// Jane Tinslay, John Allison, Joseph Perl October 2005
@@ -34,6 +34,7 @@
#include "G4TrajectoryDrawByCharge.hh"
#include "G4TrajectoryDrawByOriginVolume.hh"
#include "G4TrajectoryDrawByParticleID.hh"
#include "G4TrajectoryDrawByTouchedVolume.hh"
#include "G4TrajectoryGenericDrawer.hh"
#include "G4TrajectoryModelFactories.hh"
#include "G4VisTrajContext.hh"
@@ -145,7 +146,7 @@ G4TrajectoryDrawByParticleIDFactory::Create(const G4String& placement, const G4S
//Draw by origin volume
G4TrajectoryDrawByOriginVolumeFactory::G4TrajectoryDrawByOriginVolumeFactory()
:G4VModelFactory<G4VTrajectoryModel>("drawByOriginVolume")
:G4VModelFactory<G4VTrajectoryModel>("drawByOriginVolume")
{}
G4TrajectoryDrawByOriginVolumeFactory::~G4TrajectoryDrawByOriginVolumeFactory() {}
@@ -156,9 +157,9 @@ G4TrajectoryDrawByOriginVolumeFactory::Create(const G4String& placement, const G
Messengers messengers;
// Create default context and model
G4VisTrajContext* context = new G4VisTrajContext("default");
G4VisTrajContext* context = new G4VisTrajContext("default");
G4TrajectoryDrawByOriginVolume* model = new G4TrajectoryDrawByOriginVolume(name, context);
// Create messengers for default context configuration
G4ModelCommandUtils::AddContextMsgrs(context, messengers, placement+"/"+name);
@@ -169,3 +170,30 @@ G4TrajectoryDrawByOriginVolumeFactory::Create(const G4String& placement, const G
return ModelAndMessengers(model, messengers);
}
//Draw by touched volume
G4TrajectoryDrawByTouchedVolumeFactory::G4TrajectoryDrawByTouchedVolumeFactory()
:G4VModelFactory<G4VTrajectoryModel>("drawByTouchedVolume")
{}
G4TrajectoryDrawByTouchedVolumeFactory::~G4TrajectoryDrawByTouchedVolumeFactory() {}
ModelAndMessengers
G4TrajectoryDrawByTouchedVolumeFactory::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);
// 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));
return ModelAndMessengers(model, messengers);
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryOriginVolumeFilter.cc 66373 2012-12-18 09:41:34Z gcosmo $
// $Id: G4TrajectoryOriginVolumeFilter.cc 95115 2016-01-26 16:33:29Z gcosmo $
//
// Filter trajectories according to volume name. Only registered
// volumes will pass the filter.
@@ -43,12 +43,14 @@ G4TrajectoryOriginVolumeFilter::~G4TrajectoryOriginVolumeFilter() {}
bool
G4TrajectoryOriginVolumeFilter::Evaluate(const G4VTrajectory& traj) const
{
G4Navigator* navigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(0);
assert (0 != aTrajectoryPoint);
G4Navigator* navigator =
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup(aTrajectoryPoint->GetPosition());
G4VPhysicalVolume* volume = navigator->LocateGlobalPointAndSetup
(aTrajectoryPoint->GetPosition(), nullptr,false,true);
// Logical volume
G4LogicalVolume* logicalVolume = volume->GetLogicalVolume();
@@ -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: G4TrajectoryTouchedVolumeFilter.cc 95107 2016-01-26 12:41:11Z allison $
//
// Filter trajectories according to touched volume name. Only registered
// volumes will pass the filter.
//
// John Allison, Feb 2016
//
#include "G4TrajectoryTouchedVolumeFilter.hh"
#include "G4TransportationManager.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttValue.hh"
#include "G4RichTrajectory.hh"
G4TrajectoryTouchedVolumeFilter::G4TrajectoryTouchedVolumeFilter(const G4String& name)
:G4SmartFilter<G4VTrajectory>(name)
{}
G4TrajectoryTouchedVolumeFilter::~G4TrajectoryTouchedVolumeFilter() {}
bool
G4TrajectoryTouchedVolumeFilter::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
("G4TrajectoryTouchedVolumeFilter::Evaluate(const G4VTrajectory& traj)",
"modeling0126",
JustWarning, ed);
return false;
}
}
void
G4TrajectoryTouchedVolumeFilter::Add(const G4String& volume)
{
fVolumes.push_back(volume);
}
void
G4TrajectoryTouchedVolumeFilter::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
G4TrajectoryTouchedVolumeFilter::Clear()
{
// Clear volume vector
fVolumes.clear();
}