Belle II Software  release-08-01-10
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 
33 enum StepLimitType {
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:
57  StepLimits()
58  : limits_(ENUM_NR_ITEMS, maxLimit_), stepSign_(1) {;}
59 
60  StepLimits(const StepLimits&) = default;
61 
62  StepLimits& operator=(const StepLimits& other);
63 
65  double getLimit(StepLimitType type) const {return limits_[type];}
66  double getLimitSigned(StepLimitType type) const {
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 
97  void removeLimit(StepLimitType type) {limits_[type] = maxLimit_;}
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
Helper to store different limits on the stepsize for the RKTRackRep.
Definition: StepLimits.h:54
std::pair< StepLimitType, double > getLowestLimit(double margin=1.E-3) const
Get the lowest limit.
Definition: StepLimits.cc:44
void setStepSign(char signedVal)
sets #stepSign_ to sign of signedVal
Definition: StepLimits.cc:93
double getLowestLimitSignedVal(double margin=1.E-3) const
Get the numerical value of the lowest limit, signed with #stepSign_.
Definition: StepLimits.h:82
double getLimit(StepLimitType type) const
Get limit of type. If that limit has not yet been set, return max double value.
Definition: StepLimits.h:65
void setLimit(StepLimitType type, double value)
absolute of value will be taken! If limit is already lower, it will be set to value anyway.
Definition: StepLimits.h:91
double getLowestLimitVal(double margin=1.E-3) const
Get the unsigned numerical value of the lowest limit.
Definition: StepLimits.cc:65
void reduceLimit(StepLimitType type, double value)
absolute of value will be taken! If limit is already lower, it will stay.
Definition: StepLimits.cc:84
Defines for I/O streams used for error and debug printing.