G4ErrorSurfaceTrajParam.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 // $Id: G4ErrorSurfaceTrajParam.cc 69766 2013-05-14 14:33:55Z gcosmo $
00027 //
00028 // ------------------------------------------------------------
00029 //      GEANT 4 class implementation file 
00030 // ------------------------------------------------------------
00031 //
00032 
00033 #include "G4ErrorSurfaceTrajParam.hh"
00034 #include <iomanip>
00035 
00036 #include "G4ThreeVector.hh"
00037 #include "G4GeometryTolerance.hh"
00038 
00039 //------------------------------------------------------------------------
00040 G4ErrorSurfaceTrajParam::
00041 G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
00042                          const G4Vector3D& vecV, const G4Vector3D& vecW )
00043 {
00044   SetParameters( pos, mom, vecV, vecW );
00045 }
00046 
00047 
00048 //------------------------------------------------------------------------
00049 G4ErrorSurfaceTrajParam::
00050 G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
00051                          const G4Plane3D& plane )
00052 {
00053   SetParameters( pos, mom, plane );
00054 }
00055 
00056 //------------------------------------------------------------------------
00057 void G4ErrorSurfaceTrajParam::
00058 SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
00059                const G4Plane3D& plane )
00060 {
00061   //--- Get two perpendicular vectors: first parallel X
00062   //    (unless normal is parallel to X, then take Y)
00063 
00064   G4double kCarTolerance =
00065     G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00066 
00067   G4ThreeVector Xvec(1.,0.,0.);
00068   G4Vector3D vecV = -Xvec.cross(plane.normal());
00069   if( vecV.mag() < kCarTolerance )
00070   {
00071     G4ThreeVector Zvec(0.,0.,1.);
00072     vecV = Zvec.cross(plane.normal());
00073   }
00074 
00075   G4Vector3D vecW = plane.normal().cross( vecV );
00076 
00077   SetParameters( pos, mom, vecV, vecW );
00078 }
00079 
00080 
00081 //------------------------------------------------------------------------
00082 void G4ErrorSurfaceTrajParam::
00083 SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
00084                const G4Vector3D& vecV, const G4Vector3D& vecW )
00085 {
00086   if( mom.mag() > 0. ) {
00087     fDir = mom;
00088     fDir /= mom.mag();
00089   } else {
00090     fDir = G4Vector3D(0.,0.,0.);
00091   }
00092   fVectorV = vecV / vecV.mag();
00093   fVectorW = vecW / vecW.mag();
00094   fInvP = 1./mom.mag();
00095   G4ThreeVector momv(mom);
00096   //check 3 vectors are ortogonal and right handed
00097 
00098   // now all 4 scalar memeber variables retain the signs
00099   //  fPV = momv.project( vecV ).mag();
00100   //  fPW = momv.project( vecW ).mag();
00101   fPV = momv.dot( vecV );
00102   fPW = momv.dot( vecW );
00103 
00104 
00105   G4ThreeVector posv(pos);
00106   // fV = posv.project( vecV ).mag();
00107   // fW = posv.project( vecW ).mag();
00108   fV = posv.dot( vecV );
00109   fW = posv.dot( vecW );
00110 }
00111 
00112 
00113 //------------------------------------------------------------------------
00114 std::ostream& operator<<(std::ostream& out, const G4ErrorSurfaceTrajParam& tp)
00115 {
00116   //  long mode = out.setf(std::ios::fixed,std::ios::floatfield);
00117   
00118   //  out << tp.theType;
00119   //  out << std::setprecision(5) << std::setw(10);
00120   out << " InvP= " << tp.fInvP << " PV= " << tp.fPV
00121       << " PW= " << tp.fPW << " V= " << tp.fV << " W= " << tp.fW << G4endl;
00122   out << " vectorV direction= " << tp.fVectorV
00123       << " vectorW direction= " << tp.fVectorW << G4endl;
00124     
00125   return out;
00126 }

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