CMS 3D CMS Logo

QIE8Simulator.h
Go to the documentation of this file.
1 #ifndef CalibCalorimetry_HcalAlgos_QIE8Simulator_h_
2 #define CalibCalorimetry_HcalAlgos_QIE8Simulator_h_
3 
6 
7 //
8 // This class is needed mostly in order to represent the charge
9 // to ADC conversion inside the QIE8 chip
10 //
12 public:
13  static const unsigned maxlen = HcalInterpolatedPulse::maxlen;
14 
15  // In case the default constructor is used, "setRHS" method must be
16  // called before running the simulation
17  QIE8Simulator();
18 
19  // Constructor which includes a proper model
21  unsigned chargeNode,
22  bool interpolateCubic = false,
23  double preampOutputCut = -1.0e100,
24  double inputGain = 1.0,
25  double outputGain = 1.0);
26 
27  void setRHS(const AbsElectronicODERHS& rhs, unsigned chargeNode, bool interpolateCubic = false);
28 
29  inline const AbsElectronicODERHS& getRHS() const {
30  const AbsODERHS* ptr = solver_.getRHS();
31  if (!ptr)
32  throw cms::Exception("In QIE8Simulator::getRHS: RHS is not set");
33  return *(static_cast<const AbsElectronicODERHS*>(ptr));
34  }
35 
36  // Simple inspectors
37  inline double getInputGain() const { return inputGain_; }
38  inline double getOutputGain() const { return outputGain_; }
39  inline unsigned long getRunCount() const { return runCount_; }
40  inline double getPreampOutputCut() const { return preampOutputCut_; }
41 
42  // Examine preamp model parameters
43  inline unsigned nParameters() const { return getRHS().nParameters(); }
44  inline double getParameter(const unsigned which) const { return getRHS().getParameter(which); }
45 
46  // Set gains
47  inline void setInputGain(const double g) {
48  inputGain_ = g;
49  validateGain();
50  }
51  inline void setOutputGain(const double g) {
52  outputGain_ = g;
53  validateGain();
54  }
55 
56  // Set preamp initial conditions
57  void setInitialConditions(const double* values, const unsigned len);
58  void zeroInitialConditions();
59 
60  // Set preamp model parameters
61  inline void setParameter(const unsigned which, const double p) { modifiableRHS().setParameter(which, p); }
62  inline void setLeadingParameters(const double* values, const unsigned len) {
64  }
65 
66  // Set the minimum value for the preamp output
67  inline void setPreampOutputCut(const double p) { preampOutputCut_ = p; }
68 
69  // Set the input pulse
70  template <class Signal>
71  inline void setInputSignal(const Signal& inputSignal) {
72  modifiableRHS().setInputPulse(inputSignal);
74  }
75 
76  // Get the input pulse
77  inline const HcalInterpolatedPulse& getInputSignal() const { return getRHS().inputPulse(); }
78 
79  // Set the input pulse data. This will not modify
80  // signal begin and end times.
81  template <class Real>
82  inline void setInputShape(const Real* values, const unsigned len) {
85  }
86 
87  // Scale the input pulse by some constant factor
88  inline void scaleInputSignal(const double s) { modifiableRHS().inputPulse() *= s; }
89 
90  // Manipulate input pulse amplidude
91  inline double getInputAmplitude() const { return getRHS().inputPulse().getPeakValue() / inputGain_; }
92 
93  inline void setInputAmplitude(const double a) { modifiableRHS().inputPulse().setPeakValue(a * inputGain_); }
94 
95  // Manipulate input pulse total charge
96  inline double getInputIntegral() const { return getRHS().inputPulse().getIntegral() / inputGain_; }
97 
98  inline void setInputIntegral(const double d) { modifiableRHS().inputPulse().setIntegral(d * inputGain_); }
99 
100  // Manipulate input pulse timing
101  inline double getInputStartTime() const { return getRHS().inputPulse().getStartTime(); }
102 
103  inline void setInputStartTime(const double newStartTime) { modifiableRHS().inputPulse().setStartTime(newStartTime); }
104 
105  // Run the simulation. Parameters are as follows:
106  //
107  // dt -- Simulation time step.
108  //
109  // tstop -- At what time to stop the simulation. The actual
110  // stopping time will be the smaller of this parameter and
111  // dt*(maxlen - 1). The simulation always starts at t = 0.
112  //
113  // tDigitize -- When to start producing ADC counts. This argument
114  // must be non-negative.
115  //
116  // TS, lenTS -- Array (and its length) where ADC counts will be
117  // placed on exit.
118  //
119  // This method returns the number of "good" ADC time slices -- the
120  // ones that completely covered by the simulation interval.
121  //
122  unsigned run(double dt, double tstop, double tDigitize, double* TS, unsigned lenTS);
123 
124  // Inspect simulation results
125  double lastStopTime() const;
126  double totalIntegratedCharge(double t) const;
127  double preampPeakTime() const;
128 
129  // The following methods with simply return 0.0 in case
130  // there are no corresponding nodes in the circuit
131  double preampOutput(double t) const;
132  double controlOutput(double t) const;
133 
134  // Time slice width in nanoseconds
135  static inline double adcTSWidth() { return 25.0; }
136 
137 private:
139  AbsODERHS* ptr = solver_.getRHS();
140  if (!ptr)
141  throw cms::Exception("In QIE8Simulator::modifiableRHS: no RHS");
142  return *(static_cast<AbsElectronicODERHS*>(ptr));
143  }
144 
145  inline double getCharge(const double t) const {
146  double q;
149  else
151  return q;
152  }
153 
154  void validateGain() const;
155 
157  std::vector<double> initialConditions_;
158  std::vector<double> historyBuffer_;
160  double inputGain_;
161  double outputGain_;
162  unsigned long runCount_;
163  unsigned chargeNode_;
165  bool useCubic_;
166 };
167 
168 #endif // CalibCalorimetry_HcalAlgos_QIE8Simulator_h_
const AbsElectronicODERHS & getRHS() const
Definition: QIE8Simulator.h:29
double getInputGain() const
Definition: QIE8Simulator.h:37
float dt
Definition: AMPTWrapper.h:136
double getParameter(const unsigned which) const
std::vector< double > initialConditions_
unsigned chargeNode_
double getInputStartTime() const
double preampOutputCut_
void setStartTime(const double newStartTime)
const AbsODERHS * getRHS() const
bool integrateToGetCharge_
void setInputSignal(const Signal &inputSignal)
Definition: QIE8Simulator.h:71
double interpolateCoordinate(unsigned which, double t, bool cubic=false) const
void setInputAmplitude(const double a)
Definition: QIE8Simulator.h:93
double totalIntegratedCharge(double t) const
unsigned nParameters() const
Definition: QIE8Simulator.h:43
unsigned long runCount_
double getStartTime() const
double getInputAmplitude() const
Definition: QIE8Simulator.h:91
static double adcTSWidth()
void setShape(const Real *values, const unsigned len)
double getIntegral() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
std::vector< double > historyBuffer_
void setInitialConditions(const double *values, const unsigned len)
void scaleInputSignal(const double s)
Definition: QIE8Simulator.h:88
const HcalInterpolatedPulse & inputPulse() const
void setInputIntegral(const double d)
Definition: QIE8Simulator.h:98
void setLeadingParameters(const double *values, const unsigned len)
double interpolateIntegrated(unsigned which, double t, bool cubic=false) const
void setPreampOutputCut(const double p)
Definition: QIE8Simulator.h:67
void setParameter(const unsigned which, const double value)
double getPreampOutputCut() const
Definition: QIE8Simulator.h:40
void setRHS(const AbsElectronicODERHS &rhs, unsigned chargeNode, bool interpolateCubic=false)
d
Definition: ztail.py:151
AbsElectronicODERHS & modifiableRHS()
double Real
double controlOutput(double t) const
double preampOutput(double t) const
void setInputPulse(const Pulse &pulse)
void setParameter(const unsigned which, const double p)
Definition: QIE8Simulator.h:61
double getInputIntegral() const
Definition: QIE8Simulator.h:96
double lastStopTime() const
double getPeakValue() const
void setInputShape(const Real *values, const unsigned len)
Definition: QIE8Simulator.h:82
double preampPeakTime() const
double outputGain_
void setInputStartTime(const double newStartTime)
double getCharge(const double t) const
void validateGain() const
const HcalInterpolatedPulse & getInputSignal() const
Definition: QIE8Simulator.h:77
void setPeakValue(const double newValue)
double a
Definition: hdecay.h:121
unsigned run(double dt, double tstop, double tDigitize, double *TS, unsigned lenTS)
virtual unsigned nParameters() const =0
def which(cmd)
Definition: eostools.py:336
void setInputGain(const double g)
Definition: QIE8Simulator.h:47
unsigned long getRunCount() const
Definition: QIE8Simulator.h:39
void zeroInitialConditions()
double getParameter(const unsigned which) const
Definition: QIE8Simulator.h:44
double getOutputGain() const
Definition: QIE8Simulator.h:38
void setIntegral(const double newValue)
void setLeadingParameters(const double *values, const unsigned len)
Definition: QIE8Simulator.h:62
static const unsigned maxlen
Definition: QIE8Simulator.h:13
void setOutputGain(const double g)
Definition: QIE8Simulator.h:51