CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 > Class Template Reference

#include <DoublePadeDelay.h>

Inheritance diagram for DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >:
AbsElectronicODERHS AbsODERHS

Public Member Functions

virtual void calc (const double t, const double *x, const unsigned lenX, double *derivative)
 
virtual DoublePadeDelayclone () const
 
unsigned controlNode () const
 
 DoublePadeDelay (const unsigned padeRow1, const unsigned padeColumn1, const unsigned padeRow2, const unsigned padeColumn2)
 
 DoublePadeDelay (const unsigned padeRow1, const unsigned padeColumn1, const unsigned padeRow2, const unsigned padeColumn2, const HcalInterpolatedPulse &pulse)
 
unsigned nParameters () const
 
unsigned numberOfNodes () const
 
unsigned outputNode () const
 
- Public Member Functions inherited from AbsElectronicODERHS
 AbsElectronicODERHS ()
 
 AbsElectronicODERHS (const HcalInterpolatedPulse &pulse)
 
bool allParametersSet () const
 
const std::vector< double > & getAllParameters () const
 
double getParameter (const unsigned which) const
 
const HcalInterpolatedPulseinputPulse () const
 
HcalInterpolatedPulseinputPulse ()
 
template<class Pulse >
void setInputPulse (const Pulse &pulse)
 
void setLeadingParameters (const double *values, const unsigned len)
 
void setLeadingParameters (const std::vector< double > &values)
 
void setParameter (const unsigned which, const double value)
 
virtual ~AbsElectronicODERHS ()
 
- Public Member Functions inherited from AbsODERHS
virtual ~AbsODERHS ()
 

Private Member Functions

void validate () const
 

Private Attributes

ODE1 ode1_
 
ODE2 ode2_
 
DelayTimeModel1 tau1_
 
DelayTimeModel2 tau2_
 

Static Private Attributes

static const unsigned thisCodeNumPars = 3U
 

Additional Inherited Members

- Static Public Attributes inherited from AbsElectronicODERHS
static const unsigned invalidNode = UINT_MAX - 1U
 
- Protected Attributes inherited from AbsElectronicODERHS
HcalInterpolatedPulse inputPulse_
 
std::vector< double > params_
 

Detailed Description

template<class ODE1, class ODE2, class DelayTimeModel1, class DelayTimeModel2>
class DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >

Definition at line 17 of file DoublePadeDelay.h.

Constructor & Destructor Documentation

template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::DoublePadeDelay ( const unsigned  padeRow1,
const unsigned  padeColumn1,
const unsigned  padeRow2,
const unsigned  padeColumn2 
)
inline

Definition at line 20 of file DoublePadeDelay.h.

References DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::validate().

Referenced by DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::clone().

22  : ode1_(padeRow1, padeColumn1), ode2_(padeRow2, padeColumn2)
23  {
24  validate();
25  }
void validate() const
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::DoublePadeDelay ( const unsigned  padeRow1,
const unsigned  padeColumn1,
const unsigned  padeRow2,
const unsigned  padeColumn2,
const HcalInterpolatedPulse pulse 
)
inline

Definition at line 27 of file DoublePadeDelay.h.

References DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::validate().

30  : AbsElectronicODERHS(pulse),
31  ode1_(padeRow1, padeColumn1),
32  ode2_(padeRow2, padeColumn2)
33  {
34  validate();
35  }
void validate() const

Member Function Documentation

template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
virtual void DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::calc ( const double  t,
const double *  x,
const unsigned  lenX,
double *  derivative 
)
inlinevirtual

Implements AbsODERHS.

Definition at line 40 of file DoublePadeDelay.h.

References AbsElectronicODERHS::allParametersSet(), DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::controlNode(), InterpolatedPulse< MaxLen >::derivative(), Exception, AbsElectronicODERHS::inputPulse_, AbsElectronicODERHS::invalidNode, hpstanc_transforms::max, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode1_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode2_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::outputNode(), AbsElectronicODERHS::params_, InterpolatedPulse< MaxLen >::secondDerivative(), metsig::tau, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::tau1_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::tau2_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::thisCodeNumPars, and mitigatedMETSequence_cff::U.

43  {
44  if (!allParametersSet()) throw cms::Exception(
45  "In DoublePadeDelay::calc: timing and/or ODE parameters not set");
46 
47  // The input signal
48  const double currentIn = inputPulse_(t);
49 
50  // The output signal
51  const double currentOut = x[outputNode()];
52 
53  // Numbers of parameters used by the member objects
54  const unsigned npTau1 = tau1_.nParameters();
55  const unsigned npOde1 = ode1_.nParameters();
56  const unsigned npTau2 = tau2_.nParameters();
57  const unsigned npOde2 = ode2_.nParameters();
58 
59  // Parameters for this code.
60  // Order of parameters in the overall parameter set is:
61  // parameters for tau1, then for ode1, then tau2, then ode2,
62  // then parameters of this code.
63  const double* pstart = &params_[npTau1 + npOde1 + npTau2 + npOde2];
64  const double* pars = pstart;
65  const double ctlGainOut = *pars++;
66  const double inGainOut = *pars++;
67  const double outGainOut = *pars++;
68  assert(thisCodeNumPars == static_cast<unsigned>(pars - pstart));
69 
70  // Save a little bit of time by not calculating the input
71  // signal derivatives in case they will not be needed
72  const unsigned row = std::max(ode1_.getPadeRow(), ode2_.getPadeRow());
73  const double dIdt = row ? inputPulse_.derivative(t) : 0.0;
74  const double d2Id2t = row > 1U ? inputPulse_.secondDerivative(t) : 0.0;
75 
76  // Set the timing parameters of the control circuit
77  unsigned firstPar = npTau1 + npOde1;
78  const double tau2 = tau2_(currentIn, &params_[firstPar], npTau2);
79 
80  // Set the ODE parameters for the control circuit
81  firstPar += npTau2;
82  if (npOde2)
83  ode2_.setParameters(&params_[firstPar], npOde2);
84 
85  // Run the control circuit
86  const unsigned ctrlNode = controlNode();
87  double control;
88  if (ctrlNode < AbsElectronicODERHS::invalidNode)
89  {
90  // The control circuit solves an ODE
91  control = x[ctrlNode];
92  ode2_.calculate(tau2, currentIn, dIdt, d2Id2t,
93  x, lenX, ctrlNode, derivative);
94  }
95  else
96  {
97  // The control circuit does not solve an ODE.
98  // Instead, it drives its output directly.
99  ode2_.calculate(tau2, currentIn, dIdt, d2Id2t,
100  0, 0U, 0U, &control);
101  }
102 
103  // Timing parameter for the output circuit (the preamp)
104  const double vtau = ctlGainOut*control +
105  inGainOut*currentIn +
106  outGainOut*currentOut;
107  const double tau = tau1_(vtau, &params_[0], npTau1);
108 
109  // ODE parameters for the output circuit
110  if (npOde1)
111  ode1_.setParameters(&params_[npTau1], npOde1);
112 
113  // Run the output circuit
114  ode1_.calculate(tau, currentIn, dIdt, d2Id2t, x, lenX, 0U, derivative);
115  }
DelayTimeModel2 tau2_
static const unsigned invalidNode
Derivative< X, A >::type derivative(const A &_)
Definition: Derivative.h:18
std::vector< double > params_
double secondDerivative(const double t) const
unsigned controlNode() const
DelayTimeModel1 tau1_
unsigned outputNode() const
static const unsigned thisCodeNumPars
HcalInterpolatedPulse inputPulse_
bool allParametersSet() const
double derivative(const double t) const
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
virtual DoublePadeDelay* DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::clone ( void  ) const
inlinevirtual

Implements AbsODERHS.

Definition at line 37 of file DoublePadeDelay.h.

References DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::DoublePadeDelay().

38  {return new DoublePadeDelay(*this);}
DoublePadeDelay(const unsigned padeRow1, const unsigned padeColumn1, const unsigned padeRow2, const unsigned padeColumn2)
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
unsigned DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::controlNode ( ) const
inlinevirtual

Reimplemented from AbsElectronicODERHS.

Definition at line 133 of file DoublePadeDelay.h.

References AbsElectronicODERHS::invalidNode, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode1_, and DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode2_.

Referenced by DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::calc().

134  {
135  if (ode2_.getPadeColumn())
136  // ode2 has a real output node
137  return ode1_.getPadeColumn();
138  else
139  // ode2 does not have a real output node
141  }
static const unsigned invalidNode
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
unsigned DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::nParameters ( ) const
inlinevirtual

Implements AbsElectronicODERHS.

Definition at line 120 of file DoublePadeDelay.h.

References DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode1_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode2_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::tau1_, DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::tau2_, and DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::thisCodeNumPars.

121  {
122  const unsigned npTau1 = tau1_.nParameters();
123  const unsigned npOde1 = ode1_.nParameters();
124  const unsigned npTau2 = tau2_.nParameters();
125  const unsigned npOde2 = ode2_.nParameters();
126  return npTau1 + npOde1 + npTau2 + npOde2 + thisCodeNumPars;
127  }
DelayTimeModel2 tau2_
DelayTimeModel1 tau1_
static const unsigned thisCodeNumPars
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
unsigned DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::numberOfNodes ( ) const
inlinevirtual
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
unsigned DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::outputNode ( ) const
inlinevirtual
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
void DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::validate ( ) const
inlineprivate

Definition at line 146 of file DoublePadeDelay.h.

References DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode1_.

Referenced by DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::DoublePadeDelay().

147  {
148  // Basically, we need to avoid the situation in which
149  // we need to solve the differential equation for the control
150  // circuit but do not need to solve the differential equation
151  // for the preamp. It this case we will not have a good way
152  // to pass the preamp output to the simulator. The simplest
153  // way to ensure correctness of the whole procedure is to require
154  // that the preamp must always be modeled by an ODE. Indeed,
155  // one will almost surely need to represent it by at least
156  // a low-pass filter.
157  if (!ode1_.getPadeColumn()) throw cms::Exception(
158  "In DoublePadeDelay::validate: the output "
159  "circuit must be modeled by an ODE");
160  }

Member Data Documentation

template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
ODE1 DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode1_
private
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
ODE2 DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::ode2_
private
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
DelayTimeModel1 DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::tau1_
private
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
DelayTimeModel2 DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::tau2_
private
template<class ODE1 , class ODE2 , class DelayTimeModel1 , class DelayTimeModel2 >
const unsigned DoublePadeDelay< ODE1, ODE2, DelayTimeModel1, DelayTimeModel2 >::thisCodeNumPars = 3U
staticprivate