Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StepLimits.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file StepLimits.cc
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 #include "IO.h"
22 
23 #include <algorithm>
24 #include <assert.h>
25 #include <limits>
26 
27 
28 namespace genfit {
29 
30 const 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 
44 std::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 
65 double 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 
85  assert (type != stp_noLimit);
86  value = fabs(value);
87 
88  if (limits_[type] > value)
89  limits_[type] = value;
90 }
91 
92 
93 void StepLimits::setStepSign(char signedVal) {
94  if (signedVal < 0)
95  stepSign_ = -1;
96  else
97  stepSign_ = 1;
98 }
99 
100 void 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  printOut << " | " << limits_[i] << " cm due to ";
122  switch (static_cast<StepLimitType>(i)) {
123  case stp_noLimit:
124  break;
125  case stp_fieldCurv:
126  printOut << "stp_fieldCurv (medium limit): stepsize limited by curvature and magnetic field inhomogenities";
127  break;
128  case stp_momLoss:
129  printOut << "stp_momLoss (medium limit): stepsize limited by stepper because maximum momLoss is reached";
130  break;
131  case stp_sMax:
132  printOut << "stp_sMax (medium limit): stepsize limited by SMax defined in #estimateStep()";
133  break;
134  case stp_sMaxArg:
135  printOut << "stp_sMaxArg (hard limit): stepsize limited by argument maxStepArg passed to #estimateStep()";
136  break;
137  case stp_boundary:
138  printOut << "stp_boundary (hard limit): stepsize limited by stepper because material boundary is encountered";
139  break;
140  case stp_plane:
141  printOut << "stp_plane (hard limit): stepsize limited because destination plane is reached";
142  break;
143  case ENUM_NR_ITEMS:
144  break;
145  }
146  printOut << "\n";
147  }
148  printOut << "\n";
149 }
150 
151 } /* End of namespace genfit */