////////////////////////////////////////////////////////////////////
/// \class RAT::Sc46SourceGen
///
/// \brief  Generates events in the Sc46 Sample.
///
/// \author Nuno Barros <nuno.barros@tu-dresden.de>
/// \author Valentina Lozza <valentina.lozza@tu-dresden.de> -- contact person
/// \author David Auty <auty@ualberta.ca>
///
/// REVISION HISTORY:\n
///
///  17-07-2013 : N. Barros : Modified the class to derive from DecayChain_Gen instead of
///                           GLG4Gen. This solves the timing problem with timing of pileup events.
///
///
///  \details  Generates Sc46 decays in the button of the source
///           Requires source geometry to be loaded.  No generator position
///           modifications accepted. (currupted form
///           /generator/add sc46source
///           /generator/rate/set 1
///
////////////////////////////////////////////////////////////////////
#ifndef __RAT_Sc46SourceGen__
#define __RAT_Sc46SourceGen__

#include <globals.hh>
#include <vector>
#include <map>

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


class G4VPhysicalVolume;

namespace RAT {

// Generate decaychain events for Sc46 in the Tagged source calibration source
class Sc46SourceGen : public DecayChain_Gen
{
public:
  Sc46SourceGen();
  virtual ~Sc46SourceGen() {};
  virtual bool IsRepeatable() const { return true; };
  virtual void SetState(G4String state);
  virtual void SetPosState(G4String /*state*/);
  G4String GetEvRate() {return fEvRate;};

protected:
  std::string fTimeGenName; ///< name of time generator: default "poisson"
  std::string fPosGenName; ///< name of time generator: default "fill"
  std::string fDecayStr; ///< generator initialization, specified by user:
  std::string fSourceName;
  G4String fPosStateStr;         // Holds the position state
  G4String fTimeStateStr;        // Holds the time state

private:
    void BuildMonthMap();          // A map of month names to integers
    int GetMonthInt(std::string month); // Get the integer of the month from its name
    void SetEvRate();              // Calculate and set the event rate

    std::map< std::string, int > fMonth;// The month map
    G4String fEvRate;              // String containing the event rate
    EventTime fEvTime;             // EventTime object to handle universal times
    std::vector<double> fPos;      // The source position
    int fLCN;                      // The logical channel number for the source
    double fRefActivity;           // The reference source activity
    std::string fRefDate;               // The reference date for that activity
    std::vector<double> fHalfLife; // The Co60 half-life
    double fActivity;              // The calculated activity
};

} // namespace RAT

#endif