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
0008
0009
0010
0011
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
0039 }
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052