Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4BoundingSphereScene.cc,v 2.4 1998/11/23 10:12:16 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 7th June 1997
|
||||
// An artificial scene to reuse G4VScene code to calculate a bounding sphere.
|
||||
|
||||
#include "G4BoundingSphereScene.hh"
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4Vector3D.hh"
|
||||
|
||||
G4BoundingSphereScene::G4BoundingSphereScene ():
|
||||
fRadius (-1.),
|
||||
fpObjectTransformation (0)
|
||||
{}
|
||||
|
||||
G4BoundingSphereScene::~G4BoundingSphereScene () {}
|
||||
|
||||
G4VisExtent G4BoundingSphereScene::GetBoundingSphereExtent () {
|
||||
return G4VisExtent (fCentre, fRadius);
|
||||
}
|
||||
|
||||
void G4BoundingSphereScene::Accrue (const G4VSolid& solid) {
|
||||
const G4VisExtent& thisExtent = solid.GetExtent ();
|
||||
G4Point3D thisCentre = thisExtent.GetExtentCentre ();
|
||||
if (fpObjectTransformation) {
|
||||
thisCentre.transform (*fpObjectTransformation);
|
||||
}
|
||||
const G4double thisRadius = thisExtent.GetExtentRadius ();
|
||||
AccrueBoundingSphere (thisCentre, thisRadius);
|
||||
/***********************************************
|
||||
G4cout << "G4BoundingSphereScene::Accrue: centre: " << fCentre
|
||||
<< ", radius: " << fRadius << endl;
|
||||
***********************************************/
|
||||
}
|
||||
|
||||
void G4BoundingSphereScene::ResetBoundingSphere () {
|
||||
fCentre = G4Point3D ();
|
||||
fRadius = -1.;
|
||||
fpObjectTransformation = 0;
|
||||
}
|
||||
|
||||
void G4BoundingSphereScene::AccrueBoundingSphere
|
||||
(const G4Point3D& thisCentre,
|
||||
G4double thisRadius) {
|
||||
|
||||
if (fRadius < 0 ) { // First time.
|
||||
fCentre = thisCentre;
|
||||
fRadius = thisRadius;
|
||||
}
|
||||
else {
|
||||
G4Vector3D join = thisCentre - fCentre;
|
||||
if (join == G4Vector3D (0., 0., 0.)) { // Centres coincide.
|
||||
if (fRadius < thisRadius) fRadius = thisRadius;
|
||||
}
|
||||
else if (join.mag () + thisRadius <= fRadius) { // Inside accrued sphere.
|
||||
// Do nothing.
|
||||
}
|
||||
else {
|
||||
G4Vector3D unitJoin = join.unit ();
|
||||
G4Point3D extremity1 = fCentre - fRadius * unitJoin;
|
||||
G4Point3D extremity2 = thisCentre + thisRadius * unitJoin;
|
||||
fCentre = 0.5 * (extremity2 + extremity1);
|
||||
fRadius = 0.5 * (extremity2 - extremity1).mag ();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4FlavoredParallelWorldModel.cc,v 2.1 1998/08/22 16:35:04 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
// P. Mora de Freitas et M.Verderi - 19 June 1998.
|
||||
// Model for flavored parallel world volumes.
|
||||
|
||||
#include "G4FlavoredParallelWorldModel.hh"
|
||||
|
||||
#include "G4FlavoredParallelWorld.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
|
||||
G4FlavoredParallelWorldModel::G4FlavoredParallelWorldModel
|
||||
(G4FlavoredParallelWorld* FPW,
|
||||
G4int soughtDepth,
|
||||
const G4Transform3D& modelTransformation,
|
||||
const G4ModelingParameters* mp)
|
||||
: G4PhysicalVolumeModel (FPW -> GetThePhysicalVolumeWorld (),
|
||||
soughtDepth,
|
||||
modelTransformation,
|
||||
mp),
|
||||
theFlavoredParallelWorld (FPW)
|
||||
{
|
||||
FPW -> GetThePhysicalVolumeWorld () ->
|
||||
GetLogicalVolume () -> SetVisAttributes (G4VisAttributes::Invisible);
|
||||
}
|
||||
|
||||
G4FlavoredParallelWorldModel::~G4FlavoredParallelWorldModel () {}
|
||||
@@ -0,0 +1,38 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4HitsModel.cc,v 1.2 1998/08/31 15:42:15 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 26th August 1998.
|
||||
// Model which knows how to draw GEANT4 hits.
|
||||
|
||||
#include "G4HitsModel.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
|
||||
G4HitsModel::G4HitsModel () {
|
||||
fGlobalTag = "G4HitsModel for all hits.";
|
||||
fGlobalDescription = fGlobalTag;
|
||||
}
|
||||
|
||||
void G4HitsModel::DescribeYourselfTo (G4VGraphicsScene& scene) {
|
||||
G4RunManager* runManager = G4RunManager::GetRunManager ();
|
||||
const G4Event* event = runManager -> GetCurrentEvent ();
|
||||
if (event) {
|
||||
G4HCofThisEvent* HCE = event -> GetHCofThisEvent ();
|
||||
if (HCE) {
|
||||
G4int nHC = HCE -> GetCapacity ();
|
||||
for (int iHC = 0; iHC < nHC; iHC++) {
|
||||
HCE -> GetHC (iHC) -> DrawAllHits ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4ModelingParameters.cc,v 2.2 1998/11/25 16:24:34 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 31st December 1997.
|
||||
// Parameters associated with the modeling of GEANT4 objects.
|
||||
|
||||
#include "G4ModelingParameters.hh"
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
|
||||
G4ModelingParameters::G4ModelingParameters ():
|
||||
fpDefaultVisAttributes (0),
|
||||
fRepStyle (polyhedron),
|
||||
fCulling (false),
|
||||
fCullInvisible (false),
|
||||
fDensityCulling (false),
|
||||
fVisibleDensity (0.01 * g / cm3),
|
||||
fCullCovered (false),
|
||||
fNoOfSides (24) {}
|
||||
|
||||
G4ModelingParameters::G4ModelingParameters
|
||||
(const G4VisAttributes* pDefaultVisAttributes,
|
||||
G4ModelingParameters::RepStyle repStyle,
|
||||
G4bool isCulling,
|
||||
G4bool isCullingInvisible,
|
||||
G4bool isDensityCulling,
|
||||
G4double visibleDensity,
|
||||
G4bool isCullingCovered,
|
||||
G4int noOfSides):
|
||||
fpDefaultVisAttributes (pDefaultVisAttributes),
|
||||
fRepStyle (repStyle),
|
||||
fCulling (isCulling),
|
||||
fCullInvisible (isCullingInvisible),
|
||||
fDensityCulling (isDensityCulling),
|
||||
fVisibleDensity (visibleDensity),
|
||||
fCullCovered (isCullingCovered),
|
||||
fNoOfSides (noOfSides) {}
|
||||
|
||||
G4ModelingParameters::~G4ModelingParameters () {}
|
||||
|
||||
void G4ModelingParameters::SetVisibleDensity (G4double visibleDensity) {
|
||||
const G4double reasonableMaximum = 10.0 * g / cm3;
|
||||
if (visibleDensity < 0) {
|
||||
G4cout << "G4ModelingParameters::SetVisibleDensity: attempt to set negative "
|
||||
"density - ignored." << endl;
|
||||
}
|
||||
else {
|
||||
if (fVisibleDensity > reasonableMaximum) {
|
||||
G4cout << "G4ModelingParameters::SetVisibleDensity: density > "
|
||||
<< reasonableMaximum
|
||||
<< " g / cm3 - did you mean this?"
|
||||
<< endl;
|
||||
}
|
||||
fVisibleDensity = visibleDensity;
|
||||
}
|
||||
}
|
||||
|
||||
void G4ModelingParameters::SetNoOfSides (G4int nSides) {
|
||||
const G4int nSidesMin = 3;
|
||||
if (nSides < nSidesMin) {
|
||||
nSides = nSidesMin;
|
||||
G4cout << "G4ModelingParameters::SetNoOfSides: attempt to set the"
|
||||
"\nnumber of sides per circle < " << nSidesMin
|
||||
<< "; forced to" << nSides << endl;
|
||||
}
|
||||
fNoOfSides = nSides;
|
||||
}
|
||||
|
||||
void G4ModelingParameters::PrintDifferences
|
||||
(const G4ModelingParameters& that) const {
|
||||
|
||||
if (
|
||||
(fpDefaultVisAttributes != that.fpDefaultVisAttributes) ||
|
||||
(fRepStyle != that.fRepStyle) ||
|
||||
(fCulling != that.fCulling) ||
|
||||
(fCullInvisible != that.fCullInvisible) ||
|
||||
(fDensityCulling != that.fDensityCulling) ||
|
||||
(fVisibleDensity != that.fVisibleDensity) ||
|
||||
(fCullCovered != that.fCullCovered) ||
|
||||
(fNoOfSides != that.fNoOfSides))
|
||||
G4cout << "Difference in 1st batch." << endl;
|
||||
}
|
||||
|
||||
ostream& operator << (ostream& os, const G4ModelingParameters& mp) {
|
||||
os << "Modeling parameters and options:";
|
||||
|
||||
os << "\n Default vis. attributes: " << *mp.fpDefaultVisAttributes;
|
||||
|
||||
os << "\n Representation style for graphics reps, if needed: ";
|
||||
switch (mp.fRepStyle) {
|
||||
case G4ModelingParameters::wireframe:
|
||||
os << "wireframe"; break;
|
||||
case G4ModelingParameters::polyhedron:
|
||||
os << "polyhedron"; break;
|
||||
case G4ModelingParameters::nurbs:
|
||||
os << "nurbs"; break;
|
||||
default: os << "unrecognised"; break;
|
||||
}
|
||||
|
||||
os << "\n Culling: ";
|
||||
if (mp.fCulling) os << "on";
|
||||
else os << "off";
|
||||
|
||||
os << "\n Culling invisible objects: ";
|
||||
if (mp.fCullInvisible) os << "on";
|
||||
else os << "off";
|
||||
|
||||
os << "\n Density culling: ";
|
||||
if (mp.fDensityCulling) {
|
||||
os << "on - invisible if density less than "
|
||||
<< mp.fVisibleDensity / (1. * g / cm3) << " g cm^-3";
|
||||
}
|
||||
else os << "off";
|
||||
|
||||
os << "\n Culling daughters covered by opaque mothers: ";
|
||||
if (mp.fCullCovered) os << "on";
|
||||
else os << "off";
|
||||
|
||||
os << "\n No. of sides used in circle polygon approximation: "
|
||||
<< mp.fNoOfSides;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
G4bool operator != (const G4ModelingParameters& mp1,
|
||||
const G4ModelingParameters& mp2) {
|
||||
|
||||
if (
|
||||
(*mp1.fpDefaultVisAttributes != *mp2.fpDefaultVisAttributes) ||
|
||||
(mp1.fRepStyle != mp2.fRepStyle) ||
|
||||
(mp1.fCulling != mp2.fCulling) ||
|
||||
(mp1.fCullInvisible != mp2.fCullInvisible) ||
|
||||
(mp1.fDensityCulling != mp2.fDensityCulling) ||
|
||||
(mp1.fCullCovered != mp2.fCullCovered) ||
|
||||
(mp1.fNoOfSides != mp2.fNoOfSides))
|
||||
return true;
|
||||
|
||||
if (mp1.fDensityCulling &&
|
||||
(mp1.fVisibleDensity != mp2.fVisibleDensity)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4NullModel.cc,v 2.2 1998/08/31 15:42:16 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 4th April 1998.
|
||||
// Null model - simply a holder for modeling parameter.
|
||||
// DO NOT INVOKE DescribeYourself.
|
||||
|
||||
#include "G4NullModel.hh"
|
||||
|
||||
G4NullModel::G4NullModel (const G4ModelingParameters* pMP):
|
||||
G4VModel (G4Transform3D::Identity, pMP) {}
|
||||
|
||||
G4NullModel::~G4NullModel () {}
|
||||
|
||||
void G4NullModel::DescribeYourselfTo (G4VGraphicsScene& scene) {
|
||||
G4Exception ("G4NullModel::DescribeYourselfTo called.");
|
||||
}
|
||||
|
||||
G4bool G4NullModel::Validate () {
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,406 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4PhysicalVolumeModel.cc,v 2.6 1998/11/25 16:25:49 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 31st December 1997.
|
||||
// Model for physical volumes.
|
||||
|
||||
#include "G4PhysicalVolumeModel.hh"
|
||||
|
||||
#include "G4ModelingParameters.hh"
|
||||
#include "G4VGraphicsScene.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VPVParameterisation.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4BoundingSphereScene.hh"
|
||||
#include "G4PhysicalVolumeSearchScene.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <strstrea.h>
|
||||
#else
|
||||
#include <strstream.h>
|
||||
#endif
|
||||
|
||||
G4PhysicalVolumeModel::G4PhysicalVolumeModel
|
||||
(G4VPhysicalVolume* pVPV,
|
||||
G4int soughtDepth,
|
||||
const G4Transform3D& modelTransformation,
|
||||
const G4ModelingParameters* pMP):
|
||||
G4VModel (modelTransformation, pMP),
|
||||
fpTopPV (pVPV),
|
||||
fTopPVName (pVPV -> GetName ()),
|
||||
fTopPVCopyNo (pVPV -> GetCopyNo ()),
|
||||
fSoughtDepth (soughtDepth),
|
||||
fCurrentDepth (0),
|
||||
fpCurrentPV (0),
|
||||
fpCurrentLV (0),
|
||||
fpCurrentDepth (0),
|
||||
fppCurrentPV (0),
|
||||
fppCurrentLV (0)
|
||||
{
|
||||
const int len = 8; char a [len];
|
||||
ostrstream o (a, len); o.seekp (ios::beg);
|
||||
o << fpTopPV -> GetCopyNo () << ends;
|
||||
fGlobalTag = fpTopPV -> GetName () + "." + a;
|
||||
fGlobalDescription = "G4PhysicalVolumeModel " + fGlobalTag;
|
||||
|
||||
G4BoundingSphereScene bsScene;
|
||||
const G4ModelingParameters* tempMP = fpMP;
|
||||
G4ModelingParameters mParams
|
||||
(0, // No default vis attributes.
|
||||
G4ModelingParameters::wireframe,
|
||||
true, // Global culling.
|
||||
true, // Cull invisible volumes.
|
||||
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).
|
||||
fpMP = &mParams;
|
||||
//bsScene.SetBoundingSphereExtent
|
||||
// (fpTopPV -> GetLogicalVolume () -> GetSolid () -> GetExtent ());
|
||||
DescribeYourselfTo (bsScene);
|
||||
fExtent = bsScene.GetBoundingSphereExtent ();
|
||||
fpMP = tempMP;
|
||||
}
|
||||
|
||||
void G4PhysicalVolumeModel::DescribeYourselfTo (G4VGraphicsScene& scene) {
|
||||
|
||||
scene.EstablishSpecials (*this);
|
||||
// See .hh file for explanation of this mechanism.
|
||||
|
||||
fCurrentDepth = 0;
|
||||
// Store in working space (via pointer to working space).
|
||||
if (fpCurrentDepth) *fpCurrentDepth = fCurrentDepth;
|
||||
|
||||
//G4Transform3D startingTransformation = fTransform;
|
||||
G4Transform3D startingTransformation;
|
||||
|
||||
VisitGeometryAndGetVisReps (fpTopPV,
|
||||
fSoughtDepth,
|
||||
startingTransformation,
|
||||
scene);
|
||||
|
||||
// Clear current data and working space (via pointers to working space).
|
||||
fCurrentDepth = 0;
|
||||
fpCurrentPV = 0;
|
||||
fpCurrentLV = 0;
|
||||
if (fpCurrentDepth) *fpCurrentDepth = fCurrentDepth;
|
||||
if (fppCurrentPV) *fppCurrentPV = fpCurrentPV;
|
||||
if (fppCurrentLV) *fppCurrentLV = fpCurrentLV;
|
||||
|
||||
scene.DecommissionSpecials (*this);
|
||||
|
||||
// Clear pointers to working space.
|
||||
fpCurrentDepth = 0;
|
||||
fppCurrentPV = 0;
|
||||
fppCurrentLV = 0;
|
||||
}
|
||||
|
||||
G4String G4PhysicalVolumeModel::GetCurrentTag () const {
|
||||
const int len = 8; char a [len];
|
||||
ostrstream o (a, len); o.seekp (ios::beg);
|
||||
if (fpCurrentPV) {
|
||||
o << fpCurrentPV -> GetCopyNo () << ends;
|
||||
return fpCurrentPV -> GetName () + "." + a;
|
||||
}
|
||||
else {
|
||||
return "WARNING: NO CURRENT VOLUME - global tag is " + fGlobalTag;
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4PhysicalVolumeModel::GetCurrentDescription () const {
|
||||
return "G4PhysicalVolumeModel " + GetCurrentTag ();
|
||||
}
|
||||
|
||||
void G4PhysicalVolumeModel::DefinePointersToWorkingSpace
|
||||
(G4int* pCurrentDepth,
|
||||
G4VPhysicalVolume** ppCurrentPV,
|
||||
G4LogicalVolume** ppCurrentLV) {
|
||||
fpCurrentDepth = pCurrentDepth;
|
||||
fppCurrentPV = ppCurrentPV;
|
||||
fppCurrentLV = ppCurrentLV;
|
||||
}
|
||||
|
||||
void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
|
||||
(G4VPhysicalVolume* pVPV,
|
||||
G4int soughtDepth,
|
||||
const G4Transform3D& theAT,
|
||||
G4VGraphicsScene& scene) {
|
||||
|
||||
// Visits geometry structure to a given depth (soughtDepth), starting
|
||||
// at given physical volume with given starting transformation and
|
||||
// describes volumes to the scene.
|
||||
// soughtDepth < 0 (default) implies full visit.
|
||||
// theAT is the Accumulated Transformation.
|
||||
|
||||
// Find corresponding logical volume and (later) solid, storing in
|
||||
// local variables to preserve re-entrancy.
|
||||
G4LogicalVolume* pLV = pVPV -> GetLogicalVolume ();
|
||||
|
||||
// Maintain data members and store in working space (via pointers to
|
||||
// working space).
|
||||
if (fpCurrentDepth) *fpCurrentDepth = fCurrentDepth;
|
||||
fpCurrentPV = pVPV;
|
||||
fpCurrentLV = pLV;
|
||||
if (fppCurrentPV) *fppCurrentPV = fpCurrentPV;
|
||||
if (fppCurrentLV) *fppCurrentLV = fpCurrentLV;
|
||||
|
||||
G4VSolid* pSol;
|
||||
G4Material* pMaterial;
|
||||
if (pVPV -> IsReplicated ()) {
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width;
|
||||
G4double offset;
|
||||
G4bool consuming;
|
||||
pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
|
||||
G4VPVParameterisation* pP = pVPV -> GetParameterisation ();
|
||||
if (pP) { // Parametrised volume.
|
||||
for (int n = 0; n < nReplicas; n++) {
|
||||
pSol = pP -> ComputeSolid (n, pVPV);
|
||||
pMaterial = pP -> ComputeMaterial (n, pVPV);
|
||||
pP -> ComputeTransformation (n, pVPV);
|
||||
pSol -> ComputeDimensions (pP, n, pVPV);
|
||||
pVPV -> SetCopyNo (n);
|
||||
DescribeAndDescend (pVPV, soughtDepth, pLV, pSol, pMaterial,
|
||||
theAT, scene);
|
||||
}
|
||||
}
|
||||
else { // Plain replicated volume. From geometry_guide.txt...
|
||||
// The replica's positions are claculated by means of a linear formula.
|
||||
// Replication may occur along:
|
||||
//
|
||||
// o Cartesian axes (kXAxis,kYAxis,kZAxis)
|
||||
//
|
||||
// The replications, of specified width have coordinates of
|
||||
// form (-width*(nReplicas-1)*0.5+n*width,0,0) where n=0.. nReplicas-1
|
||||
// for the case of kXAxis, and are unrotated.
|
||||
//
|
||||
// o Radial axis (cylindrical polar) (kRho)
|
||||
//
|
||||
// The replications are cons/tubs sections, centred on the origin
|
||||
// and are unrotated.
|
||||
// They have radii of width*n+offset to width*(n+1)+offset
|
||||
// where n=0..nReplicas-1
|
||||
//
|
||||
// o Phi axis (cylindrical polar) (kPhi)
|
||||
// The replications are `phi sections' or wedges, and of cons/tubs form
|
||||
// They have phi of offset+n*width to offset+(n+1)*width where
|
||||
// n=0..nReplicas-1
|
||||
//
|
||||
for (int n = 0; n < nReplicas; n++) {
|
||||
G4ThreeVector translation; // Null.
|
||||
G4RotationMatrix rotation; // Null - life long enough for visualizing.
|
||||
G4RotationMatrix* pRotation = 0;
|
||||
switch (axis) {
|
||||
default:
|
||||
case kXAxis:
|
||||
translation = G4ThreeVector (-width*(nReplicas-1)*0.5+n*width,0,0);
|
||||
break;
|
||||
case kYAxis:
|
||||
translation = G4ThreeVector (0,-width*(nReplicas-1)*0.5+n*width,0);
|
||||
break;
|
||||
case kZAxis:
|
||||
translation = G4ThreeVector (0,0,-width*(nReplicas-1)*0.5+n*width);
|
||||
break;
|
||||
case kRho:
|
||||
G4cerr <<
|
||||
"G4PhysicalVolumeModel::VisitGeometryAndGetVisReps: WARNING:"
|
||||
"\n built-in replicated volumes replicated in radius are not yet"
|
||||
"\n properly visualizable."
|
||||
<< endl;
|
||||
break;
|
||||
case kPhi:
|
||||
rotation.rotateZ (-(offset+n*width));
|
||||
// Minus Sign because for the physical volume we need the
|
||||
// coordinate system rotation.
|
||||
pRotation = &rotation;
|
||||
break;
|
||||
}
|
||||
pVPV -> SetTranslation (translation);
|
||||
pVPV -> SetRotation (pRotation);
|
||||
pVPV -> SetCopyNo (n);
|
||||
pSol = pLV -> GetSolid ();
|
||||
pMaterial = pLV -> GetMaterial ();
|
||||
DescribeAndDescend (pVPV, soughtDepth, pLV, pSol, pMaterial,
|
||||
theAT, scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
pSol = pLV -> GetSolid ();
|
||||
pMaterial = pLV -> GetMaterial ();
|
||||
DescribeAndDescend (pVPV, soughtDepth, pLV, pSol, pMaterial, theAT, scene);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void G4PhysicalVolumeModel::DescribeAndDescend
|
||||
(G4VPhysicalVolume* pVPV,
|
||||
G4int soughtDepth,
|
||||
G4LogicalVolume* pLV,
|
||||
G4VSolid* pSol,
|
||||
const G4Material* pMaterial,
|
||||
const G4Transform3D& theAT,
|
||||
G4VGraphicsScene& scene) {
|
||||
|
||||
const HepRotation* pObjectRotation = pVPV -> GetObjectRotation ();
|
||||
const Hep3Vector& translation = pVPV -> GetTranslation ();
|
||||
G4Transform3D theLT = G4Transform3D (*pObjectRotation, translation);
|
||||
G4Transform3D theNewAT = theAT * theLT;
|
||||
|
||||
/********************************************************
|
||||
G4cout << "G4PhysicalVolumeModel::DescribeAndDescend: "
|
||||
<< pVPV -> GetName () << "." << pVPV -> GetCopyNo ();
|
||||
G4cout << "\n theAT: ";
|
||||
G4cout << "\n Rotation: ";
|
||||
HepRotation rotation = theAT.getRotation ();
|
||||
G4cout << rotation.thetaX() << ", "
|
||||
<< rotation.phiX() << ", "
|
||||
<< rotation.thetaY() << ", "
|
||||
<< rotation.phiY() << ", "
|
||||
<< rotation.thetaZ() << ", "
|
||||
<< rotation.phiZ();
|
||||
G4cout << "\n Translation: " << theAT.getTranslation();
|
||||
G4cout << "\n theNewAT: ";
|
||||
G4cout << "\n Rotation: ";
|
||||
rotation = theNewAT.getRotation ();
|
||||
G4cout << rotation.thetaX() << ", "
|
||||
<< rotation.phiX() << ", "
|
||||
<< rotation.thetaY() << ", "
|
||||
<< rotation.phiY() << ", "
|
||||
<< rotation.thetaZ() << ", "
|
||||
<< rotation.phiZ();
|
||||
G4cout << "\n Translation: " << theNewAT.getTranslation();
|
||||
G4cout << endl;
|
||||
**********************************************************/
|
||||
|
||||
// Make decision to Draw.
|
||||
G4bool thisToBeDrawn = !IsThisCulled (pLV, pMaterial);
|
||||
if (thisToBeDrawn) {
|
||||
scene.PreAddThis (theNewAT, *(pLV -> GetVisAttributes ()));
|
||||
pSol -> DescribeYourselfTo (scene);
|
||||
scene.PostAddThis ();
|
||||
}
|
||||
|
||||
// First check if mother covers...
|
||||
|
||||
// This is only effective in surface drawing style, and then only if
|
||||
// the volumes are visible and opaque, and then only if no sections
|
||||
// or cutways are in operation.
|
||||
G4bool cullDaughter = thisToBeDrawn && IsDaughterCulled (pLV);
|
||||
if (!(thisToBeDrawn && IsDaughterCulled (pLV))) {
|
||||
// OK, now let's check for daughters...
|
||||
if (soughtDepth != 0) {
|
||||
int nDaughters = pLV -> GetNoDaughters ();
|
||||
if (nDaughters) {
|
||||
for (int iDaughter = 0; iDaughter < nDaughters; iDaughter++) {
|
||||
G4VPhysicalVolume* pVPV = pLV -> GetDaughter (iDaughter);
|
||||
// Descend the geometry structure recursively...
|
||||
fCurrentDepth++;
|
||||
VisitGeometryAndGetVisReps (pVPV, soughtDepth - 1, theNewAT, scene);
|
||||
fCurrentDepth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PhysicalVolumeModel::IsThisCulled (const G4LogicalVolume* pLV,
|
||||
const G4Material* pMaterial) {
|
||||
// If true, cull, i.e., do not Draw.
|
||||
G4double density = pMaterial -> GetDensity ();
|
||||
const G4VisAttributes* pVisAttribs = pLV -> GetVisAttributes ();
|
||||
if (!pVisAttribs) pVisAttribs = fpMP -> GetDefaultVisAttributes ();
|
||||
if (fpMP) {
|
||||
return
|
||||
fpMP -> IsCulling () && // Global culling flag.
|
||||
(
|
||||
// Invisible volumes...
|
||||
(fpMP -> IsCullingInvisible () &&
|
||||
!(pVisAttribs ? pVisAttribs -> IsVisible () : true)) ||
|
||||
|
||||
// Low density volumes...
|
||||
(fpMP -> IsDensityCulling () &&
|
||||
(density < fpMP -> GetVisibleDensity ()))
|
||||
)
|
||||
;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PhysicalVolumeModel::IsDaughterCulled
|
||||
(const G4LogicalVolume* pMotherLV) {
|
||||
// If true, cull, i.e., do not Draw.
|
||||
const G4VisAttributes* pVisAttribs = pMotherLV -> GetVisAttributes ();
|
||||
if (!pVisAttribs) pVisAttribs = fpMP -> GetDefaultVisAttributes ();
|
||||
if (fpMP) {
|
||||
return
|
||||
fpMP -> IsCulling () // Global culling flag.
|
||||
&&
|
||||
(
|
||||
// Does mother request daughters not to be drawn?
|
||||
(pVisAttribs ? pVisAttribs -> IsDaughtersInvisible () : false)
|
||||
||
|
||||
(
|
||||
// Global covered daughter flag. This is affected by drawing
|
||||
// style, etc. The enforcing of this is done in
|
||||
// G4VScene::CreateModelingParameters ()
|
||||
fpMP -> IsCullingCovered ()
|
||||
&&
|
||||
// Cull only if mother is visible...
|
||||
(pVisAttribs ? pVisAttribs -> IsVisible () : true)
|
||||
// &&
|
||||
// true // ...and opaque (transparency parameter not yet implemented).
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
G4bool G4PhysicalVolumeModel::Validate () {
|
||||
G4VPhysicalVolume* world =
|
||||
G4TransportationManager::GetTransportationManager ()
|
||||
-> GetNavigatorForTracking () -> GetWorldVolume ();
|
||||
// The idea now is to seek a PV with the same name and copy no
|
||||
// in the hope it's the same one!!
|
||||
G4cout << "G4PhysicalVolumeModel::Validate() called." << endl;
|
||||
G4PhysicalVolumeSearchScene searchScene (fTopPVName, fTopPVCopyNo);
|
||||
G4PhysicalVolumeModel searchModel (world);
|
||||
searchModel.DescribeYourselfTo (searchScene);
|
||||
G4VPhysicalVolume* foundVolume = searchScene.GetFoundVolume ();
|
||||
if (foundVolume) {
|
||||
G4cout << " Volume of the same name and copy number (\""
|
||||
<< fTopPVName << "\", copy " << fTopPVCopyNo
|
||||
<< ") still exists and is being used."
|
||||
"\n Be warned that this does not necessarily guarantee it's the same"
|
||||
"\n volume you originally specified in /vis/scene/add/."
|
||||
<< endl;
|
||||
fpTopPV = foundVolume;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
G4cout << " A volume of the same name and copy number (\""
|
||||
<< fTopPVName << "\", copy " << fTopPVCopyNo
|
||||
<< ") no longer exists."
|
||||
<< endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4PhysicalVolumeSearchScene.cc,v 2.1 1998/08/22 16:35:06 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 10th August 1998.
|
||||
// An artificial scene to find physical volumes.
|
||||
|
||||
#include "G4PhysicalVolumeSearchScene.hh"
|
||||
|
||||
#include "G4VSolid.hh"
|
||||
#include "G4Vector3D.hh"
|
||||
#include "G4PhysicalVolumeModel.hh"
|
||||
|
||||
G4PhysicalVolumeSearchScene::G4PhysicalVolumeSearchScene
|
||||
(const G4String& requiredPhysicalVolumeName, G4int requiredCopyNo):
|
||||
fRequiredPhysicalVolumeName (requiredPhysicalVolumeName),
|
||||
fRequiredCopyNo (requiredCopyNo),
|
||||
fCurrentDepth (0),
|
||||
fpCurrentPV (0),
|
||||
fpCurrentLV (0),
|
||||
fpCurrentObjectTransformation (0),
|
||||
fFoundDepth (0),
|
||||
fpFoundPV (0),
|
||||
fpFoundLV (0),
|
||||
fMultipleOccurrence (false)
|
||||
{}
|
||||
|
||||
G4PhysicalVolumeSearchScene::~G4PhysicalVolumeSearchScene () {}
|
||||
|
||||
void G4PhysicalVolumeSearchScene::EstablishSpecials
|
||||
(G4PhysicalVolumeModel& pvModel) {
|
||||
pvModel.DefinePointersToWorkingSpace (&fCurrentDepth,
|
||||
&fpCurrentPV,
|
||||
&fpCurrentLV);
|
||||
}
|
||||
|
||||
void G4PhysicalVolumeSearchScene::FindVolume (const G4VSolid& solid) {
|
||||
/**************************************************
|
||||
G4cout << "Required volume: \"" << fRequiredPhysicalVolumeName
|
||||
<< "\", copy no. " << fRequiredCopyNo << endl;
|
||||
G4cout << "PhysicalVolume: \"" << fpCurrentPV -> GetName ()
|
||||
<< "\", copy no. " << fpCurrentPV -> GetCopyNo () << endl;
|
||||
*******************************************/
|
||||
if (fRequiredPhysicalVolumeName == fpCurrentPV -> GetName () &&
|
||||
fRequiredCopyNo == fpCurrentPV -> GetCopyNo ()) {
|
||||
// Current policy - take first one found!!
|
||||
if (!fpFoundPV) { // i.e., if not already found.
|
||||
fFoundDepth = fCurrentDepth;
|
||||
fpFoundPV = fpCurrentPV;
|
||||
fpFoundLV = fpCurrentLV;
|
||||
fFoundObjectTransformation = *fpCurrentObjectTransformation;
|
||||
}
|
||||
else {
|
||||
if (!fMultipleOccurrence) {
|
||||
fMultipleOccurrence = true;
|
||||
G4cout << "G4PhysicalVolumeSearchScene::FindVolume:"
|
||||
<< "\n Required volume: \"" << fRequiredPhysicalVolumeName
|
||||
<< "\", copy no. " << fRequiredCopyNo
|
||||
<< " 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."
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4TrajectoriesModel.cc,v 1.2 1998/08/31 15:42:18 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 26th August 1998.
|
||||
// Model which knows how to draw GEANT4 trajectories.
|
||||
|
||||
#include "G4TrajectoriesModel.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Event.hh"
|
||||
|
||||
G4TrajectoriesModel::G4TrajectoriesModel () {
|
||||
fGlobalTag = "G4TrajectoriesModel for all trajectories.";
|
||||
fGlobalDescription = fGlobalTag;
|
||||
}
|
||||
|
||||
void G4TrajectoriesModel::DescribeYourselfTo (G4VGraphicsScene& scene) {
|
||||
G4RunManager* runManager = G4RunManager::GetRunManager ();
|
||||
const G4Event* event = runManager -> GetCurrentEvent ();
|
||||
if (event) {
|
||||
G4TrajectoryContainer* TC = event -> GetTrajectoryContainer ();
|
||||
if (TC) {
|
||||
G4int nT = TC -> entries ();
|
||||
for (int iT = 0; iT < nT; iT++) {
|
||||
(*TC) [iT] -> DrawTrajectory (50);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// This code implementation is the intellectual property of
|
||||
// the RD44 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: G4VModel.cc,v 2.2 1998/08/22 16:34:30 allison Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// John Allison 31st December 1997.
|
||||
// Base class for models.
|
||||
|
||||
#include "G4VModel.hh"
|
||||
|
||||
#include "G4ModelingParameters.hh"
|
||||
|
||||
G4VModel::G4VModel (const G4Transform3D& modelTransformation,
|
||||
const G4ModelingParameters* pMP):
|
||||
fTransform (modelTransformation),
|
||||
fpMP (pMP)
|
||||
{
|
||||
fGlobalTag = "Default Global Tag";
|
||||
fGlobalDescription = "Default Global Description";
|
||||
}
|
||||
|
||||
ostream& operator << (ostream& os, const G4VModel& m) {
|
||||
os << m.fGlobalDescription;
|
||||
os << "\n Modeling parameters:";
|
||||
if (m.fpMP) {
|
||||
os << "\n " << *(m.fpMP);
|
||||
}
|
||||
else {
|
||||
os << " none.";
|
||||
}
|
||||
os << "\n Extent: " << m.fExtent;
|
||||
os << "\n Transformation: ";
|
||||
os << "\n Rotation: ";
|
||||
HepRotation rotation = m.fTransform.getRotation ();
|
||||
os << rotation.thetaX() << ", "
|
||||
<< rotation.phiX() << ", "
|
||||
<< rotation.thetaY() << ", "
|
||||
<< rotation.phiY() << ", "
|
||||
<< rotation.thetaZ() << ", "
|
||||
<< rotation.phiZ();
|
||||
os << "\n Translation: " << m.fTransform.getTranslation ();
|
||||
return os;
|
||||
}
|
||||
Reference in New Issue
Block a user