Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PartialPhantomParameterisation Class Reference

#include <G4PartialPhantomParameterisation.hh>

+ Inheritance diagram for G4PartialPhantomParameterisation:

Public Member Functions

 G4PartialPhantomParameterisation ()
 
 ~G4PartialPhantomParameterisation () override
 
void ComputeTransformation (const G4int, G4VPhysicalVolume *) const override
 
G4MaterialComputeMaterial (const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=nullptr) override
 
G4int GetReplicaNo (const G4ThreeVector &localPoint, const G4ThreeVector &localDir) override
 
G4ThreeVector GetTranslation (const G4int copyNo) const
 
std::size_t GetMaterialIndex (std::size_t nx, std::size_t ny, std::size_t nz) const
 
std::size_t GetMaterialIndex (std::size_t copyNo) const
 
G4MaterialGetMaterial (std::size_t nx, std::size_t ny, std::size_t nz) const
 
G4MaterialGetMaterial (std::size_t copyNo) const
 
void SetFilledIDs (std::multimap< G4int, G4int > fid)
 
void SetFilledMins (std::map< G4int, std::map< G4int, G4int > > fmins)
 
void BuildContainerWalls ()
 
- Public Member Functions inherited from G4PhantomParameterisation
 G4PhantomParameterisation ()
 
 ~G4PhantomParameterisation () override
 
void ComputeTransformation (const G4int, G4VPhysicalVolume *) const override
 
G4VSolidComputeSolid (const G4int, G4VPhysicalVolume *) override
 
G4MaterialComputeMaterial (const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=nullptr) override
 
void ComputeDimensions (G4Box &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Tubs &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Trd &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Trap &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Cons &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Orb &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Sphere &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Ellipsoid &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Torus &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Para &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Hype &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Polycone &, const G4int, const G4VPhysicalVolume *) const override
 
void ComputeDimensions (G4Polyhedra &, const G4int, const G4VPhysicalVolume *) const override
 
void BuildContainerSolid (G4VPhysicalVolume *pPhysicalVol)
 
void BuildContainerSolid (G4VSolid *pMotherSolid)
 
void SetMaterials (std::vector< G4Material * > &mates)
 
void SetMaterialIndices (std::size_t *matInd)
 
void SetVoxelDimensions (G4double halfx, G4double halfy, G4double halfz)
 
void SetNoVoxels (std::size_t nx, std::size_t ny, std::size_t nz)
 
G4double GetVoxelHalfX () const
 
G4double GetVoxelHalfY () const
 
G4double GetVoxelHalfZ () const
 
std::size_t GetNoVoxelsX () const
 
std::size_t GetNoVoxelsY () const
 
std::size_t GetNoVoxelsZ () const
 
std::size_t GetNoVoxels () const
 
std::vector< G4Material * > GetMaterials () const
 
std::size_t * GetMaterialIndices () const
 
G4VSolidGetContainerSolid () const
 
G4ThreeVector GetTranslation (const G4int copyNo) const
 
G4bool SkipEqualMaterials () const
 
void SetSkipEqualMaterials (G4bool skip)
 
std::size_t GetMaterialIndex (std::size_t nx, std::size_t ny, std::size_t nz) const
 
std::size_t GetMaterialIndex (std::size_t copyNo) const
 
G4MaterialGetMaterial (std::size_t nx, std::size_t ny, std::size_t nz) const
 
G4MaterialGetMaterial (std::size_t copyNo) const
 
void CheckVoxelsFillContainer (G4double contX, G4double contY, G4double contZ) const
 
- Public Member Functions inherited from G4VPVParameterisation
 G4VPVParameterisation ()=default
 
virtual ~G4VPVParameterisation ()=default
 
virtual G4bool IsNested () const
 
virtual G4VVolumeMaterialScannerGetMaterialScanner ()
 

Additional Inherited Members

- Protected Attributes inherited from G4PhantomParameterisation
G4double fVoxelHalfX = 0.0
 
G4double fVoxelHalfY = 0.0
 
G4double fVoxelHalfZ = 0.0
 
std::size_t fNoVoxelsX = 0
 
std::size_t fNoVoxelsY = 0
 
std::size_t fNoVoxelsZ = 0
 
std::size_t fNoVoxelsXY = 0
 
std::size_t fNoVoxels = 0
 
std::vector< G4Material * > fMaterials
 
std::size_t * fMaterialIndices = nullptr
 
G4VSolidfContainerSolid = nullptr
 
G4double fContainerWallX =0.0
 
G4double fContainerWallY =0.0
 
G4double fContainerWallZ =0.0
 
G4double kCarTolerance
 
G4bool bSkipEqualMaterials = true
 

Detailed Description

Definition at line 53 of file G4PartialPhantomParameterisation.hh.

Constructor & Destructor Documentation

◆ G4PartialPhantomParameterisation()

G4PartialPhantomParameterisation::G4PartialPhantomParameterisation ( )

Definition at line 44 of file G4PartialPhantomParameterisation.cc.

45{
46}

◆ ~G4PartialPhantomParameterisation()

G4PartialPhantomParameterisation::~G4PartialPhantomParameterisation ( )
overridedefault

Member Function Documentation

◆ BuildContainerWalls()

◆ ComputeMaterial()

G4Material * G4PartialPhantomParameterisation::ComputeMaterial ( const G4int repNo,
G4VPhysicalVolume * currentVol,
const G4VTouchable * parentTouch = nullptr )
overridevirtual

Reimplemented from G4VPVParameterisation.

Definition at line 80 of file G4PartialPhantomParameterisation.cc.

82{
83 CheckCopyNo( copyNo );
84 auto matIndex = GetMaterialIndex(copyNo);
85
86 return fMaterials[ matIndex ];
87}
std::size_t GetMaterialIndex(std::size_t nx, std::size_t ny, std::size_t nz) const
std::vector< G4Material * > fMaterials

◆ ComputeTransformation()

void G4PartialPhantomParameterisation::ComputeTransformation ( const G4int copyNo,
G4VPhysicalVolume * physVol ) const
overridevirtual

Implements G4VPVParameterisation.

Definition at line 53 of file G4PartialPhantomParameterisation.cc.

55{
56 // Voxels cannot be rotated, return translation
57 //
58 G4ThreeVector trans = GetTranslation( copyNo );
59 physVol->SetTranslation( trans );
60}
G4ThreeVector GetTranslation(const G4int copyNo) const
void SetTranslation(const G4ThreeVector &v)

◆ GetMaterial() [1/2]

G4Material * G4PartialPhantomParameterisation::GetMaterial ( std::size_t copyNo) const

Definition at line 120 of file G4PartialPhantomParameterisation.cc.

122{
123 return fMaterials[GetMaterialIndex(copyNo)];
124}

◆ GetMaterial() [2/2]

G4Material * G4PartialPhantomParameterisation::GetMaterial ( std::size_t nx,
std::size_t ny,
std::size_t nz ) const

Definition at line 112 of file G4PartialPhantomParameterisation.cc.

114{
115 return fMaterials[GetMaterialIndex(nx,ny,nz)];
116}

◆ GetMaterialIndex() [1/2]

size_t G4PartialPhantomParameterisation::GetMaterialIndex ( std::size_t copyNo) const

Definition at line 91 of file G4PartialPhantomParameterisation.cc.

93{
94 CheckCopyNo( copyNo );
95
96 if( fMaterialIndices == nullptr ) { return 0; }
97
98 return *(fMaterialIndices+copyNo);
99}

◆ GetMaterialIndex() [2/2]

size_t G4PartialPhantomParameterisation::GetMaterialIndex ( std::size_t nx,
std::size_t ny,
std::size_t nz ) const

Definition at line 103 of file G4PartialPhantomParameterisation.cc.

105{
106 std::size_t copyNo = nx + fNoVoxelsX*ny + fNoVoxelsXY*nz;
107 return GetMaterialIndex( copyNo );
108}

Referenced by ComputeMaterial(), GetMaterial(), GetMaterial(), and GetMaterialIndex().

◆ GetReplicaNo()

G4int G4PartialPhantomParameterisation::GetReplicaNo ( const G4ThreeVector & localPoint,
const G4ThreeVector & localDir )
overridevirtual

Reimplemented from G4PhantomParameterisation.

Definition at line 156 of file G4PartialPhantomParameterisation.cc.

158{
159 // Check the voxel numbers corresponding to localPoint
160 // When a particle is on a surface, it may be between -kCarTolerance and
161 // +kCartolerance. By a simple distance as:
162 // G4int nx = G4int( (localPoint.x()+)/fVoxelHalfX/2.);
163 // those between -kCartolerance and 0 will be placed on voxel N-1 and those
164 // between 0 and kCarTolerance on voxel N.
165 // To avoid precision problems place the tracks that are on the surface on
166 // voxel N-1 if they have negative direction and on voxel N if they have
167 // positive direction.
168 // Add +kCarTolerance so that they are first placed on voxel N, and then
169 // if the direction is negative substract 1
170
171 G4double fx = (localPoint.x()+fContainerWallX+kCarTolerance)/(fVoxelHalfX*2.);
172 auto nx = G4int(fx);
173
174 G4double fy = (localPoint.y()+fContainerWallY+kCarTolerance)/(fVoxelHalfY*2.);
175 auto ny = G4int(fy);
176
177 G4double fz = (localPoint.z()+fContainerWallZ+kCarTolerance)/(fVoxelHalfZ*2.);
178 auto nz = G4int(fz);
179
180 // If it is on the surface side, check the direction: if direction is
181 // negative place it on the previous voxel (if direction is positive it is
182 // already in the next voxel...).
183 // Correct also cases where n = -1 or n = fNoVoxels. It is always traced to be
184 // due to multiple scattering: track is entering a voxel but multiple
185 // scattering changes the angle towards outside
186 //
187 if( fx - nx < kCarTolerance/fVoxelHalfX )
188 {
189 if( localDir.x() < 0 )
190 {
191 if( nx != 0 )
192 {
193 nx -= 1;
194 }
195 }
196 else
197 {
198 if( nx == G4int(fNoVoxelsX) )
199 {
200 nx -= 1;
201 }
202 }
203 }
204 if( fy - ny < kCarTolerance/fVoxelHalfY )
205 {
206 if( localDir.y() < 0 )
207 {
208 if( ny != 0 )
209 {
210 ny -= 1;
211 }
212 }
213 else
214 {
215 if( ny == G4int(fNoVoxelsY) )
216 {
217 ny -= 1;
218 }
219 }
220 }
221 if( fz - nz < kCarTolerance/fVoxelHalfZ )
222 {
223 if( localDir.z() < 0 )
224 {
225 if( nz != 0 )
226 {
227 nz -= 1;
228 }
229 }
230 else
231 {
232 if( nz == G4int(fNoVoxelsZ) )
233 {
234 nz -= 1;
235 }
236 }
237 }
238
239 // Check if there are still errors
240 //
241 G4bool isOK = true;
242 if( nx < 0 )
243 {
244 nx = 0;
245 isOK = false;
246 }
247 else if( nx >= G4int(fNoVoxelsX) )
248 {
249 nx = G4int(fNoVoxelsX)-1;
250 isOK = false;
251 }
252 if( ny < 0 )
253 {
254 ny = 0;
255 isOK = false;
256 }
257 else if( ny >= G4int(fNoVoxelsY) )
258 {
259 ny = G4int(fNoVoxelsY)-1;
260 isOK = false;
261 }
262 if( nz < 0 )
263 {
264 nz = 0;
265 isOK = false;
266 }
267 else if( nz >= G4int(fNoVoxelsZ) )
268 {
269 nz = G4int(fNoVoxelsZ)-1;
270 isOK = false;
271 }
272 if( !isOK )
273 {
274 std::ostringstream message;
275 message << "Corrected the copy number! It was negative or too big."
276 << G4endl
277 << " LocalPoint: " << localPoint << G4endl
278 << " LocalDir: " << localDir << G4endl
279 << " Voxel container size: " << fContainerWallX
280 << " " << fContainerWallY << " " << fContainerWallZ << G4endl
281 << " LocalPoint - wall: "
282 << localPoint.x()-fContainerWallX << " "
283 << localPoint.y()-fContainerWallY << " "
284 << localPoint.z()-fContainerWallZ;
285 G4Exception("G4PartialPhantomParameterisation::GetReplicaNo()",
286 "GeomNav1002", JustWarning, message);
287 }
288
289 auto nyz = G4int(nz*fNoVoxelsY+ny);
290 auto ite = fFilledIDs.cbegin();
291/*
292 for( ite = fFilledIDs.cbegin(); ite != fFilledIDs.cend(); ++ite )
293 {
294 G4cout << " G4PartialPhantomParameterisation::GetReplicaNo filled "
295 << (*ite).first << " , " << (*ite).second << std::endl;
296 }
297*/
298
299 advance(ite,nyz);
300 auto iteant = ite; iteant--;
301 G4int copyNo = (*iteant).first + 1 + ( nx - (*ite).second );
302/*
303 G4cout << " G4PartialPhantomParameterisation::GetReplicaNo getting copyNo "
304 << copyNo << " nyz " << nyz << " (*iteant).first "
305 << (*iteant).first << " (*ite).second " << (*ite).second << G4endl;
306
307 G4cout << " G4PartialPhantomParameterisation::GetReplicaNo " << copyNo
308 << " nx " << nx << " ny " << ny << " nz " << nz
309 << " localPoint " << localPoint << " localDir " << localDir << G4endl;
310*/
311 return copyNo;
312}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
double z() const
double x() const
double y() const

◆ GetTranslation()

G4ThreeVector G4PartialPhantomParameterisation::GetTranslation ( const G4int copyNo) const

Definition at line 64 of file G4PartialPhantomParameterisation.cc.

66{
67 CheckCopyNo( copyNo );
68
69 std::size_t nx, ny, nz;
70 ComputeVoxelIndices( copyNo, nx, ny, nz );
71
74 (2*nz+1)*fVoxelHalfZ - fContainerWallZ);
75 return trans;
76}

Referenced by ComputeTransformation().

◆ SetFilledIDs()

void G4PartialPhantomParameterisation::SetFilledIDs ( std::multimap< G4int, G4int > fid)
inline

Definition at line 79 of file G4PartialPhantomParameterisation.hh.

80 {
81 fFilledIDs = std::move(fid);
82 }

◆ SetFilledMins()

void G4PartialPhantomParameterisation::SetFilledMins ( std::map< G4int, std::map< G4int, G4int > > fmins)
inline

Definition at line 84 of file G4PartialPhantomParameterisation.hh.

85 {
86 fFilledMins = std::move(fmins);
87 }

The documentation for this class was generated from the following files: