File indexing completed on 2025-01-18 09:14:40
0001 #ifndef Other_Helpers_hh
0002 #define Other_Helpers_hh 1
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <iostream>
0012 #include <map>
0013 #include <stdexcept>
0014
0015 namespace ODH {
0016
0017 typedef enum {
0018 kCenter = 0,
0019 kUpstream = 1,
0020 kDnstream = 2,
0021 kPunchedCenter = 3,
0022 kPunchedUpstream = 4,
0023 kPunchedDnstream = 5,
0024 kUpstreamClippedFront = 6,
0025 kDnstreamClippedFront = 7,
0026 kUpstreamClippedRear = 8,
0027 kDnstreamClippedRear = 9,
0028 kUpstreamClippedBoth = 10,
0029 kDnstreamClippedBoth = 11,
0030 kUpstreamSlicedFront = 12,
0031 kDnstreamSlicedFront = 13,
0032 kUpstreamSlicedRear = 14,
0033 kDnstreamSlicedRear = 15,
0034 kUpstreamSlicedBoth = 16,
0035 kDnstreamSlicedBoth = 17
0036 } ECrossType;
0037
0038 inline ECrossType getCrossType(std::string const& type) {
0039
0040 std::map<std::string, ODH::ECrossType> CrossTypes;
0041 CrossTypes["Center"] = ODH::kCenter;
0042 CrossTypes["Upstream"] = ODH::kUpstream;
0043 CrossTypes["Dnstream"] = ODH::kDnstream;
0044 CrossTypes["PunchedCenter"] = ODH::kPunchedCenter;
0045 CrossTypes["PunchedUpstream"] = ODH::kPunchedUpstream;
0046 CrossTypes["PunchedDnstream"] = ODH::kPunchedDnstream;
0047 CrossTypes["UpstreamClippedFront"] = ODH::kUpstreamClippedFront;
0048 CrossTypes["DnstreamClippedFront"] = ODH::kDnstreamClippedFront;
0049 CrossTypes["UpstreamClippedRear"] = ODH::kUpstreamClippedRear;
0050 CrossTypes["DnstreamClippedRear"] = ODH::kDnstreamClippedRear;
0051 CrossTypes["UpstreamClippedBoth"] = ODH::kUpstreamClippedBoth;
0052 CrossTypes["DnstreamClippedBoth"] = ODH::kDnstreamClippedBoth;
0053 CrossTypes["UpstreamSlicedFront"] = ODH::kUpstreamSlicedFront;
0054 CrossTypes["DnstreamSlicedFront"] = ODH::kDnstreamSlicedFront;
0055 CrossTypes["UpstreamSlicedRear"] = ODH::kUpstreamSlicedRear;
0056 CrossTypes["DnstreamSlicedRear"] = ODH::kDnstreamSlicedRear;
0057 CrossTypes["UpstreamSlicedBoth"] = ODH::kUpstreamSlicedBoth;
0058 CrossTypes["DnstreamSlicedBoth"] = ODH::kDnstreamSlicedBoth;
0059
0060 std::map<std::string, ODH::ECrossType>::const_iterator ct = CrossTypes.find(type);
0061 if (ct == CrossTypes.end()) {
0062 throw std::runtime_error("Unknown Crossing Type for this geometry");
0063 }
0064 return ct->second;
0065 }
0066
0067 inline bool checkForSensibleGeometry(double crossingAngle, ECrossType crossType) {
0068 if (crossingAngle == 0 && crossType != kCenter) {
0069 std::cout << "Mask: You are trying to build a crossing geometry without a crossing angle.\n"
0070 "This is probably not what you want - better check your geometry data!"
0071 << std::endl;
0072 return false;
0073 }
0074 return true;
0075 }
0076
0077 inline double getCurrentAngle(double crossingAngle, ECrossType crossType) {
0078 double tmpAngle;
0079 switch (crossType) {
0080 case kUpstream:
0081 case kPunchedUpstream:
0082 case kUpstreamClippedFront:
0083 case kUpstreamClippedRear:
0084 case kUpstreamClippedBoth:
0085 case kUpstreamSlicedFront:
0086 case kUpstreamSlicedRear:
0087 case kUpstreamSlicedBoth:
0088 tmpAngle = -crossingAngle;
0089 break;
0090 case kDnstream:
0091 case kPunchedDnstream:
0092 case kDnstreamClippedFront:
0093 case kDnstreamClippedRear:
0094 case kDnstreamClippedBoth:
0095 case kDnstreamSlicedFront:
0096 case kDnstreamSlicedRear:
0097 case kDnstreamSlicedBoth:
0098 tmpAngle = +crossingAngle;
0099 break;
0100 default:
0101 tmpAngle = 0;
0102 break;
0103 }
0104
0105 return tmpAngle;
0106 }
0107
0108 }
0109
0110 #endif