#ifndef HMDCLAYER_H
#define HMDCLAYER_H
#include "hgeomvector.h"
#include "hmdcgeomobj.h"
#include "TVector2.h"
class HMdcSizesCells;
class HMdcLayer : public TObject {
private:
    
    
    TVector2 layerP    [6][4][6][4];   
    TVector2 layerPcrop[6][4][6][4];   
    Double_t           xcrop[4][2];    
    Double_t           ycrop[4][2];    
    
    
    
    HGeomVector targetMidPoint;        
    HMdcPlane   plMdc[6];              
    
public:
    HMdcLayer();
    
    
    void   setMDCCrop         (Int_t m,Double_t xlowcrop,Double_t xupcrop,Double_t ylowcrop,Double_t yupcrop);
    void   fillLayerPoints    (HMdcSizesCells* fSizesCells, Bool_t secsys=kFALSE);
    void   calcCropedLayer    (Int_t s,Int_t m,Int_t l);
    Bool_t getLayersEdge      (TVector2& p,Int_t s,Int_t m,Int_t l,
			       Double_t& xmin ,Double_t& xmax,Double_t& ymin,Double_t& ymax,
			       Double_t& xmincrop ,Double_t& xmaxcrop,Double_t& ymincrop,Double_t& ymaxcrop);
    Bool_t getLayersEdge      (TVector2& p,Int_t s,Int_t m,Int_t l,
			       Double_t& xmin ,Double_t& xmax,Double_t& ymin,Double_t& ymax);
    Bool_t getCropedLayersEdge(TVector2& p,Int_t s,Int_t m,Int_t l,
			       Double_t& xmin ,Double_t& xmax,Double_t& ymin,Double_t& ymax);
    Bool_t isCroped            (TVector2& p,Int_t s,Int_t m,Int_t l);
    void   getLayerPoints      (Int_t s,Int_t m,Int_t l, TVector2& p0,TVector2& p1,TVector2& p2,TVector2& p3);
    void   getCropedLayerPoints(Int_t s,Int_t m,Int_t l, TVector2& p0,TVector2& p1,TVector2& p2,TVector2& p3);
    void printLayer       (Int_t s,Int_t m,Int_t l);
    void printCropedLayer (Int_t s,Int_t m,Int_t l);
    
    
    
    void   fillRKPlane         (HMdcSizesCells* fSizesCells);
    const HGeomVector&         getTargetMidPoint() { return targetMidPoint; }
    const HMdcPlane&           getMdcPlane(Int_t s){ return plMdc[s]; }
    const HMdcPlane*           getMdcPlanes()      { return &plMdc[0];}
    
    ClassDef(HMdcLayer,1)
};
#endif