Are ComputeTransformation and ComputeDimensions ommitable?

I am using the ICRP 145 whole body phantom as expressed via tetrahedral solids. Geant4 version is 10.05.p01

The ICRP publication came with a Geant4 example where all tetrahedral vertices positions and materials are loaded in vectors and there is also a vector that holds G4Tet solids made using said vertices. Vertices are relative to the world volume so it seems that to position the G4Tets one must not translate them or rotate them because all that info is in the vertices.

Now the parameterisation class has an empty ( { } ) ComputeTransformation, no ComputeDimensions but ComputeSolid returns a G4Tet from the G4Tet vector mentioned above and the ComputeMaterial returns the material from the material vector mentioned above.

Does that work? The Geant4 manual says that ComputeTransformation and ComputeDimension MUST be used. But as I see it, if ComputeSolid is called after them and it returns a G4Tet, then physical positioning requires no translation/rotation and also makes the ComputeDimension obsolete.

The example is said to take 35GB of memory when run so I want to first make sure that at least it makes sense before I run it. It compiles just fine though. Find the methods below.

In the .hh file class TETParameterisation : public G4VPVParameterisation
_tetData holds the vectors mentioned above

TETParameterisation.cc

#include "TETParameterisation.hh"
#include "G4LogicalVolume.hh"
#include "G4VisExecutive.hh"
#include "G4RunManager.hh"

TETParameterisation::TETParameterisation(TETModelImport* _tetData)
: G4VPVParameterisation(), tetData(_tetData)
{
	// initialise visAttMap which contains G4VisAttributes* for each organ
	auto colourMap =  tetData->GetColourMap();
	for(auto colour : colourMap){
		visAttMap[colour.first] = new G4VisAttributes(colour.second);
	}

	if(colourMap.size()) isforVis = true;
	else                 isforVis = false;
}

TETParameterisation::~TETParameterisation()
{}

G4VSolid* TETParameterisation::ComputeSolid(
    		       const G4int copyNo, G4VPhysicalVolume* )
{
	// return G4Tet*
	return tetData->GetTetrahedron(copyNo);
}

void TETParameterisation::ComputeTransformation(
                   const G4int,G4VPhysicalVolume*) const
{}

G4Material* TETParameterisation::ComputeMaterial(const G4int copyNo,
                                                 G4VPhysicalVolume* phy,
                                                 const G4VTouchable* )
{
   // set the colour for each organ if visualization is required
	if(isforVis){
		G4int idx = tetData->GetMaterialIndex(copyNo);
		phy->GetLogicalVolume()->SetVisAttributes(visAttMap[idx]);
	}

	// return the material data for each material index
	return tetData->GetMaterial(tetData->GetMaterialIndex(copyNo));
}

Not in answer to your question at all, but in general you don’t need to copy stuff - just use a reference:

	const auto& colourMap =  tetData->GetColourMap();
	for(const auto& colour : colourMap){

Otherwise you’re copying a lot of stuff about.

1 Like