CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: PeriodicRectangular.cc,v 1.4 2003/10/10 17:40:39 garren Exp $ 00003 #include "CLHEP/GenericFunctions/PeriodicRectangular.hh" 00004 #include "CLHEP/GenericFunctions/FixedConstant.hh" 00005 #include <assert.h> 00006 #include <cmath> // for floor() 00007 00008 namespace Genfun { 00009 FUNCTION_OBJECT_IMP(PeriodicRectangular) 00010 00011 PeriodicRectangular::PeriodicRectangular(): 00012 _a("Size-of-valley (a)", 1.0, 1.0, 10), 00013 _b("Size-of-plateau (b)", 1.0, 1.0, 10), 00014 _height("height",1, 0,10) 00015 {} 00016 00017 PeriodicRectangular::PeriodicRectangular(const PeriodicRectangular & right): 00018 _a(right._a), 00019 _b(right._b), 00020 _height(right._height) 00021 { 00022 } 00023 00024 PeriodicRectangular::~PeriodicRectangular() { 00025 } 00026 00027 double PeriodicRectangular::operator() (double x) const { 00028 double xx = x/(_a.getValue()+_b.getValue()); 00029 xx = xx - floor(xx); 00030 if (xx < _a.getValue()/(_a.getValue()+_b.getValue())) { 00031 return 0; 00032 } 00033 else { 00034 return _height.getValue(); 00035 } 00036 } 00037 00038 Parameter & PeriodicRectangular::a() { 00039 return _a; 00040 } 00041 00042 Parameter & PeriodicRectangular::b() { 00043 return _b; 00044 } 00045 00046 00047 Parameter & PeriodicRectangular::height() { 00048 return _height; 00049 } 00050 00051 00052 00053 Derivative PeriodicRectangular::partial(unsigned int index) const { 00054 assert(index==0); 00055 const AbsFunction & fPrime = FixedConstant(0); 00056 return Derivative(&fPrime); 00057 } 00058 00059 } // namespace Genfun