AmpTools
MinuitParameter.cc
Go to the documentation of this file.
1 
2 // This file is a part of MinuitInterface - a front end for the Minuit minimization
3 // package (Minuit itself was authored by Fred James, of CERN)
4 //
5 //
6 // Copyright Cornell University 1993, 1996, All Rights Reserved.
7 //
8 // This software written by Lawrence Gibbons, Cornell University.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions
12 // are met:
13 // 1. Redistributions of source code must retain the above copyright
14 // notice and author attribution, this list of conditions and the
15 // following disclaimer.
16 // 2. Redistributions in binary form must reproduce the above copyright
17 // notice and author attribution, this list of conditions and the
18 // following disclaimer in the documentation and/or other materials
19 // provided with the distribution.
20 // 3. Neither the name of the University nor the names of its contributors
21 // may be used to endorse or promote products derived from this software
22 // without specific prior written permission.
23 //
24 // Creation of derivative forms of this software for commercial
25 // utilization may be subject to restriction; written permission may be
26 // obtained from Cornell University.
27 //
28 // CORNELL MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. By way
29 // of example, but not limitation, CORNELL MAKES NO REPRESENTATIONS OR
30 // WARRANTIES OF MERCANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
31 // THE USE OF THIS SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS,
32 // COPYRIGHTS, TRADEMARKS, OR OTHER RIGHTS. Cornell University shall not be
33 // held liable for any liability with respect to any claim by the user or any
34 // other party arising from use of the program.
35 //
36 
37 #include <ios>
38 #include <iomanip>
39 
42 
43 using namespace std;
44 
45 MinuitParameter::MinuitParameter( const string& name,
46  MinuitParameterManager& aManager,
47  double initialValue,
48  bool bounded,
49  double lowerBound,
50  double upperBound ) :
51  Parameter( name, initialValue, 0 ),
52  m_minuitId( kUnknownMinuitId ),
53  m_floating( true ),
54  m_lowerBound( lowerBound ),
55  m_upperBound( upperBound ),
56  m_bounded( bounded ),
57  m_validErrors( false ),
58  m_asymmetricErrors(),
59  m_parameterManager( aManager )
60 {
61  registerWithManager();
62 }
63 
65 {}
66 
67 void
69  m_parameterManager.registerParameter( this );
70 }
71 
73  m_parameterManager.removeParameter( this );
74 }
75 
76 void
78  m_floating = false;
79 }
80 
81 void
83  m_floating = true;
84 }
85 
86 void
87 MinuitParameter::bound( double lowerBound, double upperBound ) {
88  m_lowerBound = lowerBound;
89  m_upperBound = upperBound;
90  m_bounded = true;
91 }
92 
93 void
95  m_bounded = false;
96  m_lowerBound = 0;
97  m_upperBound = 0;
98 }
99 
100 unsigned int
102  return m_minuitId;
103 }
104 
105 bool
107  return m_floating;
108 }
109 
110 double
112  if ( !m_validErrors ) { m_parameterManager.updateErrors(); }
113  return Parameter::error();
114 }
115 
116 const AsymmetricError&
118  if ( !m_validErrors ) { m_parameterManager.updateErrors(); }
119  return m_asymmetricErrors;
120 }
121 
122 double
124  return m_globalCorrelationCoefficient;
125 }
126 
127 bool
129  return m_bounded;
130 }
131 
132 double
134  return m_lowerBound;
135 }
136 
137 double
139  return m_upperBound;
140 }
141 
142 void
144  m_validErrors = false;
145 }
146 
147 void
149  m_validErrors = true;
150 }
151 
152 void
153 MinuitParameter::setAsymmetricErrors( const pair<double,double>& newAsymmetricErrors ) {
154  m_asymmetricErrors = newAsymmetricErrors;
155 }
156 
157 void
158 MinuitParameter::setGlobalCorrelation( double globalCorrelationCoefficient ) {
159  m_globalCorrelationCoefficient = globalCorrelationCoefficient;
160 }
161 
162 void
163 MinuitParameter::setMinuitId( unsigned int anId ) {
164  m_minuitId = anId;
165 }
166 
167 ostream&
168 MinuitParameter::dump( ostream& aStream ) const {
169  const AsymmetricError asymmErr = asymmetricErrors();
170 
171  aStream << name();
172  aStream.setf(ios::floatfield);
173  aStream.precision(5);
174  aStream << " " << setw(9) << value();
175  aStream << " " << setw(9) << error();
176  aStream << " " << setw(9) << asymmErr.lower() << " " << setw(9) << asymmErr.upper();
177  if ( bounded() ) {
178  aStream << " bounds: " << setw(9) << lowerBound() << " " << setw(9) << upperBound();
179  }
180 
181  return aStream;
182 }
double lowerBound() const
double upper() const
void removeParameter(MinuitParameter *aParameter)
bool floating() const
MinuitParameter(const std::string &name, MinuitParameterManager &aManager, double initialValue=0, bool bounded=false, double lowerBound=0, double upperBound=0)
std::ostream & dump(std::ostream &aStream) const
bool bounded() const
void registerWithManager()
void setGlobalCorrelation(double globalCorrelationCoefficient)
void bound(double lowerBound, double upperBound)
void setAsymmetricErrors(const std::pair< double, double > &newAsymmetricErrors)
double error() const
void setMinuitId(unsigned int minuitId)
virtual double error() const
Definition: Parameter.h:59
double upperBound() const
double globalCorrelationCoefficient() const
double lower() const
unsigned int minuitId() const
const AsymmetricError & asymmetricErrors() const
virtual ~MinuitParameter()
bool registerParameter(MinuitParameter *newParameter)