#ifndef MARS_MBadPixelsTreat
#define MARS_MBadPixelsTreat

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

class MGeomCam;
class MCerPhotEvt;
class MPedPhotCam;
class MBadPixelsCam;

class MBadPixelsTreat : public MTask
{
private:
    MGeomCam      *fGeomCam;   //!
    MPedPhotCam   *fPedPhot;   //!
    MCerPhotEvt   *fEvt;       //!
    MBadPixelsCam *fBadPixels; //!

    Byte_t fFlags;       // flag for the method which is used
    Byte_t fNumMinNeighbors;

    enum
    {
        kUseInterpolation = 1,
        kUseCentralPixel  = 2,
        kProcessRMS       = 3
    };

    static Double_t Pow2(Double_t x) { return x*x; }

    void InterpolateSignal() const;
    void InterpolatePedestals() const;

    void   Unmap() const;
    void   StreamPrimitive(ofstream &out) const;

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

public:
    MBadPixelsTreat(const char *name=NULL, const char *title=NULL);

    void SetUseInterpolation(Bool_t b=kTRUE)
    {
        b ? SETBIT(fFlags, kUseInterpolation) : CLRBIT(fFlags, kUseInterpolation);
    }
    void SetUseCentralPixel(Bool_t b=kTRUE)
    {
        b ? SETBIT(fFlags, kUseCentralPixel) : CLRBIT(fFlags, kUseCentralPixel);
    }
    void SetProcessRMS(Bool_t b=kTRUE)
    {
        b ? SETBIT(fFlags, kProcessRMS) : CLRBIT(fFlags, kProcessRMS);
    }
    void SetNumMinNeighbors(UShort_t num) { fNumMinNeighbors=num; }


    ClassDef(MBadPixelsTreat, 1) // Task to treat bad pixels (interpolation, unmapping)
}; 

#endif

