AmpTools
Parameter.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 <string>
38 
40 
41 using namespace std;
42 
43 Parameter::Parameter( const string& name, double initialValue, double initialError ) :
44 m_name( name ),
45 m_value( initialValue ),
46 m_error( initialError )
47 {}
48 
50 
51 void
52 Parameter::setValue( double newValue ) {
53 
54  if( m_value != newValue ){
55 
56  // In practice the comparison above could probably "safely" be
57  // done within some tolerance, but set to exact comparison for now.
58  // This check avoids falsely notifying observers when the
59  // parameter hasn't actually changed.
60 
61  m_value = newValue;
62  notify();
63  }
64 }
65 
66 void
67 Parameter::setError( double newError, bool doNotify ) {
68  m_error = newError;
69  if ( doNotify ) notify();
70 }
71 
72 void
73 Parameter::setValueError( double newValue, double newError ) {
74  m_value = newValue;
75  m_error = newError;
76  notify();
77 }
78 
79 const string&
80 Parameter::name() const {
81  return m_name;
82 }
83 
void setValue(double newValue)
Definition: Parameter.cc:52
void setValueError(double newValue, double newError)
Definition: Parameter.cc:73
void notify()
Definition: MISubject.cc:60
virtual void setError(double newError, bool notify=false)
Definition: Parameter.cc:67
virtual ~Parameter()
Definition: Parameter.cc:49
const std::string & name() const
Definition: Parameter.cc:80
Parameter(const std::string &name, double initialValue=0, double initialError=0)
Definition: Parameter.cc:43