Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AdjointPrimaryGeneratorAction.hh
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// G4AdjointPrimaryGeneratorAction
27//
28// Class description:
29//
30// This class represents the PrimaryGeneratorAction that is used during
31// the entire adjoint simulation.
32// It uses the class G4AdjointPrimaryGenerator to generate randomly
33// adjoint primary particles on a user selected adjoint source
34// (External surface of a volume or Sphere).
35// The spectrum of the primary adjoint particles is set as 1/E with
36// user defined max and min energy.
37// The weight of the primary is set according to ReverseMC theory as
38// w=log(Emax/Emin)*E*adjoint_source_area*pi/n, with E the energy of
39// the particle, n the number of adjoint primary particles of same type
40// that will be generated during the simulation.
41// Different types of adjoint particles are generated event after event
42// in order to cover all the type of primaries and secondaries needed
43// for the simulation. For example if reverse e- ionisation, brem,
44// photo electric effect, and compton are considered both adjoint gamma
45// and adjoint e- will be considered alternatively as adjoint primary.
46// The user can decide to consider/neglect some type of particle by
47// using the macro commands "/adjoint/ConsiderAsPrimary" and
48// "/adjoint/NeglectAsPrimary". If an adjoint primary or its secondary
49// has reached the external surface, in the next event a fwd primary
50// particle equivalent to the last generated adjoint primary is
51// generated with the same position, energy but opposite direction
52// and the forward tracking phase starts.
53
54// --------------------------------------------------------------------
55// Class Name: G4AdjointPrimaryGeneratorAction
56// Author: L. Desorgher, 2007-2009
57// Organisation: SpaceIT GmbH
58// Contract: ESA contract 21435/08/NL/AT
59// Customer: ESA/ESTEC
60// --------------------------------------------------------------------
61#ifndef G4AdjointPrimaryGeneratorAction_hh
62#define G4AdjointPrimaryGeneratorAction_hh 1
63
64#include "G4ThreeVector.hh"
66#include "globals.hh"
67
68#include <iterator>
69#include <map>
70#include <vector>
71
73class G4ParticleGun;
74class G4Event;
77
78// --------------------------------------------------------------------
79
81{
82 public:
85
88
89 void GeneratePrimaries(G4Event*) override;
90 void SetEmin(G4double val);
91 void SetEmax(G4double val);
92 void SetEminIon(G4double val);
93 void SetEmaxIon(G4double val);
96 void ConsiderParticleAsPrimary(const G4String& particle_name);
97 void NeglectParticleAsPrimary(const G4String& particle_name);
100
101 inline void SetRndmFlag(const G4String& val) { rndmFlag = val; }
102 inline size_t GetNbOfAdjointPrimaryTypes() { return ListOfPrimaryAdjParticles.size(); }
103 inline std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles()
104 {
105 return &ListOfPrimaryFwdParticles;
106 }
107 inline const G4String& GetPrimaryIonName() { return ion_name; }
108 inline void SetNbPrimaryFwdGammasPerEvent(G4int nb) { nb_fwd_gammas_per_event = nb; }
110 {
111 nb_adj_primary_gammas_per_event = nb;
112 }
114 {
115 nb_adj_primary_electrons_per_event = nb;
116 }
118 {
119 return ListOfPrimaryFwdParticles[index_particle];
120 }
121
122 private: // methods
123 G4double ComputeEnergyDistWeight(G4double energy, G4double E1, G4double E2);
124
125 private: // attributes
126 G4String rndmFlag; // flag for a rndm impact point
127
128 // The generator of primary vertex except for weight
129 G4AdjointPrimaryGenerator* theAdjointPrimaryGenerator = nullptr;
130
131 // Emin and Emax energies of the adjoint source
132 //---------------------------------------------
133 G4double Emin = 0.0;
134 G4double Emax = 0.0;
135 G4double EminIon = 0.0;
136 G4double EmaxIon = 0.0;
137
138 // List of type of primary adjoint and forward particle used in the
139 // simulation
140 //------------------------------------------------------------------
141 std::vector<G4ParticleDefinition*> ListOfPrimaryFwdParticles;
142 std::vector<G4ParticleDefinition*> ListOfPrimaryAdjParticles;
143 std::map<G4String, G4bool> PrimariesConsideredInAdjointSim;
144 // if true considered if false not considered
145
146 std::size_t index_particle = 100000;
147
148 G4ThreeVector pos, direction, p;
149
150 G4String type_of_adjoint_source; // Spherical ExtSurfaceOfAVolume
151 G4double radius_spherical_source = 0.0;
152 G4ThreeVector center_spherical_source;
153 G4int nb_fwd_gammas_per_event = 1;
154 G4int nb_adj_primary_gammas_per_event = 1;
155 G4int nb_adj_primary_electrons_per_event = 1;
156
157 // For simulation with ions
158 //--------------------------
159 G4ParticleDefinition* fwd_ion = nullptr;
160 G4ParticleDefinition* adj_ion = nullptr;
161 G4String ion_name = "not_defined";
162};
163
164#endif
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4AdjointPrimaryGeneratorAction & operator=(const G4AdjointPrimaryGeneratorAction &)=delete
std::vector< G4ParticleDefinition * > * GetListOfPrimaryFwdParticles()
void ConsiderParticleAsPrimary(const G4String &particle_name)
G4AdjointPrimaryGeneratorAction(const G4AdjointPrimaryGeneratorAction &)=delete
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String &volume_name)
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos)
G4ParticleDefinition * GetLastGeneratedFwdPrimaryParticle()
void NeglectParticleAsPrimary(const G4String &particle_name)
void SetPrimaryIon(G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon)