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_
QIE8Simulator::preampOutputCut_
double preampOutputCut_
Definition: QIE8Simulator.h:159
InterpolatedPulse::setShape
void setShape(const Real *values, const unsigned len)
Definition: InterpolatedPulse.h:96
InterpolatedPulse::getIntegral
double getIntegral() const
Definition: InterpolatedPulse.h:242
QIE8Simulator::getPreampOutputCut
double getPreampOutputCut() const
Definition: QIE8Simulator.h:40
QIE8Simulator::setInputShape
void setInputShape(const Real *values, const unsigned len)
Definition: QIE8Simulator.h:82
QIE8Simulator::setInputIntegral
void setInputIntegral(const double d)
Definition: QIE8Simulator.h:98
QIE8Simulator::getCharge
double getCharge(const double t) const
Definition: QIE8Simulator.h:145
InterpolatedPulse::getStartTime
double getStartTime() const
Definition: InterpolatedPulse.h:115
QIE8Simulator::initialConditions_
std::vector< double > initialConditions_
Definition: QIE8Simulator.h:157
QIE8Simulator::inputGain_
double inputGain_
Definition: QIE8Simulator.h:160
QIE8Simulator::QIE8Simulator
QIE8Simulator()
Definition: QIE8Simulator.cc:6
InterpolatedPulse< 1500U >::maxlen
Definition: InterpolatedPulse.h:17
QIE8Simulator::getRunCount
unsigned long getRunCount() const
Definition: QIE8Simulator.h:39
AbsElectronicODERHS::setParameter
void setParameter(const unsigned which, const double value)
Definition: AbsElectronicODERHS.h:70
QIE8Simulator
Definition: QIE8Simulator.h:11
Signal
ConstantStepOdeSolver.h
QIE8Simulator::maxlen
static const unsigned maxlen
Definition: QIE8Simulator.h:13
QIE8Simulator::getParameter
double getParameter(const unsigned which) const
Definition: QIE8Simulator.h:44
QIE8Simulator::zeroInitialConditions
void zeroInitialConditions()
Definition: QIE8Simulator.cc:166
QIE8Simulator::setLeadingParameters
void setLeadingParameters(const double *values, const unsigned len)
Definition: QIE8Simulator.h:62
QIE8Simulator::scaleInputSignal
void scaleInputSignal(const double s)
Definition: QIE8Simulator.h:88
QIE8Simulator::getOutputGain
double getOutputGain() const
Definition: QIE8Simulator.h:38
ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.model
model
Definition: ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi.py:11
ConstantStepOdeSolver::interpolateCoordinate
double interpolateCoordinate(unsigned which, double t, bool cubic=false) const
Definition: ConstantStepOdeSolver.cc:159
QIE8Simulator::controlOutput
double controlOutput(double t) const
Definition: QIE8Simulator.cc:121
dt
float dt
Definition: AMPTWrapper.h:136
AbsElectronicODERHS
Definition: AbsElectronicODERHS.h:16
QIE8Simulator::getInputSignal
const HcalInterpolatedPulse & getInputSignal() const
Definition: QIE8Simulator.h:77
alignCSCRings.s
s
Definition: alignCSCRings.py:92
QIE8Simulator::setInputGain
void setInputGain(const double g)
Definition: QIE8Simulator.h:47
AbsElectronicODERHS::setInputPulse
void setInputPulse(const Pulse &pulse)
Definition: AbsElectronicODERHS.h:31
InterpolatedPulse::setStartTime
void setStartTime(const double newStartTime)
Definition: InterpolatedPulse.h:121
QIE8Simulator::lastStopTime
double lastStopTime() const
Definition: QIE8Simulator.cc:182
QIE8Simulator::historyBuffer_
std::vector< double > historyBuffer_
Definition: QIE8Simulator.h:158
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
QIE8Simulator::setParameter
void setParameter(const unsigned which, const double p)
Definition: QIE8Simulator.h:61
QIE8Simulator::getInputIntegral
double getInputIntegral() const
Definition: QIE8Simulator.h:96
QIE8Simulator::outputGain_
double outputGain_
Definition: QIE8Simulator.h:161
fftjetcms::Real
double Real
Definition: fftjetTypedefs.h:21
QIE8Simulator::validateGain
void validateGain() const
Definition: QIE8Simulator.cc:177
AbsODERHS
Definition: AbsODERHS.h:7
AbsElectronicODERHS::nParameters
virtual unsigned nParameters() const =0
AbsElectronicODERHS.h
QIE8Simulator::solver_
RK4 solver_
Definition: QIE8Simulator.h:156
QIE8Simulator::getInputGain
double getInputGain() const
Definition: QIE8Simulator.h:37
QIE8Simulator::runCount_
unsigned long runCount_
Definition: QIE8Simulator.h:162
QIE8Simulator::adcTSWidth
static double adcTSWidth()
Definition: QIE8Simulator.h:135
a
double a
Definition: hdecay.h:119
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
QIE8Simulator::setPreampOutputCut
void setPreampOutputCut(const double p)
Definition: QIE8Simulator.h:67
QIE8Simulator::run
unsigned run(double dt, double tstop, double tDigitize, double *TS, unsigned lenTS)
Definition: QIE8Simulator.cc:35
QIE8Simulator::preampOutput
double preampOutput(double t) const
Definition: QIE8Simulator.cc:111
ConstantStepOdeSolver::getRHS
const AbsODERHS * getRHS() const
Definition: ConstantStepOdeSolver.h:34
QIE8Simulator::getInputAmplitude
double getInputAmplitude() const
Definition: QIE8Simulator.h:91
submitPVResolutionJobs.q
q
Definition: submitPVResolutionJobs.py:84
QIE8Simulator::chargeNode_
unsigned chargeNode_
Definition: QIE8Simulator.h:163
QIE8Simulator::getRHS
const AbsElectronicODERHS & getRHS() const
Definition: QIE8Simulator.h:29
InterpolatedPulse::setIntegral
void setIntegral(const double newValue)
Definition: InterpolatedPulse.h:252
QIE8Simulator::setInputAmplitude
void setInputAmplitude(const double a)
Definition: QIE8Simulator.h:93
QIE8Simulator::setInputSignal
void setInputSignal(const Signal &inputSignal)
Definition: QIE8Simulator.h:71
QIE8Simulator::totalIntegratedCharge
double totalIntegratedCharge(double t) const
Definition: QIE8Simulator.cc:188
QIE8Simulator::setRHS
void setRHS(const AbsElectronicODERHS &rhs, unsigned chargeNode, bool interpolateCubic=false)
Definition: QIE8Simulator.cc:154
InterpolatedPulse< 1500U >
Exception
Definition: hltDiff.cc:245
QIE8Simulator::getInputStartTime
double getInputStartTime() const
Definition: QIE8Simulator.h:101
QIE8Simulator::preampPeakTime
double preampPeakTime() const
Definition: QIE8Simulator.cc:131
QIE8Simulator::integrateToGetCharge_
bool integrateToGetCharge_
Definition: QIE8Simulator.h:164
ConstantStepOdeSolver::interpolateIntegrated
double interpolateIntegrated(unsigned which, double t, bool cubic=false) const
Definition: ConstantStepOdeSolver.cc:198
QIE8Simulator::setInputStartTime
void setInputStartTime(const double newStartTime)
Definition: QIE8Simulator.h:103
ztail.d
d
Definition: ztail.py:151
QIE8Simulator::setInitialConditions
void setInitialConditions(const double *values, const unsigned len)
Definition: QIE8Simulator.cc:140
InterpolatedPulse::getPeakValue
double getPeakValue() const
Definition: InterpolatedPulse.h:259
AbsElectronicODERHS::inputPulse
const HcalInterpolatedPulse & inputPulse() const
Definition: AbsElectronicODERHS.h:26
QIE8Simulator::setOutputGain
void setOutputGain(const double g)
Definition: QIE8Simulator.h:51
RK4
Definition: ConstantStepOdeSolver.h:141
QIE8Simulator::modifiableRHS
AbsElectronicODERHS & modifiableRHS()
Definition: QIE8Simulator.h:138
QIE8Simulator::nParameters
unsigned nParameters() const
Definition: QIE8Simulator.h:43
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
AbsElectronicODERHS::getParameter
double getParameter(const unsigned which) const
Definition: AbsElectronicODERHS.h:77
eostools.which
def which(cmd)
Definition: eostools.py:336
InterpolatedPulse::setPeakValue
void setPeakValue(const double newValue)
Definition: InterpolatedPulse.h:268
AbsElectronicODERHS::setLeadingParameters
void setLeadingParameters(const double *values, const unsigned len)
Definition: AbsElectronicODERHS.h:93
g
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
QIE8Simulator::useCubic_
bool useCubic_
Definition: QIE8Simulator.h:165