//////////////////////////////////////////////////////////////////////// /// \class RAT::SolarGen /// \author Nuno Barros -- contact person /// \date 13-Dec-2011 /// /// \brief Specific solar neutrino generator with configurable sub-generators for time and position. /// \details /// This class implements the solar neutrino generator in RAT. The generator is configurable through a series of methods and by /// using the messenger RAT::SolarMessenger. /// The vertex generator is fixed to the ES generator, which is the only solar neutrino interaction in SNO+. /// The options passed to the messenger can be provided in two ways: /// - GLSim: flux and neutrino type /// - SolarMessenger : direction /// /// REVISION HISTORY: /// - 13-dec-2011 (Nuno Barros): /// -# Initial implementation based on the combo generator. /// -# Ephemeris data not used yet (direction fixed). /// - 07-may-2014 (Nuno Barros) /// -# Added additional debug message to control the generator is /// producing sensible data /// - 26-nov-2014 (Matt Strait) - doxygen fixes /// - 10-feb-2015 (Nuno Barros) - Moved sun direction calculation out of the generator. /// Now located in src/util/SunUtil.hh /// - 07-Feb-2017 (Nuno Barros) - Removed low level generators inherited from GLG4Gen /// /// \todo Move the options passed from GLSim into RAT::SolarMessenger (containment of the specific options) /// //////////////////////////////////////////////////////////////////////// #ifndef __RAT_SolarGen_ #define __RAT_SolarGen_ /// RAT includes #include #include #include /// Geant4 includes #include #include /// Forward declarations class TGraph; namespace RAT { /// Forward declarations inside namespace class SolarMessenger; class SolarGen: public GLG4Gen { public: /** Default constructor*/ SolarGen(); /** Destructor */ virtual ~SolarGen(); /** * \brief Generates an event * * The workhorse of the generator. It calls all other methods and produces an event which is then returned by reference. * Implements GLG4Gen::GenerateEvent * * \param[out] event Generated event. */ virtual void GenerateEvent(G4Event *event); /** * \brief Resets the event time. * * Implements GLG4Gen::ResetTime * * \param[in] offset to be applied to the next event time. */ virtual void ResetTime(double offset=0.0); /** Defines repeatability of the generator. One can invoke multiple generators to produce different fluxes or different flavors. */ virtual bool IsRepeatable() const { return true; }; /** * State setter. * * Method that sets the state for this generator instance. The state string has the form [flux]:[flavor] where * - [flux] can be any of pp,pep,be7,b8,n13,o15,f17. * - [flavor] can be any of nue,nuebar,numu,numubar * Both parameters are passed into the vertex generator to define the spectrum shape and the cross section to be used. * * \param[in] state Encoded string with the generator configuration. */ virtual void SetState(G4String state); /** State getter. Returns an encoded string with the present state. */ virtual G4String GetState() const; /* The methods below are being overridden to disallow the * behavior implemented in GLG4Gen. * These methods have no influence in this generator. */ /** * Sets the state of the internal time generator. * * \param[in] "" New state for the time generator * \sa GLG4TimeGen */ virtual void SetTimeState(G4String /*state*/) { }; /** Return the present state of the internal time generator. */ virtual G4String GetTimeState() const; /** * Set the state of the vertex generator. Implements GLG4Gen::SetVertexState. * \attention This is a dummy method. The vertex generator has its own messenger class to configure. States passed by here are not checked and directly forwarded to the vertex generator. * * @param "" String containing the new state. */ virtual void SetVertexState(G4String /*state*/) {;}; /** Getter for the vertex generator state. */ virtual G4String GetVertexState() const {return "";}; /** Setter for state of the position generator. No checks performed here. */ virtual void SetPosState(G4String /*state*/); /** Getter for state of the position generator. */ virtual G4String GetPosState() const; /** * Return the presently set Nu direction * @return vector with the present nu direction on the generator. */ G4ThreeVector GetNuDirection() { return fNuDir;}; /** * Sets the default neutrino generator direction. * @param[in] dir direction. */ void SetNuDirection(G4ThreeVector dir); /** * Sets the time generator to use. * @param[in] generator Name of the generator to be used. * @param[in] force Force the instantiation of the generator (default: false). */ void SetTimeGenerator(G4String generator, bool force = false); /** * Returns the time generator to use. * @return string describing the time generator. */ G4String GetTimeGenerator() {return fTimeGenName;}; /** * Sets the position generator to use. * @param[in] generator Name of the generator to be used. * @param[in] force Force the instantiation of the generator (default: false). */ void SetPosGenerator(G4String generator, bool force = false); /** * Returns the position generator in use. * @return string describing the time generator. */ G4String GetPosGenerator() {return fPosGenName;}; /** * Sets the scale for the flux being generated (in units of SSM). * @param[in] scale Number of SSMs to scale the flux (default 1.0). */ void SetFluxScale(G4double scale); /** * Returns the scale of the flux in the generator in units of SSM. * @return the scale of the flux. */ G4double GetFluxScale() {return fFluxScale;}; /** * Returns the event rate for this generator. * Depends on the flux, its scale, the nu flavor and cross section. * * @return Event rate (in Hz). */ G4double GetEvtRate() {return fEvtRate;}; protected: /** * Sets the event rate in Hz. Implemented only for debug. * * @return Event rate (in Hz). */ void SetEvtRate(G4double rate) {fEvtRate = rate;}; /** * Triggers the generation of a new incoming neutrino direction. * * This method triggers the generation of a new direction for the neutrino, considering the given options. */ void GenerateNuDirection(); /* * Auxiliary custom method to parse configuration strings. * * This function is somewhat similar to others implemented in GLG4StringUtil.hh and RAT::StringUtil * Given a string it picks up only the first token and returns the rest as a body. * Implemented to deal with multiple conditional encodings in a single string. It removes the separator between first and rest. * * @param[in] in Input string. * @param[out] first First matching token. * @param[out] rest Rest of the string. */ //void pop_first_word(G4String in, G4String &first, G4String &rest, G4String separator = ":"); /** \brief Auxiliary function that generates a random number for a given interval.*/ G4double GetRandomNumber(const double rmin, const double rmax); /** \brief Manages the state passed by GSim concerning the generator "flux:flavor". */ G4String fStateStr; /** \brief Pointer to the time generator. */ /** \brief Name of the time generator. */ G4String fTimeGenName; /** \brief Name of the position generator. */ G4String fPosGenName; /** \brief Messenger for the solar generator */ SolarMessenger *fMessenger; private: /// Mandatory parameters for the vertex generator /** \brief Flux to be generated. Possible options : "pp,pep,hep,be7,b8,c13,o15,f17". */ G4String fFlux; /** \brief Neutrino flavor to be generated. Possible options : "nue,numu". * * This option is passed down to the vertex generator, which on the other hand passes it to the cross-section calculation. * \attention Keep in mind that 'numu' stands for the ES scattering cross-section for non-electron neutrinos (both muon and tau). * */ G4String fNuFlavor; /** \brief Flag to for using the ephemeris data. The properties have to be passed by messenger. */ G4bool fUseEphemerisData; /** \brief Direction of next incoming neutrino.*/ G4ThreeVector fNuDir; // Direction of the incoming neutrino for the next event to be generated /** EventTime object to deal with the non-sequentiality of the generated events. */ EventTime fEvTime; /** Flux scale in N SSMs*/ G4double fFluxScale; /** Event rate. It is the product between the flux and the total cross section * Needs to account for the flux scale. */ G4double fEvtRate; G4bool volumeInfoLoaded; /** Rate per target **/ G4double fRatePerTarget; DBLinkPtr solarmcdblink; #ifdef RATDEBUG G4double fUTtime; #endif }; inline G4double SolarGen::GetRandomNumber(const double rmin, const double rmax) { G4double rnd = G4UniformRand(); // random number from 0 to 1. G4double value = rmin + (rmax - rmin) * rnd; return value; } } #endif /* SOLARGEN_H_ */