// // $Id: SiWedge.cpp,v 1.11 2003/02/11 11:13:02 skulik Exp $ // // File: SiWedge.cpp // Purpose: // Created: 22-OCT-1997 Tom Trippe // // $Revision: 1.11 $ // // // Include files #include "SiWedge.hpp" #include #include #include // Global definitions using namespace std; using namespace dgs; // Constructors/Destructors // Accessors const list SiWedge::get_children() { list empty_list; return empty_list; } SpacePoint SiWedge::local_to_global(const CartesianCoordinate& lpt) const { CartesianCoordinate ulpt(lpt.x(),lpt.z(),-lpt.y()); return GeometryElement::local_to_global(ulpt); } MatrixD SiWedge::local_to_global(const CartesianMatrix& theMatrix) const { double ladder_to_plane[9]={1.0,0.0,0.0,0.0,0.0,1.0,0.0,-1.0,0.0}; MatrixD l2p(3,ladder_to_plane); MatrixD planeMatrix = l2p*theMatrix*l2p.inverse(); return GeometryElement::local_to_global(planeMatrix); } CartesianCoordinate SiWedge::global_to_local(const SpacePoint& gpt) const { float _halfheight=get_hhsize(); float _halfwidth1=get_hw1size(); float _halfwidth2=get_hw2size(); CartesianCoordinate undone = get_position().invert(gpt); float x = undone.x(); float z = undone.y(); if( fabs(undone.z()) > 1.e-4 ) { //std::cerr << " SiWedge::global_to_local. Local coordinate" // << " has non-zero y-component "<_halfheight) { // std::cerr << " SiWedge::global_to_local. z = " << z // << "outside range of [" << -_halfheight << "," << _halfheight << "]" << endl; return CartesianCoordinate(x,0.0,z); } float xmin=-(_halfwidth1+((_halfwidth2-_halfwidth1)/(2*_halfheight)) *(z+_halfheight)); float xmax=-xmin; // Check x if(xxmax) { // std::cerr << " Wedge::global_to_local. x = " << x // << "outside range of [" << xmin << "," << xmax << "]" << endl; return CartesianCoordinate(x,0.0,z); } // OK return CartesianCoordinate(x,0.0,z); } std::ostream& operator<< (std::ostream& os, const SiWedge& me) { const Wedge* me_as_wedge = &me; os << "SiWedge: " << *me_as_wedge; return os; } bool operator ==(const SiWedge& lhs, const SiWedge& rhs) { if( lhs.get_position() != rhs.get_position() ) return false; if( lhs.get_hw1size() != rhs.get_hw1size() ) return false; if( lhs.get_hw2size() != rhs.get_hw2size() ) return false; if( lhs.get_hhsize() != rhs.get_hhsize() ) return false; return true; } bool operator !=(const SiWedge& lhs, const SiWedge& rhs) { return !(lhs==rhs); } float SiWedge::get_aw1size() const { if( fabs(_act_halfwidth1)< 1e-7 ) return get_hw1size(); return _act_halfwidth1; } float SiWedge::get_aw2size() const { if( fabs(_act_halfwidth2)< 1e-7 ) return get_hw2size(); return _act_halfwidth2; } float SiWedge::get_ahsize() const { if( fabs(_act_halfheight)< 1e-7 ) return get_hhsize(); return _act_halfheight; } float SiWedge::get_acenter() const { return _act_center; }