Geant4  10.03
pyG4ThreeVector.cc
Go to the documentation of this file.
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: pyG4ThreeVector.cc 76884 2013-11-18 12:54:03Z gcosmo $
27 // ====================================================================
28 // pyG4ThreeVector.cc
29 //
30 // 2005 Q
31 // ====================================================================
32 #include <boost/python.hpp>
33 #include "G4ThreeVector.hh"
34 #include "G4RotationMatrix.hh"
35 
36 using namespace boost::python;
37 using namespace CLHEP;
38 
39 typedef G4ThreeVector XXX; // ...
40 
41 // ====================================================================
42 // thin wrappers
43 // ====================================================================
44 namespace pyG4ThreeVector {
45 
46 G4double(XXX::*f1_theta)() const= &XXX::theta;
47 G4double(XXX::*f2_theta)(const XXX&) const = &XXX::theta;
48 
49 G4double(XXX::*f1_cosTheta)() const= &XXX::cosTheta;
50 G4double(XXX::*f2_cosTheta)(const XXX&) const = &XXX::cosTheta;
51 
52 G4double(XXX::*f1_cos2Theta)() const= &XXX::cos2Theta;
53 G4double(XXX::*f2_cos2Theta)(const XXX&) const = &XXX::cos2Theta;
54 
55 G4double(XXX::*f1_perp2)() const= &XXX::perp2;
56 G4double(XXX::*f2_perp2)(const XXX&) const = &XXX::perp2;
57 
58 G4double(XXX::*f1_perp)() const= &XXX::perp;
59 G4double(XXX::*f2_perp)(const XXX&) const = &XXX::perp;
60 
62 G4double(XXX::*f2_angle)(const XXX&) const = &XXX::angle;
63 
64 G4double(XXX::*f1_eta)() const= &XXX::eta;
65 G4double(XXX::*f2_eta)(const XXX&) const = &XXX::eta;
66 
67 XXX(XXX::*f1_project)() const= &XXX::project;
68 XXX(XXX::*f2_project)(const XXX&) const = &XXX::project;
69 
70 XXX(XXX::*f1_perpPart)() const= &XXX::perpPart;
71 XXX(XXX::*f2_perpPart)(const XXX&) const = &XXX::perpPart;
72 
73 G4double(XXX::*f1_rapidity)() const= &XXX::rapidity;
74 G4double(XXX::*f2_rapidity)(const XXX&) const = &XXX::rapidity;
75 
76 G4double(XXX::*f1_polarAngle)(const XXX&) const= &XXX::polarAngle;
77 G4double(XXX::*f2_polarAngle)(const XXX&, const XXX&) const = &XXX::polarAngle;
78 
79 G4double(XXX::*f1_azimAngle)(const XXX&) const= &XXX::azimAngle;
80 G4double(XXX::*f2_azimAngle)(const XXX&, const XXX&) const = &XXX::azimAngle;
81 
82 XXX&(XXX::*f1_rotate)(G4double, const XXX&)= &XXX::rotate;
83 XXX&(XXX::*f2_rotate)(const XXX&, G4double)= &XXX::rotate;
84 XXX&(XXX::*f3_rotate)(const HepAxisAngle&)= &XXX::rotate;
85 XXX&(XXX::*f4_rotate)(const HepEulerAngles&)= &XXX::rotate;
86 XXX&(XXX::*f5_rotate)(G4double, G4double, G4double)= &XXX::rotate;
87 
88 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_isNear, isNear, 1, 2)
89 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_isParallel, isParallel, 1, 2)
90 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_isOrthogonal, isOrthogonal, 1, 2)
91 
92 }
93 
94 using namespace pyG4ThreeVector;
95 
96 // ====================================================================
97 // module definition
98 // ====================================================================
100 {
101  class_<G4ThreeVector>("G4ThreeVector", "general 3-vector")
102  // constructors
103  .def(init<G4double>())
104  .def(init<G4double, G4double>())
105  .def(init<G4double, G4double, G4double>())
106  .def(init<const XXX&>())
107 
108  // property
109  .add_property("x", &XXX::x, &XXX::setX)
110  .add_property("y", &XXX::y, &XXX::setY)
111  .add_property("z", &XXX::z, &XXX::setZ)
112 
113  // methods
114  .def("set", &XXX::set)
115  .def("phi", &XXX::phi)
116  .def("mag", &XXX::mag)
117  .def("mag2", &XXX::mag2)
118  .def("setPhi", &XXX::setPhi)
119  .def("setTheta", &XXX::setTheta)
120  .def("setMag", &XXX::setMag)
121  .def("setPerp", &XXX::setPerp)
122  .def("setCylTheta", &XXX::setCylTheta)
123  .def("howNear", &XXX::howNear)
124  .def("deltaR", &XXX::deltaR)
125  .def("unit", &XXX::unit)
126  .def("orthogonal", &XXX::orthogonal)
127  .def("dot", &XXX::dot)
128  .def("cross", &XXX::cross)
129  .def("pseudoRapidity", &XXX::pseudoRapidity)
130  .def("setEta", &XXX::setEta)
131  .def("setCylEta",&XXX::setCylEta)
132  .def("setRThetaPhi", &XXX::setRThetaPhi)
133  .def("setREtaPhi", &XXX::setREtaPhi)
134  .def("setRhoPhiZ", &XXX::setRhoPhiZ)
135  .def("setRhoPhiEta", &XXX::setRhoPhiEta)
136  .def("getX", &XXX::getX)
137  .def("getY", &XXX::getY)
138  .def("getZ", &XXX::getZ)
139  .def("getR", &XXX::getR)
140  .def("getTheta", &XXX::getTheta)
141  .def("getPhi", &XXX::getPhi)
142  .def("r", &XXX::r)
143  .def("rho", &XXX::rho)
144  .def("getRho", &XXX::getRho)
145  .def("getEta", &XXX::getEta)
146  .def("setR", &XXX::setR)
147  .def("setRho", &XXX::setRho)
148  .def("compare", &XXX::compare)
149  .def("diff2", &XXX::diff2)
150  .def("setTolerance", &XXX::setTolerance)
151  .staticmethod("setTolerance")
152  .def("getTolerance", &XXX::getTolerance)
153  .staticmethod("getTolerance")
154  .def("isNear", &XXX::isNear, f_isNear())
155  .def("isParallel", &XXX::isParallel, f_isParallel())
156  .def("isOrthogonal", &XXX::isOrthogonal, f_isOrthogonal())
157  .def("howParallel", &XXX::howParallel)
158  .def("howOrthogonal", &XXX::howOrthogonal)
159  .def("beta", &XXX::beta)
160  .def("gamma", &XXX::gamma)
161  .def("deltaPhi", &XXX::deltaPhi)
162  .def("coLinearRapidity", &XXX::coLinearRapidity)
163  .def("theta", f1_theta)
164  .def("theta", f2_theta)
165  .def("cosTheta", f1_cosTheta)
166  .def("cosTheta", f2_cosTheta)
167  .def("cos2Theta", f1_cos2Theta)
168  .def("cos2Theta", f2_cos2Theta)
169  .def("perp2", f1_perp2)
170  .def("perp2", f2_perp2)
171  .def("angle", f1_angle)
172  .def("angle", f2_angle)
173  .def("eta", f1_eta)
174  .def("eta", f2_eta)
175  .def("project", f1_project)
176  .def("project", f2_project)
177  .def("perpPart", f1_perpPart)
178  .def("perpPart", f2_perpPart)
179  .def("rapidity", f1_rapidity)
180  .def("rapidity", f2_rapidity)
181  .def("polarAngle",f1_polarAngle)
182  .def("polarAngle",f2_polarAngle)
183  .def("azimAngle", f1_azimAngle)
184  .def("azimAngle", f2_azimAngle)
185  .def("rotateX", &XXX::rotateX,
186  return_value_policy<reference_existing_object>())
187  .def("rotateY", &XXX::rotateY,
188  return_value_policy<reference_existing_object>())
189  .def("rotateZ", &XXX::rotateZ,
190  return_value_policy<reference_existing_object>())
191  .def("rotateUz", &XXX::rotateUz,
192  return_value_policy<reference_existing_object>())
193  .def("transform",&XXX::transform,
194  return_value_policy<reference_existing_object>())
195  .def("rotate", f1_rotate,
196  return_value_policy<reference_existing_object>())
197  .def("rotate", f2_rotate,
198  return_value_policy<reference_existing_object>())
199  .def("rotate", f5_rotate,
200  return_value_policy<reference_existing_object>())
201 
202  // operators
203  .def(self_ns::str(self))
204  .def(self == self)
205  .def(self != self)
206  .def(self += self)
207  .def(self -= self)
208  .def(self - self)
209  .def(self + self)
210  .def(self * self)
211  .def(self * G4double())
212  .def(self / G4double())
213  .def(G4double() * self)
214  .def(self *= G4double())
215  .def(self /= G4double())
216  .def(self > self)
217  .def(self < self)
218  .def(self >= self)
219  .def(self <= self)
220  ;
221 }
222 
XXX(XXX::* f1_project)() const
G4double(XXX::* f1_angle)() const
G4double(XXX::* f2_azimAngle)(const XXX &, const XXX &) const
CLHEP::Hep3Vector G4ThreeVector
G4double(XXX::* f2_theta)(const XXX &) const
G4double(XXX::* f2_angle)(const XXX &) const
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateTubeVolume, CreateTubeVolume, 4, 6) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_CreateConeVolume
void export_G4ThreeVector()
static G4double angle[DIM]
G4double(XXX::* f1_theta)() const
G4double(XXX::* f2_perp)(const XXX &) const
XXX(XXX::* f1_perpPart)() const
XXX &(XXX::* f5_rotate)(G4double, G4double, G4double)
G4double(XXX::* f1_eta)() const
XXX(XXX::* f2_perpPart)(const XXX &) const
G4double(XXX::* f2_eta)(const XXX &) const
XXX &(XXX::* f2_rotate)(const XXX &, G4double)
XXX &(XXX::* f3_rotate)(const HepAxisAngle &)
G4double(XXX::* f2_polarAngle)(const XXX &, const XXX &) const
XXX(XXX::* f2_project)(const XXX &) const
G4double(XXX::* f1_cosTheta)() const
G4double(XXX::* f2_cos2Theta)(const XXX &) const
G4double(XXX::* f2_perp2)(const XXX &) const
G4double(XXX::* f1_perp)() const
G4double(XXX::* f1_perp2)() const
G4double(XXX::* f2_cosTheta)(const XXX &) const
G4double(XXX::* f1_cos2Theta)() const
G4ThreeVector XXX
XXX &(XXX::* f4_rotate)(const HepEulerAngles &)
G4double(XXX::* f1_polarAngle)(const XXX &) const
G4double(XXX::* f1_rapidity)() const
G4double(XXX::* f2_rapidity)(const XXX &) const
double G4double
Definition: G4Types.hh:76
XXX &(XXX::* f1_rotate)(G4double, const XXX &)
G4double(XXX::* f1_azimAngle)(const XXX &) const