G4AdjointPrimaryGeneratorAction.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00029 //      Class Name:     G4AdjointPrimaryGeneratorAction
00030 //      Author:         L. Desorgher
00031 //      Organisation:   SpaceIT GmbH
00032 //      Contract:       ESA contract 21435/08/NL/AT
00033 //      Customer:       ESA/ESTEC
00035 //
00036 // CHANGE HISTORY
00037 // --------------
00038 //      ChangeHistory: 
00039 //              10-01-2007 creation by L. Desorgher     
00040 //              1-11-2009 Splitting of G4AdjointPrimaryGeneratorAction in two classes  G4AdjointPrimaryGeneratorAction and G4AdjointPrimaryGenerator L.Desorgher
00041 //                                      
00042 //
00043 //-------------------------------------------------------------
00044 //      Documentation:
00045 //              This class represents the PrimaryGeneratorAction that is used during the entire adjoint simulation.
00046 //              It uses the class G4AdjointPrimaryGenerator to generate randomly adjoint primary particles on a user selected 
00047 //              adjoint source (External surface of a volume or Sphere).
00048 //              The spectrum of the primary  adjoint particles is set as 1/E with user defined max and min energy.
00049 //              The weight of the primary is set according to ReverseMC theory as  w=log(Emax/Emin)*E*adjoint_source_area*pi/n, with E the energy of the
00050 //              particle, n the number of adjoint primary particles of same type that will be generated during the simulation.  
00051 //              Different types of adjoint particles are generated event after event in order
00052 //              to cover all the type of primaries and secondaries needed for the simulation. For example if reverse e- ionisation, brem, photo electric effect, and
00053 //              compton are considered both adjoint gamma and adjoint e- will be considered alternatively as adjoint primary. 
00054 //              The user can decide to consider/neglect some type of particle by using the macro
00055 //              commands   /adjoint/ConsiderAsPrimary and /adjoint/NeglectAsPrimary. If  an adjoint primary or its secondary has reached the external surface, 
00056 //              in the next event a fwd primary particle equivalent to the last generated adjoint primary is generated with the same position, energy but opposite direction
00057 //              and the forward tracking phase starts. 
00058 //              
00059 //              
00060 //
00061 #ifndef G4AdjointPrimaryGeneratorAction_h
00062 #define G4AdjointPrimaryGeneratorAction_h 1
00063 #include "G4VUserPrimaryGeneratorAction.hh"
00064 #include "globals.hh"
00065 #include"G4ThreeVector.hh"
00066 #include <vector>
00067 #include <map>
00068 #include <iterator>
00069 
00070 class G4AdjointPosOnPhysVolGenerator;
00071 class G4ParticleGun;
00072 class G4Event;
00073 class G4AdjointPrimaryGenerator;
00074 class G4ParticleDefinition;
00075 
00077 //
00078 class G4AdjointPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
00079 {
00080   public: //constructor, destructor
00081 
00082     G4AdjointPrimaryGeneratorAction();    
00083    ~G4AdjointPrimaryGeneratorAction();
00084 
00085   public: //public methods
00086     
00087     void GeneratePrimaries(G4Event*);
00088     void SetRndmFlag(const G4String& val) { rndmFlag = val;}
00089     void SetEmin(G4double val);
00090     void SetEmax(G4double val); 
00091     void SetEminIon(G4double val);
00092     void SetEmaxIon(G4double val);
00093     void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos);
00094     void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name);
00095     void ConsiderParticleAsPrimary(const G4String& particle_name);
00096     void NeglectParticleAsPrimary(const G4String& particle_name);
00097     void SetPrimaryIon(G4ParticleDefinition* adjointIon, G4ParticleDefinition* fwdIon);
00098     void UpdateListOfPrimaryParticles();
00099     inline size_t GetNbOfAdjointPrimaryTypes(){return ListOfPrimaryAdjParticles.size();}
00100     inline std::vector<G4ParticleDefinition*> GetListOfPrimaryFwdParticles(){return ListOfPrimaryFwdParticles;}
00101     inline const G4String& GetPrimaryIonName(){return ion_name;}
00102 
00103   private: //private methods
00104 
00105     G4double ComputeEnergyDistWeight(G4double energy, G4double E1, G4double E2);
00106   
00107   private: //attributes
00108     
00109     G4String  rndmFlag;   //flag for a rndm impact point
00110     
00111     //The generator of primary vertex except for weight
00112     G4AdjointPrimaryGenerator* theAdjointPrimaryGenerator;
00113   
00114     //Emin and Emax energies of the adjoint source
00115     //---------------------------------------------
00116     G4double Emin;
00117     G4double Emax;
00118     G4double EminIon;
00119     G4double EmaxIon;
00120 
00121     //List of type of primary adjoint and forward  particle used in the simulation
00122     //---------------------------------------------------------------------------
00123     std::vector<G4ParticleDefinition*> ListOfPrimaryFwdParticles;
00124     std::vector<G4ParticleDefinition*> ListOfPrimaryAdjParticles;
00125     std::map<G4String, G4bool> PrimariesConsideredInAdjointSim; //if true considered if false not considered
00126     G4int NbOfAdjointPrimaryTypes;
00127 
00128     size_t index_particle;
00129     G4bool last_generated_part_was_adjoint;
00130     G4ThreeVector  pos,  direction, p; 
00131    
00132     G4String type_of_adjoint_source; //Spherical ExtSurfaceOfAVolume
00133     G4double radius_spherical_source;
00134     G4ThreeVector center_spherical_source;
00135     
00136     //For simulation with ions
00137     //--------------------------
00138     G4ParticleDefinition* fwd_ion;
00139     G4ParticleDefinition* adj_ion;
00140     G4String ion_name;
00141 };
00142 #endif
00143 
00144 

Generated on Mon May 27 17:47:37 2013 for Geant4 by  doxygen 1.4.7