// HitCylPhi.cpp #include "HitCylPhi.h" #include "objstream/ObjData.hpp" #include "objstream/ObjTable.hpp" #include "trfutil/trfstream.h" #include "trfbase/ETrack.h" #include "trfutil/TRFMath.h" using namespace trf; //********************************************************************** // Free functions. //********************************************************************** namespace { // Creator. ObjPtr create_cluster(const ObjData& data) { assert( data.get_object_type() == "ClusCylPhi" ); double radius = data.get_double("radius"); double phi = data.get_double("phi"); double dphi = data.get_double("dphi"); #ifdef ObjData_supports_lists McIdList mcids; data.get_int_list("mcids",mcids); #endif return ObjPtr( new ClusCylPhi(radius,phi,dphi,mcids) ); } ObjPtr create_hit(const ObjData& data) { assert(false); abort(); return ObjPtr(0); } } //********************************************************************** // ClusCylPhi //********************************************************************** // output stream void ClusCylPhi::ostr(ostream& stream) const { stream << begin_object; stream << "Hit at " << _scy << ": phi = " << _phi << " +/- " << _dphi; stream << " MC ID's:"; const McIdList& mcids = get_mc_ids(); for ( McIdList::const_iterator imc=mcids.begin(); imc!=mcids.end(); ++imc ) stream << " " << *imc; stream << end_object; } //********************************************************************** // equality bool ClusCylPhi::equal(const Cluster& clus) const { assert( this->get_type() == clus.get_type() ); const ClusCylPhi& ccp = (const ClusCylPhi&) clus; return ( _phi == ccp._phi ) && ( _dphi == ccp._dphi ) && ( _scy == ccp._scy ); } //********************************************************************** // constructor ClusCylPhi::ClusCylPhi(double radius, double phi, double dphi) : _scy(radius), _phi(phi), _dphi(dphi) { assert( _dphi >= 0.0 ); } //********************************************************************** // constructor with MC ID's ClusCylPhi::ClusCylPhi(double radius, double phi, double dphi, const McIdList& mcids) : McCluster(mcids), _scy(radius), _phi(phi), _dphi(dphi) { assert( _dphi >= 0.0 ); } //********************************************************************** // copy constructor ClusCylPhi::ClusCylPhi(const ClusCylPhi& rhs) : McCluster(rhs), _scy(rhs._scy), _phi(rhs._phi), _dphi(rhs._dphi) { } //********************************************************************** // destructor ClusCylPhi::~ClusCylPhi( ) { } //********************************************************************** // Return the creator. ObjCreator ClusCylPhi::get_creator() { return create_cluster; } //********************************************************************** // Write the object data. ObjData ClusCylPhi::write_data() const { ObjData data( get_type_name() ); data.add_double( "radius", get_radius() ); data.add_double( "phi", get_phi() ); data.add_double( "dphi", get_dphi() ); #ifdef ObjData_supports_lists data.add_int_list( "mcids", get_mc_ids() ); #endif return data; } //********************************************************************** // generate track prediction HitList ClusCylPhi::_predict(const ETrack& tre) const { HitList hits; hits.push_back( HitPtr( new HitCylPhi( tre.get_vector()(0), tre.get_error()(0,0) ) ) ); return hits; } //********************************************************************** // HitCylPhi //********************************************************************** // output stream void HitCylPhi::ostr(ostream& stream) const { if ( _pclus ) { stream << "prediction for "; stream << *_pclus; } else stream << "No parent cluster."; } //********************************************************************** // equality // if the hits are the same, then the predictions are the same bool HitCylPhi::equal(const Hit& thit) const { assert( this->get_type() == thit.get_type() ); return get_cluster() == thit.get_cluster(); } //********************************************************************** // constructor HitCylPhi::HitCylPhi(double phi, double ephi) : _phi_pre(phi), _ephi_pre(ephi) { } //********************************************************************** // copy constructor HitCylPhi::HitCylPhi(const HitCylPhi& lhs) : Hit(lhs), _phi_pre(lhs._phi_pre), _ephi_pre(lhs._ephi_pre) { } //********************************************************************** // destructor HitCylPhi::~HitCylPhi() { } //********************************************************************** // Return the creator. ObjCreator HitCylPhi::get_creator() { return create_hit; } //********************************************************************** // Write the object data. ObjData HitCylPhi::write_data() const { ObjData data( get_type_name() ); return data; } //********************************************************************** // return the measured hit vector HitVector HitCylPhi::measured_vector() const { return HitVector( get_full_cluster().get_phi() ); } //********************************************************************** // return the measured hit error HitError HitCylPhi::measured_error() const { double dphi = get_full_cluster().get_dphi(); return HitError( dphi*dphi ); } //********************************************************************** // return the predicted hit vector HitVector HitCylPhi::predicted_vector() const { return HitVector( _phi_pre ); } //********************************************************************** // return the predicted hit error HitError HitCylPhi::predicted_error() const { return HitError( _ephi_pre ); } //********************************************************************** // return the derivative HitDerivative HitCylPhi::dhit_dtrack() const { double values[] = { 1.0, 0.0, 0.0, 0.0, 0.0 }; HitDerivative deriv(1,values); return deriv; } //********************************************************************** // return the difference between prediction and measurement. HitVector HitCylPhi::difference_vector() const { return HitVector( fmod2(_phi_pre - get_full_cluster().get_phi(),TWOPI) ); } //********************************************************************** // update the prediction (measurement and derivative do not change) void HitCylPhi::update( const ETrack& tre) { _phi_pre = tre.get_vector()(0); _ephi_pre = tre.get_error()(0,0); } //**********************************************************************