Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:33

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