Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StepLimits.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file StepLimits.h
1 /* Copyright 2008-2014, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 #ifndef genfit_StepLimits_h
25 #define genfit_StepLimits_h
26 
27 #include <vector>
28 #include <math.h>
29 
30 
31 namespace genfit {
32 
34  // soft limits (only rough estimation, can go beyond safely)
35  stp_noLimit = 0, // only for internal use
36 
37  // medium limits (can go a bit further if e.g. plane or boundary will be reached)
38  stp_fieldCurv, // stepsize limited by curvature and magnetic field inhomogenities
39  stp_momLoss, // stepsize limited by stepper because maximum momLoss is reached
40  stp_sMax, // stepsize limited by SMax defined in #estimateStep()
41 
42  // hard limits (must stop there at any case!)
43  stp_sMaxArg, // stepsize limited by argument maxStepArg passed to #estimateStep()
44  stp_boundary, // stepsize limited by stepper because material boundary is encountered
45  stp_plane, // stepsize limited because destination plane is reached
46 
47  ENUM_NR_ITEMS // only for internal use
48 };
49 
50 
54 class StepLimits {
55 
56  public:
59 
60  StepLimits(const StepLimits&) = default;
61 
62  StepLimits& operator=(const StepLimits& other);
63 
65  double getLimit(StepLimitType type) const {return limits_[type];}
67  return stepSign_*getLimit(type);
68  }
69 
77  std::pair<StepLimitType, double> getLowestLimit(double margin = 1.E-3) const;
78 
80  double getLowestLimitVal(double margin = 1.E-3) const;
82  double getLowestLimitSignedVal(double margin = 1.E-3) const {
83  return getLowestLimitVal(margin) * stepSign_;
84  }
85 
86  char getStepSign() const {return stepSign_;} // +- 1
87 
89  void reduceLimit(StepLimitType type, double value);
91  void setLimit(StepLimitType type, double value) {limits_[type] = fabs(value);}
93  void setStepSign(char signedVal);
95  void setStepSign(double signedVal);
96 
98 
99  void reset();
100  void Print();
101 
102  private:
103  std::vector<double> limits_; // limits are unsigned (i.e. non-negative)
104  signed char stepSign_;
105  static const double maxLimit_;
106 
107 };
108 
109 } /* End of namespace genfit */
112 #endif // genfit_StepLimits_h