50 :
Emin(0.),
Emax(0.), EminIon(0.), EmaxIon(0.),
51 index_particle(100000),
52 radius_spherical_source(0.), fwd_ion(0), adj_ion(0),
53 ion_name(
"not_defined")
57 PrimariesConsideredInAdjointSim[
G4String(
"e-")]=
false;
58 PrimariesConsideredInAdjointSim[
G4String(
"gamma")]=
false;
59 PrimariesConsideredInAdjointSim[
G4String(
"proton")]=
false;
60 PrimariesConsideredInAdjointSim[
G4String(
"ion")]=
false;
62 ListOfPrimaryFwdParticles.clear();
63 ListOfPrimaryAdjParticles.clear();
64 nb_fwd_gammas_per_event = 1;
65 nb_adj_primary_gammas_per_event = 1;
66 nb_adj_primary_electrons_per_event = 1;
73 delete theAdjointPrimaryGenerator;
81 size_t n=ListOfPrimaryAdjParticles.size();
82 index_particle=size_t(evt_id)-n*(size_t(evt_id)/
n);
89 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
"adj_proton") {
93 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() ==
"adjoint_nucleus") {
94 G4int A= ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass();
105 G4double m0=ListOfPrimaryFwdParticles[index_particle]->GetPDGMass();
106 G4double ekin=std::sqrt( m0*m0 + pmag*pmag) -m0;
125 weight_correction=1.;
127 if (ListOfPrimaryFwdParticles[index_particle] ==
G4Gamma::Gamma() && nb_fwd_gammas_per_event>1 ){
128 G4double weight = (1./nb_fwd_gammas_per_event);
130 for (
int i=0;i<nb_fwd_gammas_per_event-1;i++){
133 newFwdPrimVertex->
SetT0(0.);
145 adjPrimVertex->
SetT0(0.);
147 -
p.x(),-
p.y(),-
p.z());
154 G4double adjoint_weight = weight_correction*ComputeEnergyDistWeight(ekin,E1,E2)*adjoint_source_area*
pi;
156 if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
"adj_gamma") {
158 adjoint_weight = adjoint_weight/nb_adj_primary_gammas_per_event;
159 for (
int i=0;i<nb_adj_primary_gammas_per_event-1;i++){
162 newAdjPrimVertex->
SetT0(0.);
164 -
p.x(),-
p.y(),-
p.z());
166 newAdjPrimVertex->
SetWeight(adjoint_weight);
170 else if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
"adj_electron") {
172 adjoint_weight = adjoint_weight/nb_adj_primary_electrons_per_event;
173 for (
int i=0;i<nb_adj_primary_electrons_per_event-1;i++){
176 newAdjPrimVertex->
SetT0(0.);
178 -
p.x(),-
p.y(),-
p.z());
180 newAdjPrimVertex->
SetWeight(adjoint_weight);
184 adjPrimVertex->
SetWeight(adjoint_weight);
299 radius_spherical_source = radius;
300 center_spherical_source = center_pos;
301 type_of_adjoint_source =
"Spherical";
308 type_of_adjoint_source =
"ExternalSurfaceOfAVolume";
315 if (PrimariesConsideredInAdjointSim.find(particle_name) != PrimariesConsideredInAdjointSim.end()){
316 PrimariesConsideredInAdjointSim[particle_name]=
true;
324 if (PrimariesConsideredInAdjointSim.find(particle_name) != PrimariesConsideredInAdjointSim.end()){
325 PrimariesConsideredInAdjointSim[particle_name]=
false;
334 ListOfPrimaryFwdParticles.clear();
335 ListOfPrimaryAdjParticles.clear();
336 std::map<G4String, G4bool>::iterator iter;
337 for( iter = PrimariesConsideredInAdjointSim.begin(); iter != PrimariesConsideredInAdjointSim.end(); ++iter ) {
340 if ( fwd_particle_name !=
"ion") {
342 ListOfPrimaryFwdParticles.push_back(theParticleTable->
FindParticle(fwd_particle_name));
343 ListOfPrimaryAdjParticles.push_back(theParticleTable->
FindParticle(adj_particle_name));
357 ListOfPrimaryFwdParticles.push_back(fwd_ion);
358 ListOfPrimaryAdjParticles.push_back(adj_ion);
361 ListOfPrimaryFwdParticles.push_back(0);
362 ListOfPrimaryAdjParticles.push_back(0);
374 adj_ion = adjointIon;
static G4AdjointSimManager * GetInstance()
void UpdateListOfPrimaryParticles()
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void ClearEndOfAdjointTrackInfoVectors()
G4ThreeVector GetMomentum() const
G4ThreeVector GetPosition() const
void SetEmaxIon(G4double val)
void SetWeight(G4double w)
void SetEmax(G4double val)
void AddPrimaryVertex(G4PrimaryVertex *aPrimaryVertex)
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String &volume_name)
~G4AdjointPrimaryGeneratorAction()
const G4String & GetParticleName() const
G4int GetNbEvtOfLastRun()
void SetPrimaryIon(G4ParticleDefinition *adjointIon, G4ParticleDefinition *fwdIon)
G4PrimaryParticle * GetPrimary(G4int i=0) const
void ConsiderParticleAsPrimary(const G4String &particle_name)
double A(double temperature)
void SetAdjointTrackingMode(G4bool aBool)
G4AdjointPrimaryGeneratorAction()
void GeneratePrimaries(G4Event *)
void SetEminIon(G4double val)
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
void GenerateFwdPrimaryVertex(G4Event *anEvt, G4ParticleDefinition *adj_part, G4double E1, G4double E2)
static G4ParticleTable * GetParticleTable()
void NeglectParticleAsPrimary(const G4String &particle_name)
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String &volume_name)
static const G4double Emin
void SetPrimary(G4PrimaryParticle *pp)
void SetPosition(G4double x0, G4double y0, G4double z0)
G4double GetAdjointSourceArea()
static const G4double Emax
static constexpr double pi
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos)
void SetEmin(G4double val)
void ResetDidOneAdjPartReachExtSourceDuringEvent()