//////////////////////////////////////////////////////////////////// /// \class RAT::VertexGen_Spectrum /// /// \brief Vertex Generator - events of given particle (or ion) type, with energies sampled from spectrum via DB /// /// \author Jeanne Wilson -- contact person /// /// REVISION HISTORY: /// - first version : 18-July-2008 /// - 2014-11-26: Matt Strait - doxygen fixes /// - 2015-08-04: Matt Mottram - Use G4IonTable to get ions /// - 2017-02-10: Nuno Barros - Added BeginOfRun to load database contents /// /// \details This vertex generator (to be used in composite generators like combo of coincidence) produces isotropic particles /// or ions with kinetic energies sampled from a data-base defined distribution. An option to limit the range /// of the energy distribution is available //////////////////////////////////////////////////////////////////////// #ifndef __RAT_VertexGen_Spectrum__ #define __RAT_VertexGen_Spectrum__ #include #include "RAT/DB.hh" #include #include #include #include namespace RAT { class VertexGen_Spectrum: public GLG4VertexGen { public: VertexGen_Spectrum(const char *arg_dbname = "SPECTRUM"); virtual ~VertexGen_Spectrum(); /** generate and add new vertex to this event. Position and * time of vertex are offset from 0 by dx and dt. (These * are usually derived from GLG4PosGen and GLG4TimeGen.) */ virtual void GeneratePrimaryVertex(G4Event* argEvent, G4ThreeVector& dx, G4double dt); /** set the state for generator. Format: pname specname * where pname is the particle name, and specname is the database spectrum name */ virtual void SetState(G4String newValues); /** return current state */ virtual G4String GetState(); /** Set up the spectrum array in memory - create normalised cumulative magnitude for easy sampling*/ virtual void InitialiseSpectrum(); /** Sample energy from spectrum between bounds Elim_lo and Elim_hi */ virtual float SampleEnergy(); /** For this generator, it is possible to limit the output energies */ virtual bool ELimitable() { return true; } ; /** Set the limits on the generated energy */ virtual void LimitEnergies(float Elo, float Ehi); /** Return the maximum possible energy */ virtual float EMaximum(); /** Return the minimum possible energy */ virtual float EMinimum(); virtual void BeginOfRun(); private: G4String fParticle; // name of the particle type G4ParticleDefinition* fPDef; // particle definition G4String fSpectrum; // name of the spectrum to use DBLinkPtr fLSpec; // link to spectrum entry in database float fEMin; // valid range for spectrum in MeV float fEMax; std::vector fSpecE; // spectrum energy values std::vector fSpecMag; // spectrum magnitude values std::vector fSpecCumMag;// spectrum cumulative non-normalised magnitude values float fELimUniLow; // user applied universal lower limit to energy range float fELimUniHigh; // user applied universal higher limit to energy range float fELimTempLow; // temporary lower energy limit (applies to one event) float fELimTempHigh; // temporary higher energy limit (applies to one event) }; } // namespace RAT #endif