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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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"
 65 #include "G4VUserPrimaryGeneratorAction.hh"
 66 #include "globals.hh"
 67 
 68 #include <iterator>
 69 #include <map>
 70 #include <vector>
 71 
 72 class G4AdjointPosOnPhysVolGenerator;
 73 class G4ParticleGun;
 74 class G4Event;
 75 class G4AdjointPrimaryGenerator;
 76 class G4ParticleDefinition;
 77 
 78 // --------------------------------------------------------------------
 79 
 80 class G4AdjointPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
 81 {
 82   public:
 83     G4AdjointPrimaryGeneratorAction();
 84     ~G4AdjointPrimaryGeneratorAction() override;
 85 
 86     G4AdjointPrimaryGeneratorAction(const G4AdjointPrimaryGeneratorAction&) = delete;
 87     G4AdjointPrimaryGeneratorAction& operator=(const G4AdjointPrimaryGeneratorAction&) = delete;
 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);
 94     void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos);
 95     void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name);
 96     void ConsiderParticleAsPrimary(const G4String& particle_name);
 97     void NeglectParticleAsPrimary(const G4String& particle_name);
 98     void SetPrimaryIon(G4ParticleDefinition* adjointIon, G4ParticleDefinition* fwdIon);
 99     void UpdateListOfPrimaryParticles();
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; }
109     inline void SetNbAdjointPrimaryGammasPerEvent(G4int nb)
110     {
111       nb_adj_primary_gammas_per_event = nb;
112     }
113     inline void SetNbAdjointPrimaryElectronsPerEvent(G4int nb)
114     {
115       nb_adj_primary_electrons_per_event = nb;
116     }
117     inline G4ParticleDefinition* GetLastGeneratedFwdPrimaryParticle()
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
165