CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Rectangular.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: Rectangular.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
3#include "CLHEP/GenericFunctions/Rectangular.hh"
4#include "CLHEP/GenericFunctions/FixedConstant.hh"
5#include <assert.h>
6#include <iostream>
7
8namespace Genfun {
9FUNCTION_OBJECT_IMP(Rectangular)
10
12 _x0("x0", -1.0, -10, 0),
13 _x1("x1", 1.0, 0, 10),
14 _baseline("baseline", 0,-10, 10),
15 _height("height",1, -10, 10)
16{}
17
19AbsFunction(right),
20_x0(right._x0),
21_x1(right._x1),
22_baseline(right._baseline),
23_height(right._height)
24{
25}
26
28}
29
30double Rectangular::operator() (double x) const {
31 if (x<_x0.getValue()) {
32 return _baseline.getValue();
33 }
34 else if (x<_x1.getValue()) {
35 return _height.getValue();
36 }
37 else {
38 return _baseline.getValue();
39 }
40}
41
43 return _x0;
44}
45
47 return _x1;
48}
49
51 return _baseline;
52}
53
55 return _height;
56}
57
58const Parameter & Rectangular::x0() const {
59 return _x0;
60}
61
62const Parameter & Rectangular::x1() const {
63 return _x1;
64}
65
67 return _baseline;
68}
69
71 return _height;
72}
73
74// don't generate warnings about unused parameter inside assert
75#if defined __GNUC__
76 #if __GNUC__ > 3 && __GNUC_MINOR__ > 6
77 #pragma GCC diagnostic push
78 #pragma GCC diagnostic ignored "-Wunused-parameter"
79 #endif
80#endif
81#ifdef __clang__
82 #pragma clang diagnostic push
83 #pragma clang diagnostic ignored "-Wunused-parameter"
84#endif
85Derivative Rectangular::partial(unsigned int index) const {
86 assert(index==0);
87 const AbsFunction & fPrime = FixedConstant(0);;
88 return Derivative(&fPrime);
89}
90#if defined __GNUC__
91 #if __GNUC__ > 3 && __GNUC_MINOR__ > 6
92 #pragma GCC diagnostic pop
93 #endif
94#endif
95#ifdef __clang__
96 #pragma clang diagnostic pop
97#endif
98
99} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual double getValue() const
Definition: Parameter.cc:29
const Parameter & height() const
Definition: Rectangular.cc:70
const Parameter & x1() const
Definition: Rectangular.cc:62
virtual double operator()(double argument) const override
Definition: Rectangular.cc:30
const Parameter & baseline() const
Definition: Rectangular.cc:66
virtual ~Rectangular()
Definition: Rectangular.cc:27
Derivative partial(unsigned int) const override
Definition: Rectangular.cc:85
const Parameter & x0() const
Definition: Rectangular.cc:58
Definition: Abs.hh:14
FunctionNoop Derivative
Definition: AbsFunction.hh:42