File indexing completed on 2025-08-05 08:18:30
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "StepLimits.h"
0021 #include "IO.h"
0022
0023 #include <algorithm>
0024 #include <assert.h>
0025 #include <limits>
0026
0027
0028 namespace genfit {
0029
0030 const double StepLimits::maxLimit_ = 99.E99;
0031
0032
0033 StepLimits& StepLimits::operator=(const StepLimits& other) {
0034 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
0035 limits_[i] = other.limits_[i];
0036 }
0037
0038 stepSign_ = other.stepSign_;
0039
0040 return *this;
0041 }
0042
0043
0044 std::pair<StepLimitType, double> StepLimits::getLowestLimit(double margin) const {
0045
0046 double lowest(maxLimit_);
0047 unsigned int iLowest(0);
0048
0049 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
0050
0051
0052 if (i == int(stp_sMaxArg))
0053 lowest *= (1+margin);
0054
0055 if (limits_[i] < lowest) {
0056 lowest = limits_[i];
0057 iLowest = i;
0058 }
0059 }
0060
0061 return std::pair<StepLimitType, double>(static_cast<StepLimitType>(iLowest), lowest);
0062 }
0063
0064
0065 double StepLimits::getLowestLimitVal(double margin) const {
0066
0067 double lowest(maxLimit_);
0068
0069 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
0070
0071
0072 if (i == int(stp_sMaxArg))
0073 lowest *= (1+margin);
0074
0075 if (limits_[i] < lowest) {
0076 lowest = limits_[i];
0077 }
0078 }
0079
0080 return lowest;
0081 }
0082
0083
0084 void StepLimits::reduceLimit(StepLimitType type, double value) {
0085 assert (type != stp_noLimit);
0086 value = fabs(value);
0087
0088 if (limits_[type] > value)
0089 limits_[type] = value;
0090 }
0091
0092
0093 void StepLimits::setStepSign(char signedVal) {
0094 if (signedVal < 0)
0095 stepSign_ = -1;
0096 else
0097 stepSign_ = 1;
0098 }
0099
0100 void StepLimits::setStepSign(double signedVal) {
0101 if (signedVal < 0.)
0102 stepSign_ = -1;
0103 else
0104 stepSign_ = 1;
0105 }
0106
0107
0108 void StepLimits::reset() {
0109 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
0110 limits_[i] = maxLimit_;
0111 }
0112 stepSign_ = 1;
0113 }
0114
0115
0116 void StepLimits::Print() {
0117 for (unsigned int i=0; i<ENUM_NR_ITEMS; ++i) {
0118 if (limits_[i] >= maxLimit_)
0119 continue;
0120
0121 printOut << " | " << limits_[i] << " cm due to ";
0122 switch (static_cast<StepLimitType>(i)) {
0123 case stp_noLimit:
0124 break;
0125 case stp_fieldCurv:
0126 printOut << "stp_fieldCurv (medium limit): stepsize limited by curvature and magnetic field inhomogenities";
0127 break;
0128 case stp_momLoss:
0129 printOut << "stp_momLoss (medium limit): stepsize limited by stepper because maximum momLoss is reached";
0130 break;
0131 case stp_sMax:
0132 printOut << "stp_sMax (medium limit): stepsize limited by SMax defined in #estimateStep()";
0133 break;
0134 case stp_sMaxArg:
0135 printOut << "stp_sMaxArg (hard limit): stepsize limited by argument maxStepArg passed to #estimateStep()";
0136 break;
0137 case stp_boundary:
0138 printOut << "stp_boundary (hard limit): stepsize limited by stepper because material boundary is encountered";
0139 break;
0140 case stp_plane:
0141 printOut << "stp_plane (hard limit): stepsize limited because destination plane is reached";
0142 break;
0143 case ENUM_NR_ITEMS:
0144 break;
0145 }
0146 printOut << "\n";
0147 }
0148 printOut << "\n";
0149 }
0150
0151 }