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