#ifndef MARS_MImgCleanStd
#define MARS_MImgCleanStd

#ifndef MARS_MGTask
#include "MGTask.h"
#endif

class MGeomCam;
class MSigmabar;
class MSignalCam;
class MPedPhotCam;
class MArrivalTime;
class MCameraData;

class MGGroupFrame;

class MImgCleanStd : public MGTask
{
public:
    typedef enum {
        kStandard,
        kScaled,
        kDemocratic,
        kProbability,
        kAbsolute
    } CleaningMethod_t;

private:
    static const TString gsNamePedPhotCam; // default name of the 'MPedPhotCam' container
    static const TString gsNameGeomCam;    // default name of the 'MGeomCam' container
    static const TString gsNameSignalCam;  // default name of the 'MSignalCam' container

    const MGeomCam     *fCam;  //!
          MSignalCam  *fEvt;  //!
          MPedPhotCam  *fPed;  //!
          MCameraData  *fData; //!

    CleaningMethod_t fCleaningMethod;

    Float_t  fCleanLvl1;
    Float_t  fCleanLvl2;

    UShort_t fCleanRings;
    Bool_t   fKeepSinglePixels;

    TString  fNamePedPhotCam; // name of the 'MPedPhotCam' container
    TString  fNameGeomCam;    // name of the 'MGeomCam' container
    TString  fNameSignalCam;  // name of the 'MSignalCam' container

    // MImgCleanStd
    void    CleanStep1();
    Short_t CleanStep2(Float_t &size);
    void    CleanStep3();
    void    CleanStep3b(Int_t idx);
    void    CleanStep4(UShort_t r, Int_t idx);

    // MGTask, MTask, MParContainer
    void    CreateGuiElements(MGGroupFrame *f);
    void    StreamPrimitive(ofstream &out) const;
    Int_t   ReadEnv(const TEnv &env, TString prefix, Bool_t print);

    Int_t PreProcess(MParList *pList);
    Int_t Process();

public:
    MImgCleanStd(const Float_t lvl1=3.0, const Float_t lvl2=2.5,
                 const char *name=NULL, const char *title=NULL);
    void Print(Option_t *o="") const;

    Float_t  GetCleanLvl1() const { return fCleanLvl1; }
    Float_t  GetCleanLvl2() const { return fCleanLvl2; }
    UShort_t GetCleanRings() const { return fCleanRings;}

    void SetCleanRings(UShort_t r) { if(r==0) r=1; fCleanRings=r; }
    void SetMethod(CleaningMethod_t m) { fCleaningMethod = m; }
    void SetKeepSinglePixels(Bool_t b=kTRUE) { fKeepSinglePixels=b; }

    Bool_t ProcessMessage(Int_t msg, Int_t submsg, Long_t param1, Long_t param2);

    void SetNamePedPhotCam(const char *name)  { fNamePedPhotCam = name; }
    void SetNameSignalCam(const char *name)   { fNameSignalCam = name; }
    void SetNameGeomCam(const char *name)     { fNameGeomCam = name; }

    ClassDef(MImgCleanStd, 3)    // task doing the image cleaning
}; 

#endif
