////////////////////////////////////////////////////////////////////
/// \class RAT::Sc48SourceGen
///
/// \brief  Generates events in the Ti volume of the Sc48Source
///
/// \author Valentina Lozza <valentina.lozza@tu-dresden.de> -- contact person
///
/// REVISION HISTORY:\n
///     15 November 2012 : V. Lozza - First version.
///     14 March 2017 : N. Barros - Small change to comply with base generator changes
///
///  \details  Generates decays of the 48Sc sample nuclides in the titanium
///           volume of the Sc48 source for any source position.
///           Requires source geometry to be loaded.  No generator position
///           modifications accepted. The rates (in Bq) are set with the state
///           string, for example:
///
///             /generator/add Sc48Source 48Sc:400 47Sc:350 46Sc:15 DecayTime:3day
///
///           If the DecayTime parameter is given (with a Geant4 time unit),
///           the activities are calculated according to their half-lives.
///
///           Nuclides for which no activity is given are not generated.
///
////////////////////////////////////////////////////////////////////

#ifndef __RAT_Sc48SourceGen__
#define __RAT_Sc48SourceGen__

#include <RAT/GLG4Gen.hh>
#include <RAT/DecayChain_Gen.hh>

#include <map>

class G4Event;

namespace RAT {

class Sc48SourceGen : public GLG4Gen
{
public:
    Sc48SourceGen();
    virtual ~Sc48SourceGen();
    virtual void GenerateEvent(G4Event *event);
    virtual void SubtractTime(double time);
    virtual void ResetTime(double offset=0.0);
    virtual bool IsRepeatable() const { return true; };

    virtual void SetState(G4String state);
    virtual G4String GetState() const;

    virtual void SetTimeState(G4String state);
    virtual void SetPosState(G4String state);

protected:
    /// calculate activity of nuclide after decayTime when it had an initialActivity at t=0
    double GetActivityAfterDecayTime(const G4String &nuclide, const double initialActivity, const double decayTime) const;

    std::map<G4String, DecayChain_Gen*> fGenerators; ///< map of generators for the different nuclides
    DecayChain_Gen *fNextGen; ///< pointer to the generator for the next decay to be simulated

    std::map<G4String, double> fHalfLives; ///< map of half lives

    G4String fStateStr; ///< state string
    G4String const fActiveVolumeName; ///< name of the volume containing the nuclides
};

} // namespace RAT

#endif