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: G4ErrorFreeTrajParam.cc 69766 2013-05-14 14:33:55Z gcosmo $ 00027 // 00028 // ------------------------------------------------------------ 00029 // GEANT 4 class implementation file 00030 // ------------------------------------------------------------ 00031 // 00032 00033 #include "G4ErrorFreeTrajParam.hh" 00034 #include "G4ThreeVector.hh" 00035 #include "G4SystemOfUnits.hh" 00036 00037 #include <iomanip> 00038 00039 //------------------------------------------------------------------------ 00040 G4ErrorFreeTrajParam::G4ErrorFreeTrajParam( const G4Point3D& pos, 00041 const G4Vector3D& mom ) 00042 { 00043 SetParameters( pos, mom ); 00044 } 00045 00046 00047 //------------------------------------------------------------------------ 00048 void G4ErrorFreeTrajParam::SetParameters( const G4Point3D& pos, 00049 const G4Vector3D& mom ) 00050 { 00051 fInvP = 1./mom.mag(); 00052 fDir = mom*fInvP; 00053 fLambda = 90.*deg - mom.theta(); 00054 fPhi = mom.phi(); 00055 G4Vector3D vxPerp(0.,0.,0.); 00056 if( mom.mag() > 0.) { 00057 vxPerp = mom/mom.mag(); 00058 } 00059 G4Vector3D vyPerp = G4Vector3D( -vxPerp.y(), vxPerp.x(), 0.); 00060 vyPerp /= vyPerp.mag(); 00061 G4Vector3D vzPerp = vxPerp.cross( vyPerp ); 00062 vzPerp /= vzPerp.mag(); 00063 // check if right handed 00064 // fXPerp = pos.proj( mom ); 00065 G4ThreeVector posv(pos); 00066 if( vyPerp.mag() != 0. ) { 00067 // now all 2 scalar memeber variables retain the signs 00068 // fYPerp = posv.project( vyPerp ).mag(); 00069 // fZPerp = posv.project( vzPerp ).mag(); 00070 fYPerp = posv.dot( vyPerp ); 00071 fZPerp = posv.dot( vzPerp ); 00072 } else { 00073 fYPerp = 0.; 00074 fZPerp = 0.; 00075 } 00076 } 00077 00078 //------------------------------------------------------------------------ 00079 void G4ErrorFreeTrajParam::Update( const G4Track* aTrack ) 00080 { 00081 SetParameters( aTrack->GetPosition(), aTrack->GetMomentum() ); 00082 00083 } 00084 00085 00086 //------------------------------------------------------------------------ 00087 std::ostream& operator<<(std::ostream& out, const G4ErrorFreeTrajParam& tp) 00088 { 00089 G4int oldprc = out.precision(8); 00090 out << " InvP= " << tp.fInvP << " Theta= " 00091 << tp.fLambda << " Phi= " << tp.fPhi << " YPerp= " << tp.fYPerp 00092 << " ZPerp= " << tp.fZPerp << G4endl; 00093 out << " momentum direction= " << tp.fDir << G4endl; 00094 out.precision(oldprc); 00095 00096 return out; 00097 }