//////////////////////////////////////////////////////////////////////// /// \class RAT::Gen_Flux /// /// \brief Top Level Event Producer - for two-fold differential spectra d^3N / dE dCosTheta (e.g. cosmic muon flux) /// /// \author Belina von Krosigk /// \author Eric Vazquez-Jauregui -- contact person /// /// REVISION HISTORY:\n /// 24/03/2011 : Belina von Krosigk - initial revision \n /// 17/05/2011 : Belina von Krosigk - minor changes in constructor and destructor and tidy up. example macro improved to deal with great amount of secondaries. \n /// 07-02-2017 : N. Barros - Cleared out low level generators (inherited from GLG4Gen) /// - Introduced BeginOfRun /// /// \details This generator is basically a flux driver. It simulates particles with momentum and position sampled from a predetermined distribution (FLUX.ratdb). The cosmic muon flux is provided as well as a flat angular and energy distribution of electrons with the index "cosmic" resp. "flat". The "flat" flux is meant to be a fast example flux, no physical motivation. The "cosmic" flux is taken from the MPAR bank in SNOMAN. It is simulated by passing the muon surface flux according to Gaisser's parameterization through matter with MUSIC code.\n /// the command to use this generator is: /generator/add flux \n /// the command to set the flux spectrum is: /generator/flux/setspectrum name (were "name" is the index set in FLUX.ratdb). The spectrum has to be set by the user! No default value is given.\n /// This generator implements a standard time generator, the default option is the poisson time generator. To change this use the command: /generator/flux/settimegen \n /// This generator allows the user to change the radius of the sphere on whose surface the vertices are created. To change this use the command: /generator/flux/setradius double . The default value is the psup h2o outer radius 8800.0 mm. \n /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_Gen_Flux__ #define __RAT_Gen_Flux__ #include #include #include #include #include #include #include class G4ParticleDefinition; namespace RAT { class Gen_FluxMessenger; class Gen_Flux : public GLG4Gen { public: class FluxException : public std::runtime_error{ public: FluxException(const std::string& errorStr_) : runtime_error(errorStr_) {} }; Gen_Flux(); virtual ~Gen_Flux(); virtual void GenerateEvent(G4Event *event); virtual void ResetTime(double offset=0.0); virtual bool IsRepeatable() const { return true; }; virtual void SetState(G4String state); virtual G4String GetState() const; //! specify time generator, default is poisson virtual void SetTimeGen(G4String state); //! position setter. virtual void SetGeneratorPosition(const double x0_,const double y0_,const double z0_); virtual void SetGeneratorPosition(const double theta_,const double phi_); virtual void SetGeneratorDirection(const double theta_,const double phi_); //! overall time state - time from one event to next virtual void SetTimeState(G4String state); virtual G4String GetTimeState() const; //! specify radius of spherical surface for vertex production, default is 8800.0 mm virtual void SetRadius(double radius); virtual double GetRadius() const; //! specify flux spectrum virtual void SetSpectrum(G4String state); virtual G4String GetSpectrum(); //! Sampling energy for a given cos(theta) void SampleE(double &E, const double CosTheta); virtual void InitialiseSpectrum(); void GenInit(double &E, double &CosTheta); void GenVertex(double long_radius, G4ThreeVector direction, double &x_vertex, double &y_vertex, double &z_vertex); virtual void BeginOfRun(); protected: DBLinkPtr fLFlux; G4String fStateStr; // generator initialization, specified by user // NFB : FIXME : Remove this after testing //GLG4TimeGen* fTimeGen; // time generator G4String fFlux; // name of the flux to use G4ParticleDefinition* fPDef; // particle definition Gen_FluxMessenger* fMessenger; // allows to change parameters via command line G4String spectrum; double fR1; double fEmin; double fEmax; double fCosTmin; double fCosTmax; double fMmax; bool fQpositionXYZ; bool fQpositionThetaPhi; bool fQDirectionThetaPhi; double fTheta; double fPhi; double fTheta_dir, fPhi_dir; double fPosz; double fPosy; double fPosx; MultivariateInterp fMagnitude; }; } //namespace RAT #endif