Geant4  10.00.p03
Em10PrimaryGeneratorAction.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 //
28 //
29 //
30 // $Id: Em10PrimaryGeneratorAction.cc 73033 2013-08-15 09:24:45Z gcosmo $
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
36 
38 
41 
42 #include "G4Event.hh"
43 #include "G4ParticleGun.hh"
44 #include "G4ParticleTable.hh"
45 #include "G4ParticleDefinition.hh"
46 #include "Randomize.hh"
47 #include "G4ios.hh"
48 #include "G4PhysicalConstants.hh"
49 #include "G4SystemOfUnits.hh"
50 
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
54 
57 // Em10DetectorConstruction* Em10DC)
59 // Em10Detector(Em10DC),
60  rndmFlag("off"),xvertex(0.),yvertex(0.),zvertex(0.),
61  vertexdefined(false)
62 {
63  G4int n_particle = 1;
64  particleGun = new G4ParticleGun(n_particle);
65 
66  //create a messenger for this class
68 
69  // default particle kinematic
70 
72  G4String particleName;
73  G4ParticleDefinition* particle
74  = particleTable->FindParticle(particleName="proton");
76 
78 
81 
82  zvertex = 0.0 ; // -0.5*(Em10Detector->GetAbsorberThickness());
84 
85 }
86 
87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
88 
90 {
91  delete particleGun;
92  delete gunMessenger;
93 }
94 
95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
96 
98 {
99  //this function is called at the begining of event
100  //
102  GetParticleName();
103  /* ****************************************************
104  G4double x0,y0,z0;
105  if(vertexdefined)
106  {
107  x0 = xvertex;
108  y0 = yvertex;
109  z0 = zvertex;
110  }
111  else
112  {
113  x0 = 0.;
114  y0 = 0.;
115  z0 = 0.; // -0.5*(Em10Detector->GetWorldSizeZ()) ;
116  }
117  G4double r0,phi0;
118  if (rndmFlag == "on")
119  {
120  r0 = Em10Detector->GetAbsorberRadius())*std::sqrt(G4UniformRand();
121  phi0 = twopi*G4UniformRand();
122  x0 = r0*std::cos(phi0);
123  y0 = r0*std::sin(phi0);
124  }
125  ********************************************* */
126  // particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 
134 {
135  return thePrimaryParticleName;
136 }
137 
138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 
141 {
142  vertexdefined = true;
143  zvertex = z;
144  G4cout << " Z coordinate of the primary vertex = " << zvertex/mm <<
145  " mm." << G4endl;
146 }
147 
148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
149 
151 {
152  vertexdefined = true;
153  xvertex = x;
154  G4cout << " X coordinate of the primary vertex = " << xvertex/mm <<
155  " mm." << G4endl;
156 }
157 
158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
159 
161 {
162  vertexdefined = true;
163  yvertex = y;
164  G4cout << " Y coordinate of the primary vertex = " << yvertex/mm <<
165  " mm." << G4endl;
166 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
CLHEP::Hep3Vector G4ThreeVector
G4double z
Definition: TRTMaterials.hh:39
Em10PrimaryGeneratorMessenger * gunMessenger
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
int G4int
Definition: G4Types.hh:78
virtual void GeneratePrimaryVertex(G4Event *evt)
const G4String & GetParticleName() const
Definition of the Em10PrimaryGeneratorAction class.
Em10PrimaryGeneratorAction(Em10DetectorConstruction *)
void SetParticlePosition(G4ThreeVector aPosition)
G4GLOB_DLL std::ostream G4cout
static const double GeV
Definition: G4SIunits.hh:196
void SetParticleEnergy(G4double aKineticEnergy)
Definition of the Em10PrimaryGeneratorMessenger class.
static G4ParticleTable * GetParticleTable()
Definition of the Em10DetectorConstruction class.
G4ParticleDefinition * GetParticleDefinition() const
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static const double mm
Definition: G4SIunits.hh:102
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)