G4PartialPhantomParameterisation Class Reference

#include <G4PartialPhantomParameterisation.hh>

Inheritance diagram for G4PartialPhantomParameterisation:

G4PhantomParameterisation G4VPVParameterisation

Public Member Functions

 G4PartialPhantomParameterisation ()
 ~G4PartialPhantomParameterisation ()
void ComputeTransformation (const G4int, G4VPhysicalVolume *) const
G4MaterialComputeMaterial (const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
G4int GetReplicaNo (const G4ThreeVector &localPoint, const G4ThreeVector &localDir)
G4ThreeVector GetTranslation (const G4int copyNo) const
size_t GetMaterialIndex (size_t nx, size_t ny, size_t nz) const
size_t GetMaterialIndex (size_t copyNo) const
G4MaterialGetMaterial (size_t nx, size_t ny, size_t nz) const
G4MaterialGetMaterial (size_t copyNo) const
void SetFilledIDs (std::multimap< G4int, G4int > fid)
void SetFilledMins (std::map< G4int, std::map< G4int, G4int > > fmins)
void BuildContainerWalls ()

Detailed Description

Definition at line 57 of file G4PartialPhantomParameterisation.hh.


Constructor & Destructor Documentation

G4PartialPhantomParameterisation::G4PartialPhantomParameterisation (  ) 

Definition at line 49 of file G4PartialPhantomParameterisation.cc.

00050   : G4PhantomParameterisation()
00051 {
00052 }

G4PartialPhantomParameterisation::~G4PartialPhantomParameterisation (  ) 

Definition at line 56 of file G4PartialPhantomParameterisation.cc.

00057 {
00058 }


Member Function Documentation

void G4PartialPhantomParameterisation::BuildContainerWalls (  ) 

Definition at line 340 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fContainerWallX, G4PhantomParameterisation::fContainerWallY, G4PhantomParameterisation::fContainerWallZ, G4PhantomParameterisation::fNoVoxelX, G4PhantomParameterisation::fNoVoxelY, G4PhantomParameterisation::fNoVoxelZ, G4PhantomParameterisation::fVoxelHalfX, G4PhantomParameterisation::fVoxelHalfY, and G4PhantomParameterisation::fVoxelHalfZ.

G4Material * G4PartialPhantomParameterisation::ComputeMaterial ( const G4int  repNo,
G4VPhysicalVolume currentVol,
const G4VTouchable parentTouch = 0 
) [virtual]

Reimplemented from G4PhantomParameterisation.

Definition at line 91 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fMaterials, and GetMaterialIndex().

00092 { 
00093   CheckCopyNo( copyNo );
00094   size_t matIndex = GetMaterialIndex(copyNo);
00095 
00096   return fMaterials[ matIndex ];
00097 }

void G4PartialPhantomParameterisation::ComputeTransformation ( const   G4int,
G4VPhysicalVolume  
) const [virtual]

Reimplemented from G4PhantomParameterisation.

Definition at line 62 of file G4PartialPhantomParameterisation.cc.

References GetTranslation(), and G4VPhysicalVolume::SetTranslation().

00063 {
00064   // Voxels cannot be rotated, return translation
00065   //
00066   G4ThreeVector trans = GetTranslation( copyNo );
00067   physVol->SetTranslation( trans );
00068 }

G4Material * G4PartialPhantomParameterisation::GetMaterial ( size_t  copyNo  )  const

Reimplemented from G4PhantomParameterisation.

Definition at line 131 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fMaterials, and GetMaterialIndex().

00132 {
00133   return fMaterials[GetMaterialIndex(copyNo)];
00134 }

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

Reimplemented from G4PhantomParameterisation.

Definition at line 123 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fMaterials, and GetMaterialIndex().

00124 {
00125   return fMaterials[GetMaterialIndex(nx,ny,nz)];
00126 }

size_t G4PartialPhantomParameterisation::GetMaterialIndex ( size_t  copyNo  )  const

Reimplemented from G4PhantomParameterisation.

Definition at line 102 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fMaterialIndices.

00103 {
00104   CheckCopyNo( copyNo );
00105 
00106   if( !fMaterialIndices ) { return 0; }
00107 
00108   return *(fMaterialIndices+copyNo);
00109 }

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

Reimplemented from G4PhantomParameterisation.

Definition at line 114 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fNoVoxelX, and G4PhantomParameterisation::fNoVoxelXY.

Referenced by ComputeMaterial(), and GetMaterial().

00115 {
00116   size_t copyNo = nx + fNoVoxelX*ny + fNoVoxelXY*nz;
00117   return GetMaterialIndex( copyNo );
00118 }

G4int G4PartialPhantomParameterisation::GetReplicaNo ( const G4ThreeVector localPoint,
const G4ThreeVector localDir 
) [virtual]

Reimplemented from G4PhantomParameterisation.

Definition at line 165 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fContainerWallX, G4PhantomParameterisation::fContainerWallY, G4PhantomParameterisation::fContainerWallZ, G4PhantomParameterisation::fNoVoxelX, G4PhantomParameterisation::fNoVoxelY, G4PhantomParameterisation::fNoVoxelZ, G4PhantomParameterisation::fVoxelHalfX, G4PhantomParameterisation::fVoxelHalfY, G4PhantomParameterisation::fVoxelHalfZ, G4endl, G4Exception(), JustWarning, and G4PhantomParameterisation::kCarTolerance.

00166 {
00167   // Check the voxel numbers corresponding to localPoint
00168   // When a particle is on a surface, it may be between -kCarTolerance and
00169   // +kCartolerance. By a simple distance as:
00170   //   G4int nx = G4int( (localPoint.x()+)/fVoxelHalfX/2.);
00171   // those between -kCartolerance and 0 will be placed on voxel N-1 and those
00172   // between 0 and kCarTolerance on voxel N.
00173   // To avoid precision problems place the tracks that are on the surface on
00174   // voxel N-1 if they have negative direction and on voxel N if they have
00175   // positive direction.
00176   // Add +kCarTolerance so that they are first placed on voxel N, and then
00177   // if the direction is negative substract 1
00178 
00179   G4double fx = (localPoint.x()+fContainerWallX+kCarTolerance)/(fVoxelHalfX*2.);
00180   G4int nx = G4int(fx);
00181 
00182   G4double fy = (localPoint.y()+fContainerWallY+kCarTolerance)/(fVoxelHalfY*2.);
00183   G4int ny = G4int(fy);
00184 
00185   G4double fz = (localPoint.z()+fContainerWallZ+kCarTolerance)/(fVoxelHalfZ*2.);
00186   G4int nz = G4int(fz);
00187 
00188   // If it is on the surface side, check the direction: if direction is
00189   // negative place it on the previous voxel (if direction is positive it is
00190   // already in the next voxel...). 
00191   // Correct also cases where n = -1 or n = fNoVoxel. It is always traced to be
00192   // due to multiple scattering: track is entering a voxel but multiple
00193   // scattering changes the angle towards outside
00194   //
00195   if( fx - nx < kCarTolerance/fVoxelHalfX )
00196   {
00197     if( localDir.x() < 0 )
00198     {
00199       if( nx != 0 )
00200       {
00201         nx -= 1;
00202       }
00203     }
00204     else
00205     {
00206       if( nx == G4int(fNoVoxelX) )  
00207       {
00208         nx -= 1;       
00209       }
00210     }
00211   }
00212   if( fy - ny < kCarTolerance/fVoxelHalfY )
00213   {
00214     if( localDir.y() < 0 )
00215     {
00216       if( ny != 0 )
00217       {
00218         ny -= 1;
00219       }
00220     }
00221     else
00222     {
00223       if( ny == G4int(fNoVoxelY) )  
00224       {
00225         ny -= 1;       
00226       }
00227     }
00228   }
00229   if( fz - nz < kCarTolerance/fVoxelHalfZ )
00230   {
00231     if( localDir.z() < 0 )
00232     {
00233       if( nz != 0 )
00234       {
00235         nz -= 1;
00236       }
00237     }
00238     else
00239     {
00240       if( nz == G4int(fNoVoxelZ) )  
00241       {
00242         nz -= 1;       
00243       }
00244     }
00245   }
00246   
00247   // Check if there are still errors 
00248   //
00249   G4bool isOK = true;
00250   if( nx < 0 )
00251   {
00252     nx = 0;
00253     isOK = false;
00254   }
00255   else if( nx >= G4int(fNoVoxelX) )
00256   {
00257     nx = fNoVoxelX-1;
00258     isOK = false;
00259   }
00260   if( ny < 0 )
00261   {
00262     ny = 0;
00263     isOK = false;
00264   }
00265   else if( ny >= G4int(fNoVoxelY) )
00266   {
00267     ny = fNoVoxelY-1;
00268     isOK = false;
00269   }
00270   if( nz < 0 )
00271   {
00272     nz = 0;
00273     isOK = false;
00274   }
00275   else if( nz >= G4int(fNoVoxelZ) )
00276   {
00277     nz = fNoVoxelZ-1;
00278     isOK = false;
00279   }
00280   if( !isOK )
00281   {
00282     std::ostringstream message;
00283     message << "Corrected the copy number! It was negative or too big."
00284             << G4endl
00285             << "          LocalPoint: " << localPoint << G4endl
00286             << "          LocalDir: " << localDir << G4endl
00287             << "          Voxel container size: " << fContainerWallX
00288             << " " << fContainerWallY << " " << fContainerWallZ << G4endl
00289             << "          LocalPoint - wall: "
00290             << localPoint.x()-fContainerWallX << " "
00291             << localPoint.y()-fContainerWallY << " "
00292             << localPoint.z()-fContainerWallZ;
00293     G4Exception("G4PartialPhantomParameterisation::GetReplicaNo()",
00294                 "GeomNav1002", JustWarning, message);
00295   }
00296 
00297   G4int nyz = nz*fNoVoxelY+ny;
00298   std::multimap<G4int,G4int>::iterator ite = fFilledIDs.begin();
00299 /*
00300   for( ite = fFilledIDs.begin(); ite != fFilledIDs.end(); ite++ )
00301   {
00302     G4cout << " G4PartialPhantomParameterisation::GetReplicaNo filled "
00303            << (*ite).first << " , " << (*ite).second << std::endl;
00304   }
00305 */
00306   ite = fFilledIDs.begin();
00307 
00308   advance(ite,nyz);
00309   std::multimap<G4int,G4int>::iterator iteant = ite; iteant--;
00310   G4int copyNo = (*iteant).first + 1 + ( nx - (*ite).second );
00311 /*
00312   G4cout << " G4PartialPhantomParameterisation::GetReplicaNo getting copyNo "
00313          << copyNo << "  nyz " << nyz << "  (*iteant).first "
00314          << (*iteant).first << "  (*ite).second " <<  (*ite).second << G4endl;
00315 
00316   G4cout << " G4PartialPhantomParameterisation::GetReplicaNo " << copyNo
00317          << " nx " << nx << " ny " << ny << " nz " << nz
00318          << " localPoint " << localPoint << " localDir " << localDir << G4endl;
00319 */
00320   return copyNo;
00321 }

G4ThreeVector G4PartialPhantomParameterisation::GetTranslation ( const G4int  copyNo  )  const

Reimplemented from G4PhantomParameterisation.

Definition at line 73 of file G4PartialPhantomParameterisation.cc.

References G4PhantomParameterisation::fContainerWallX, G4PhantomParameterisation::fContainerWallY, G4PhantomParameterisation::fContainerWallZ, G4PhantomParameterisation::fVoxelHalfX, G4PhantomParameterisation::fVoxelHalfY, and G4PhantomParameterisation::fVoxelHalfZ.

Referenced by ComputeTransformation().

00074 {
00075   CheckCopyNo( copyNo );
00076 
00077   size_t nx;
00078   size_t ny;
00079   size_t nz;
00080   ComputeVoxelIndices( copyNo, nx, ny, nz );
00081 
00082   G4ThreeVector trans( (2*nx+1)*fVoxelHalfX - fContainerWallX,
00083                        (2*ny+1)*fVoxelHalfY - fContainerWallY,
00084                        (2*nz+1)*fVoxelHalfZ - fContainerWallZ);
00085   return trans;
00086 }

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

Definition at line 83 of file G4PartialPhantomParameterisation.hh.

00083                                                        {
00084       fFilledIDs = fid; 
00085     }

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

Definition at line 87 of file G4PartialPhantomParameterisation.hh.

00087                                                                      {
00088       fFilledMins = fmins;
00089     }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:52:49 2013 for Geant4 by  doxygen 1.4.7