File indexing completed on 2024-04-06 11:58:08
0001 #include <cmath>
0002 #include <cassert>
0003 #include "FWCore/Utilities/interface/Exception.h"
0004
0005 #include "CalibCalorimetry/HcalAlgos/interface/ThirdOrderDelayODE.h"
0006
0007 void ThirdOrderDelayODE::calculate(const double tau,
0008 const double currentIn,
0009 double ,
0010 double ,
0011 const double* x,
0012 const unsigned lenX,
0013 const unsigned firstNode,
0014 double* derivative) const {
0015
0016 if (lenX < firstNode + 3U)
0017 throw cms::Exception("In ThirdOrderDelayODE::calculate: insufficient number of variables");
0018 if (tau <= 0.0)
0019 throw cms::Exception("In ThirdOrderDelayODE::calculate: delay time is not positive");
0020 assert(x);
0021 assert(derivative);
0022
0023 derivative[firstNode] = x[firstNode + 1];
0024 derivative[firstNode + 1] = x[firstNode + 2];
0025 derivative[firstNode + 2] =
0026 6.0 / a_ * (currentIn - x[firstNode] - c_ * tau * x[firstNode + 1] - b_ / 2.0 * tau * tau * x[firstNode + 2]) /
0027 tau / tau / tau;
0028 }
0029
0030 void ThirdOrderDelayODE::setParameters(const double* pars, const unsigned nPars) {
0031 assert(nPars == 3U);
0032 assert(pars);
0033 a_ = exp(pars[0]);
0034 b_ = exp(pars[1]);
0035 c_ = exp(pars[2]);
0036 }