/** * File : PDTGeometryHit.cpp * Package : muo_hit * Class : PDTGeometryHit * Author : O.Peters ( opeters@fnal.gov ) * Created : 27-Apr-2000 * Modified :DH 9/02 add MuoIndex to getDridDFistance * Description : Adaptor class using data in the PDTHit class to calculate other properties * : This is the most simple implementation, no caching, no fancy things. * : Other adaptors (which might inherit from this one) can be written to * : speed things up or to add more functionality * TODO : Apply alignment constants **/ #include #include "muo_hit/PDTGeometryHit.hpp" #include "muon_geometry/base/MuoGeometer.hpp" namespace Muon { //==================== //=== constuctors === //==================== PDTGeometryHit::PDTGeometryHit() : _hit(0x0), _angle(0.), _driftdistance(0.), _position(CartesianPoint(0.,0.,0.)), _orientation(Z_HAT), _calcs_done(false) {} PDTGeometryHit::PDTGeometryHit(const PDTHit *hit, double angle) : _hit(hit), _angle(angle) { double pos[3] = {0.,0.,0.}; double ort[3] = {0.,0.,1.}; // equivalent to "Z_HAT" _calcs_done = MuoGeometer::get_instance()->getPosition(_hit->getMuoIndex(), pos, ort); _position = CartesianPoint(pos[0],pos[1],pos[2]); _orientation = UnitVector(ort[0],ort[1],ort[2]); _driftdistance = PDTHitTimes::getDriftDistance(_hit->getDriftTime(), _angle, _hit->getMuoIndex()); } PDTGeometryHit::~PDTGeometryHit() { // No deletion here, for we do not have ownership of the hit } SpacePoint PDTGeometryHit::getCounterPosition() const { // Get half the wirelength double halfwire = 0.5*getWireLength(); // Calculate the position of the counter double x = _position.x() - halfwire*_orientation.x(); double y = _position.y() - halfwire*_orientation.y(); double z = _position.z() - halfwire*_orientation.z(); return CartesianPoint(x,y,z); } SpacePoint PDTGeometryHit::getGlobalPosition() const { double halfwire = 0.5*getWireLength(); double axialdist = getAxialDistance(); double diff = axialdist - halfwire; double x = _position.x() + diff*_orientation.x(); double y = _position.y() + diff*_orientation.y(); double z = _position.z() + diff*_orientation.z(); return CartesianPoint(x,y,z); } /* OP Removed - costs too much time on L3, and I do not know how valid this is double PDTGeometryHit::getDriftDistanceError() const { double time_error = _hit->getDriftTimeError(); double time = _hit->getDriftTime(); double dist = PDTHitTimes::getDriftDistance(time, _angle); double max_dist = PDTHitTimes::getDriftDistance(time + time_error, _angle); double min_dist = PDTHitTimes::getDriftDistance(time - time_error, _angle); return fabs((max_dist - min_dist)/2); } */ void PDTGeometryHit::setAngle(const double &angle) { if( (_angle != angle) || !_calcs_done) { _angle = angle; double pos[3] = {0.,0.,0.}; double ort[3] = {0.,0.,1.}; // equivalent to "Z_HAT" _calcs_done = MuoGeometer::get_instance()-> getPosition(_hit->getMuoIndex(),pos,ort); _position = CartesianPoint(pos[0],pos[1],pos[2]); _orientation = UnitVector(ort[0],ort[1],ort[2]); // OP 4/13 added, 8/02 DH modified _driftdistance = PDTHitTimes::getDriftDistance(_hit->getDriftTime(), _angle, _hit->getMuoIndex()); } } bool PDTGeometryHit::operator==(const PDTGeometryHit& rhs) const { if( this == &rhs ) return true; return _hit == rhs._hit; } std::ostream& operator<<(std::ostream& os, const PDTGeometryHit& rhs) { os << "PDTGeometryHit with hit: " << std::endl << *rhs._hit << std::endl; return os; } } // Namespace Muon