File indexing completed on 2024-04-06 12:05:26
0001 #include "DetectorDescription/Core/interface/DDTypes.h"
0002 #include "DataFormats/Math/interface/GeantUnits.h"
0003
0004 #include <iostream>
0005 #include <utility>
0006
0007 using namespace geant_units;
0008 using namespace geant_units::operators;
0009
0010
0011
0012 std::ostream& operator<<(std::ostream& os, const DDNumericArguments& t) {
0013 DDNumericArguments::const_iterator it(t.begin()), ed(t.end());
0014 for (; it != ed; ++it) {
0015 os << it->first << '=' << it->second << std::endl;
0016 }
0017 return os;
0018 }
0019
0020 std::ostream& operator<<(std::ostream& os, const DDStringArguments& t) {
0021 DDStringArguments::const_iterator it(t.begin()), ed(t.end());
0022 for (; it != ed; ++it) {
0023 os << it->first << '=' << it->second << std::endl;
0024 }
0025 return os;
0026 }
0027
0028 std::ostream& operator<<(std::ostream& os, const DDVectorArguments& t) {
0029 DDVectorArguments::const_iterator it(t.begin()), ed(t.end());
0030 for (; it != ed; ++it) {
0031 os << it->first << ": ";
0032 std::vector<double>::const_iterator vit(it->second.begin()), ved(it->second.end());
0033 for (; vit != ved; ++vit) {
0034 os << *vit << ' ';
0035 }
0036 os << std::endl;
0037 }
0038 return os;
0039 }
0040
0041 std::ostream& operator<<(std::ostream& os, const DDMapArguments& t) {
0042 DDMapArguments::const_iterator it(t.begin()), ed(t.end());
0043 for (; it != ed; ++it) {
0044 os << it->first << ": ";
0045 std::map<std::string, double>::const_iterator mit(it->second.begin()), med(it->second.end());
0046 for (; mit != med; ++mit) {
0047 os << mit->first << '=' << mit->second << ' ';
0048 }
0049 os << std::endl;
0050 }
0051 return os;
0052 }
0053
0054 std::ostream& operator<<(std::ostream& os, const DDStringVectorArguments& t) {
0055 DDStringVectorArguments::const_iterator it(t.begin()), ed(t.end());
0056 for (; it != ed; ++it) {
0057 os << it->first << ": ";
0058 std::vector<std::string>::const_iterator vit(it->second.begin()), ved(it->second.end());
0059 for (; vit != ved; ++vit) {
0060 os << *vit << ' ';
0061 }
0062 os << std::endl;
0063 }
0064 return os;
0065 }
0066
0067
0068 std::string formatAsDegrees(double radianVal) {
0069 const unsigned short numlen = 12;
0070 char degstr[numlen];
0071 int retval = snprintf(degstr, numlen, "%0*f", numlen - 1, convertRadToDeg(radianVal));
0072 if (retval == numlen - 1)
0073 return degstr;
0074 else
0075 return "0000.000000";
0076 }
0077
0078
0079 std::string formatAsDegreesInInteger(double radianVal) {
0080 const unsigned short numlen = 4;
0081 char degstr[numlen];
0082 int degVal = std::lround(convertRadToDeg(radianVal));
0083 if (degVal < 0)
0084 degVal += 360;
0085 else if (degVal >= 360)
0086 degVal -= 360;
0087 int retval = snprintf(degstr, numlen, "%0*d", numlen - 1, degVal);
0088
0089 if (retval == numlen - 1)
0090 return degstr;
0091 else
0092 return "000";
0093 }