source: trunk/source/error_propagation/src/G4ErrorSurfaceTrajParam.cc @ 1202

Last change on this file since 1202 was 1058, checked in by garnier, 15 years ago

file release beta

File size: 4.5 KB
Line 
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// $Id: G4ErrorSurfaceTrajParam.cc,v 1.3 2007/05/31 20:22:45 arce Exp $
27// GEANT4 tag $Name: geant4-09-02-ref-02 $
28//
29// ------------------------------------------------------------
30//      GEANT 4 class implementation file
31// ------------------------------------------------------------
32//
33
34#include "G4ErrorSurfaceTrajParam.hh"
35#include <iomanip>
36
37#include "G4ThreeVector.hh"
38#include "G4GeometryTolerance.hh"
39
40//------------------------------------------------------------------------
41G4ErrorSurfaceTrajParam::
42G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
43                         const G4Vector3D& vecV, const G4Vector3D& vecW )
44{
45  SetParameters( pos, mom, vecV, vecW );
46}
47
48
49//------------------------------------------------------------------------
50G4ErrorSurfaceTrajParam::
51G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
52                         const G4Plane3D& plane )
53{
54  SetParameters( pos, mom, plane );
55}
56
57//------------------------------------------------------------------------
58void G4ErrorSurfaceTrajParam::
59SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
60               const G4Plane3D& plane )
61{
62  //--- Get two perpendicular vectors: first parallel X
63  //    (unless normal is parallel to X, then take Y)
64
65  G4double kCarTolerance =
66    G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
67
68  G4ThreeVector Xvec(1.,0.,0.);
69  G4Vector3D vecV = -Xvec.cross(plane.normal());
70  if( vecV.mag() < kCarTolerance )
71  {
72    G4ThreeVector Zvec(0.,0.,1.);
73    vecV = Zvec.cross(plane.normal());
74  }
75
76  G4Vector3D vecW = plane.normal().cross( vecV );
77
78  SetParameters( pos, mom, vecV, vecW );
79}
80
81
82//------------------------------------------------------------------------
83void G4ErrorSurfaceTrajParam::
84SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
85               const G4Vector3D& vecV, const G4Vector3D& vecW )
86{
87  if( mom.mag() > 0. ) {
88    fDir = mom;
89    fDir /= mom.mag();
90  } else {
91    fDir = G4Vector3D(0.,0.,0.);
92  }
93  fVectorV = vecV / vecV.mag();
94  fVectorW = vecW / vecW.mag();
95  fInvP = 1./mom.mag();
96  G4ThreeVector momv(mom);
97  //check 3 vectors are ortogonal and right handed
98
99  fPV = momv.project( vecV ).mag();
100  fPW = momv.project( vecW ).mag();
101
102  G4ThreeVector posv(pos);
103  fV = posv.project( vecV ).mag();
104  fW = posv.project( vecW ).mag();
105}
106
107
108//------------------------------------------------------------------------
109std::ostream& operator<<(std::ostream& out, const G4ErrorSurfaceTrajParam& tp)
110{
111  //  long mode = out.setf(std::ios::fixed,std::ios::floatfield);
112 
113  //  out << tp.theType;
114  //  out << std::setprecision(5) << std::setw(10);
115  out << " InvP= " << tp.fInvP << " PV= " << tp.fPV
116      << " PW= " << tp.fPW << " V= " << tp.fV << " W= " << tp.fW << G4endl;
117  out << " vectorV direction= " << tp.fVectorV
118      << " vectorW direction= " << tp.fVectorW << G4endl;
119   
120  return out;
121}
Note: See TracBrowser for help on using the repository browser.