Import Geant4 8.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:36:02 +02:00
parent d93e1e39a9
commit 8a51e0bc40
5471 changed files with 99628 additions and 55248 deletions
@@ -22,7 +22,7 @@
//
//
// $Id: G4AxesModel.cc,v 1.5 2001/08/14 18:43:29 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 3rd April 2001
@@ -22,7 +22,7 @@
//
//
// $Id: G4BoundingSphereScene.cc,v 1.9 2005/01/27 20:06:49 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 7th June 1997
@@ -22,7 +22,7 @@
//
//
// $Id: G4FlavoredParallelWorldModel.cc,v 1.6 2002/11/20 17:21:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
// P. Mora de Freitas et M.Verderi - 19 June 1998.
// Model for flavored parallel world volumes.
@@ -22,7 +22,7 @@
//
//
// $Id: G4HitsModel.cc,v 1.11 2005/01/27 20:06:52 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 26th August 1998.
@@ -22,7 +22,7 @@
//
//
// $Id: G4LogicalVolumeModel.cc,v 1.11 2005/02/15 14:51:33 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 26th July 1999.
@@ -0,0 +1,141 @@
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4ModelCommandsDrawByCharge.cc,v 1.6 2005/11/28 20:07:11 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
#include "G4ModelCommandsDrawByCharge.hh"
#include "G4TrajectoryDrawByCharge.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcommand.hh"
#include <sstream>
//Set colour with string
G4ModelCommandDrawByChargeSet::G4ModelCommandDrawByChargeSet(G4TrajectoryDrawByCharge* model, const G4String& placement)
:G4VModelCommand<G4TrajectoryDrawByCharge>(model)
{
G4String name = model->Name();
G4String myCommand = placement+"/"+name+"/set";
fpCommand = new G4UIcmdWithAString(myCommand, this);
fpCommand->SetGuidance("Set trajectory colour through a string.");
fpCommand->SetGuidance("Two inputs are expected, for example");
G4String example = myCommand+" -1 red";
fpCommand->SetGuidance(example);
fpCommand->SetParameterName("parameters", false);
}
G4ModelCommandDrawByChargeSet::~G4ModelCommandDrawByChargeSet()
{
delete fpCommand;
}
void G4ModelCommandDrawByChargeSet::SetNewValue(G4UIcommand*, G4String newValue)
{
G4int charge(-999);
G4String colour;
std::istringstream is (newValue);
is >> charge >> colour;
G4TrajectoryDrawByCharge::Charge myCharge = G4TrajectoryDrawByCharge::Positive;
switch (charge) {
case 1:
myCharge = G4TrajectoryDrawByCharge::Positive;
break;
case 0:
myCharge = G4TrajectoryDrawByCharge::Neutral;
break;
case -1:
myCharge = G4TrajectoryDrawByCharge::Negative;
break;
default:
std::ostringstream o;
o << "Invalid charge "<<charge;
G4Exception
("G4ModelCommandDrawByChargeSet::SetNewValue (G4UIcommand*, G4String newValue) ",
"InvalidCharge", FatalErrorInArgument, o.str().c_str());
}
// Configure model as requested
Model()->Set(myCharge, colour);
}
//Set colour by red, green, blue and alpha components
G4ModelCommandDrawByChargeSetRGBA::G4ModelCommandDrawByChargeSetRGBA(G4TrajectoryDrawByCharge* model, const G4String& placement)
:G4VModelCommand<G4TrajectoryDrawByCharge>(model)
{
G4String name = model->Name();
G4String myCommand = placement+"/"+name+"/setRGBA";
fpCommand = new G4UIcmdWithAString(myCommand, this);
fpCommand->SetGuidance("Set trajectory colour through red, green, blue and alpha components.");
fpCommand->SetGuidance("Five inputs are expected, for example");
G4String example = myCommand+" -1 1 1 1 1";
;
fpCommand->SetGuidance(example);
fpCommand->SetParameterName("parameters", false);
}
G4ModelCommandDrawByChargeSetRGBA::~G4ModelCommandDrawByChargeSetRGBA()
{
delete fpCommand;
}
void G4ModelCommandDrawByChargeSetRGBA::SetNewValue(G4UIcommand*, G4String newValue)
{
G4int charge(-999);
G4double red(0), green(0), blue(0), alpha(0);
std::istringstream is (newValue);
is >> charge >> red >> green >> blue >> alpha;
G4TrajectoryDrawByCharge::Charge myCharge = G4TrajectoryDrawByCharge::Positive;
switch (charge) {
case 1:
myCharge = G4TrajectoryDrawByCharge::Positive;
break;
case 0:
myCharge = G4TrajectoryDrawByCharge::Neutral;
break;
case -1:
myCharge = G4TrajectoryDrawByCharge::Negative;
break;
default:
std::ostringstream o;
o << "Invalid charge "<<charge;
G4Exception
("G4ModelCommandDrawByChargeSetRGBA::SetNewValue (G4UIcommand*, G4String newValue) ",
"InvalidCharge", FatalErrorInArgument, o.str().c_str());
}
G4Colour myColour(red, green, blue, alpha);
// Configure model as requested
Model()->Set(myCharge, myColour);
}
@@ -0,0 +1,163 @@
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4ModelCommandsDrawByParticleID.cc,v 1.3 2005/11/28 20:07:11 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
#include "G4ModelCommandsDrawByParticleID.hh"
#include "G4TrajectoryDrawByParticleID.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcommand.hh"
#include <sstream>
//Set colour with string
G4ModelCommandDrawByParticleIDSet::G4ModelCommandDrawByParticleIDSet(G4TrajectoryDrawByParticleID* model, const G4String& placement)
:G4VModelCommand<G4TrajectoryDrawByParticleID>(model)
{
G4String name = model->Name();
G4String myCommand = placement+"/"+name+"/set";
fpCommand = new G4UIcmdWithAString(myCommand, this);
fpCommand->SetGuidance("Set trajectory colour through a string.");
fpCommand->SetGuidance("Two inputs are expected, for example");
G4String example = myCommand+" gamma red";
fpCommand->SetGuidance(example);
fpCommand->SetParameterName("parameters", false);
}
G4ModelCommandDrawByParticleIDSet::~G4ModelCommandDrawByParticleIDSet()
{
delete fpCommand;
}
void G4ModelCommandDrawByParticleIDSet::SetNewValue(G4UIcommand*, G4String newValue)
{
G4String particle;
G4String colour;
std::istringstream is (newValue);
is >> particle >> colour;
// Configure model as requested
Model()->Set(particle, colour);
}
//Set colour by red, green, blue and alpha components
G4ModelCommandDrawByParticleIDSetRGBA::G4ModelCommandDrawByParticleIDSetRGBA(G4TrajectoryDrawByParticleID* model, const G4String& placement)
:G4VModelCommand<G4TrajectoryDrawByParticleID>(model)
{
G4String name = model->Name();
G4String myCommand = placement+"/"+name+"/setRGBA";
fpCommand = new G4UIcmdWithAString(myCommand, this);
fpCommand->SetGuidance("Set trajectory colour through red, green, blue and alpha components.");
fpCommand->SetGuidance("Five inputs are expected, for example");
G4String example = myCommand+" gamma 1 1 1 1";
;
fpCommand->SetGuidance(example);
fpCommand->SetParameterName("parameters", false);
}
G4ModelCommandDrawByParticleIDSetRGBA::~G4ModelCommandDrawByParticleIDSetRGBA()
{
delete fpCommand;
}
void G4ModelCommandDrawByParticleIDSetRGBA::SetNewValue(G4UIcommand*, G4String newValue)
{
G4String particle;
G4double red(0), green(0), blue(0), alpha(0);
std::istringstream is (newValue);
is >> particle >> red >> green >> blue >> alpha;
G4Colour myColour(red, green, blue, alpha);
// Configure model as requested
Model()->Set(particle, myColour);
}
//Set default colour with string
G4ModelCommandDrawByParticleIDSetDefault::G4ModelCommandDrawByParticleIDSetDefault(G4TrajectoryDrawByParticleID* model, const G4String& placement)
:G4VModelCommand<G4TrajectoryDrawByParticleID>(model)
{
G4String name = model->Name();
G4String myCommand = placement+"/"+name+"/setDefault";
fpCommand = new G4UIcmdWithAString(myCommand, this);
fpCommand->SetGuidance("Set default trajectory colour through a string.");
fpCommand->SetGuidance("One input is expected, for example");
G4String example = myCommand+" red";
fpCommand->SetGuidance(example);
fpCommand->SetParameterName("parameters", false);
}
G4ModelCommandDrawByParticleIDSetDefault::~G4ModelCommandDrawByParticleIDSetDefault()
{
delete fpCommand;
}
void G4ModelCommandDrawByParticleIDSetDefault::SetNewValue(G4UIcommand*, G4String newValue)
{
// Configure model as requested
Model()->SetDefault(newValue);
}
//Set colour by red, green, blue and alpha components
G4ModelCommandDrawByParticleIDSetDefaultRGBA::G4ModelCommandDrawByParticleIDSetDefaultRGBA(G4TrajectoryDrawByParticleID* model, const G4String& placement)
:G4VModelCommand<G4TrajectoryDrawByParticleID>(model)
{
G4String name = model->Name();
G4String myCommand = placement+"/"+name+"/setDefaultRGBA";
fpCommand = new G4UIcmdWithAString(myCommand, this);
fpCommand->SetGuidance("Set default trajectory colour through red, green, blue and alpha components.");
fpCommand->SetGuidance("Four inputs are expected, for example");
G4String example = myCommand+" 1 1 1 1";
;
fpCommand->SetGuidance(example);
fpCommand->SetParameterName("parameters", false);
}
G4ModelCommandDrawByParticleIDSetDefaultRGBA::~G4ModelCommandDrawByParticleIDSetDefaultRGBA()
{
delete fpCommand;
}
void G4ModelCommandDrawByParticleIDSetDefaultRGBA::SetNewValue(G4UIcommand*, G4String newValue)
{
G4double red(0), green(0), blue(0), alpha(0);
std::istringstream is (newValue);
is >> red >> green >> blue >> alpha;
G4Colour myColour(red, green, blue, alpha);
// Configure model as requested
Model()->SetDefault(myColour);
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4ModelingParameters.cc,v 1.7 2005/03/15 12:56:29 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 31st December 1997.
@@ -22,7 +22,7 @@
//
//
// $Id: G4NullModel.cc,v 1.7 2003/05/30 13:01:32 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 4th April 1998.
@@ -22,7 +22,7 @@
//
//
// $Id: G4PhysicalVolumeMassScene.cc,v 1.4 2005/01/26 16:48:56 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 10th August 1998.
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeModel.cc,v 1.32 2005/06/07 16:54:33 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4PhysicalVolumeModel.cc,v 1.36 2005/11/24 11:15:21 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 31st December 1997.
@@ -44,7 +44,7 @@
#include "G4VVisManager.hh"
#include "G4Polyhedron.hh"
#include <strstream>
#include <sstream>
G4PhysicalVolumeModel::G4PhysicalVolumeModel
(G4VPhysicalVolume* pVPV,
@@ -68,10 +68,9 @@ G4PhysicalVolumeModel::G4PhysicalVolumeModel
fppCurrentLV (0),
fppCurrentMaterial (0)
{
const int len = 8; char a [len];
std::ostrstream o (a, len); o.seekp (std::ios::beg);
o << fpTopPV -> GetCopyNo () << std::ends;
fGlobalTag = fpTopPV -> GetName () + "." + a;
std::ostringstream o;
o << fpTopPV -> GetCopyNo ();
fGlobalTag = fpTopPV -> GetName () + "." + o.str();
fGlobalDescription = "G4PhysicalVolumeModel " + fGlobalTag;
CalculateExtent ();
@@ -158,11 +157,10 @@ void G4PhysicalVolumeModel::DescribeYourselfTo
}
G4String G4PhysicalVolumeModel::GetCurrentTag () const {
const int len = 8; char a [len];
std::ostrstream o (a, len); o.seekp (std::ios::beg);
if (fpCurrentPV) {
o << fpCurrentPV -> GetCopyNo () << std::ends;
return fpCurrentPV -> GetName () + "." + a;
std::ostringstream o;
o << fpCurrentPV -> GetCopyNo ();
return fpCurrentPV -> GetName () + "." + o.str();
}
else {
return "WARNING: NO CURRENT VOLUME - global tag is " + fGlobalTag;
@@ -252,8 +250,16 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
// They have phi of offset+n*width to offset+(n+1)*width where
// n=0..nReplicas-1
//
pSol = pLV -> GetSolid ();
pMaterial = pLV -> GetMaterial ();
G4ThreeVector originalTranslation = pVPV -> GetTranslation ();
G4RotationMatrix* pOriginalRotation = pVPV -> GetRotation ();
G4double originalRMin = 0., originalRMax = 0.;
if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
originalRMin = ((G4Tubs*)pSol)->GetInnerRadius();
originalRMax = ((G4Tubs*)pSol)->GetOuterRadius();
}
G4bool visualisable = true;
for (int n = 0; n < nReplicas; n++) {
G4ThreeVector translation; // Null.
G4RotationMatrix rotation; // Null - life long enough for visualizing.
@@ -270,11 +276,20 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
translation = G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
break;
case kRho:
G4cout <<
"G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
"\n built-in replicated volumes replicated in radius are not yet"
"\n properly visualizable."
<< G4endl;
if (pSol->GetEntityType() == "G4Tubs") {
((G4Tubs*)pSol)->SetInnerRadius(width*n+offset);
((G4Tubs*)pSol)->SetOuterRadius(width*(n+1)+offset);
} else {
G4cout <<
"G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
"\n built-in replicated volumes replicated in radius for "
<< pSol->GetEntityType() <<
"-type\n solids (your solid \""
<< pSol->GetName() <<
"\") are not visualisable."
<< G4endl;
visualisable = false;
}
break;
case kPhi:
rotation.rotateZ (-(offset+(n+0.5)*width));
@@ -286,14 +301,18 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
pVPV -> SetTranslation (translation);
pVPV -> SetRotation (pRotation);
pVPV -> SetCopyNo (n);
pSol = pLV -> GetSolid ();
pMaterial = pLV -> GetMaterial ();
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
if (visualisable) {
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
}
}
// Restore originals...
pVPV -> SetTranslation (originalTranslation);
pVPV -> SetRotation (pOriginalRotation);
if (axis == kRho && pSol->GetEntityType() == "G4Tubs") {
((G4Tubs*)pSol)->SetInnerRadius(originalRMin);
((G4Tubs*)pSol)->SetOuterRadius(originalRMax);
}
}
}
@@ -485,8 +504,9 @@ G4bool G4PhysicalVolumeModel::IsDaughterCulled
&&
// Cull only if mother is visible...
(pVisAttribs ? pVisAttribs -> IsVisible () : true)
// &&
// true // ...and opaque (transparency parameter not yet implemented).
&&
// ...and opaque...
(pVisAttribs ? (pVisAttribs -> GetColour ().GetAlpha() >= 1.) : true)
)
)
;
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeSearchScene.cc,v 1.8 2005/01/26 17:07:37 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4PhysicalVolumeSearchScene.cc,v 1.9 2005/11/22 16:34:20 allison Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 10th August 1998.
@@ -90,9 +90,9 @@ void G4PhysicalVolumeSearchScene::FindVolume (const G4VSolid&) {
}
G4cout << " found more than once."
"\n This function is not smart enough to distinguish identical"
"\n physical volumes which have different parentage. Besides,"
"\n it's tricky to specify in general; we plan a GUI to do this."
"\n This function gives you access to the first occurrence only."
"\n physical volumes which have different parentage. It is"
"\n tricky to specify in general. This function gives you access"
"\n to the first occurrence only."
<< G4endl;
}
}
@@ -22,7 +22,7 @@
//
//
// $Id: G4ScaleModel.cc,v 1.3 2001/08/14 18:43:31 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 21st July 2001.
@@ -22,7 +22,7 @@
//
//
// $Id: G4TextModel.cc,v 1.6 2005/06/07 16:53:40 allison Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 3rd April 2001
@@ -22,7 +22,7 @@
//
//
// $Id: G4TrajectoriesModel.cc,v 1.14 2005/01/27 20:07:05 johna Exp $
// GEANT4 tag $Name: geant4-07-01 $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 26th August 1998.
@@ -0,0 +1,148 @@
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByCharge.cc,v 1.3 2005/11/23 20:24:15 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
#include "G4TrajectoryDrawByCharge.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4TrajectoryDrawerUtils.hh"
#include "G4VisAttributes.hh"
#include "G4VTrajectory.hh"
#include "G4VVisManager.hh"
#include <sstream>
G4TrajectoryDrawByCharge::G4TrajectoryDrawByCharge(const G4String& name)
:G4VTrajectoryModel(name)
{
// Default configuration
fMap[Positive] = G4Color::Blue();
fMap[Negative] = G4Colour::Red();
fMap[Neutral] = G4Colour::Green();
}
G4TrajectoryDrawByCharge::G4TrajectoryDrawByCharge(const G4String& name,
const G4Colour& positive,
const G4Colour& negative,
const G4Colour& neutral)
:G4VTrajectoryModel(name)
{
fMap[Positive] = positive;
fMap[Negative] = negative;
fMap[Neutral] = neutral;
}
G4TrajectoryDrawByCharge::~G4TrajectoryDrawByCharge() {}
void
G4TrajectoryDrawByCharge::Draw(const G4VTrajectory& traj, G4int i_mode) const
{
// If i_mode>=0, draws a trajectory as a polyline (default is blue for
// positive, red for negative, green for neutral) and, if i_mode!=0,
// adds markers - yellow circles for step points and magenta squares
// for auxiliary points, if any - whose screen size in pixels is
// given by std::abs(i_mode)/1000. E.g: i_mode = 5000 gives easily
// visible markers.
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (0 == pVVisManager) return;
const G4double markerSize = std::abs(i_mode)/1000;
G4bool lineRequired (i_mode >= 0);
G4bool markersRequired (markerSize > 0.);
// Return if don't need to do anything
if (!lineRequired && !markersRequired) return;
// Get points to draw
G4Polyline trajectoryLine;
G4Polymarker stepPoints;
G4Polymarker auxiliaryPoints;
G4TrajectoryDrawerUtils::GetPoints(traj, trajectoryLine,
auxiliaryPoints, stepPoints);
if (lineRequired) {
G4Colour colour;
const G4double charge = traj.GetCharge();
if(charge>0.) colour = fMap.find(Positive)->second;
else if(charge<0.) colour = fMap.find(Negative)->second;
else colour = fMap.find(Neutral)->second;
G4VisAttributes trajectoryLineAttribs(colour);
trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
pVVisManager->Draw(trajectoryLine);
}
if (markersRequired) {
auxiliaryPoints.SetMarkerType(G4Polymarker::squares);
auxiliaryPoints.SetScreenSize(markerSize);
auxiliaryPoints.SetFillStyle(G4VMarker::filled);
G4VisAttributes auxiliaryPointsAttribs(G4Colour(0.,1.,1.)); // Magenta
auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs);
pVVisManager->Draw(auxiliaryPoints);
stepPoints.SetMarkerType(G4Polymarker::circles);
stepPoints.SetScreenSize(markerSize);
stepPoints.SetFillStyle(G4VMarker::filled);
G4VisAttributes stepPointsAttribs(G4Colour(1.,1.,0.)); // Yellow.
stepPoints.SetVisAttributes(&stepPointsAttribs);
pVVisManager->Draw(stepPoints);
}
}
void
G4TrajectoryDrawByCharge::Print(std::ostream& ostr) const
{
ostr<<"G4TrajectoryDrawByCharge model "<< Name() <<" colour scheme: "<<std::endl;
std::map<Charge, G4Colour>::const_iterator iter = fMap.begin();
while (iter != fMap.end()) {
ostr<< iter->first <<" : "<< iter->second <<G4endl;
iter++;
}
}
void
G4TrajectoryDrawByCharge::Set(Charge charge, const G4String& colour)
{
G4Colour myColour(G4Colour::White());
// Will not modify myColour if colour key does not exist
if (!G4Colour::GetColour(colour, myColour)) {
std::ostringstream o;
o << "G4Colour with key "<<colour<<" does not exist ";
G4Exception
("G4TrajectoryDrawByCharge::Set(Charge charge, const G4String& colour)",
"NonExistentColour", JustWarning, o.str().c_str());
}
Set(charge, myColour);
}
void
G4TrajectoryDrawByCharge::Set(Charge charge, const G4Colour& colour)
{
fMap[charge] = colour;
}
@@ -0,0 +1,166 @@
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawByParticleID.cc,v 1.4 2005/11/23 20:24:15 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
#include "G4TrajectoryDrawByParticleID.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4TrajectoryDrawerUtils.hh"
#include "G4VisAttributes.hh"
#include "G4VTrajectory.hh"
#include "G4VVisManager.hh"
#include <sstream>
G4TrajectoryDrawByParticleID::G4TrajectoryDrawByParticleID(const G4String& name)
:G4VTrajectoryModel(name)
,fDefault(G4Color::Grey())
{}
G4TrajectoryDrawByParticleID::~G4TrajectoryDrawByParticleID() {}
void
G4TrajectoryDrawByParticleID::SetDefault(const G4String& colour)
{
G4Colour myColour(G4Colour::White());
// Will not modify myColour if colour key does not exist
if (!G4Colour::GetColour(colour, myColour)) {
std::ostringstream o;
o << "G4Colour with key "<<colour<<" does not exist ";
G4Exception
("G4TrajectoryDrawByParticleID::SetDefault(const G4String& colour)",
"NonExistentColour", JustWarning, o.str().c_str());
}
SetDefault(myColour);
}
void
G4TrajectoryDrawByParticleID::SetDefault(const G4Colour& colour)
{
fDefault = colour;
}
void
G4TrajectoryDrawByParticleID::Set(const G4String& particle, const G4String& colour)
{
G4Colour myColour(fDefault);
// Will not modify myColour if colour key does not exist
if (!G4Colour::GetColour(colour, myColour)) {
std::ostringstream o;
o << "G4Colour with key "<<colour<<" does not exist ";
G4Exception
("G4TrajectoryDrawByParticleID::Set(const G4String& particle, const G4String& colour)",
"NonExistentColour", JustWarning, o.str().c_str());
}
Set(particle, myColour);
}
void
G4TrajectoryDrawByParticleID::Set(const G4String& particle, const G4Colour& colour)
{
std::map<G4String, G4Colour>::iterator iter = fMap.find(particle);
if (iter == fMap.end()) {
fMap[particle] = colour;
}
else {
std::ostringstream o;
o << "Particle "<<particle<<" already has colour "<<colour<<" assigned.";
G4Exception
("G4TrajectoryDrawByParticleID::Set(const G4String& particle, const G4String& colour)",
"ParticleColourExists", JustWarning, o.str().c_str());
}
}
void
G4TrajectoryDrawByParticleID::Draw(const G4VTrajectory& traj, G4int i_mode) const
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (0 == pVVisManager) return;
const G4double markerSize = std::abs(i_mode)/1000;
G4bool lineRequired (i_mode >= 0);
G4bool markersRequired (markerSize > 0.);
//Return if don't need to do anything
if (!lineRequired && !markersRequired) return;
//Get points to draw
G4Polyline trajectoryLine;
G4Polymarker stepPoints;
G4Polymarker auxiliaryPoints;
G4TrajectoryDrawerUtils::GetPoints(traj, trajectoryLine,
auxiliaryPoints, stepPoints);
if (lineRequired) {
G4Colour colour(fDefault);
G4String particle = traj.GetParticleName();
map<G4String, G4Colour>::const_iterator iter = fMap.find(particle);
if (iter != fMap.end()) colour = iter->second;
G4VisAttributes trajectoryLineAttribs(colour);
trajectoryLine.SetVisAttributes(&trajectoryLineAttribs);
pVVisManager->Draw(trajectoryLine);
}
if (markersRequired) {
auxiliaryPoints.SetMarkerType(G4Polymarker::squares);
auxiliaryPoints.SetScreenSize(markerSize);
auxiliaryPoints.SetFillStyle(G4VMarker::filled);
G4VisAttributes auxiliaryPointsAttribs(G4Colour(0.,1.,1.)); // Magenta
auxiliaryPoints.SetVisAttributes(&auxiliaryPointsAttribs);
pVVisManager->Draw(auxiliaryPoints);
stepPoints.SetMarkerType(G4Polymarker::circles);
stepPoints.SetScreenSize(markerSize);
stepPoints.SetFillStyle(G4VMarker::filled);
G4VisAttributes stepPointsAttribs(G4Colour(1.,1.,0.)); // Yellow.
stepPoints.SetVisAttributes(&stepPointsAttribs);
pVVisManager->Draw(stepPoints);
}
return;
}
void
G4TrajectoryDrawByParticleID::Print(std::ostream& ostr) const
{
ostr<<"G4TrajectoryDrawByParticleID model "<< Name() <<" colour scheme: "<<std::endl;
ostr<<"Default : "<<fDefault<<G4endl;
std::map<G4String, G4Colour>::const_iterator iter = fMap.begin();
while (iter != fMap.end()) {
ostr<<iter->first <<" : "<< iter->second <<G4endl;
iter++;
}
}
@@ -0,0 +1,56 @@
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawerUtils.cc,v 1.2 2005/11/21 05:44:44 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
#include "G4TrajectoryDrawerUtils.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4VTrajectory.hh"
#include "G4VTrajectoryPoint.hh"
namespace G4TrajectoryDrawerUtils {
void GetPoints(const G4VTrajectory& traj, G4Polyline& trajectoryLine,
G4Polymarker& auxiliaryPoints, G4Polymarker& stepPoints)
{
for (G4int i=0; i<traj.GetPointEntries(); i++) {
G4VTrajectoryPoint* aTrajectoryPoint = traj.GetPoint(i);
const std::vector<G4ThreeVector>* auxiliaries
= aTrajectoryPoint->GetAuxiliaryPoints();
if (auxiliaries) {
for (size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
const G4ThreeVector pos((*auxiliaries)[iAux]);
trajectoryLine.push_back(pos);
auxiliaryPoints.push_back(pos);
}
}
const G4ThreeVector pos(aTrajectoryPoint->GetPosition());
trajectoryLine.push_back(pos);
stepPoints.push_back(pos);
}
}
}
@@ -0,0 +1,76 @@
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
// $Id: G4TrajectoryModelFactories.cc,v 1.2 2005/11/23 05:19:23 tinslay Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
// Jane Tinslay, John Allison, Joseph Perl October 2005
#include "G4ModelCommandsDrawByCharge.hh"
#include "G4ModelCommandsDrawByParticleID.hh"
#include "G4TrajectoryDrawByCharge.hh"
#include "G4TrajectoryDrawByParticleID.hh"
#include "G4TrajectoryModelFactories.hh"
G4TrajectoryDrawByChargeFactory::G4TrajectoryDrawByChargeFactory()
:G4VModelFactory<G4VTrajectoryModel>("drawByCharge")
{}
G4TrajectoryDrawByChargeFactory::~G4TrajectoryDrawByChargeFactory() {}
ModelAndMessengers
G4TrajectoryDrawByChargeFactory::Create(const G4String& placement, const G4String& name)
{
// Create model
G4TrajectoryDrawByCharge* model = new G4TrajectoryDrawByCharge(name);
// Create associated messengers
Messengers messengers;
messengers.push_back(new G4ModelCommandDrawByChargeSet(model, placement));
messengers.push_back(new G4ModelCommandDrawByChargeSetRGBA(model, placement));
return ModelAndMessengers(model, messengers);
}
//Draw by particle ID
G4TrajectoryDrawByParticleIDFactory::G4TrajectoryDrawByParticleIDFactory()
:G4VModelFactory<G4VTrajectoryModel>("drawByParticleID")
{}
G4TrajectoryDrawByParticleIDFactory::~G4TrajectoryDrawByParticleIDFactory() {}
ModelAndMessengers
G4TrajectoryDrawByParticleIDFactory::Create(const G4String& placement, const G4String& name)
{
// Create model
G4TrajectoryDrawByParticleID* model = new G4TrajectoryDrawByParticleID(name);
// Create associated messengers
Messengers messengers;
messengers.push_back(new G4ModelCommandDrawByParticleIDSet(model, placement));
messengers.push_back(new G4ModelCommandDrawByParticleIDSetRGBA(model, placement));
messengers.push_back(new G4ModelCommandDrawByParticleIDSetDefault(model, placement));
messengers.push_back(new G4ModelCommandDrawByParticleIDSetDefaultRGBA(model, placement));
return ModelAndMessengers(model, messengers);
}
+13 -9
View File
@@ -21,8 +21,8 @@
// ********************************************************************
//
//
// $Id: G4VModel.cc,v 1.9 2003/06/16 17:14:32 gunter Exp $
// GEANT4 tag $Name: geant4-07-01 $
// $Id: G4VModel.cc,v 1.11 2005/11/30 16:06:18 gcosmo Exp $
// GEANT4 tag $Name: geant4-08-00 $
//
//
// John Allison 31st December 1997.
@@ -30,25 +30,29 @@
#include "G4VModel.hh"
#include "G4RotationMatrix.hh"
#include "G4ModelingParameters.hh"
G4VModel::G4VModel (const G4Transform3D& modelTransformation,
const G4ModelingParameters* pMP):
fGlobalTag ("Empty"),
fGlobalDescription ("Empty"),
fTransform (modelTransformation),
fpMP (pMP)
{
fGlobalTag = "Default Global Tag";
fGlobalDescription = "Default Global Description";
}
{}
G4VModel::~G4VModel () {}
G4String G4VModel::GetCurrentTag () const {
return G4String("Default Current Tag");
return G4String
("WARNING: GetCurrentTag() not implemented by concrete class."
"\n Global tag: " + fGlobalTag);
}
G4String G4VModel::GetCurrentDescription () const {
return G4String("Default Current Description");
return G4String
("WARNING: GetCurrentDescription() not implemented by concrete class."
"\n Global description: " + fGlobalDescription);
}
G4bool G4VModel::Validate (G4bool) {
@@ -67,7 +71,7 @@ std::ostream& operator << (std::ostream& os, const G4VModel& m) {
os << "\n Extent: " << m.fExtent;
os << "\n Transformation: ";
os << "\n Rotation: ";
HepRotation rotation = m.fTransform.getRotation ();
G4RotationMatrix rotation = m.fTransform.getRotation ();
os << rotation.thetaX() << ", "
<< rotation.phiX() << ", "
<< rotation.thetaY() << ", "