CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
PeriodicRectangular.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: PeriodicRectangular.cc,v 1.4 2003/10/10 17:40:39 garren Exp $
3#include "CLHEP/GenericFunctions/PeriodicRectangular.hh"
4#include "CLHEP/GenericFunctions/FixedConstant.hh"
5#include <assert.h>
6#include <cmath> // for floor()
7#include <iostream>
8
9namespace Genfun {
10FUNCTION_OBJECT_IMP(PeriodicRectangular)
11
13 _a("Size-of-valley (a)", 1.0, 1.0, 10),
14 _b("Size-of-plateau (b)", 1.0, 1.0, 10),
15 _height("height",1, 0,10)
16{}
17
19AbsFunction(right),
20_a(right._a),
21_b(right._b),
22_height(right._height)
23{
24}
25
27}
28
29double PeriodicRectangular::operator() (double x) const {
30 double xx = x/(_a.getValue()+_b.getValue());
31 xx = xx - floor(xx);
32 if (xx < _a.getValue()/(_a.getValue()+_b.getValue())) {
33 return 0;
34 }
35 else {
36 return _height.getValue();
37 }
38}
39
41 return _a;
42}
43
45 return _b;
46}
47
48
50 return _height;
51}
52
53// don't generate warnings about unused parameter inside assert
54#if defined __GNUC__
55 #if __GNUC__ > 3 && __GNUC_MINOR__ > 6
56 #pragma GCC diagnostic push
57 #pragma GCC diagnostic ignored "-Wunused-parameter"
58 #endif
59#endif
60#ifdef __clang__
61 #pragma clang diagnostic push
62 #pragma clang diagnostic ignored "-Wunused-parameter"
63#endif
64Derivative PeriodicRectangular::partial(unsigned int index) const {
65 assert(index==0);
66 const AbsFunction & fPrime = FixedConstant(0);
67 return Derivative(&fPrime);
68}
69#if defined __GNUC__
70 #if __GNUC__ > 3 && __GNUC_MINOR__ > 6
71 #pragma GCC diagnostic pop
72 #endif
73#endif
74#ifdef __clang__
75 #pragma clang diagnostic pop
76#endif
77
78} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual double getValue() const
Definition: Parameter.cc:29
virtual double operator()(double argument) const override
Derivative partial(unsigned int) const override
Definition: Abs.hh:14
FunctionNoop Derivative
Definition: AbsFunction.hh:42