Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
pyG4ParticleGun.cc
이 파일의 문서화 페이지로 가기
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: pyG4ParticleGun.cc 76884 2013-11-18 12:54:03Z gcosmo $
27 // ====================================================================
28 // pyG4ParticleGun.cc
29 //
30 // 2005 Q
31 // ====================================================================
32 #include <boost/python.hpp>
33 #include "G4Version.hh"
34 #include "G4ParticleGun.hh"
35 #include "G4ParticleTable.hh"
36 #include "G4Event.hh"
37 
38 using namespace boost::python;
39 
40 #if G4VERSION_NUMBER < 910
41 // ====================================================================
42 // miscs
43 // ====================================================================
44 // What a hell!
45 
49 {
50  *this= right;
51 }
52 
56 {
57  NumberOfParticlesToBeGenerated= right.NumberOfParticlesToBeGenerated;
58  particle_definition= right.particle_definition;
59  particle_momentum_direction= right.particle_momentum_direction;
60  particle_energy= right.particle_energy;
61  particle_charge= right.particle_charge;
62  particle_polarization= right.particle_polarization;
63 
64  return *this;
65 }
66 
70 {
71  return 0;
72 }
73 
77 {
78  return 0;
79 }
80 
81 #endif
82 
83 
84 // ====================================================================
85 // thin wrappers
86 // ====================================================================
87 namespace pyG4ParticleGun {
88 
89 #if G4VERSION_NUMBER >= 910
90 // SetParticleMomentum
91 void (G4ParticleGun::*f1_SetParticleMomentum)(G4double)
93 void (G4ParticleGun::*f2_SetParticleMomentum)(G4ParticleMomentum)
95 #endif
96 
97 
99 void SetParticleByName(G4ParticleGun* gun, const std::string& pname)
101 {
103  G4ParticleDefinition* pd= particleTable-> FindParticle(pname);
104  if (pd != 0) {
105  gun-> SetParticleDefinition(pd);
106  } else {
107  G4cout << "*** \"" << pname << "\" is not registered "
108  << "in available particle list" << G4endl;
109  }
110 }
111 
115 {
116  const G4ParticleDefinition* pd= gun-> GetParticleDefinition();
117  return (pd-> GetParticleName()).c_str();
118 }
119 
120 }
121 
122 using namespace pyG4ParticleGun;
123 
124 // ====================================================================
125 // module definition
126 // ====================================================================
128 {
129 #if G4VERSION_NUMBER < 910
130  class_<G4ParticleGun>
131 #else
132  class_<G4ParticleGun, boost::noncopyable>
133 #endif
134  ("G4ParticleGun", "particle gun")
135  // constructor
136  .def(init<G4int>())
137  .def(init<G4ParticleDefinition*>())
138  .def(init<G4ParticleDefinition*, G4int>())
139  // ---
140  .def("GeneratePrimaryVertex", &G4ParticleGun::GeneratePrimaryVertex)
141  .def("SetParticleDefinition", &G4ParticleGun::SetParticleDefinition)
142  .def("GetParticleDefinition", &G4ParticleGun::GetParticleDefinition,
143  return_value_policy<reference_existing_object>())
144 #if G4VERSION_NUMBER >= 910
145  .def("SetParticleMomentum", f1_SetParticleMomentum)
146  .def("SetParticleMomentum", f2_SetParticleMomentum)
147 #else
148  .def("SetParticleMomentum", &G4ParticleGun::SetParticleMomentum)
149 #endif
150  .def("SetParticleMomentumDirection",
152  .def("GetParticleMomentumDirection",
154  .def("SetParticleEnergy", &G4ParticleGun::SetParticleEnergy)
155  .def("GetParticleEnergy", &G4ParticleGun::GetParticleEnergy)
156  .def("SetParticleCharge", &G4ParticleGun::SetParticleCharge)
157  .def("GetParticleCharge", &G4ParticleGun::GetParticleCharge)
158  .def("SetParticlePolarization", &G4ParticleGun::SetParticlePolarization)
159  .def("GetParticlePolarization", &G4ParticleGun::GetParticlePolarization)
160  .def("SetNumberOfParticles", &G4ParticleGun::SetNumberOfParticles)
161  .def("GetNumberOfParticles", &G4ParticleGun::GetNumberOfParticles)
162  .def("SetParticlePosition", &G4ParticleGun::SetParticlePosition)
163  .def("GetParticlePosition", &G4ParticleGun::GetParticlePosition)
164  .def("SetParticleTime", &G4ParticleGun::SetParticleTime)
165  .def("GetParticleTime", &G4ParticleGun::GetParticleTime)
166  .def("SetParticleByName", SetParticleByName)
167  .def("GetParticleByName", GetParticleByName)
168  ;
169 }
const G4ParticleGun & operator=(const G4ParticleGun &)=delete
G4double particle_energy
G4ThreeVector G4ParticleMomentum
void SetParticleTime(G4double aTime)
static G4ParticleTable * GetParticleTable()
G4int operator==(const G4ParticleGun &) const =delete
#define G4endl
Definition: G4ios.hh:61
G4double particle_charge
std::string GetParticleByName(MedicalBeam *beam)
void SetParticlePosition(G4ThreeVector aPosition)
G4ParticleDefinition * particle_definition
void export_G4ParticleGun()
G4int GetNumberOfParticles() const
G4int NumberOfParticlesToBeGenerated
double G4double
Definition: G4Types.hh:76
G4ParticleMomentum particle_momentum_direction
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
G4ThreeVector GetParticlePolarization() const
void SetParticlePolarization(G4ThreeVector aVal)
G4double GetParticleCharge() const
G4int operator!=(const G4ParticleGun &) const =delete
int G4int
Definition: G4Types.hh:78
G4ThreeVector GetParticlePosition()
G4double GetParticleEnergy() const
virtual void GeneratePrimaryVertex(G4Event *evt)
G4GLOB_DLL std::ostream G4cout
void SetParticleEnergy(G4double aKineticEnergy)
void SetParticleMomentum(G4double aMomentum)
void SetParticleByName(MedicalBeam *beam, const std::string &pname)
G4ParticleDefinition * GetParticleDefinition() const
G4ParticleMomentum GetParticleMomentumDirection() const
G4ThreeVector particle_polarization
void SetNumberOfParticles(G4int i)
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
void SetParticleCharge(G4double aCharge)