source: trunk/source/geometry/navigation/include/G4ReplicaNavigation.icc @ 1337

Last change on this file since 1337 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 7.7 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
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.                             *
10// *                                                                  *
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.         *
17// *                                                                  *
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// ********************************************************************
25//
26//
27// $Id: G4ReplicaNavigation.icc,v 1.5 2006/06/29 18:36:22 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31// class G4ReplicaNavigation Inline implementation
32//
33// --------------------------------------------------------------------
34
35// ********************************************************************
36// VoxelLocate
37// ********************************************************************
38//
39inline
40G4int
41G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
42                                  const G4ThreeVector& localPoint,
43                                  const G4int blocked ) const
44{
45  EAxis targetHeaderAxis;
46  G4double coord=0.;
47  G4double targetHeaderMin, targetHeaderMax;
48  G4double targetHeaderNodeWidth, targetNodePos;
49  G4int targetHeaderNoSlices, targetNodeNo;
50 
51  targetHeaderAxis = pHead->GetAxis();
52  targetHeaderNoSlices = pHead->GetNoSlices();
53  targetHeaderMin = pHead->GetMinExtent();
54  targetHeaderMax = pHead->GetMaxExtent();
55  targetHeaderNodeWidth = ( targetHeaderMax-targetHeaderMin )
56                          / targetHeaderNoSlices;
57
58  switch (targetHeaderAxis)
59  {
60    case kXAxis:
61      coord = localPoint.x();
62      break;
63    case kYAxis:
64      coord = localPoint.y();
65      break;
66    case kZAxis:
67      coord = localPoint.z();
68      break;
69    case kRho:
70      coord = localPoint.perp();
71      break;
72    case kPhi:
73      coord = localPoint.phi();
74      if ( (coord<0) && (coord<targetHeaderMin) ) coord += 2.0*pi;
75      break;
76    case kRadial3D:
77    default:
78      break;
79  }
80  targetNodePos = (coord-targetHeaderMin)/targetHeaderNodeWidth;
81  targetNodeNo = (G4int) targetNodePos;
82
83  if ( targetNodeNo==blocked )
84  {
85    targetNodeNo = (targetNodePos-targetNodeNo<0.5)
86                   ? targetNodeNo-1 : targetNodeNo+1;
87     
88    // Do not need to check range: If on outer edge of zeroth
89    // voxel & it is blocked => should have exited mother
90    // (or similar)       P.Kent
91    // assert(targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices);
92    //
93    // The assert above fails for simulation of high energy electrons
94    // It is not clear what is the cause for this failure.
95    // The code below attempts to rectify this problem until a
96    // complete resolution is possible.   
97    //           J.Apostolakis, June 12, 1998
98
99    if( (targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices) )
100    {
101
102#ifdef G4DEBUG_NAVIGATION
103      G4cerr << " WARNING: assert in G4ReplicaNavigation::VoxelLocate "
104             << " has failed : " << G4endl
105             << " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
106             << " targetNodeNo= " << targetNodeNo
107             << " Number of Slices =  " << targetHeaderNoSlices << G4endl;
108#endif
109      // In the case of rotational symmetry and an extent over the
110      // whole 360 degrees, the above is not true and you can go from
111      // the last voxel to the zeroth and vice versa
112      //                                        H.Boie, April 30, 2001 
113      if ( (targetHeaderAxis==kPhi)
114           && (targetHeaderMin==0) && (targetHeaderMax==2*pi) )
115      {
116        if ( targetNodeNo<0 )
117          targetNodeNo = targetHeaderNoSlices-1;
118        else if ( targetNodeNo>=targetHeaderNoSlices )
119          targetNodeNo = 0;
120      }
121      else
122      {
123        if( targetNodeNo<0 )
124          targetNodeNo = 0;
125        else if ( targetNodeNo>=targetHeaderNoSlices )
126          targetNodeNo = targetHeaderNoSlices-1;
127      }
128    }
129  }
130  else
131  {
132    // Rounding protection
133    //
134    if ( targetNodeNo<0 )
135    {
136      targetNodeNo = 0;
137    }
138    else if ( targetNodeNo>=targetHeaderNoSlices )
139    {
140      targetNodeNo = targetHeaderNoSlices-1;
141    }
142  }
143  return targetNodeNo;
144}
145
146// ********************************************************************
147// LevelLocate
148// ********************************************************************
149//
150inline
151G4bool
152G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
153                            const G4VPhysicalVolume* blockedVol,
154                            const G4int              blockedNum,
155                            const G4ThreeVector&,     // globalPoint
156                            const G4ThreeVector*,     // globalDirection
157                            const G4bool,             // pLocatedOnEdge
158                                  G4ThreeVector& localPoint )
159{
160  G4VPhysicalVolume *motherPhysical, *pPhysical;
161  G4LogicalVolume *motherLogical;
162  G4SmartVoxelHeader *motherVoxelHeader;
163  G4int nodeNo;
164
165  motherPhysical = history.GetTopVolume();
166  motherLogical = motherPhysical->GetLogicalVolume();
167  motherVoxelHeader = motherLogical->GetVoxelHeader();
168  pPhysical = motherLogical->GetDaughter(0);
169
170  if ( blockedVol==pPhysical )
171  {
172    nodeNo = VoxelLocate(motherVoxelHeader, localPoint, blockedNum);
173  }
174  else
175  {
176    nodeNo = VoxelLocate(motherVoxelHeader, localPoint);
177  }
178
179  ComputeTransformation(nodeNo, pPhysical, localPoint);
180  history.NewLevel(pPhysical, kReplica, nodeNo);
181  pPhysical->SetCopyNo(nodeNo);
182
183  return true;
184}
185
186// ********************************************************************
187// SetPhiTransformation
188// ********************************************************************
189//
190inline
191void
192G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
193                                                 G4VPhysicalVolume* pVol ) const
194{
195  G4RotationMatrix rm;
196  rm.rotateZ(ang);
197  if ( pVol )
198    *pVol->GetRotation() = rm;
199}
200
201// ********************************************************************
202// GetVerboseLevel
203// ********************************************************************
204//
205inline
206G4int G4ReplicaNavigation::GetVerboseLevel() const
207{
208  return fVerbose;
209}
210
211// ********************************************************************
212// SetVerboseLevel
213// ********************************************************************
214//
215inline
216void  G4ReplicaNavigation::SetVerboseLevel(G4int level)
217{
218  fVerbose = level;
219}
220
221// ********************************************************************
222// CheckMode
223// ********************************************************************
224//
225inline
226void  G4ReplicaNavigation::CheckMode(G4bool mode)
227{
228  fCheck = mode;
229}
Note: See TracBrowser for help on using the repository browser.