CMS 3D CMS Logo

UnitConverter.cc

Go to the documentation of this file.
00001 #include "Alignment/CocoaToDDL/interface/UnitConverter.h"
00002 #include "Alignment/CocoaToDDL/interface/CocoaUnitsTable.h"
00003 #include "CLHEP/Units/SystemOfUnits.h"
00004 #include <sstream>
00005 #include <strstream>
00006 #include <string>
00007 
00008 /*
00009 UnitConverter::UnitConverter(const G4BestUnit & bu)
00010  : bu_(bu)
00011 {
00012   //ostrstream s;
00013   //s << bu;
00014   
00015 }
00016 */
00017 
00018 UnitConverter::UnitConverter(ALIdouble val, const ALIstring & category)
00019  : bu_(new CocoaBestUnit(val,category)), angl_(false)
00020 { 
00021    if (category=="Angle")
00022     angl_=true;
00023 }
00024 
00025 UnitConverter::~UnitConverter()
00026 {
00027   delete bu_;
00028 }  
00029 
00030 std::string UnitConverter::ucstring()
00031 {
00032 
00033    std::ostrstream str;
00034    
00035    if (angl_) {
00036      str.precision(11);
00037      double x = ( *(bu_->GetValue()) ) / deg;
00038      str << x << std::string("*deg") << '\0';
00039      return std::string(str.str());
00040    
00041    }
00042    else {
00043      str << *bu_ << '\0';
00044      std::string s(str.str());
00045      return s.replace(s.find(" "),1,"*");
00046    }  
00047    //return s;
00048 
00049 }
00050 
00051 /*
00052 ostream & operator<<(ostream & os, const UnitConverter & uc)
00053 {
00054   ostrstream temp;
00055   //temp << uc.bu_;
00056   //temp << '\0';
00057   //string s(temp.str());
00058   //cout << "NOW: " << s << endl;
00059   os << *(uc.bu_);
00060 }
00061 
00062 */

Generated on Tue Jun 9 17:23:40 2009 for CMSSW by  doxygen 1.5.4