CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
13 public:
14  static const unsigned maxlen = HcalInterpolatedPulse::maxlen;
15 
16  // In case the default constructor is used, "setRHS" method must be
17  // called before running the simulation
18  QIE8Simulator();
19 
20  // Constructor which includes a proper model
22  unsigned chargeNode,
23  bool interpolateCubic = false,
24  double preampOutputCut = -1.0e100,
25  double inputGain = 1.0,
26  double outputGain = 1.0);
27 
28  void setRHS(const AbsElectronicODERHS& rhs, unsigned chargeNode,
29  bool interpolateCubic=false);
30 
31  inline const AbsElectronicODERHS& getRHS() const
32  {
33  const AbsODERHS* ptr = solver_.getRHS();
34  if (!ptr) throw cms::Exception(
35  "In QIE8Simulator::getRHS: RHS is not set");
36  return *(static_cast<const AbsElectronicODERHS*>(ptr));
37  }
38 
39  // Simple inspectors
40  inline double getInputGain() const {return inputGain_;}
41  inline double getOutputGain() const {return outputGain_;}
42  inline unsigned long getRunCount() const {return runCount_;}
43  inline double getPreampOutputCut() const {return preampOutputCut_;}
44 
45  // Examine preamp model parameters
46  inline unsigned nParameters() const
47  {return getRHS().nParameters();}
48  inline double getParameter(const unsigned which) const
49  {return getRHS().getParameter(which);}
50 
51  // Set gains
52  inline void setInputGain(const double g) {inputGain_ = g; validateGain();}
53  inline void setOutputGain(const double g) {outputGain_ = g; validateGain();}
54 
55  // Set preamp initial conditions
56  void setInitialConditions(const double* values, const unsigned len);
57  void zeroInitialConditions();
58 
59  // Set preamp model parameters
60  inline void setParameter(const unsigned which, const double p)
61  {modifiableRHS().setParameter(which, p);}
62  inline void setLeadingParameters(const double* values, const unsigned len)
63  {modifiableRHS().setLeadingParameters(values, len);}
64 
65  // Set the minimum value for the preamp output
66  inline void setPreampOutputCut(const double p)
67  {preampOutputCut_ = p;}
68 
69  // Set the input pulse
70  template<class Signal>
71  inline void setInputSignal(const Signal& inputSignal)
72  {
73  modifiableRHS().setInputPulse(inputSignal);
75  }
76 
77  // Get the input pulse
78  inline const HcalInterpolatedPulse& getInputSignal() const
79  {return getRHS().inputPulse();}
80 
81  // Set the input pulse data. This will not modify
82  // signal begin and end times.
83  template<class Real>
84  inline void setInputShape(const Real* values, const unsigned len)
85  {
86  modifiableRHS().inputPulse().setShape(values, len);
88  }
89 
90  // Scale the input pulse by some constant factor
91  inline void scaleInputSignal(const double s)
92  {modifiableRHS().inputPulse() *= s;}
93 
94  // Manipulate input pulse amplidude
95  inline double getInputAmplitude() const
97 
98  inline void setInputAmplitude(const double a)
100 
101  // Manipulate input pulse total charge
102  inline double getInputIntegral() const
103  {return getRHS().inputPulse().getIntegral()/inputGain_;}
104 
105  inline void setInputIntegral(const double d)
107 
108  // Manipulate input pulse timing
109  inline double getInputStartTime() const
110  {return getRHS().inputPulse().getStartTime();}
111 
112  inline void setInputStartTime(const double newStartTime)
113  {modifiableRHS().inputPulse().setStartTime(newStartTime);}
114 
115  // Run the simulation. Parameters are as follows:
116  //
117  // dt -- Simulation time step.
118  //
119  // tstop -- At what time to stop the simulation. The actual
120  // stopping time will be the smaller of this parameter and
121  // dt*(maxlen - 1). The simulation always starts at t = 0.
122  //
123  // tDigitize -- When to start producing ADC counts. This argument
124  // must be non-negative.
125  //
126  // TS, lenTS -- Array (and its length) where ADC counts will be
127  // placed on exit.
128  //
129  // This method returns the number of "good" ADC time slices -- the
130  // ones that completely covered by the simulation interval.
131  //
132  unsigned run(double dt, double tstop,
133  double tDigitize, double* TS, unsigned lenTS);
134 
135  // Inspect simulation results
136  double lastStopTime() const;
137  double totalIntegratedCharge(double t) const;
138  double preampPeakTime() const;
139 
140  // The following methods with simply return 0.0 in case
141  // there are no corresponding nodes in the circuit
142  double preampOutput(double t) const;
143  double controlOutput(double t) const;
144 
145  // Time slice width in nanoseconds
146  static inline double adcTSWidth() {return 25.0;}
147 
148 private:
150  {
151  AbsODERHS* ptr = solver_.getRHS();
152  if (!ptr) throw cms::Exception(
153  "In QIE8Simulator::modifiableRHS: no RHS");
154  return *(static_cast<AbsElectronicODERHS*>(ptr));
155  }
156 
157  inline double getCharge(const double t) const
158  {
159  double q;
162  else
164  return q;
165  }
166 
167  void validateGain() const;
168 
170  std::vector<double> initialConditions_;
171  std::vector<double> historyBuffer_;
173  double inputGain_;
174  double outputGain_;
175  unsigned long runCount_;
176  unsigned chargeNode_;
178  bool useCubic_;
179 };
180 
181 #endif // CalibCalorimetry_HcalAlgos_QIE8Simulator_h_
double preampPeakTime() const
float dt
Definition: AMPTWrapper.h:126
std::vector< double > initialConditions_
const HcalInterpolatedPulse & getInputSignal() const
Definition: QIE8Simulator.h:78
unsigned chargeNode_
double getParameter(const unsigned which) const
Definition: QIE8Simulator.h:48
double preampOutputCut_
void setStartTime(const double newStartTime)
double interpolateIntegrated(unsigned which, double t, bool cubic=false) const
double totalIntegratedCharge(double t) const
bool integrateToGetCharge_
void setInputSignal(const Signal &inputSignal)
Definition: QIE8Simulator.h:71
double lastStopTime() const
void setInputAmplitude(const double a)
Definition: QIE8Simulator.h:98
double getIntegral() const
unsigned long runCount_
static double adcTSWidth()
void setShape(const Real *values, const unsigned len)
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_
double getInputIntegral() const
void setInitialConditions(const double *values, const unsigned len)
const HcalInterpolatedPulse & inputPulse() const
void scaleInputSignal(const double s)
Definition: QIE8Simulator.h:91
double getInputGain() const
Definition: QIE8Simulator.h:40
void setInputIntegral(const double d)
double getParameter(const unsigned which) const
double getPeakValue() const
void setLeadingParameters(const double *values, const unsigned len)
void setPreampOutputCut(const double p)
Definition: QIE8Simulator.h:66
const AbsElectronicODERHS & getRHS() const
Definition: QIE8Simulator.h:31
void validateGain() const
double getInputAmplitude() const
Definition: QIE8Simulator.h:95
void setParameter(const unsigned which, const double value)
void setRHS(const AbsElectronicODERHS &rhs, unsigned chargeNode, bool interpolateCubic=false)
double getStartTime() const
const AbsODERHS * getRHS() const
AbsElectronicODERHS & modifiableRHS()
double getCharge(const double t) const
double Real
double interpolateCoordinate(unsigned which, double t, bool cubic=false) const
void setInputPulse(const Pulse &pulse)
void setParameter(const unsigned which, const double p)
Definition: QIE8Simulator.h:60
void setInputShape(const Real *values, const unsigned len)
Definition: QIE8Simulator.h:84
double outputGain_
void setInputStartTime(const double newStartTime)
unsigned long getRunCount() const
Definition: QIE8Simulator.h:42
void setPeakValue(const double newValue)
double a
Definition: hdecay.h:121
double preampOutput(double t) const
unsigned run(double dt, double tstop, double tDigitize, double *TS, unsigned lenTS)
double getInputStartTime() const
double getOutputGain() const
Definition: QIE8Simulator.h:41
virtual unsigned nParameters() const =0
void setInputGain(const double g)
Definition: QIE8Simulator.h:52
double getPreampOutputCut() const
Definition: QIE8Simulator.h:43
void zeroInitialConditions()
unsigned nParameters() const
Definition: QIE8Simulator.h:46
void setIntegral(const double newValue)
void setLeadingParameters(const double *values, const unsigned len)
Definition: QIE8Simulator.h:62
static const unsigned maxlen
Definition: QIE8Simulator.h:14
Definition: vlib.h:39
void setOutputGain(const double g)
Definition: QIE8Simulator.h:53
double controlOutput(double t) const