////////////////////////////////////////////////////////////////////////
/// \class RAT::Gen_ELLIE
///
/// \brief Top Level Event Producer - for ELLIE (or other light source) beams
///
///  \author Jeanne Wilson <j.r.wilson@qmul.ac.uk> -- contact person
///
///  REVISION HISTORY\n
///  	first version : unknown\n
///	5th, 20th November 2008 : J. Wilson - tidy and add functionality\n
///     1st March 2010 : J. Wilson - fixed bug in wavelength distribution - select wavelength for each photon, not each pulse \n
///                              - store number of photons for each pulse in calib branch (taking into account poissonian fluctuations \n
///     22nd March 2010 : J. Wilson - major changes to implementation. Changed format of ratdb file so that now you can
///                                specify different LEDs with different wavelength, time or angle distributions
///                                functionality should remain the same
///     24th May 2010 : G Orebi Gann - Allow user to specify npoints for interpolation.
///     29th July 2011 : J. Wilson - Tidy up documentation ambiguity
///     November 2013: J. Wilson - Major refactor to make generator for current fibre hardware (SMELLIE, TELLIE and AMELLIE) either laser or led.
///     07-Feb-2017 : N. Barros - Remove private instances of private generators (they are now inherited from GLG4Gen)
///
///  \details This generator simulates bunches of photons from fibres (could be LED or laser). User RatDB settings for fibre position, direction, angular, timing and wavelength distributions.
///
////////////////////////////////////////////////////////////////////////


#ifndef __RAT_Gen_ELLIE__
#define __RAT_Gen_ELLIE__

#include <vector>
#include <RAT/GLG4Gen.hh>
#include <RAT/PosGen_ELLIE.hh>
#include <RAT/VertexGen_ELLIE.hh>

class G4ParticleDefinition;

namespace RAT {

class Gen_ELLIEMessenger;

class Gen_ELLIE : public GLG4Gen {
public:
  Gen_ELLIE();
  virtual ~Gen_ELLIE();

  virtual void GenerateEvent(G4Event *event);
  virtual bool IsRepeatable() const { return true; };

  /// Basic state - does nothing yet but should allow choice of time generator for between pulses here
  ///
  /// @param[in] state SetState state
  virtual void SetState(G4String state);
  virtual G4String GetState() const;

  /// specify the type of time generator to use to give time BETWEEN ELLIE pulses, default is Poisson
  /// @param[in] state the time generator state
  virtual void SetTimeGen(G4String state);
  /// @param[in] offset Time reset to this value
  virtual void ResetTime(double offset=0.0);

  /// specify/get parameters for time generator for BETWEEN ELLIE pulses (eg from generator/rate/ commands)
  /// @param[in] state the time generator state
  virtual void SetTimeState(G4String state);
  virtual G4String GetTimeState() const;

  /// specify/get parameters for vertex generator - (eg from generator/vtx/ commands) These don't apply for this ELLIE generator so just print a warning
  /// @param[in] state the vertex generator state
  virtual void SetVertexState(G4String state);
  virtual G4String GetVertexState() const;

  /// specify/get parameters for position generator - (eg from generator/pos/ commands) These don't apply for  this ELLIE generator so just print a warning
  /// @param[in] state the Position generator state
  virtual void SetPosState(G4String state);
  virtual G4String GetPosState() const;

  /// Set Poisson fluctuations for number of photons per pulse
  /// @param[in] set boolean setting, 1 for poisson fluctuations on
  void SetPoissonFluctuations(G4bool set);

protected:
  G4String fStateStr;
  G4bool fPoisson; /// poisson fluctuations flag
  std::string fFibreID; /// Fibre IDs
  Gen_ELLIEMessenger* fMessenger;/// Allows the user to change parameters via the command line.


};

} // namespace RAT

#endif