Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-10 02:20:14

0001 #include "Alignment/CocoaToDDL/interface/UnitConverter.h"
0002 #include "Alignment/CocoaToDDL/interface/CocoaUnitsTable.h"
0003 #include <CLHEP/Units/SystemOfUnits.h>
0004 #include <sstream>
0005 
0006 /*
0007 UnitConverter::UnitConverter(const G4BestUnit & bu)
0008  : bu_(bu)
0009 {
0010   //ostrstream s;
0011   //s << bu;
0012   
0013 }
0014 */
0015 
0016 UnitConverter::UnitConverter(ALIdouble val, const ALIstring& category)
0017     : bu_(new CocoaBestUnit(val, category)), angl_(false) {
0018   if (category == "Angle")
0019     angl_ = true;
0020 }
0021 
0022 UnitConverter::~UnitConverter() { delete bu_; }
0023 
0024 std::string UnitConverter::ucstring() {
0025   std::ostringstream str;
0026 
0027   if (angl_) {
0028     str.precision(11);
0029     double x = (*(bu_->GetValue())) / CLHEP::deg;
0030     str << x << std::string("*deg") << '\0';
0031     return std::string(str.str());
0032 
0033   } else {
0034     str << *bu_ << '\0';
0035     std::string s(str.str());
0036     return s.replace(s.find(' '), 1, "*");
0037   }
0038   //return s;
0039 }
0040 
0041 /*
0042 ostream & operator<<(ostream & os, const UnitConverter & uc)
0043 {
0044   std::ostringstream temp;
0045   //temp << uc.bu_;
0046   //temp << '\0';
0047   //string s(temp.str());
0048   //cout << "NOW: " << s << endl;
0049   os << *(uc.bu_);
0050 }
0051 
0052 */