// // $Id: SiLayer.cpp,v 1.19 2002/03/21 01:30:59 skulik Exp $ // // File: SiLayer.cc // Purpose: Implement SiLayer // Created: 21-OCT-1997 John Hobbs // // $Revision: 1.19 $ // // // Include files #include "SiLayer.hpp" #include #include "PhysicsVectors/Rotation.h" // Global definitions using namespace std; using namespace dgs; bool operator<(const SiLayer& lhs, const SiLayer&rhs) { return lhs.get_position()[2] < rhs.get_position()[2]; } bool operator==(const SiLayer& lhs, const SiLayer &rhs) { if( lhs.get_position() != rhs.get_position() ) return false; if( lhs.get_ladder_count() != rhs.get_ladder_count() ) return false; for( int i=1 ; i<=lhs.get_ladder_count() ; i++ ) if( *(lhs.get_ladder(i)) != *(rhs.get_ladder(i)) ) return false; if( lhs.get_radius() != rhs.get_radius() ) return false; if( lhs.get_zhalf() != rhs.get_zhalf() ) return false; // OK... return true; } //----------------------------------------------------------------------------- // // Implement SiLayer here // //----------------------------------------------------------------------------- // Constructors/Destructors SiLayer::SiLayer() { // Make the z-axis of children parallel to the symmetry axis of the cylinder. set_primary_directions(); } SiLayer::SiLayer(float radius, float zhalf, int nladders, float phi0,float zpos, bool flipped/*false*/, const SiLadder* prototype/*NULL*/): CylindricalSurface(radius,zhalf) { // Make the z-axis of children parallel to the symmetry axis of the cylinder. set_primary_directions(); const SiLadder* use_this; // If no SiLadder is passed, just fill the vector with empties... if( prototype ) use_this = prototype; else use_this = new SiLadder; const float twopi=2*3.1415926535898; //Can I get this elsewhere? for( int i=0 ; i &ladders): CylindricalSurface(radius,zhalf), _ladders(ladders) { // Make the z-axis of children parallel to the symmetry axis of the cylinder. set_primary_directions(); const float twopi=2*3.1415926535898; //Can I get this elsewhere? for( int i=0 ; i SiLayer::get_children() { list kids; for( int i=0 ; i<_ladders.size() ; i++ ) kids.push_back(&_ladders[i]); return kids; } // Accessors int SiLayer::get_ladder_count() const { return _ladders.size(); } SiLadder* SiLayer::get_mutable_ladder(int ilad) { return &_ladders[ilad-1]; } void SiLayer::flip_ladder(int i) { double pi=3.14159265358987; GeometryXform spin =_ladders[i].get_relative_position(get_position()); GeometryXform spinZ180(0.0,0.0,0.0,pi,0.0,0.0); spin = spin.apply(spinZ180); _ladders[i].set_relative_position(get_position(),spin); } void SiLayer::set_primary_directions() { const double pihalf=3.14159265358987/2.0; Rotation defRot(pihalf,pihalf,0.0); Rotation tRot(0.0,-pihalf,0.0); set_tangent_Xform(tRot*defRot); } const SiLadder* SiLayer::get_ladder(int ilad) const { return &_ladders[ilad-1]; } std::ostream& operator<<(std::ostream& os, const SiLayer& me) { os << "SiLayer of radius " << me.get_radius() <<" has " << me.get_ladder_count() << " ladders" << endl; for( int i=1 ; i<=me.get_ladder_count() ; i++ ) os << " " << *(me.get_ladder(i)) << endl; return os; }