//----------------------------------------------------------- // File and Version Information: // $Id$ // // Description: // Implementation of class TpcPad // see TpcPad.h for details // // Environment: // Software developed for the PANDA Detector at FAIR. // // Author List: // Sebastian Neubert TUM (original author) // Cristoforo Simonetto TUM // // //----------------------------------------------------------- // This Class' Header ------------------ #include "TpcPad.h" // C/C++ Headers ---------------------- #include // Collaborating Class Headers -------- #include "TpcAbsPadShape.h" #include "TError.h" // Class Member definitions ----------- TpcPad::TpcPad() : _x(0),_y(0),_angle(0),_width(0),_height(0),_shape(0),_sectorId(0),_id(0) {;} TpcPad::TpcPad(const double x, const double y, const double angle, TpcAbsPadShape* const shape, const unsigned int sectorID, const unsigned int ID) : _x(x),_y(y),_angle(angle),_shape(shape),_sectorId(sectorID),_id(ID) { EvalBoundingRect(); } bool TpcPad::Contains(const double x, const double y) const { if (_shape == 0) Fatal("TpcPad::Contains","No AbsPadShapePolygon assigned."); double xSh = x; double ySh = y; ToShapeCoord(xSh, ySh); return(_shape->Contains(xSh, ySh)); } bool TpcPad::CircleIntersection(const double x, const double y, const double r) const { double dx=std::fabs(_x-x); double dy=std::fabs(_y-y); double hw = 0.5*_width; double hh = 0.5*_height; //most Pads are far away if (dx > hw+r || dy > hh+r ) return(false); return ( (dx < hw+r && dy < hh) || (dx < hw && dy < hh+r) || (dx-hw)*(dx-hw)+(dy-hh)*(dy-hh) < r*r ); } double TpcPad::GetValue(const double x, const double y) const { if (_shape == 0) Fatal("TpcPad::GetValue","No AbsPadShape assigned."); double xSh = x; double ySh = y; ToShapeCoord(xSh, ySh); return(_shape->GetValue(xSh, ySh)); } int TpcPad::GetNBoundaryPoints() const { if (_shape == 0) Fatal("TpcPad::GetNBoundaryPoints","No AbsPadShape assigned."); return(_shape->GetNBoundaryPoints()); } void TpcPad::GetBoundaryPoint(const int index, double& x, double& y) const { if (_shape == 0) Fatal("TpcPad::GetBoundaryPoint","No AbsPadShape assigned."); _shape->GetBoundaryPoint(index, x, y); ToPlaneCoord(x, y); } bool operator== (const TpcPad& lhs, const TpcPad& rhs) { //true if same position, angle and shape double dx=lhs._x-rhs._x; double dy=lhs._y-rhs._y; double da=lhs._angle-rhs._angle; return lhs._shape==rhs._shape && (dx*dx<1E-10) && (dy*dy<1E-10) && (da*da<1E-10); } bool operator< (const TpcPad& lhs, const TpcPad& rhs){ //true if lhs below (y) or left (x) of rhs double dy=lhs._y-rhs._y; double dx=lhs._x-rhs._x; bool flag=(dy*dy<1E-10) && (dx<-1E-5); return (dy<-1E-5) || flag; } std::ostream& operator<< (std::ostream& s, const TpcPad& me){ return s << "TpcPad\n" << "sectorID="<EvalBoundingRect(_width, _height, _angle); }