00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 inline
00039 G4int
00040 G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
00041 const G4ThreeVector& localPoint,
00042 const G4int blocked ) const
00043 {
00044 EAxis targetHeaderAxis;
00045 G4double coord=0.;
00046 G4double targetHeaderMin, targetHeaderMax;
00047 G4double targetHeaderNodeWidth, targetNodePos;
00048 G4int targetHeaderNoSlices, targetNodeNo;
00049
00050 targetHeaderAxis = pHead->GetAxis();
00051 targetHeaderNoSlices = pHead->GetNoSlices();
00052 targetHeaderMin = pHead->GetMinExtent();
00053 targetHeaderMax = pHead->GetMaxExtent();
00054 targetHeaderNodeWidth = ( targetHeaderMax-targetHeaderMin )
00055 / targetHeaderNoSlices;
00056
00057 switch (targetHeaderAxis)
00058 {
00059 case kXAxis:
00060 coord = localPoint.x();
00061 break;
00062 case kYAxis:
00063 coord = localPoint.y();
00064 break;
00065 case kZAxis:
00066 coord = localPoint.z();
00067 break;
00068 case kRho:
00069 coord = localPoint.perp();
00070 break;
00071 case kPhi:
00072 coord = localPoint.phi();
00073 if ( (coord<0) && (coord<targetHeaderMin) ) coord += CLHEP::twopi;
00074 break;
00075 case kRadial3D:
00076 default:
00077 break;
00078 }
00079 targetNodePos = (coord-targetHeaderMin)/targetHeaderNodeWidth;
00080 targetNodeNo = (G4int) targetNodePos;
00081
00082 if ( targetNodeNo==blocked )
00083 {
00084 targetNodeNo = (targetNodePos-targetNodeNo<0.5)
00085 ? targetNodeNo-1 : targetNodeNo+1;
00086
00087
00088
00089
00090
00091
00092 if( (targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices) )
00093 {
00094
00095 #ifdef G4DEBUG_NAVIGATION
00096 G4cerr << " WARNING: assert in G4ReplicaNavigation::VoxelLocate "
00097 << " has failed : " << G4endl
00098 << " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
00099 << " targetNodeNo= " << targetNodeNo
00100 << " Number of Slices = " << targetHeaderNoSlices << G4endl;
00101 #endif
00102
00103
00104
00105
00106 if ( (targetHeaderAxis==kPhi)
00107 && (targetHeaderMin==0) && (targetHeaderMax==CLHEP::twopi) )
00108 {
00109 if ( targetNodeNo<0 )
00110 targetNodeNo = targetHeaderNoSlices-1;
00111 else if ( targetNodeNo>=targetHeaderNoSlices )
00112 targetNodeNo = 0;
00113 }
00114 else
00115 {
00116 if( targetNodeNo<0 )
00117 targetNodeNo = 0;
00118 else if ( targetNodeNo>=targetHeaderNoSlices )
00119 targetNodeNo = targetHeaderNoSlices-1;
00120 }
00121 }
00122 }
00123 else
00124 {
00125
00126
00127 if ( targetNodeNo<0 )
00128 {
00129 targetNodeNo = 0;
00130 }
00131 else if ( targetNodeNo>=targetHeaderNoSlices )
00132 {
00133 targetNodeNo = targetHeaderNoSlices-1;
00134 }
00135 }
00136 return targetNodeNo;
00137 }
00138
00139
00140
00141
00142
00143 inline
00144 G4bool
00145 G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
00146 const G4VPhysicalVolume* blockedVol,
00147 const G4int blockedNum,
00148 const G4ThreeVector&,
00149 const G4ThreeVector*,
00150 const G4bool,
00151 G4ThreeVector& localPoint )
00152 {
00153 G4VPhysicalVolume *motherPhysical, *pPhysical;
00154 G4LogicalVolume *motherLogical;
00155 G4SmartVoxelHeader *motherVoxelHeader;
00156 G4int nodeNo;
00157
00158 motherPhysical = history.GetTopVolume();
00159 motherLogical = motherPhysical->GetLogicalVolume();
00160 motherVoxelHeader = motherLogical->GetVoxelHeader();
00161 pPhysical = motherLogical->GetDaughter(0);
00162
00163 if ( blockedVol==pPhysical )
00164 {
00165 nodeNo = VoxelLocate(motherVoxelHeader, localPoint, blockedNum);
00166 }
00167 else
00168 {
00169 nodeNo = VoxelLocate(motherVoxelHeader, localPoint);
00170 }
00171
00172 ComputeTransformation(nodeNo, pPhysical, localPoint);
00173 history.NewLevel(pPhysical, kReplica, nodeNo);
00174 pPhysical->SetCopyNo(nodeNo);
00175
00176 return true;
00177 }
00178
00179
00180
00181
00182
00183 inline
00184 void
00185 G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
00186 G4VPhysicalVolume* pVol ) const
00187 {
00188 G4RotationMatrix rm;
00189 rm.rotateZ(ang);
00190 if ( pVol )
00191 *pVol->GetRotation() = rm;
00192 }
00193
00194
00195
00196
00197
00198 inline
00199 G4int G4ReplicaNavigation::GetVerboseLevel() const
00200 {
00201 return fVerbose;
00202 }
00203
00204
00205
00206
00207
00208 inline
00209 void G4ReplicaNavigation::SetVerboseLevel(G4int level)
00210 {
00211 fVerbose = level;
00212 }
00213
00214
00215
00216
00217
00218 inline
00219 void G4ReplicaNavigation::CheckMode(G4bool mode)
00220 {
00221 fCheck = mode;
00222 }