// HitZPlane1.cpp #include "HitZPlane1.h" #include "trfbase/ETrack.h" #include "trfutil/TRFMath.h" #include "trfutil/trfstream.h" #include "objstream/ObjData.hpp" #include "objstream/ObjTable.hpp" using namespace trf; //********************************************************************** // Free functions. //********************************************************************** namespace { // Creator. ObjPtr create_cluster(const ObjData& data) { assert( data.get_object_type() == "ClusZPlane1" ); double z = data.get_double("z"); double ax = data.get_double("xweight"); double ay = data.get_double("yweight"); double xy = data.get_double("xy"); double dxy = data.get_double("dxy"); #ifdef ObjData_supports_lists McIdList mcids; data.get_int_list("mcids",mcids); #endif return ObjPtr( new ClusZPlane1(z,ax,ay,xy,dxy,mcids) ); } ObjPtr create_hit(const ObjData& data) { assert(false); abort(); return ObjPtr(0); } } //********************************************************************** // ClusZPlane1 //********************************************************************** // output stream void ClusZPlane1::ostr(ostream& stream) const { stream << begin_object ; stream << "axy " << _szp << " and x weight " << _wx << " and y weight " << _wy << ": axy = " << _axy << " +/- " << _daxy; stream << end_object; } //********************************************************************** // equality bool ClusZPlane1::equal(const Cluster& clus) const { assert( this->get_type() == clus.get_type() ); const ClusZPlane1& ccp = (const ClusZPlane1&) clus; return ( _wx == ccp._wx ) && ( _wy == ccp._wy ) && ( _axy == ccp._axy ) && ( _daxy == ccp._daxy ) && ( _szp == ccp._szp ); } //********************************************************************** // constructor ClusZPlane1::ClusZPlane1(double zpos, double wx, double wy, double axy,double daxy ) : _szp(zpos), _wx(wx), _wy(wy), _axy(axy), _daxy(daxy) { assert( _daxy >= 0.0 ); } ClusZPlane1::ClusZPlane1(double zpos, double wx, double wy, double axy,double daxy,const McIdList& mcids ) : _szp(zpos), _wx(wx), _wy(wy), _axy(axy), _daxy(daxy),McCluster(mcids) { assert( _daxy >= 0.0 ); } //********************************************************************** // copy constructor ClusZPlane1::ClusZPlane1(const ClusZPlane1& rhs) : _szp(rhs._szp), _wx(rhs._wx), _wy(rhs._wy), _axy(rhs._axy), _daxy(rhs._daxy),McCluster(rhs) { } //********************************************************************** // destructor ClusZPlane1::~ClusZPlane1( ) { } //********************************************************************** // generate hits from a track HitList ClusZPlane1::_predict(const ETrack& tre) const { HitList hits; double x_track = tre.get_vector()(SurfZPlane::IX); double y_track = tre.get_vector()(SurfZPlane::IY); double exx_track = tre.get_error()(SurfZPlane::IX,SurfZPlane::IX); double exy_track = tre.get_error()(SurfZPlane::IX,SurfZPlane::IY); double eyy_track = tre.get_error()(SurfZPlane::IY,SurfZPlane::IY); double axy = _wx*x_track + _wy*y_track; double eaxy = exx_track*_wx*_wx + 2.*exy_track*_wx*_wy + eyy_track*_wy*_wy; hits.push_back( HitPtr(new HitZPlane1( axy, eaxy ) )); return hits; } //********************************************************************** // Return the creator. ObjCreator ClusZPlane1::get_creator() { return create_cluster; } //********************************************************************** // Write the object data. ObjData ClusZPlane1::write_data() const { ObjData data( get_type_name() ); data.add_double( "z", ((const SurfZPlane&)(get_surface())).get_z() ); data.add_double( "xweight", get_wx() ); data.add_double( "yweight", get_wy() ); data.add_double( "xy", get_axy() ); data.add_double( "dxy", get_daxy() ); #ifdef ObjData_supports_lists data.add_int_list( "mcids", get_mc_ids() ); #endif return data; } //********************************************************************** // HitZPlane1 //********************************************************************** // output stream void HitZPlane1::ostr(ostream& stream) const { stream << begin_object ; if( _pclus ) { stream << "hit from "; stream << *_pclus; } else { stream << "Hit with no parent clusters"; } stream << end_object; } //********************************************************************** // equality // Hits are equal if they have the same parent cluster. bool HitZPlane1::equal(const Hit& hit) const { assert( this->get_type() == hit.get_type() ); return get_cluster() == hit.get_cluster(); } //********************************************************************** // constructor HitZPlane1::HitZPlane1(double axy, double eaxy) : _axy_pre(axy), _eaxy_pre(eaxy) { } //********************************************************************** // copy constructor HitZPlane1::HitZPlane1(const HitZPlane1& lhs) : Hit(lhs), _axy_pre(lhs._axy_pre), _eaxy_pre(lhs._eaxy_pre) { } //********************************************************************** // destructor HitZPlane1::~HitZPlane1() { } //********************************************************************** // return the measured hit vector HitVector HitZPlane1::measured_vector() const { return HitVector( get_full_cluster().get_axy() ); } //********************************************************************** // return the measured hit error HitError HitZPlane1::measured_error() const { double daxy = get_full_cluster().get_daxy(); return HitError( daxy*daxy ); } //********************************************************************** // return the predicted hit vector HitVector HitZPlane1::predicted_vector() const { return HitVector( _axy_pre ); } //********************************************************************** // return the predicted hit error HitError HitZPlane1::predicted_error() const { return HitError( _eaxy_pre ); } //********************************************************************** // return the derivative HitDerivative HitZPlane1::dhit_dtrack() const { double values[] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; values[0] = get_full_cluster().get_wx(); values[1] = get_full_cluster().get_wy(); HitDerivative deriv(1,values); return deriv; } //********************************************************************** // return the difference between prediction and measurement. HitVector HitZPlane1::difference_vector() const { return HitVector( _axy_pre-get_full_cluster().get_axy() ); } //********************************************************************** // update the hit prediction (measurement and derivative do not change) void HitZPlane1::update( const ETrack& tre) { double x_track = tre.get_vector()(SurfZPlane::IX); double y_track = tre.get_vector()(SurfZPlane::IY); double exx_track = tre.get_error()(SurfZPlane::IX,SurfZPlane::IX); double exy_track = tre.get_error()(SurfZPlane::IX,SurfZPlane::IY); double eyy_track = tre.get_error()(SurfZPlane::IY,SurfZPlane::IY); double cl_wx = get_full_cluster().get_wx(); double cl_wy = get_full_cluster().get_wy(); _axy_pre = cl_wx*x_track + cl_wy*y_track; _eaxy_pre = exx_track*cl_wx*cl_wx + 2.*exy_track*cl_wx*cl_wy + eyy_track*cl_wy*cl_wy; } //********************************************************************** // Return the creator. ObjCreator HitZPlane1::get_creator() { return create_hit; } //********************************************************************** // Write the object data. ObjData HitZPlane1::write_data() const { ObjData data( get_type_name() ); return data; } //**********************************************************************