CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

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 $
5 #include <assert.h>
6 #include <cmath> // for floor()
7 
8 namespace Genfun {
9 FUNCTION_OBJECT_IMP(PeriodicRectangular)
10 
12  _a("Size-of-valley (a)", 1.0, 1.0, 10),
13  _b("Size-of-plateau (b)", 1.0, 1.0, 10),
14  _height("height",1, 0,10)
15 {}
16 
18 _a(right._a),
19 _b(right._b),
20 _height(right._height)
21 {
22 }
23 
25 }
26 
27 double PeriodicRectangular::operator() (double x) const {
28  double xx = x/(_a.getValue()+_b.getValue());
29  xx = xx - floor(xx);
30  if (xx < _a.getValue()/(_a.getValue()+_b.getValue())) {
31  return 0;
32  }
33  else {
34  return _height.getValue();
35  }
36 }
37 
39  return _a;
40 }
41 
43  return _b;
44 }
45 
46 
48  return _height;
49 }
50 
51 
52 
53 Derivative PeriodicRectangular::partial(unsigned int index) const {
54  assert(index==0);
55  const AbsFunction & fPrime = FixedConstant(0);
56  return Derivative(&fPrime);
57 }
58 
59 } // namespace Genfun