Import Geant4 9.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 16:15:05 +02:00
parent b79225fb37
commit 74cad5e589
3877 changed files with 234205 additions and 167127 deletions
@@ -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: G4PSHitsModel.cc,v 1.4 2009/11/04 12:44:39 allison Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// Created: Mar. 31, 2009 Akinori Kimura
// Model which draws the primtive scorer hits.
//
#include "G4PSHitsModel.hh"
#include "G4ModelingParameters.hh"
#include "G4VGraphicsScene.hh"
#include "G4Event.hh"
#include "G4ScoringManager.hh"
G4PSHitsModel::~G4PSHitsModel () {}
G4PSHitsModel::G4PSHitsModel (const G4String& requestedMapName):
fRequestedMapName(requestedMapName), fpCurrentHits(0)
{
fGlobalTag = "G4PSHitsModel for G4THitsMap<G4double> hits.";
fGlobalDescription = fGlobalTag;
}
void G4PSHitsModel::DescribeYourselfTo (G4VGraphicsScene& sceneHandler)
{
G4ScoringManager* scoringManager =
G4ScoringManager::GetScoringManagerIfExist();
if (scoringManager) {
size_t nMeshes = scoringManager->GetNumberOfMesh();
for (size_t i = 0; i < nMeshes; ++i) {
G4VScoringMesh* mesh = scoringManager->GetMesh(i);
if (mesh && mesh->IsActive()) {
MeshScoreMap scoreMap = mesh->GetScoreMap();
for(MeshScoreMap::const_iterator i = scoreMap.begin();
i != scoreMap.end(); ++i) {
const G4String& name = i->first;
if (fRequestedMapName == "all" || name == fRequestedMapName) {
fpCurrentHits = i->second;
//G4cout << name << ": " << fpCurrentHits << G4endl;
if (fpCurrentHits) sceneHandler.AddCompound(*fpCurrentHits);
}
}
}
}
}
}
@@ -24,8 +24,8 @@
// ********************************************************************
//
//
// $Id: G4PhysicalVolumeModel.cc,v 1.63 2007/11/10 14:56:36 allison Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4PhysicalVolumeModel.cc,v 1.66 2009/10/23 08:08:19 allison Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
//
// John Allison 31st December 1997.
@@ -45,6 +45,7 @@
#include "G4PhysicalVolumeSearchScene.hh"
#include "G4TransportationManager.hh"
#include "G4Polyhedron.hh"
#include "HepPolyhedronProcessor.h"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttValue.hh"
@@ -53,32 +54,6 @@
#include <sstream>
G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
(const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& right) const
{
if (fpPV < right.fpPV) return true;
if (fpPV == right.fpPV) {
if (fCopyNo < right.fCopyNo) return true;
if (fCopyNo == right.fCopyNo)
return fNonCulledDepth < right.fNonCulledDepth;
}
return false;
}
std::ostream& operator<<
(std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID node)
{
G4VPhysicalVolume* pPV = node.GetPhysicalVolume();
if (pPV) {
os << pPV->GetName()
<< ':' << node.GetCopyNo()
<< '[' << node.GetNonCulledDepth() << ']';
} else {
os << "Null node";
}
return os;
}
G4PhysicalVolumeModel::G4PhysicalVolumeModel
(G4VPhysicalVolume* pVPV,
G4int requestedDepth,
@@ -231,12 +206,17 @@ void G4PhysicalVolumeModel::VisitGeometryAndGetVisReps
pVPV -> GetReplicationData (axis, nReplicas, width, offset, consuming);
G4VPVParameterisation* pP = pVPV -> GetParameterisation ();
if (pP) { // Parametrised volume.
if (fCurrentDepth == 0) nReplicas = 1; // Just draw first
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);
// Create a touchable of current parent for ComputeMaterial.
// fFullPVPath has not been updated yet so at this point it
// corresponds to the parent.
G4PhysicalVolumeModelTouchable parentTouchable(fFullPVPath);
pMaterial = pP -> ComputeMaterial (n, pVPV, &parentTouchable);
DescribeAndDescend (pVPV, requestedDepth, pLV, pSol, pMaterial,
theAT, sceneHandler);
}
@@ -362,32 +342,6 @@ void G4PhysicalVolumeModel::DescribeAndDescend
if (fCurrentDepth != 0) theNewAT = theAT * theLT;
fpCurrentTransform = &theNewAT;
/********************************************************
G4cout << "G4PhysicalVolumeModel::DescribeAndDescend: "
<< pVPV -> GetName () << "." << pVPV -> GetCopyNo ();
G4cout << "\n theAT: ";
G4cout << "\n Rotation: ";
G4RotationMatrix 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 << G4endl;
**********************************************************/
// Make decision to draw...
const G4VisAttributes* pVisAttribs = pLV->GetVisAttributes();
if (!pVisAttribs) pVisAttribs = fpMP->GetDefaultVisAttributes();
@@ -428,14 +382,16 @@ void G4PhysicalVolumeModel::DescribeAndDescend
// Update full path of physical volumes...
G4int copyNo = fpCurrentPV->GetCopyNo();
fFullPVPath.push_back
(G4PhysicalVolumeNodeID(fpCurrentPV,copyNo,fCurrentDepth));
(G4PhysicalVolumeNodeID
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
if (thisToBeDrawn) {
// Update path of drawn physical volumes...
G4int copyNo = fpCurrentPV->GetCopyNo();
fDrawnPVPath.push_back
(G4PhysicalVolumeNodeID(fpCurrentPV,copyNo,fCurrentDepth));
(G4PhysicalVolumeNodeID
(fpCurrentPV,copyNo,fCurrentDepth,*fpCurrentTransform));
if (fpMP->IsExplode() && fDrawnPVPath.size() == 1) {
// For top-level drawn volumes, explode along radius...
@@ -562,69 +518,82 @@ void G4PhysicalVolumeModel::DescribeSolid
G4Polyhedron::SetNumberOfRotationSteps(fpMP->GetNoOfSides());
G4Polyhedron* pOriginal = pSol->GetPolyhedron();
G4Polyhedron::ResetNumberOfRotationSteps();
if (!pOriginal) {
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
<< pSol->GetName() <<
"\" has no polyhedron. Cannot by clipped."
<< G4endl;
pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment.
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: solid\n \""
<< pSol->GetName() <<
"\" has no polyhedron. Cannot by clipped."
<< G4endl;
pSol -> DescribeYourselfTo (sceneHandler); // Standard treatment.
} else {
G4Polyhedron resultant = *pOriginal;
G4VisAttributes resultantVisAttribs(*pVisAttribs);
if (fpClippingPolyhedron) {
G4Polyhedron clipper = *fpClippingPolyhedron; // Local copy.
clipper.Transform(theAT.inverse());
HepPolyhedronProcessor processor;
switch (fClippingMode) {
default:
case subtraction: resultant = resultant.subtract(clipper); break;
case intersection: resultant = resultant.intersect(clipper); break;
case subtraction: processor.push_back(HepPolyhedronProcessor::SUBTRACTION, clipper); break;
case intersection: processor.push_back(HepPolyhedronProcessor::INTERSECTION, clipper); break;
}
if(resultant.IsErrorBooleanProcess()) {
if (!processor.execute(resultant)) {
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: clipped polyhedron for"
"\n solid \"" << pSol->GetName() <<
"\" not defined due to error during Boolean processing."
"\n It will be drawn in red."
<< G4endl;
// Nevertheless, keep resultant.
// Nevertheless, keep resultant, but draw it in red
resultantVisAttribs.SetColour(G4Colour::Red());
}
}
if (pSectionPolyhedron) {
G4Polyhedron sectioner = *pSectionPolyhedron; // Local copy.
sectioner.Transform(theAT.inverse());
resultant = resultant.intersect(sectioner);
if(resultant.IsErrorBooleanProcess()) {
HepPolyhedronProcessor processor;
processor.push_back(HepPolyhedronProcessor::INTERSECTION, sectioner);
if (!processor.execute(resultant)) {
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: sectioned polyhedron for"
"\n solid \"" << pSol->GetName() <<
"\" not defined due to error during Boolean processing."
"\n It will be drawn in red."
<< G4endl;
// Nevertheless, keep resultant.
// Nevertheless, keep resultant, but draw it in red
resultantVisAttribs.SetColour(G4Colour::Red());
}
}
if (pCutawayPolyhedron) {
G4Polyhedron cutter = *pCutawayPolyhedron; // Local copy.
cutter.Transform(theAT.inverse());
resultant = resultant.subtract(cutter);
if(resultant.IsErrorBooleanProcess()) {
HepPolyhedronProcessor processor;
processor.push_back(HepPolyhedronProcessor::SUBTRACTION, cutter);
if (!processor.execute(resultant)) {
if (fpMP->IsWarning())
G4cout <<
"WARNING: G4PhysicalVolumeModel::DescribeSolid: cutaway polyhedron for"
"\n solid \"" << pSol->GetName() <<
"\" not defined due to error during Boolean processing."
"\n It will be drawn in red."
<< G4endl;
// Nevertheless, keep resultant.
// Nevertheless, keep resultant, but draw it in red
resultantVisAttribs.SetColour(G4Colour::Red());
}
}
// Finally, force polyhedron drawing...
resultant.SetVisAttributes(pVisAttribs);
resultant.SetVisAttributes(resultantVisAttribs);
sceneHandler.BeginPrimitives(theAT);
sceneHandler.AddPrimitive(resultant);
sceneHandler.EndPrimitives();
@@ -759,6 +728,16 @@ std::vector<G4AttValue>* G4PhysicalVolumeModel::CreateCurrentAttValues() const
<< ':' << fFullPVPath[i].GetCopyNo();
if (i != fFullPVPath.size() - 1) oss << '/';
}
if (!fpCurrentLV) {
G4Exception
("G4PhysicalVolumeModel::CreateCurrentAttValues",
"",
JustWarning,
"Current logical volume not defined.");
return values;
}
values->push_back(G4AttValue("PVPath", oss.str(),""));
values->push_back(G4AttValue("LVol", fpCurrentLV->GetName(),""));
G4VSolid* pSol = fpCurrentLV->GetSolid();
@@ -784,3 +763,98 @@ std::vector<G4AttValue>* G4PhysicalVolumeModel::CreateCurrentAttValues() const
values->push_back(G4AttValue("RootRegion", oss.str(),""));
return values;
}
G4bool G4PhysicalVolumeModel::G4PhysicalVolumeNodeID::operator<
(const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID& right) const
{
if (fpPV < right.fpPV) return true;
if (fpPV == right.fpPV) {
if (fCopyNo < right.fCopyNo) return true;
if (fCopyNo == right.fCopyNo)
return fNonCulledDepth < right.fNonCulledDepth;
}
return false;
}
std::ostream& operator<<
(std::ostream& os, const G4PhysicalVolumeModel::G4PhysicalVolumeNodeID node)
{
G4VPhysicalVolume* pPV = node.GetPhysicalVolume();
if (pPV) {
os << pPV->GetName()
<< ':' << node.GetCopyNo()
<< '[' << node.GetNonCulledDepth() << ']'
<< ':' << node.GetTransform();
} else {
os << "Null node";
}
return os;
}
G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::G4PhysicalVolumeModelTouchable
(const std::vector<G4PhysicalVolumeNodeID>& fullPVPath):
fFullPVPath(fullPVPath) {}
const G4ThreeVector& G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetTranslation(G4int depth) const
{
size_t i = fFullPVPath.size() - depth - 1;
if (i >= fFullPVPath.size()) {
G4Exception("G4PhysicalVolumeModelTouchable::GetTranslation",
"Index out of range",
FatalErrorInArgument,
"Asking for non-existent depth");
}
static G4ThreeVector tempTranslation;
tempTranslation = fFullPVPath[i].GetTransform().getTranslation();
return tempTranslation;
}
const G4RotationMatrix* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetRotation(G4int depth) const
{
size_t i = fFullPVPath.size() - depth - 1;
if (i >= fFullPVPath.size()) {
G4Exception("G4PhysicalVolumeModelTouchable::GetRotation",
"Index out of range",
FatalErrorInArgument,
"Asking for non-existent depth");
}
static G4RotationMatrix tempRotation;
tempRotation = fFullPVPath[i].GetTransform().getRotation();
return &tempRotation;
}
G4VPhysicalVolume* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetVolume(G4int depth) const
{
size_t i = fFullPVPath.size() - depth - 1;
if (i >= fFullPVPath.size()) {
G4Exception("G4PhysicalVolumeModelTouchable::GetVolume",
"Index out of range",
FatalErrorInArgument,
"Asking for non-existent depth");
}
return fFullPVPath[i].GetPhysicalVolume();
}
G4VSolid* G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetSolid(G4int depth) const
{
size_t i = fFullPVPath.size() - depth - 1;
if (i >= fFullPVPath.size()) {
G4Exception("G4PhysicalVolumeModelTouchable::GetSolid",
"Index out of range",
FatalErrorInArgument,
"Asking for non-existent depth");
}
return fFullPVPath[i].GetPhysicalVolume()->GetLogicalVolume()->GetSolid();
}
G4int G4PhysicalVolumeModel::G4PhysicalVolumeModelTouchable::GetReplicaNumber(G4int depth) const
{
size_t i = fFullPVPath.size() - depth - 1;
if (i >= fFullPVPath.size()) {
G4Exception("G4PhysicalVolumeModelTouchable::GetReplicaNumber",
"Index out of range",
FatalErrorInArgument,
"Asking for non-existent depth");
}
return fFullPVPath[i].GetCopyNo();
}
@@ -23,8 +23,8 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4TrajectoryDrawerUtils.cc,v 1.11 2007/05/30 08:56:55 allison Exp $
// GEANT4 tag $Name: geant4-09-02 $
// $Id: G4TrajectoryDrawerUtils.cc,v 1.12 2009/02/24 12:00:56 allison Exp $
// GEANT4 tag $Name: geant4-09-03 $
//
// Jane Tinslay, John Allison, Joseph Perl November 2005
//
@@ -253,7 +253,7 @@ namespace G4TrajectoryDrawerUtils {
if (myContext.GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
auxiliaryPoints.SetMarkerType(myContext.GetAuxPtsType());
auxiliaryPoints.SetScreenSize(myContext.GetAuxPtsSize());
auxiliaryPoints.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
auxiliaryPoints.SetFillStyle(myContext.GetAuxPtsFillStyle());
G4VisAttributes auxiliaryPointsAttribs(myContext.GetAuxPtsColour());
@@ -265,7 +265,7 @@ namespace G4TrajectoryDrawerUtils {
if (myContext.GetDrawStepPts() && (stepPoints.size() > 0)) {
stepPoints.SetMarkerType(myContext.GetStepPtsType());
stepPoints.SetScreenSize(myContext.GetStepPtsSize());
stepPoints.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
stepPoints.SetFillStyle(myContext.GetStepPtsFillStyle());
G4VisAttributes stepPointsAttribs(myContext.GetStepPtsColour());
@@ -312,7 +312,7 @@ namespace G4TrajectoryDrawerUtils {
G4Polymarker point;
point.push_back(auxiliaryPoints[i]);
point.SetMarkerType(myContext.GetAuxPtsType());
point.SetScreenSize(myContext.GetAuxPtsSize());
point.SetSize(myContext.GetAuxPtsSizeType(), myContext.GetAuxPtsSize());
point.SetFillStyle(myContext.GetAuxPtsFillStyle());
auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
@@ -329,7 +329,7 @@ namespace G4TrajectoryDrawerUtils {
G4Polymarker point;
point.push_back(stepPoints[i]);
point.SetMarkerType(myContext.GetStepPtsType());
point.SetScreenSize(myContext.GetStepPtsSize());
point.SetSize(myContext.GetStepPtsSizeType(), myContext.GetStepPtsSize());
point.SetFillStyle(myContext.GetStepPtsFillStyle());
stepPointsAttribs.SetStartTime(stepPointTimes[i]);
stepPointsAttribs.SetEndTime(stepPointTimes[i]);
@@ -34,12 +34,14 @@ G4VisTrajContext::G4VisTrajContext(const G4String& name)
,fDrawAuxPts(false)
,fAuxPtsType(G4Polymarker::squares)
,fAuxPtsSize(2)
,fAuxPtsSizeType(G4VMarker::screen)
,fAuxPtsFillStyle(G4VMarker::filled)
,fAuxPtsColour(G4Colour::Magenta())
,fAuxPtsVisible(true)
,fDrawStepPts(false)
,fStepPtsType(G4Polymarker::circles)
,fStepPtsSize(2)
,fStepPtsSizeType(G4VMarker::screen)
,fStepPtsFillStyle(G4VMarker::filled)
,fStepPtsColour(G4Colour::Yellow())
,fStepPtsVisible(true)