CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Parameter.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: Parameter.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
3#include "CLHEP/GenericFunctions/Parameter.hh"
4
5#include <iostream>
6
7namespace Genfun {
9
10Parameter::Parameter(std::string name, double value, double lowerLimit, double upperLimit):
11 _name(name),_value(value),_lowerLimit(lowerLimit),_upperLimit(upperLimit),_sourceParameter(NULL)
12{
13}
14
16}
17
18std::ostream & operator << ( std::ostream & o, const Parameter & p) {
19 return o << p.getName() << "\t" << " value = "
20 << p.getValue() << "\t" <<" limits: ["
21 << p.getLowerLimit() << ","
22 << p.getUpperLimit() << "]" << std::endl;
23}
24
25const std::string & Parameter::getName() const {
26 return _name;
27}
28
29double Parameter::getValue() const
30{
31 if (_sourceParameter) {
32 return _sourceParameter->getValue();
33 }
34 else {
35 return _value;
36 }
37}
38
40{
41 if (_sourceParameter) {
42 return -1E-100;
43 }
44 else {
45 return _lowerLimit;
46 }
47}
48
50{
51 if (_sourceParameter) {
52 return 1E100;
53 }
54 else {
55 return _upperLimit;
56 }
57}
58
59void Parameter::setValue(double value)
60{
61 if (_sourceParameter) {
62 std::cerr
63 << "Warning: Parameter is connected. Function has no effect."
64 << std::endl;
65 }
66 else {
67 _value=value;
68 }
69}
70
71void Parameter::setLowerLimit(double lowerLimit)
72{
73 if (_sourceParameter) {
74 std::cerr
75 << "Warning: Parameter is connected. Function has no effect."
76 << std::endl;
77 }
78 else {
79 _lowerLimit=lowerLimit;
80 }
81}
82
83void Parameter::setUpperLimit(double upperLimit)
84{
85 if (_sourceParameter) {
86 std::cerr
87 << "Warning: Parameter is connected. Function has no effect."
88 << std::endl;
89 }
90 else {
91 _upperLimit=upperLimit;
92 }
93}
94
96{
97 const Parameter *sp = source->parameter();
98 if (sp && sp->_sourceParameter) {
99 connectFrom(sp->_sourceParameter);
100 }
101 else {
102 _sourceParameter = source;
103 }
104}
105
106
108 AbsParameter(right),
109 _name(right._name),
110 _value(right._value),
111 _lowerLimit(right._lowerLimit),
112 _upperLimit(right._upperLimit),
113 _sourceParameter(right._sourceParameter)
114{
115}
116
118 if (this != &right) {
119 _name=right._name;
120 _value=right._value;
121 _lowerLimit=right._lowerLimit;
122 _upperLimit=right._upperLimit;
123 _sourceParameter=right._sourceParameter;
124 }
125 return *this;
126}
127
128} // namespace Genfun
#define PARAMETER_OBJECT_IMP(classname)
Definition: AbsParameter.hh:86
virtual double getValue() const =0
virtual Parameter * parameter()
Definition: AbsParameter.hh:42
const Parameter & operator=(const Parameter &right)
Definition: Parameter.cc:117
const std::string & getName() const
Definition: Parameter.cc:25
void setLowerLimit(double lowerLimit)
Definition: Parameter.cc:71
virtual double getValue() const
Definition: Parameter.cc:29
void connectFrom(const AbsParameter *source)
Definition: Parameter.cc:95
double getLowerLimit() const
Definition: Parameter.cc:39
void setUpperLimit(double upperLimit)
Definition: Parameter.cc:83
double getUpperLimit() const
Definition: Parameter.cc:49
virtual ~Parameter()
Definition: Parameter.cc:15
Parameter(std::string name, double value, double lowerLimit=-1e100, double upperLimit=1e100)
Definition: Parameter.cc:10
void setValue(double value)
Definition: Parameter.cc:59
Definition: Abs.hh:14
std::ostream & operator<<(std::ostream &os, const Argument &a)
Definition: Argument.hh:81