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
@@ -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();
}