2
2
#ifndef PrimaryGeneratorAction_h
3
3
#define PrimaryGeneratorAction_h 1
4
4
5
+ #include < TF3.h>
5
6
#include < TH1D.h>
6
7
8
+ #include < fstream>
9
+ #include < iostream>
10
+
7
11
#include < G4IonTable.hh>
8
12
#include < G4ParticleGun.hh>
9
13
#include < G4VUserPrimaryGeneratorAction.hh>
10
- #include < fstream>
11
14
#include < globals.hh>
12
- #include < iostream>
13
15
14
16
#include " DetectorConstruction.hh"
17
+ #include " TRestGeant4Particle.h"
15
18
16
19
using namespace std ;
17
20
@@ -28,54 +31,21 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
28
31
virtual void GeneratePrimaries (G4Event*);
29
32
G4ParticleGun* GetParticleGun () { return fParticleGun ; };
30
33
31
- void SetSpectrum (TH1D* spt, double eMin = 0 , double eMax = 0 ) {
32
- TString xLabel = (TString)spt->GetXaxis ()->GetTitle ();
33
-
34
- if (xLabel.Contains (" MeV" )) {
35
- energyFactor = 1 .e3 ;
36
- } else if (xLabel.Contains (" GeV" )) {
37
- energyFactor = 1 .e6 ;
38
- } else {
39
- energyFactor = 1 .;
40
- }
41
-
42
- fSpectrum = spt;
43
- fSpectrumIntegral = fSpectrum ->Integral ();
44
-
45
- startEnergyBin = 1 ;
46
- endEnergyBin = fSpectrum ->GetNbinsX ();
47
-
48
- if (eMin > 0 ) {
49
- for (int i = startEnergyBin; i <= endEnergyBin; i++) {
50
- if (fSpectrum ->GetBinCenter (i) > eMin) {
51
- startEnergyBin = i;
52
- break ;
53
- }
54
- }
55
- }
56
-
57
- if (eMax > 0 ) {
58
- for (int i = startEnergyBin; i <= endEnergyBin; i++) {
59
- if (fSpectrum ->GetBinCenter (i) > eMax) {
60
- endEnergyBin = i;
61
- break ;
62
- }
63
- }
64
- }
65
-
66
- fSpectrumIntegral = fSpectrum ->Integral (startEnergyBin, endEnergyBin);
67
- }
34
+ void SetSpectrum (TH1D* spt, double eMin = 0 , double eMax = 0 );
35
+ void SetGeneratorSpatialDensity (TString str);
68
36
69
37
void SetAngularDistribution (TH1D* ang) { fAngularDistribution = ang; }
70
38
71
39
private:
40
+ vector<TRestGeant4Particle> fTempParticles ;
41
+
72
42
G4ParticleGun* fParticleGun ;
73
43
DetectorConstruction* fDetector ;
74
-
75
44
G4ParticleDefinition* fParticle = nullptr ;
76
45
77
46
TH1D* fSpectrum ;
78
47
TH1D* fAngularDistribution ;
48
+ TF3* fGeneratorSpatialDensityFunction ;
79
49
80
50
Int_t startEnergyBin;
81
51
Int_t endEnergyBin;
@@ -88,15 +58,26 @@ class PrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
88
58
Double_t lastEnergy;
89
59
90
60
void SetParticlePosition ();
91
- void SetParticlePosition (int n);
92
- G4ParticleDefinition* SetParticleDefinition (int n);
93
- void SetParticleEnergy (int n);
94
- void SetParticleDirection (int n);
61
+ G4ParticleDefinition* SetParticleDefinition (Int_t particlesourceindex, TRestGeant4Particle p);
62
+ void SetParticleEnergy (Int_t particlesourceindex, TRestGeant4Particle p);
63
+ void SetParticleDirection (Int_t particlesourceindex, TRestGeant4Particle p);
95
64
96
65
G4ThreeVector GetIsotropicVector ();
97
66
Double_t GetAngle (G4ThreeVector x, G4ThreeVector y);
98
67
Double_t GetCosineLowRandomThetaAngle ();
99
68
69
+ void GenPositionOnGDMLVolume (double & x, double & y, double & z);
70
+ void GenPositionOnGDMLSurface (double & x, double & y, double & z);
71
+ void GenPositionOnBoxVolume (double & x, double & y, double & z);
72
+ void GenPositionOnBoxSurface (double & x, double & y, double & z);
73
+ void GenPositionOnSphereVolume (double & x, double & y, double & z);
74
+ void GenPositionOnSphereSurface (double & x, double & y, double & z);
75
+ void GenPositionOnCylinderVolume (double & x, double & y, double & z);
76
+ void GenPositionOnCylinderSurface (double & x, double & y, double & z);
77
+ void GenPositionOnPoint (double & x, double & y, double & z);
78
+ void GenPositionOnWall (double & x, double & y, double & z);
79
+ void GenPositionOnPlate (double & x, double & y, double & z);
80
+
100
81
G4String fParType ;
101
82
G4String fGenType ;
102
83
G4double fParEnergy ;
0 commit comments