SND@LHC Software
Loading...
Searching...
No Matches
StepLimits.cc
Go to the documentation of this file.
1/* Copyright 2008-2010, 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
20#include "StepLimits.h"
21
22#include <algorithm>
23#include <assert.h>
24#include <iostream>
25#include <limits>
26
27
28namespace genfit {
29
30const double StepLimits::maxLimit_ = 99.E99;
31
32
34 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
35 limits_[i] = other.limits_[i];
36 }
37
38 stepSign_ = other.stepSign_;
39
40 return *this;
41}
42
43
44std::pair<StepLimitType, double> StepLimits::getLowestLimit(double margin) const {
45
46 double lowest(maxLimit_);
47 unsigned int iLowest(0);
48
49 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
50
51 // lowest hard limit may exceed lowest soft limit by up to #margin
52 if (i == int(stp_sMaxArg))
53 lowest *= (1+margin);
54
55 if (limits_[i] < lowest) {
56 lowest = limits_[i];
57 iLowest = i;
58 }
59 }
60
61 return std::pair<StepLimitType, double>(static_cast<StepLimitType>(iLowest), lowest);
62}
63
64
65double StepLimits::getLowestLimitVal(double margin) const {
66
67 double lowest(maxLimit_);
68
69 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
70
71 // lowest hard limit may exceed lowest soft limit by up to #margin
72 if (i == int(stp_sMaxArg))
73 lowest *= (1+margin);
74
75 if (limits_[i] < lowest) {
76 lowest = limits_[i];
77 }
78 }
79
80 return lowest;
81}
82
83
84void StepLimits::reduceLimit(StepLimitType type, double value) {
85 assert (type != stp_noLimit);
86 value = fabs(value);
87
88 if (limits_[type] > value)
89 limits_[type] = value;
90}
91
92
93void StepLimits::setStepSign(char signedVal) {
94 if (signedVal < 0)
95 stepSign_ = -1;
96 else
97 stepSign_ = 1;
98}
99
100void StepLimits::setStepSign(double signedVal) {
101 if (signedVal < 0.)
102 stepSign_ = -1;
103 else
104 stepSign_ = 1;
105}
106
107
109 for (unsigned int i=1; i<ENUM_NR_ITEMS; ++i) {
110 limits_[i] = maxLimit_;
111 }
112 stepSign_ = 1;
113}
114
115
117 for (unsigned int i=0; i<ENUM_NR_ITEMS; ++i) {
118 if (limits_[i] >= maxLimit_)
119 continue;
120
121 std::cout << " | " << limits_[i] << " cm due to ";
122 switch (static_cast<StepLimitType>(i)) {
123 case stp_noLimit:
124 break;
125 case stp_fieldCurv:
126 std::cout << "stp_fieldCurv (medium limit): stepsize limited by curvature and magnetic field inhomogenities";
127 break;
128 case stp_momLoss:
129 std::cout << "stp_momLoss (medium limit): stepsize limited by stepper because maximum momLoss is reached";
130 break;
131 case stp_sMax:
132 std::cout << "stp_sMax (medium limit): stepsize limited by SMax defined in #estimateStep()";
133 break;
134 case stp_sMaxArg:
135 std::cout << "stp_sMaxArg (hard limit): stepsize limited by argument maxStepArg passed to #estimateStep()";
136 break;
137 case stp_boundary:
138 std::cout << "stp_boundary (hard limit): stepsize limited by stepper because material boundary is encountered";
139 break;
140 case stp_plane:
141 std::cout << "stp_plane (hard limit): stepsize limited because destination plane is reached";
142 break;
143 case ENUM_NR_ITEMS:
144 break;
145 }
146 std::cout << "\n";
147 }
148 std::cout << "\n";
149}
150
151} /* End of namespace genfit */
Helper to store different limits on the stepsize for the RKTRackRep.
Definition StepLimits.h:54
void reduceLimit(StepLimitType type, double value)
absolute of value will be taken! If limit is already lower, it will stay.
Definition StepLimits.cc:84
StepLimits & operator=(const StepLimits &other)
Definition StepLimits.cc:33
std::pair< StepLimitType, double > getLowestLimit(double margin=1.E-3) const
Get the lowest limit.
Definition StepLimits.cc:44
std::vector< double > limits_
Definition StepLimits.h:101
void setStepSign(char signedVal)
sets stepSign_ to sign of signedVal
Definition StepLimits.cc:93
signed char stepSign_
Definition StepLimits.h:102
double getLowestLimitVal(double margin=1.E-3) const
Get the unsigned numerical value of the lowest limit.
Definition StepLimits.cc:65
static const double maxLimit_
Definition StepLimits.h:103
Matrix inversion tools.
Definition AbsBField.h:29
StepLimitType
Definition StepLimits.h:33
@ stp_noLimit
Definition StepLimits.h:35
@ stp_fieldCurv
Definition StepLimits.h:38
@ stp_boundary
Definition StepLimits.h:44
@ stp_sMax
Definition StepLimits.h:40
@ ENUM_NR_ITEMS
Definition StepLimits.h:47
@ stp_sMaxArg
Definition StepLimits.h:43
@ stp_momLoss
Definition StepLimits.h:39
@ stp_plane
Definition StepLimits.h:45