Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GeomTestErrorList.cc
Go to the documentation of this file.
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$
28 //
29 // --------------------------------------------------------------------
30 // GEANT 4 class source file
31 //
32 // G4GeomTestErrorList
33 //
34 // Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
35 // --------------------------------------------------------------------
36 
37 #include "G4GeomTestErrorList.hh"
38 #include "G4VPhysicalVolume.hh"
41 
42 //
43 // Constructor
44 //
46  : mother(theMother)
47 {
48  FindGlobalCoordinateSystem();
49 }
50 
51 
52 //
53 // Destructor
54 //
56 
57 
58 //
59 // AddError
60 //
61 // Add a new Error point to our list, where the point
62 // is given in the coordinate system of the mother
63 //
65  const G4ThreeVector &s2 )
66 {
67  segments.push_back( Segment(s1,s2) );
68 }
69 
70 
71 //
72 // Accessors
73 //
75 {
76  return mother;
77 }
78 
79 
80 //
81 // Return number of segments
82 //
84 {
85  return segments.size();
86 }
87 
88 
89 //
90 // GetMotherPoints
91 //
92 // Return start and end points in the coordinate system
93 // of the mother
94 //
96  G4ThreeVector &s1,
97  G4ThreeVector &s2 ) const
98 {
99  s1 = segments[i].GetS1();
100  s2 = segments[i].GetS2();
101 }
102 
103 
104 //
105 // GetGlobalPoints
106 //
107 // Return start and end points in the global coordinate system
108 //
110  G4ThreeVector &s1,
111  G4ThreeVector &s2 ) const
112 {
113  s1 = globalTranslation + globalRotation*segments[i].GetS1();
114  s2 = globalTranslation + globalRotation*segments[i].GetS2();
115 }
116 
117 
118 //
119 // GetOneDaughtPoints
120 //
121 // Return start and end points in the coordinate system of
122 // a daughter
123 //
125  G4int i,
126  G4ThreeVector &s1,
127  G4ThreeVector &s2 ) const
128 {
129  const G4RotationMatrix *rotation = daught->GetFrameRotation();
130  const G4ThreeVector &translation = daught->GetFrameTranslation();
131 
132  if (rotation) {
133  s1 = (*rotation)*(translation + segments[i].GetS1());
134  s2 = (*rotation)*(translation + segments[i].GetS2());
135  }
136  else {
137  s1 = translation + segments[i].GetS1();
138  s2 = translation + segments[i].GetS2();
139  }
140 }
141 
142 
143 //
144 // FindGlobalCoordinateSystem
145 //
146 // Calculate rotation & translation to global coordinates
147 //
148 void G4GeomTestErrorList::FindGlobalCoordinateSystem()
149 {
150  G4TouchableHistoryHandle aTouchable =
152  GetNavigatorForTracking()->CreateTouchableHistoryHandle();
153  G4AffineTransform globTransform =
154  aTouchable->GetHistory()->GetTopTransform().Inverse();
155 
156  globalTranslation = globTransform.NetTranslation();
157  globalRotation = globTransform.NetRotation();
158 }