CMS 3D CMS Logo

UnitConverter.cc
Go to the documentation of this file.
3 #include <CLHEP/Units/SystemOfUnits.h>
4 #include <sstream>
5 
6 /*
7 UnitConverter::UnitConverter(const G4BestUnit & bu)
8  : bu_(bu)
9 {
10  //ostrstream s;
11  //s << bu;
12 
13 }
14 */
15 
17  : bu_(new CocoaBestUnit(val, category)), angl_(false) {
18  if (category == "Angle")
19  angl_ = true;
20 }
21 
23 
25  std::ostringstream str;
26 
27  if (angl_) {
28  str.precision(11);
29  double x = (*(bu_->GetValue())) / CLHEP::deg;
30  str << x << std::string("*deg") << '\0';
31  return std::string(str.str());
32 
33  } else {
34  str << *bu_ << '\0';
35  std::string s(str.str());
36  return s.replace(s.find(' '), 1, "*");
37  }
38  //return s;
39 }
40 
41 /*
42 ostream & operator<<(ostream & os, const UnitConverter & uc)
43 {
44  std::ostringstream temp;
45  //temp << uc.bu_;
46  //temp << '\0';
47  //string s(temp.str());
48  //cout << "NOW: " << s << endl;
49  os << *(uc.bu_);
50 }
51 
52 */
long double ALIdouble
Definition: CocoaGlobals.h:11
CocoaBestUnit * bu_
Definition: UnitConverter.h:22
std::string ucstring()
std::string ALIstring
Definition: CocoaGlobals.h:9
ALIdouble * GetValue()
UnitConverter(ALIdouble val, const ALIstring &category)
#define str(s)