#include <G4ErrorCylSurfaceTarget.hh>
Inheritance diagram for G4ErrorCylSurfaceTarget:
Public Member Functions | |
G4ErrorCylSurfaceTarget (const G4double &radius, const G4ThreeVector &trans=G4ThreeVector(), const G4RotationMatrix &rotm=G4RotationMatrix()) | |
G4ErrorCylSurfaceTarget (const G4double &radius, const G4AffineTransform &trans) | |
~G4ErrorCylSurfaceTarget () | |
virtual G4ThreeVector | IntersectLocal (const G4ThreeVector &point, const G4ThreeVector &direc) const |
virtual G4double | GetDistanceFromPoint (const G4ThreeVector &point, const G4ThreeVector &direc) const |
virtual G4double | GetDistanceFromPoint (const G4ThreeVector &point) const |
virtual G4Plane3D | GetTangentPlane (const G4ThreeVector &point) const |
virtual void | Dump (const G4String &msg) const |
Definition at line 52 of file G4ErrorCylSurfaceTarget.hh.
G4ErrorCylSurfaceTarget::G4ErrorCylSurfaceTarget | ( | const G4double & | radius, | |
const G4ThreeVector & | trans = G4ThreeVector() , |
|||
const G4RotationMatrix & | rotm = G4RotationMatrix() | |||
) |
Definition at line 47 of file G4ErrorCylSurfaceTarget.cc.
References Dump(), G4ErrorTarget_CylindricalSurface, G4ErrorTarget::theType, and G4ErrorPropagatorData::verbose().
00050 : fradius(radius) 00051 { 00052 theType = G4ErrorTarget_CylindricalSurface; 00053 00054 ftransform = G4AffineTransform( rotm.inverse(), -trans ); 00055 #ifdef G4VERBOSE 00056 if(G4ErrorPropagatorData::verbose() >= 2 ) { 00057 Dump( " $$$ creating G4ErrorCylSurfaceTarget "); 00058 } 00059 #endif 00060 }
G4ErrorCylSurfaceTarget::G4ErrorCylSurfaceTarget | ( | const G4double & | radius, | |
const G4AffineTransform & | trans | |||
) |
Definition at line 65 of file G4ErrorCylSurfaceTarget.cc.
References Dump(), G4ErrorTarget_CylindricalSurface, G4ErrorTarget::theType, and G4ErrorPropagatorData::verbose().
00067 : fradius(radius), ftransform(trans.Inverse()) 00068 { 00069 theType = G4ErrorTarget_CylindricalSurface; 00070 00071 #ifdef G4VERBOSE 00072 if(G4ErrorPropagatorData::verbose() >= 2 ) 00073 { 00074 Dump( " $$$ creating G4ErrorCylSurfaceTarget "); 00075 } 00076 #endif 00077 }
G4ErrorCylSurfaceTarget::~G4ErrorCylSurfaceTarget | ( | ) |
void G4ErrorCylSurfaceTarget::Dump | ( | const G4String & | msg | ) | const [virtual] |
Implements G4ErrorSurfaceTarget.
Definition at line 222 of file G4ErrorCylSurfaceTarget.cc.
References G4cout, G4endl, G4AffineTransform::NetRotation(), and G4AffineTransform::NetTranslation().
Referenced by G4ErrorCylSurfaceTarget(), GetDistanceFromPoint(), and IntersectLocal().
00223 { 00224 G4cout << msg << " radius " << fradius 00225 << " centre " << ftransform.NetTranslation() 00226 << " rotation " << ftransform.NetRotation() << G4endl; 00227 }
G4double G4ErrorCylSurfaceTarget::GetDistanceFromPoint | ( | const G4ThreeVector & | point | ) | const [virtual] |
Implements G4ErrorSurfaceTarget.
Definition at line 122 of file G4ErrorCylSurfaceTarget.cc.
References Dump(), G4cout, G4endl, G4AffineTransform::TransformPoint(), and G4ErrorPropagatorData::verbose().
00123 { 00124 G4ThreeVector localPoint = ftransform.TransformPoint( point ); 00125 00126 #ifdef G4VERBOSE 00127 if(G4ErrorPropagatorData::verbose() >= 3 ) 00128 { 00129 G4cout << " G4ErrorCylSurfaceTarget::GetDistanceFromPoint:" << G4endl 00130 << " Global point " << point << G4endl 00131 << " Distance " << fradius - localPoint.perp() << G4endl; 00132 Dump( " CylSurface: " ); 00133 } 00134 #endif 00135 00136 return fradius - localPoint.perp(); 00137 }
G4double G4ErrorCylSurfaceTarget::GetDistanceFromPoint | ( | const G4ThreeVector & | point, | |
const G4ThreeVector & | direc | |||
) | const [virtual] |
Implements G4ErrorSurfaceTarget.
Definition at line 88 of file G4ErrorCylSurfaceTarget.cc.
References Dump(), FatalException, G4cout, G4endl, G4Exception(), IntersectLocal(), G4AffineTransform::TransformAxis(), G4AffineTransform::TransformPoint(), and G4ErrorPropagatorData::verbose().
00090 { 00091 if( dir.mag() == 0. ) 00092 { 00093 G4Exception("G4ErrorCylSurfaceTarget::GetDistanceFromPoint()", 00094 "GeomMgt0003", FatalException, "Direction is zero !"); 00095 } 00096 00097 //----- Get intersection point 00098 G4ThreeVector localPoint = ftransform.TransformPoint( point ); 00099 G4ThreeVector localDir = ftransform.TransformAxis( dir ); 00100 G4ThreeVector inters = IntersectLocal(localPoint, localDir); 00101 00102 G4double dist = (localPoint-inters).mag(); 00103 00104 #ifdef G4VERBOSE 00105 if(G4ErrorPropagatorData::verbose() >= 3 ) 00106 { 00107 G4cout << " G4ErrorCylSurfaceTarget::GetDistanceFromPoint():" << G4endl 00108 << " Global point " << point << " dir " << dir << G4endl 00109 << " Intersection " << inters << G4endl 00110 << " Distance " << dist << G4endl; 00111 Dump( " CylSurface: " ); 00112 } 00113 #endif 00114 00115 return dist; 00116 }
G4Plane3D G4ErrorCylSurfaceTarget::GetTangentPlane | ( | const G4ThreeVector & | point | ) | const [virtual] |
Implements G4ErrorSurfaceTarget.
Definition at line 195 of file G4ErrorCylSurfaceTarget.cc.
References G4endl, G4Exception(), G4GeometryTolerance::GetInstance(), G4GeometryTolerance::GetSurfaceTolerance(), JustWarning, G4AffineTransform::NetTranslation(), and G4AffineTransform::TransformPoint().
00196 { 00197 G4ThreeVector localPoint = ftransform.TransformPoint( point ); 00198 00199 // check that point is at cylinder surface 00200 // 00201 if( std::fabs( localPoint.perp() - fradius ) 00202 > 1000.*G4GeometryTolerance::GetInstance()->GetSurfaceTolerance() ) 00203 { 00204 std::ostringstream message; 00205 message << "Local point not at surface !" << G4endl 00206 << " Point: " << point << ", local: " << localPoint 00207 << G4endl 00208 << " is not at surface, but far away by: " 00209 << localPoint.perp() - fradius << " !"; 00210 G4Exception("G4ErrorCylSurfaceTarget::GetTangentPlane()", 00211 "GeomMgt1002", JustWarning, message); 00212 } 00213 00214 G4Normal3D normal = localPoint - ftransform.NetTranslation(); 00215 00216 return G4Plane3D( normal, point ); 00217 }
G4ThreeVector G4ErrorCylSurfaceTarget::IntersectLocal | ( | const G4ThreeVector & | point, | |
const G4ThreeVector & | direc | |||
) | const [virtual] |
Definition at line 142 of file G4ErrorCylSurfaceTarget.cc.
References Dump(), G4cout, G4endl, G4Exception(), JustWarning, G4InuclParticleNames::lambda, and G4ErrorPropagatorData::verbose().
Referenced by GetDistanceFromPoint().
00144 { 00145 G4double eqa = localDir.x()*localDir.x()+localDir.y()*localDir.y(); 00146 G4double eqb = 2*(localPoint.x()*localDir.x()+localPoint.y()*localDir.y()); 00147 G4double eqc = -fradius*fradius+localPoint.x()*localPoint.x() 00148 +localPoint.y()*localPoint.y(); 00149 G4int inside = (localPoint.perp() > fradius) ? -1 : 1; 00150 G4double lambda; 00151 00152 if( eqa*inside > 0. ) 00153 { 00154 lambda = (-eqb + std::sqrt(eqb*eqb-4*eqa*eqc) ) / (2.*eqa); 00155 } 00156 else if( eqa*inside < 0. ) 00157 { 00158 lambda = (-eqb - std::sqrt(eqb*eqb-4*eqa*eqc) ) / (2.*eqa); 00159 } 00160 else 00161 { 00162 if( eqb != 0. ) 00163 { 00164 lambda = -eqc/eqb; 00165 } 00166 else 00167 { 00168 std::ostringstream message; 00169 message << "Intersection not possible !" << G4endl 00170 << " Point: " << localPoint << ", direction: " 00171 << localDir; 00172 Dump( " CylSurface: " ); 00173 G4Exception("G4ErrorCylSurfaceTarget::IntersectLocal()", 00174 "GeomMgt1002", JustWarning, message); 00175 lambda = kInfinity; 00176 } 00177 } 00178 00179 G4ThreeVector inters = localPoint + lambda*localDir/localDir.mag(); 00180 00181 #ifdef G4VERBOSE 00182 if(G4ErrorPropagatorData::verbose() >= 4 ) { 00183 G4cout << " G4ErrorCylSurfaceTarget::IntersectLocal " << inters << " " 00184 << inters.perp() << " localPoint " << localPoint << " localDir " 00185 << localDir << G4endl; 00186 } 00187 #endif 00188 00189 return inters; 00190 }