CMS 3D CMS Logo

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