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