#ifndef MARS_MEnergyEstParam
#define MARS_MEnergyEstParam

#ifndef MARS_MTask
#include "MTask.h"
#endif

#ifndef ROOT_TArrayD
#include <TArrayD.h>
#endif

class MHillasSrc;
class MEnergyEst;
class MHillas;
class MMcEvt;
class MHMatrix;

class MEnergyEstParam : public MTask
{
private:
    Int_t     fMap[100];

    MHMatrix *fMatrix;

    TList    *fPairs;

    TList    *fHillasSrc;
    TList    *fEnergy;

    MHillas  *fHillas;
    TString   fHillasName;

    TArrayD   fA;
    TArrayD   fB;

    MMcEvt   *fMc;

    void InitCoefficients();

    Double_t GetVal(Int_t i) const;


public:
    MEnergyEstParam(const char *hil="MHillas", const char *name=NULL, const char *title=NULL);
    ~MEnergyEstParam();

    Bool_t PreProcess(MParList *plist);
    Bool_t Process();

    void Add(const TString hillas, const TString energy="MEnergyEst");

    void InitMapping(MHMatrix *mat);
    void StopMapping();

    Int_t GetNumCoeff() const { return fA.GetSize()+fB.GetSize(); }

    void SetCoeff(const TArrayD &arr);
    void SetCoeffA(const TArrayD &arr);
    void SetCoeffB(const TArrayD &arr);

    Double_t GetCoeff(Int_t i) { return i<fA.GetSize()? fA[i] : fB[i-fA.GetSize()]; }

    void Print(Option_t *o=NULL);

    ClassDef(MEnergyEstParam, 0) // Task to estimate the energy
};

#endif
