00001
00002
00004
00005 #ifndef GEOPRIMITIVESTOSTRINGCONVERTER_H_
00006 #define GEOPRIMITIVESTOSTRINGCONVERTER_H_
00007
00008 #include "EventPrimitives/EventPrimitivesToStringConverter.h"
00009 #include "GeoPrimitives/CLHEPtoEigenConverter.h"
00010 #include "GeoPrimitives/GeoPrimitives.h"
00011 #ifndef XAOD_STANDALONE
00012 # include "CLHEP/Geometry/Transform3D.h"
00013 # include "CLHEP/Geometry/Point3D.h"
00014 # include "CLHEP/Vector/TwoVector.h"
00015 #endif // not XAOD_STANDALONE
00016
00017 namespace Amg {
00018
00034 inline std::string toString( const Amg::Translation3D& translation, int precision = 4 ){
00035 Amg::Vector3D trans;
00036 trans[0] = translation.x();
00037 trans[1] = translation.y();
00038 trans[2] = translation.z();
00039 return toString( trans, precision );
00040 }
00041
00042
00043 inline std::string toString( const Amg::Transform3D& transform, int precision = 4, std::string offset="" ){
00044 std::ostringstream sout;
00045 sout << "Translation : " << toString( transform.translation(), precision ) << std::endl;
00046 std::string rotationOffset = offset + " ";
00047 sout << offset << "Rotation : " << toString( transform.rotation(), precision+2, rotationOffset );
00048 return sout.str();
00049 }
00050
00051 #ifndef XAOD_STANDALONE
00052
00053 inline std::string toString( const CLHEP::HepRotation& rot, int precision = 4, std::string offset="" ){
00054 std::ostringstream sout;
00055
00056 sout << std::setiosflags(std::ios::fixed) << std::setprecision(precision);
00057 for( int i=0;i<3;++i ){
00058 for( int j=0;j<3;++j ){
00059 if( j == 0 ) sout << "(";
00060 double val = roundWithPrecision(rot(i,j),precision);
00061 sout << val;
00062 if( j == 2 ) sout << ")";
00063 else sout << ", ";
00064 }
00065 if( i != 2 ) {
00066 sout << std::endl;
00067 sout << offset;
00068 }
00069 }
00070 return sout.str();
00071 }
00072
00073
00074 inline std::string toString( const CLHEP::Hep3Vector& translation, int precision = 4){
00075 std::ostringstream sout;
00076 sout << std::setiosflags(std::ios::fixed) << std::setprecision(precision);
00077 for( int j=0;j<3;++j ){
00078 if( j == 0 ) sout << "(";
00079 double val = roundWithPrecision( translation[j],precision);
00080 sout << val;
00081 if( j == 2 ) sout << ")";
00082 else sout << ", ";
00083 }
00084 return sout.str();
00085 }
00086
00087 inline std::string toString( const CLHEP::Hep2Vector& translation, int precision = 4){
00088 std::ostringstream sout;
00089 sout << std::setiosflags(std::ios::fixed) << std::setprecision(precision);
00090 for( int j=0;j<2;++j ){
00091 if( j == 0 ) sout << "(";
00092 double val = roundWithPrecision( translation[j],precision);
00093 sout << val;
00094 if( j == 1 ) sout << ")";
00095 else sout << ", ";
00096 }
00097 return sout.str();
00098 }
00099
00100 inline std::string toString( const HepGeom::Transform3D& transf, int precision = 4, std::string offset=""){
00101 std::ostringstream sout;
00102 sout << "Translation : " << toString( transf.getTranslation(), precision ) << std::endl;
00103 std::string rotationOffset = offset + " ";
00104 sout << offset << "Rotation : " << toString( transf.getRotation(), precision+2, rotationOffset );
00105 return sout.str();
00106 }
00107
00108 #endif // not XAOD_STANDALONE
00109
00110 }
00111
00112 #endif