2 // ********************************************************************
3 // * License and Disclaimer *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
27 // $Id: G4ReplicaNavigation.icc 66356 2012-12-18 09:02:32Z gcosmo $
30 // class G4ReplicaNavigation Inline implementation
32 // --------------------------------------------------------------------
34 // ********************************************************************
36 // ********************************************************************
40 G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
41 const G4ThreeVector& localPoint,
42 const G4int blocked ) const
44 EAxis targetHeaderAxis;
46 G4double targetHeaderMin, targetHeaderMax;
47 G4double targetHeaderNodeWidth, targetNodePos;
48 G4int targetHeaderNoSlices, targetNodeNo;
50 targetHeaderAxis = pHead->GetAxis();
51 targetHeaderNoSlices = pHead->GetNoSlices();
52 targetHeaderMin = pHead->GetMinExtent();
53 targetHeaderMax = pHead->GetMaxExtent();
54 targetHeaderNodeWidth = ( targetHeaderMax-targetHeaderMin )
55 / targetHeaderNoSlices;
57 switch (targetHeaderAxis)
60 coord = localPoint.x();
63 coord = localPoint.y();
66 coord = localPoint.z();
69 coord = localPoint.perp();
72 coord = localPoint.phi();
73 if ( (coord<0) && (coord<targetHeaderMin) ) coord += CLHEP::twopi;
79 targetNodePos = (coord-targetHeaderMin)/targetHeaderNodeWidth;
80 targetNodeNo = (G4int) targetNodePos;
82 if ( targetNodeNo==blocked )
84 targetNodeNo = (targetNodePos-targetNodeNo<0.5)
85 ? targetNodeNo-1 : targetNodeNo+1;
87 // Do not need to check range: If on outer edge of zeroth
88 // voxel & it is blocked => should have exited mother
89 // (or similar) P.Kent
90 // assert(targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices);
92 if( (targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices) )
95 #ifdef G4DEBUG_NAVIGATION
96 G4cerr << " WARNING: assert in G4ReplicaNavigation::VoxelLocate "
97 << " has failed : " << G4endl
98 << " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
99 << " targetNodeNo= " << targetNodeNo
100 << " Number of Slices = " << targetHeaderNoSlices << G4endl;
102 // In the case of rotational symmetry and an extent over the
103 // whole 360 degrees, the above is not true and you can go from
104 // the last voxel to the zeroth and vice versa
105 // H.Boie, April 30, 2001
106 if ( (targetHeaderAxis==kPhi)
107 && (targetHeaderMin==0) && (targetHeaderMax==CLHEP::twopi) )
109 if ( targetNodeNo<0 )
110 targetNodeNo = targetHeaderNoSlices-1;
111 else if ( targetNodeNo>=targetHeaderNoSlices )
118 else if ( targetNodeNo>=targetHeaderNoSlices )
119 targetNodeNo = targetHeaderNoSlices-1;
125 // Rounding protection
127 if ( targetNodeNo<0 )
131 else if ( targetNodeNo>=targetHeaderNoSlices )
133 targetNodeNo = targetHeaderNoSlices-1;
139 // ********************************************************************
141 // ********************************************************************
145 G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
146 const G4VPhysicalVolume* blockedVol,
147 const G4int blockedNum,
148 const G4ThreeVector&, // globalPoint
149 const G4ThreeVector*, // globalDirection
150 const G4bool, // pLocatedOnEdge
151 G4ThreeVector& localPoint )
153 G4VPhysicalVolume *motherPhysical, *pPhysical;
154 G4LogicalVolume *motherLogical;
155 G4SmartVoxelHeader *motherVoxelHeader;
158 motherPhysical = history.GetTopVolume();
159 motherLogical = motherPhysical->GetLogicalVolume();
160 motherVoxelHeader = motherLogical->GetVoxelHeader();
161 pPhysical = motherLogical->GetDaughter(0);
163 if ( blockedVol==pPhysical )
165 nodeNo = VoxelLocate(motherVoxelHeader, localPoint, blockedNum);
169 nodeNo = VoxelLocate(motherVoxelHeader, localPoint);
172 ComputeTransformation(nodeNo, pPhysical, localPoint);
173 history.NewLevel(pPhysical, kReplica, nodeNo);
174 pPhysical->SetCopyNo(nodeNo);
179 // ********************************************************************
180 // SetPhiTransformation
181 // ********************************************************************
185 G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
186 G4VPhysicalVolume* pVol ) const
191 *pVol->GetRotation() = rm;
194 // ********************************************************************
196 // ********************************************************************
199 G4int G4ReplicaNavigation::GetVerboseLevel() const
204 // ********************************************************************
206 // ********************************************************************
209 void G4ReplicaNavigation::SetVerboseLevel(G4int level)
214 // ********************************************************************
216 // ********************************************************************
219 void G4ReplicaNavigation::CheckMode(G4bool mode)