File indexing completed on 2026-09-27 09:11:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 inline
0036 G4int
0037 G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
0038 const G4ThreeVector& localPoint,
0039 const G4int blocked ) const
0040 {
0041 EAxis targetHeaderAxis;
0042 G4double coord = 0.;
0043 G4double targetHeaderMin, targetHeaderMax;
0044 G4double targetHeaderNodeWidth, targetNodePos;
0045 G4int targetHeaderNoSlices, targetNodeNo;
0046
0047 targetHeaderAxis = pHead->GetAxis();
0048 targetHeaderNoSlices = G4int(pHead->GetNoSlices());
0049 targetHeaderMin = pHead->GetMinExtent();
0050 targetHeaderMax = pHead->GetMaxExtent();
0051 targetHeaderNodeWidth = ( targetHeaderMax-targetHeaderMin )
0052 / targetHeaderNoSlices;
0053
0054 switch (targetHeaderAxis)
0055 {
0056 case kXAxis:
0057 coord = localPoint.x();
0058 break;
0059 case kYAxis:
0060 coord = localPoint.y();
0061 break;
0062 case kZAxis:
0063 coord = localPoint.z();
0064 break;
0065 case kRho:
0066 coord = localPoint.perp();
0067 break;
0068 case kPhi:
0069 coord = localPoint.phi();
0070 if ( (coord<0) && (coord<targetHeaderMin) ) { coord += CLHEP::twopi; }
0071 break;
0072 case kRadial3D:
0073 default:
0074 break;
0075 }
0076 targetNodePos = (coord-targetHeaderMin)/targetHeaderNodeWidth;
0077 targetNodeNo = (G4int) targetNodePos;
0078
0079 if ( targetNodeNo==blocked )
0080 {
0081 targetNodeNo = (targetNodePos-targetNodeNo<0.5)
0082 ? targetNodeNo-1 : targetNodeNo+1;
0083
0084
0085
0086
0087
0088
0089 if( (targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices) )
0090 {
0091
0092 #ifdef G4DEBUG_NAVIGATION
0093 std::ostringstream message;
0094 message << "Voxel location failed:" << G4endl
0095 << " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
0096 << G4endl
0097 << " - targetNodeNo= " << targetNodeNo << G4endl
0098 << " - Number of Slices = " << targetHeaderNoSlices;
0099 G4Exception("G4ReplicaNavigation::VoxelLocate()",
0100 "GeomNav1002", JustWarning, message);
0101 #endif
0102
0103
0104
0105
0106 if ( (targetHeaderAxis==kPhi)
0107 && (targetHeaderMin==0) && (targetHeaderMax==CLHEP::twopi) )
0108 {
0109 if ( targetNodeNo<0 )
0110 {
0111 targetNodeNo = targetHeaderNoSlices-1;
0112 }
0113 else if ( targetNodeNo>=targetHeaderNoSlices )
0114 {
0115 targetNodeNo = 0;
0116 }
0117 }
0118 else
0119 {
0120 if( targetNodeNo<0 )
0121 {
0122 targetNodeNo = 0;
0123 }
0124 else if ( targetNodeNo>=targetHeaderNoSlices )
0125 {
0126 targetNodeNo = targetHeaderNoSlices-1;
0127 }
0128 }
0129 }
0130 }
0131 else
0132 {
0133
0134
0135 if ( targetNodeNo<0 )
0136 {
0137 targetNodeNo = 0;
0138 }
0139 else if ( targetNodeNo>=targetHeaderNoSlices )
0140 {
0141 targetNodeNo = targetHeaderNoSlices-1;
0142 }
0143 }
0144 return targetNodeNo;
0145 }
0146
0147
0148
0149
0150
0151 inline
0152 G4bool
0153 G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
0154 const G4VPhysicalVolume* blockedVol,
0155 const G4int blockedNum,
0156 const G4ThreeVector&,
0157 const G4ThreeVector*,
0158 const G4bool,
0159 G4ThreeVector& localPoint )
0160 {
0161 G4VPhysicalVolume *motherPhysical, *pPhysical;
0162 G4LogicalVolume *motherLogical;
0163 G4SmartVoxelHeader *motherVoxelHeader;
0164 G4int nodeNo;
0165
0166 motherPhysical = history.GetTopVolume();
0167 motherLogical = motherPhysical->GetLogicalVolume();
0168 motherVoxelHeader = motherLogical->GetVoxelHeader();
0169 pPhysical = motherLogical->GetDaughter(0);
0170
0171 if ( blockedVol==pPhysical )
0172 {
0173 nodeNo = VoxelLocate(motherVoxelHeader, localPoint, blockedNum);
0174 }
0175 else
0176 {
0177 nodeNo = VoxelLocate(motherVoxelHeader, localPoint);
0178 }
0179
0180 ComputeTransformation(nodeNo, pPhysical, localPoint);
0181 history.NewLevel(pPhysical, kReplica, nodeNo);
0182 pPhysical->SetCopyNo(nodeNo);
0183
0184 return true;
0185 }
0186
0187
0188
0189
0190
0191 inline
0192 void
0193 G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
0194 G4VPhysicalVolume* pVol ) const
0195 {
0196 G4RotationMatrix rm;
0197 rm.rotateZ(ang);
0198 if ( pVol != nullptr )
0199 {
0200 *pVol->GetRotation() = rm;
0201 }
0202 }
0203
0204
0205
0206
0207
0208 inline
0209 G4int G4ReplicaNavigation::GetVerboseLevel() const
0210 {
0211 return fVerbose;
0212 }
0213
0214
0215
0216
0217
0218 inline
0219 void G4ReplicaNavigation::SetVerboseLevel(G4int level)
0220 {
0221 fVerbose = level;
0222 }
0223
0224
0225
0226
0227
0228 inline
0229 void G4ReplicaNavigation::CheckMode(G4bool mode)
0230 {
0231 fCheck = mode;
0232 }