#ifndef  __JRECONSTRUCTION__JSHOWERPOINTSIMPLEXPARAMETERS__
#define  __JRECONSTRUCTION__JSHOWERPOINTSIMPLEXPARAMETERS__

#include <TROOT.h>
#include <TObject.h>

#include "JReconstruction/JRange_t.hh"

/**
 * \author adomi
 */
namespace JRECONSTRUCTION {

  struct JShowerPointSimplexParameters_t:
    public TObject
  {
    /**
     * Default constructor.
     */
    JShowerPointSimplexParameters_t()
    {
      this->reset();
    }

    /**
     * Virtual destructor.
     */
    virtual ~JShowerPointSimplexParameters_t()
    {}
    
    /**
     * Reset fit parameters.
     */
    void reset()
    {
      numberOfPrefits  =     0;  // 0 means process all inputs
      numberOfOutfits  =   100;
      minPrefitsSize   =     8;
      sigma_ns         =     1;
      TMaxLocal_ns     =    10;
      TMax_ns          =    60.0;  
      TMin_ns          =   -60.0;   
      roadWidth_m      =    50.0;
      ctMin            =     0.2;
      TWindow_ns       =  JRange_t(-130, 120);
      pos_grid_m       =  JRange_t( -20,  20);
      pos_step_m       =    20;
      time_grid_ns     =  JRange_t( -90,  90);
      time_step_ns     =    20;
      simplex_step_m   =     5;
      simplex_step_ns  =    10;
      tukey_std_dev    =    20;
      NMax             =  1000;
    }

    /**
     * Equality
     *
     * \param  parameters       fit parameters
     * \return                  true if equals; else false
     */
    bool equals(const JShowerPointSimplexParameters_t& parameters) const
    {
      return (this->numberOfPrefits  == parameters.numberOfPrefits  &&         
	      this->numberOfOutfits  == parameters.numberOfOutfits  &&         
	      this->minPrefitsSize   == parameters.minPrefitsSize   &&
	      this->sigma_ns         == parameters.sigma_ns         &&
	      this->TMaxLocal_ns     == parameters.TMaxLocal_ns     &&
	      this->TMax_ns          == parameters.TMax_ns          &&
	      this->TMin_ns          == parameters.TMin_ns          &&
	      this->roadWidth_m      == parameters.roadWidth_m      &&
	      this->ctMin            == parameters.ctMin            &&
	      this->TWindow_ns       == parameters.TWindow_ns       &&
	      this->pos_grid_m       == parameters.pos_grid_m       &&
	      this->pos_step_m       == parameters.pos_step_m       &&
	      this->time_grid_ns     == parameters.time_grid_ns     &&
	      this->time_step_ns     == parameters.time_step_ns     &&
	      this->simplex_step_m   == parameters.simplex_step_m   &&
	      this->simplex_step_ns  == parameters.simplex_step_ns  &&
	      this->tukey_std_dev    == parameters.tukey_std_dev    &&
	      this->NMax             == parameters.NMax);
    }

    ClassDef(JShowerPointSimplexParameters_t, 1);

    size_t                  numberOfPrefits;     ///< number of prefits
    size_t                  numberOfOutfits;     ///< number of fits to be saved in output
    size_t                  minPrefitsSize;      ///< number of prefits under which an event is treated as a very low energy one
    double                  sigma_ns;            ///< time resolution [ns]
    double                  TMaxLocal_ns;        ///< time window for local coincidences [ns]
    double                  TMax_ns;             ///< maximum time for local coincidences [ns] 
    double                  TMin_ns;             ///< minimum time for local coincidences [ns] 
    double                  roadWidth_m;         ///< road width [m]
    double                  ctMin;               ///< minimal cosine space angle between PMT axes
    JRange_t                TWindow_ns;          ///< time window for local coincidences [ns] for events with few prefits
    JRange_t                pos_grid_m;          ///< edges in [m] of the position grid 
    double                  pos_step_m;          ///< step in [m] of position grid
    JRange_t                time_grid_ns;        ///< edges in [ns] of the time grid  
    double                  time_step_ns;        ///< step in [ns] of time grid 
    double                  simplex_step_m;      ///< step in [m] of JSimplex minimiser 
    double                  simplex_step_ns;     ///< step in [ns] of JSimplex minimiser
    double                  tukey_std_dev;       ///< standard deviation of Tukey estimator
    int                     NMax;                ///< maximum number of iterations   
  };
}

/**                                                                                                      
 * Read fit parameters from input.                                                                                   
 *                                                                                                              
 * \param  in           input stream                                                                                
 * \param  parameters   fit parameters                                                                              
 * \return              input stream                                                                                   
 */
std::istream& operator>>(std::istream& in, JRECONSTRUCTION::JShowerPointSimplexParameters_t& parameters);

/**                                                                                                          
 * Write fit parameters to output.                                                                                  
 *                                                                                                                      
 * \param  out          output stream                                                                                 
 * \param  parameters   fit parameters                                                                                  
 * \return              output stream                                                                                   
 */
std::ostream& operator<<(std::ostream& out,  const JRECONSTRUCTION::JShowerPointSimplexParameters_t& parameters);

#endif