//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Pad plane in the PndTpc // // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Sebastian Neubert TUM (original author) // // //----------------------------------------------------------- #ifndef TPCPADPLANE_HH #define TPCPADPLANE_HH // Base Class Headers ---------------- // Collaborating Class Headers ------- #include // remove if you do not need streaming op #include "PndTpcPad.h" #include #include #include "math.h" // Collaborating Class Declarations -- class PndTpcPadShapePool; class PndTpcPadPlane { public: // Constructors/Destructors --------- PndTpcPadPlane(int nx, int ny, double xbin, double ybin, double x0, double y0); PndTpcPadPlane(const char* const filename, const PndTpcPadShapePool* const pspool); ~PndTpcPadPlane(); // Operators friend std::ostream& operator<< (std::ostream& s, const PndTpcPadPlane& me); // Accessors ----------------------- void GetPadList(const double x, const double y, const double r, std::vector& buffer) const; void GetPadXY(const unsigned int PadID, double& x, double& y) const; PndTpcPad* GetPad(const unsigned int PadID) const; unsigned int GetNPads() const;//the number of pads const std::vector& GetPads() const {return PadReferences;} const unsigned int GetNSectors() const {return _nSectors;} std::map* GetSectorList(unsigned int sectorId) {return _SectorLists[sectorId];} std::vector GetSectorIds()const; // a simple bounding box struct bounding_box { bounding_box() : minx(999),maxx(-999),miny(999),maxy(-999) {} double minx,maxx,miny,maxy; }; bounding_box& GetSector(unsigned int i) {return _Sectors[i];} const int GetNX() const {return nx;} const int GetNY() const {return nx;} const double GetXBin() const {return xbin;} const double GetYBin() const {return ybin;} const double GetX0() const {return x0;} const double GetY0() const {return y0;} // Modifiers ----------------------- // Pad Plane will take Ownership! void AddPad(PndTpcPad* pad); void ReadFromFile(const char* const filename, const PndTpcPadShapePool* const pspool); // Reserves place in the Mapping vector PadReferences void AllocatePadReferences(const int n){PadReferences.resize(n,0);} // Operations ---------------------- struct PadIndexer { PadIndexer(int _nx, int _ny, double _xbin, double _ybin, double _x0, double _y0) : nx(_nx),ny(_ny),xbin(_xbin),ybin(_ybin),x0(_x0),y0(_y0){;} int operator()(PndTpcPad* p) const { double res=floor((p->x()-x0)/xbin) + floor((p->y()-y0)/ybin)*nx; return (int)res; } int operator()(double x, double y) const { double res=floor((x-x0)/xbin) + floor((y-y0)/ybin)*nx; return (int)res; } int nx; int ny; double xbin; double ybin; double x0; double y0; }; void WriteToStream(std::ostream& stream) const; private: // Private Data Members ------------ int nx; // Number of Regions in x direction int ny; // Number of Regions in y direction double xbin; // bin width in x double ybin; // bin width in y double x0; // (x0,y0) Origin of plane double y0; PadIndexer Indexer; std::vector< std::vector* > Regions; // regions are just // for fast searching std::vector PadReferences; std::map _Sectors; std::map* > _SectorLists; unsigned int _nSectors; // assume Sectors are enumerated 0...(n-1) // a sector represents the collection of pads // that is read out by one front end processor // Private Methods ----------------- bool ReadLine(const char* const line, const PndTpcPadShapePool* const pspool); }; // exceptions thrown by this class #include struct unknown_padID : std::exception{ virtual const char* what() const throw() { return "Unkown Pad ID"; } }; struct used_padID : std::exception{ virtual const char* what() const throw() { return "The Pad ID is already assigned."; } }; #endif //-------------------------------------------------------------- // $Log$ //--------------------------------------------------------------