CLHEP VERSION Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: Exponential.cc,v 1.4 2003/10/10 17:40:39 garren Exp $ 00003 #include "CLHEP/GenericFunctions/Exponential.hh" 00004 #include <assert.h> 00005 #include <cmath> // for exp() 00006 00007 namespace Genfun { 00008 FUNCTION_OBJECT_IMP(Exponential) 00009 00010 Exponential::Exponential(): 00011 _decayConstant("Decay Constant", 1.0, 0,10) 00012 {} 00013 00014 Exponential::Exponential(const Exponential & right): 00015 AbsFunction(right), 00016 _decayConstant(right._decayConstant) 00017 { 00018 } 00019 00020 Exponential::~Exponential() { 00021 } 00022 00023 double Exponential::operator() (double x) const { 00024 if (x<0) return 0; 00025 return exp(-x/_decayConstant.getValue())/_decayConstant.getValue(); 00026 } 00027 00028 Parameter & Exponential::decayConstant() { 00029 return _decayConstant; 00030 } 00031 00032 const Parameter & Exponential::decayConstant() const { 00033 return _decayConstant; 00034 } 00035 00036 00037 Derivative Exponential::partial(unsigned int index) const { 00038 assert(index==0); 00039 const AbsFunction & fPrime = -_decayConstant*(*this); 00040 return Derivative(&fPrime); 00041 } 00042 00043 00044 } // namespace Genfun