G4ErrorPlaneSurfaceTarget.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 //
00030 // --------------------------------------------------------------------
00031 //      GEANT 4 class implementation file 
00032 // --------------------------------------------------------------------
00033 
00034 #include "G4ErrorPlaneSurfaceTarget.hh"
00035 
00036 #ifdef G4VERBOSE
00037 #include "G4ErrorPropagatorData.hh" //for verbosity checking
00038 #endif
00039 
00040 #include "G4Point3D.hh"
00041 #include "G4ThreeVector.hh"
00042 
00043 //---------------------------------------------------------------------
00044 
00045 G4ErrorPlaneSurfaceTarget::
00046 G4ErrorPlaneSurfaceTarget(G4double aa, G4double ab, G4double ac, G4double ad)
00047   : G4Plane3D( aa, ab, ac, ad ) 
00048 {
00049   theType = G4ErrorTarget_PlaneSurface;
00050 
00051 #ifdef G4VERBOSE
00052   if(G4ErrorPropagatorData::verbose() >= 2 )
00053   { 
00054     Dump( " $$$ creating G4ErrorPlaneSurfaceTarget from parameters");
00055   }
00056 #endif
00057 }
00058 
00059 //---------------------------------------------------------------------
00060 
00061 G4ErrorPlaneSurfaceTarget::
00062 G4ErrorPlaneSurfaceTarget(const G4Normal3D &norm, const G4Point3D &pt)
00063   : G4Plane3D( norm, pt ) 
00064 {
00065   theType = G4ErrorTarget_PlaneSurface;
00066 
00067 #ifdef G4VERBOSE
00068   if(G4ErrorPropagatorData::verbose() >= 2 )
00069   { 
00070     Dump( " $$$ creating G4ErrorPlaneSurfaceTarget from point and normal");
00071   }
00072 #endif
00073 }
00074 
00075 //---------------------------------------------------------------------
00076 
00077 G4ErrorPlaneSurfaceTarget::
00078 G4ErrorPlaneSurfaceTarget(const G4Point3D &p1,
00079                           const G4Point3D &p2,
00080                           const G4Point3D &p3)
00081   : G4Plane3D( p1, p2, p3 )
00082 {
00083   theType = G4ErrorTarget_PlaneSurface;
00084 
00085 #ifdef G4VERBOSE
00086   if(G4ErrorPropagatorData::verbose() >= 2 )
00087   { 
00088     Dump( " $$$ creating G4ErrorPlaneSurfaceTarget from three points");
00089   }
00090 #endif
00091 }
00092 
00093 //---------------------------------------------------------------------
00094 
00095 G4ErrorPlaneSurfaceTarget::~G4ErrorPlaneSurfaceTarget()
00096 {
00097 }
00098 
00099 //---------------------------------------------------------------------
00100 
00101 G4ThreeVector G4ErrorPlaneSurfaceTarget::
00102 Intersect( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
00103 {
00104   G4double lam = GetDistanceFromPoint( pt, dir );
00105   G4Point3D inters = pt + lam * dir;
00106 
00107 #ifdef G4VERBOSE
00108   if(G4ErrorPropagatorData::verbose() >= 4 )
00109   { 
00110     G4cout << " $$$ creating G4ErrorPlaneSurfaceTarget::Intersect "
00111            << inters << G4endl;
00112   }
00113 #endif
00114 
00115   return inters;
00116 }
00117 
00118 //---------------------------------------------------------------------
00119 
00120 G4double G4ErrorPlaneSurfaceTarget::
00121 GetDistanceFromPoint( const G4ThreeVector& pt, const G4ThreeVector& dir ) const
00122 {
00123   if( std::fabs( dir.mag() -1. ) > 1.E-6 )
00124   {
00125     std::ostringstream message;
00126     message << "Direction is not a unit vector: " << dir << " !";
00127     G4Exception("G4ErrorPlaneSurfaceTarget::GetDistanceFromPoint()",
00128                 "GeomMgt1002", JustWarning, message);
00129   }
00130   G4double dist = -(a_ * pt.x() + b_ * pt.y() + c_ * pt.z() + d_)
00131                  / (a_ * dir.x() + b_ * dir.y() + c_ * dir.z() );
00132 
00133 #ifdef G4VERBOSE
00134   if(G4ErrorPropagatorData::verbose() >= 3 )
00135   {
00136     G4cout << " G4ErrorPlaneSurfaceTarget::GetDistanceFromPoint()" << G4endl
00137            << "   Point: " << pt << ", Direction: " << dir << G4endl
00138            << "   Distance: " << dist << G4endl;
00139   }
00140 #endif
00141   
00142   return dist;
00143 }
00144 
00145 //---------------------------------------------------------------------
00146 
00147 G4double G4ErrorPlaneSurfaceTarget::
00148 GetDistanceFromPoint( const G4ThreeVector& pt ) const
00149 {
00150   G4ThreeVector vec = point() - pt;
00151   G4double alpha = std::acos( vec * normal() / vec.mag() / normal().mag() );
00152   G4double dist = std::fabs(vec.mag() * std::cos( alpha ));
00153   
00154 #ifdef G4VERBOSE
00155   if(G4ErrorPropagatorData::verbose() >= 3 )
00156   {
00157     G4cout << " G4ErrorPlaneSurfaceTarget::GetDistanceFromPoint()" << G4endl
00158            << "   Point: " << pt << G4endl
00159            << "   Distance: " << dist << G4endl;
00160   }
00161 #endif
00162 
00163   return dist;
00164 }
00165 
00166 //---------------------------------------------------------------------
00167 
00168 G4Plane3D G4ErrorPlaneSurfaceTarget::
00169 GetTangentPlane( const G4ThreeVector& ) const
00170 {
00171   return *this;
00172 }
00173 
00174 
00175 void G4ErrorPlaneSurfaceTarget::Dump( const G4String& msg ) const
00176 {
00177   G4cout << msg << " point = " << point()
00178                 << " normal = " << normal() << G4endl;
00179 }

Generated on Mon May 27 17:48:11 2013 for Geant4 by  doxygen 1.4.7