Geant4-11
pyG4ParticleGun.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// ====================================================================
27// pyG4ParticleGun.cc
28//
29// 2005 Q
30// ====================================================================
31#include <boost/python.hpp>
32#include "G4Version.hh"
33#include "G4ParticleGun.hh"
34#include "G4ParticleTable.hh"
35#include "G4Event.hh"
36
37using namespace boost::python;
38
39#if G4VERSION_NUMBER < 910
40// ====================================================================
41// miscs
42// ====================================================================
43// What a hell!
44
48{
49 *this= right;
50}
51
55{
62
63 return *this;
64}
65
69{
70 return false;
71}
72
76{
77 return false;
78}
79
80#endif
81
82
83// ====================================================================
84// thin wrappers
85// ====================================================================
86namespace pyG4ParticleGun {
87
88#if G4VERSION_NUMBER >= 910
89// SetParticleMomentum
90void (G4ParticleGun::*f1_SetParticleMomentum)(G4double)
92void (G4ParticleGun::*f2_SetParticleMomentum)(G4ParticleMomentum)
94#endif
95
96
98void SetParticleByName(G4ParticleGun* gun, const std::string& pname)
100{
102 G4ParticleDefinition* pd= particleTable-> FindParticle(pname);
103 if (pd != 0) {
104 gun-> SetParticleDefinition(pd);
105 } else {
106 G4cout << "*** \"" << pname << "\" is not registered "
107 << "in available particle list" << G4endl;
108 }
109}
110
114{
115 const G4ParticleDefinition* pd= gun-> GetParticleDefinition();
116 return (pd-> GetParticleName()).c_str();
117}
118
119}
120
121using namespace pyG4ParticleGun;
122
123// ====================================================================
124// module definition
125// ====================================================================
127{
128#if G4VERSION_NUMBER < 910
129 class_<G4ParticleGun>
130#else
131 class_<G4ParticleGun, boost::noncopyable>
132#endif
133 ("G4ParticleGun", "particle gun")
134 // constructor
135 .def(init<G4int>())
136 .def(init<G4ParticleDefinition*>())
137 .def(init<G4ParticleDefinition*, G4int>())
138 // ---
139 .def("GeneratePrimaryVertex", &G4ParticleGun::GeneratePrimaryVertex)
140 .def("SetParticleDefinition", &G4ParticleGun::SetParticleDefinition)
141 .def("GetParticleDefinition", &G4ParticleGun::GetParticleDefinition,
142 return_value_policy<reference_existing_object>())
143#if G4VERSION_NUMBER >= 910
144 .def("SetParticleMomentum", f1_SetParticleMomentum)
145 .def("SetParticleMomentum", f2_SetParticleMomentum)
146#else
147 .def("SetParticleMomentum", &G4ParticleGun::SetParticleMomentum)
148#endif
149 .def("SetParticleMomentumDirection",
151 .def("GetParticleMomentumDirection",
153 .def("SetParticleEnergy", &G4ParticleGun::SetParticleEnergy)
154 .def("GetParticleEnergy", &G4ParticleGun::GetParticleEnergy)
155 .def("SetParticleCharge", &G4ParticleGun::SetParticleCharge)
156 .def("GetParticleCharge", &G4ParticleGun::GetParticleCharge)
157 .def("SetParticlePolarization", &G4ParticleGun::SetParticlePolarization)
158 .def("GetParticlePolarization", &G4ParticleGun::GetParticlePolarization)
159 .def("SetNumberOfParticles", &G4ParticleGun::SetNumberOfParticles)
160 .def("GetNumberOfParticles", &G4ParticleGun::GetNumberOfParticles)
161 .def("SetParticlePosition", &G4ParticleGun::SetParticlePosition)
162 .def("GetParticlePosition", &G4ParticleGun::GetParticlePosition)
163 .def("SetParticleTime", &G4ParticleGun::SetParticleTime)
164 .def("GetParticleTime", &G4ParticleGun::GetParticleTime)
165 .def("SetParticleByName", SetParticleByName)
166 .def("GetParticleByName", GetParticleByName)
167 ;
168}
G4ThreeVector G4ParticleMomentum
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
#define G4VERSION_NUMBER
Definition: G4Version.hh:43
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
const G4ParticleGun & operator=(const G4ParticleGun &)=delete
G4ThreeVector GetParticlePolarization() const
G4ParticleMomentum GetParticleMomentumDirection() const
G4double particle_energy
G4bool operator!=(const G4ParticleGun &) const =delete
G4bool operator==(const G4ParticleGun &) const =delete
void SetNumberOfParticles(G4int i)
void SetParticlePolarization(G4ThreeVector aVal)
G4ParticleDefinition * GetParticleDefinition() const
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4ThreeVector particle_polarization
G4ParticleMomentum particle_momentum_direction
G4int NumberOfParticlesToBeGenerated
G4double particle_charge
G4int GetNumberOfParticles() const
void SetParticleEnergy(G4double aKineticEnergy)
void SetParticleMomentumDirection(G4ParticleMomentum aMomDirection)
G4double GetParticleCharge() const
G4ParticleDefinition * particle_definition
virtual void GeneratePrimaryVertex(G4Event *evt)
void SetParticleMomentum(G4double aMomentum)
G4double GetParticleEnergy() const
void SetParticleCharge(G4double aCharge)
static G4ParticleTable * GetParticleTable()
void SetParticleTime(G4double aTime)
G4ThreeVector GetParticlePosition()
void SetParticlePosition(G4ThreeVector aPosition)
string pname
Definition: eplot.py:33
void SetParticleByName(G4ParticleGun *gun, const std::string &pname)
std::string GetParticleByName(G4ParticleGun *gun)
void export_G4ParticleGun()