Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
XrayFluoPlanePrimaryGeneratorAction.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 //
27 // $Id: XrayFluoPlanePrimaryGeneratorAction.cc
28 // GEANT4 tag $Name:
29 //
30 // Author: Alfonso Mantero (Alfonso.Mantero@ge.infn.it)
31 //
32 // History:
33 // -----------
34 // 02 Sep 2003 Alfonso Mantero created
35 //
36 // -------------------------------------------------------------------
37 
41 #include "XrayFluoRunAction.hh"
43 #include "XrayFluoDataSet.hh"
44 #include "G4PhysicalConstants.hh"
45 #include "G4SystemOfUnits.hh"
46 #include "G4UnitsTable.hh"
47 #include "G4DataVector.hh"
48 #include "G4Event.hh"
49 #include "G4ParticleGun.hh"
50 #include "G4ParticleTable.hh"
51 #include "G4ParticleDefinition.hh"
52 #include "Randomize.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
55 
57  :rndmFlag("on"),beam("off"),spectrum("off"),isoVert("off")
58 {
59 
60  XrayFluoDetector = XrayFluoDC;
61 
62  G4int n_particle = 1;
63  particleGun = new G4ParticleGun(n_particle);
64 
65  //create a messenger for this class
68 
69  // default particle kinematic
70 
72  G4String particleName;
73  G4ParticleDefinition* particle
74  = particleTable->FindParticle(particleName="gamma");
77 
78 
82 
83  G4cout << "XrayFluoPlanePrimaryGeneratorAction created UUUUUUUUUUAAAAAAAAAAAAAAAAAAAAAAAaa" << G4endl;
84 
85 }
86 
87 
88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
89 
91 {
92  delete particleGun;
93  delete gunMessenger;
94  delete runManager;
95 
96  G4cout << "XrayFluoPlanePrimaryGeneratorAction deleted" << G4endl;
97 
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
101 
103 {
104  //this function is called at the begining of event
105  //
107  G4double y0 = 0.*m, x0 = 0.*m;
109  if (rndmFlag == "on")
110 
111  {y0 = (XrayFluoDetector->GetPlaneSizeXY())*(G4UniformRand()-0.5);
112  x0 = (XrayFluoDetector->GetPlaneSizeXY())*(G4UniformRand()-0.5) + dX;
113  }
114 
115  z0 = -1 * dX;
116 
118 
120 
121  //randomize starting point
122  if (beam == "on")
123  {
124  G4double radius = 0.5 * mm;
125  G4double rho = radius*std::sqrt(G4UniformRand());
126  G4double theta = 2*pi*G4UniformRand()*rad;
128 
129  G4double y = rho * std::sin(theta);
130  G4double x = rho * std::cos(theta);
131 
133  }
134  //shoot particles according to a certain spectrum
135  if (spectrum =="on")
136  {
138  ->GetParticleName();
139  if(particle == "proton"|| particle == "alpha")
140  {
141  G4DataVector* energies = runManager->GetEnergies();
143 
145  G4double partSum = 0;
146  G4int j = 0;
147  G4double random= sum*G4UniformRand();
148  while (partSum<random)
149  {
150  partSum += (*data)[j];
151  j++;
152  }
153 
154  particleGun->SetParticleEnergy((*energies)[j]);
155 
156  }
157  else if (particle == "gamma")
158  {
159  const XrayFluoDataSet* dataSet = runManager->GetGammaSet();
160 
161  G4int i = 0;
162  G4int id = 0;
163  G4double minEnergy = 0. * keV;
164  G4double particleEnergy= 0.;
165  G4double maxEnergy = 10. * keV;
166  G4double energyRange = maxEnergy - minEnergy;
167 
168  while ( i == 0)
169  {
170  G4double random = G4UniformRand();
171 
172  G4double randomNum = G4UniformRand(); //*5.0E6;
173 
174  particleEnergy = (random*energyRange) + minEnergy;
175 
176  if ((dataSet->FindValue(particleEnergy,id)) > randomNum)
177  {
178  i = 1;
179 
180  }
181  }
182  particleGun->SetParticleEnergy(particleEnergy);
183  }
184  }
185 
186  if (isoVert == "on")
187  {
188  G4double rho = 1. *m;
189  //theta in [0;pi/2]
190  G4double theta = (pi/2)*G4UniformRand();
191  //phi in [-pi;pi]
192  G4double phi = (G4UniformRand()*2*pi)- pi;
193  G4double x = rho*std::sin(theta)*std::sin(phi);
194  G4double y = rho*std::sin(theta)*std::cos(phi);
195  G4double z = -(rho*std::cos(theta));
197 
200 
201  G4double Dx = Xdim*(G4UniformRand()-0.5);
202 
203  G4double Dy = Ydim*(G4UniformRand()-0.5);
204 
206 
207  }
208 #ifdef G4ANALYSIS_USE
209 
210  G4double partEnergy = particleGun->GetParticleEnergy();
212  analysis->analysePrimaryGenerator(partEnergy/keV);
213 
214 #endif
215 
217 }
218 
219 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
220 
221 
222 
223 
224 
225 
226 
227 
228 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
Float_t x
Definition: compare.C:6
XrayFluoPlanePrimaryGeneratorAction(const XrayFluoPlaneDetectorConstruction *)
CLHEP::Hep3Vector G4ThreeVector
static XrayFluoAnalysisManager * getInstance()
static G4ParticleTable * GetParticleTable()
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double mm
Definition: G4SIunits.hh:115
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
Double_t z
XrayFluoPlanePrimaryGeneratorMessenger * gunMessenger
const G4String & GetParticleName() const
const XrayFluoDataSet * GetGammaSet() const
G4double GetDataSum() const
void SetParticlePosition(G4ThreeVector aPosition)
const XML_Char const XML_Char * data
Definition: expat.h:268
static constexpr double m
Definition: G4SIunits.hh:129
double G4double
Definition: G4Types.hh:76
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)
#define G4UniformRand()
Definition: Randomize.hh:53
static constexpr double rad
Definition: G4SIunits.hh:149
Double_t radius
int G4int
Definition: G4Types.hh:78
G4double FindValue(G4double e, G4int) const
G4double GetParticleEnergy() const
void analysePrimaryGenerator(G4double energy)
virtual void GeneratePrimaryVertex(G4Event *evt)
G4GLOB_DLL std::ostream G4cout
static constexpr double cm
Definition: G4SIunits.hh:119
void SetParticleEnergy(G4double aKineticEnergy)
const XrayFluoPlaneDetectorConstruction * XrayFluoDetector
static constexpr double pi
Definition: G4SIunits.hh:75
G4DataVector * GetData() const
G4DataVector * GetEnergies() const
G4ParticleDefinition * GetParticleDefinition() const
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)