EIC 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& operator=(const StepLimits& other);
61 
63  double getLimit(StepLimitType type) const {return limits_[type];}
64  double getLimitSigned(StepLimitType type) const {
65  return stepSign_*getLimit(type);
66  }
67 
75  std::pair<StepLimitType, double> getLowestLimit(double margin = 1.E-3) const;
76 
78  double getLowestLimitVal(double margin = 1.E-3) const;
80  double getLowestLimitSignedVal(double margin = 1.E-3) const {
81  return getLowestLimitVal(margin) * stepSign_;
82  }
83 
84  char getStepSign() const {return stepSign_;} // +- 1
85 
87  void reduceLimit(StepLimitType type, double value);
89  void setLimit(StepLimitType type, double value) {limits_[type] = fabs(value);}
91  void setStepSign(char signedVal);
93  void setStepSign(double signedVal);
94 
96 
97  void reset();
98  void Print();
99 
100  private:
101  std::vector<double> limits_; // limits are unsigned (i.e. non-negative)
102  signed char stepSign_;
103  static const double maxLimit_;
104 
105 };
106 
107 } /* End of namespace genfit */
110 #endif // genfit_StepLimits_h