PandaRoot
StepLimits.h
Go to the documentation of this file.
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 namespace genfit {
31 
33  // soft limits (only rough estimation, can go beyond safely)
34  stp_noLimit = 0, // only for internal use
35 
36  // medium limits (can go a bit further if e.g. plane or boundary will be reached)
37  stp_fieldCurv, // stepsize limited by curvature and magnetic field inhomogenities
38  stp_momLoss, // stepsize limited by stepper because maximum momLoss is reached
39  stp_sMax, // stepsize limited by SMax defined in #estimateStep()
40 
41  // hard limits (must stop there at any case!)
42  stp_sMaxArg, // stepsize limited by argument maxStepArg passed to #estimateStep()
43  stp_boundary, // stepsize limited by stepper because material boundary is encountered
44  stp_plane, // stepsize limited because destination plane is reached
45 
46  ENUM_NR_ITEMS // only for internal use
47 };
48 
52 class StepLimits {
53 
54  public:
55  StepLimits() : limits_(ENUM_NR_ITEMS, maxLimit_), stepSign_(1) { ; }
56 
57  StepLimits &operator=(const StepLimits &other);
58 
60  double getLimit(StepLimitType type) const { return limits_[type]; }
61  double getLimitSigned(StepLimitType type) const { return stepSign_ * getLimit(type); }
62 
70  std::pair<StepLimitType, double> getLowestLimit(double margin = 1.E-3) const;
71 
73  double getLowestLimitVal(double margin = 1.E-3) const;
75  double getLowestLimitSignedVal(double margin = 1.E-3) const { return getLowestLimitVal(margin) * stepSign_; }
76 
77  char getStepSign() const { return stepSign_; } // +- 1
78 
80  void reduceLimit(StepLimitType type, double value);
82  void setLimit(StepLimitType type, double value) { limits_[type] = fabs(value); }
84  void setStepSign(char signedVal);
86  void setStepSign(double signedVal);
87 
88  void removeLimit(StepLimitType type) { limits_[type] = maxLimit_; }
89 
90  void reset();
91  void Print();
92 
93  private:
94  std::vector<double> limits_; // limits are unsigned (i.e. non-negative)
95  signed char stepSign_;
96  static const double maxLimit_;
97 };
98 
99 } /* End of namespace genfit */
102 #endif // genfit_StepLimits_h
char getStepSign() const
Definition: StepLimits.h:77
StepLimits & operator=(const StepLimits &other)
void setStepSign(char signedVal)
sets #stepSign_ to sign of signedVal
double getLowestLimitSignedVal(double margin=1.E-3) const
Get the numerical value of the lowest limit, signed with #stepSign_.
Definition: StepLimits.h:75
Helper to store different limits on the stepsize for the RKTRackRep.
Definition: StepLimits.h:52
StepLimitType
Definition: StepLimits.h:32
double getLimit(StepLimitType type) const
Get limit of type. If that limit has not yet been set, return max double value.
Definition: StepLimits.h:60
double getLimitSigned(StepLimitType type) const
Definition: StepLimits.h:61
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:46
std::pair< StepLimitType, double > getLowestLimit(double margin=1.E-3) const
Get the lowest limit.
double getLowestLimitVal(double margin=1.E-3) const
Get the unsigned numerical value of the lowest limit.
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:82
void reduceLimit(StepLimitType type, double value)
absolute of value will be taken! If limit is already lower, it will stay.
Matrix inversion tools.
Definition: AbsBField.h:28
void removeLimit(StepLimitType type)
Definition: StepLimits.h:88