LDMX Software
ldmx::HgcrocEmulator::CompositePulse Class Reference

CompositePulse. More...

Public Member Functions

 CompositePulse (TF1 &func, const double &g, const double &p)
 Constructore.
 
void addOrMerge (const std::pair< double, double > &hit, double hit_merge_ns)
 Put another hit into this composite pulse.
 
double findCrossing (double low, double high, double level, double prec=0.01)
 Find the time at which we cross the input level.
 
void setGainPedestal (double gain, double pedestal)
 Configure the pulses for the current chip.
 
double operator() (double time) const
 Evaluating this object as a function gives the same result as at.
 
double at (double time) const
 Measure the voltage at the input time.
 
const std::vector< std::pair< double, double > > & hits () const
 Get list of individual pulses that are entering the chip.
 

Private Attributes

std::vector< std::pair< double, double > > hits_
 pulses entering the chip
 
TF1 & pulseFunc_
 reference to pulse shape function shared by all pulses
 
double gain_
 gain for current chip we are emulating
 
double pedestal_
 pedestal for current chip we are emulating
 

Detailed Description

CompositePulse.

An emulator for a pulse that the chip needs to read. This handles merging two hits that are "close-enough" to one another.

Definition at line 237 of file HgcrocEmulator.h.

Constructor & Destructor Documentation

◆ CompositePulse()

ldmx::HgcrocEmulator::CompositePulse::CompositePulse ( TF1 & func,
const double & g,
const double & p )
inline

Constructore.

Connect this pulse emulator with the pulse shape function already configured by the chip emulator.

Definition at line 246 of file HgcrocEmulator.h.

247 : pulseFunc_{func}, gain_{g}, pedestal_{p} {}
double pedestal_
pedestal for current chip we are emulating
double gain_
gain for current chip we are emulating
TF1 & pulseFunc_
reference to pulse shape function shared by all pulses

Member Function Documentation

◆ addOrMerge()

void ldmx::HgcrocEmulator::CompositePulse::addOrMerge ( const std::pair< double, double > & hit,
double hit_merge_ns )
inline

Put another hit into this composite pulse.

If the hit is within the merge input of a hit already included, then it is merged with that hit. Otherwise, it is included as its own hit.

Parameters
[in]hitvoltage,time pair representing a sime hit
[in]hit_merge_nsmaximum time separation [ns] to merge two hits

Definition at line 259 of file HgcrocEmulator.h.

259 {
260 auto imerge{hits_.begin()};
261 for (; imerge != hits_.end(); imerge++)
262 if (fabs(imerge->second - hit.second) < hit_merge_ns) break;
263 if (imerge == hits_.end()) { // didn't find a match, add to the list
264 hits_.push_back(hit);
265 } else { // merge hits, shifting time to average
266 imerge->second =
267 (imerge->second * imerge->first + hit.first * hit.second);
268 imerge->first += hit.first;
269 imerge->second /= imerge->first;
270 }
271 }
std::vector< std::pair< double, double > > hits_
pulses entering the chip

References hits_.

Referenced by ldmx::HgcrocEmulator::digitize().

◆ at()

double ldmx::HgcrocEmulator::CompositePulse::at ( double time) const
inline

Measure the voltage at the input time.

Includes the effects from all pulses but does not put any noise into the measurement.

Parameters
[in]timetime to measure [ns]
Returns
voltage at that time [mV]

Definition at line 326 of file HgcrocEmulator.h.

326 {
327 double signal = gain_ * pedestal_;
328 for (auto hit : hits_)
329 signal += hit.first * pulseFunc_.Eval(time - hit.second);
330 return signal;
331 };

References gain_, hits_, pedestal_, and pulseFunc_.

Referenced by findCrossing(), and operator()().

◆ findCrossing()

double ldmx::HgcrocEmulator::CompositePulse::findCrossing ( double low,
double high,
double level,
double prec = 0.01 )
inline

Find the time at which we cross the input level.

We use the midpoint algorithm, assuming the input low is below the threshold and hight is above.

Parameters
[in]lowminimum value (below threshold) to start search at [mV]
[in]highmaximum value (above threshold) to start search at [mV]
[in]levelthreshold to look for time [mV]
[in]precprecision with which to look [mV]
Returns
time [ns] at which the pulse cross level

Definition at line 285 of file HgcrocEmulator.h.

286 {
287 // use midpoint algorithm, assumes low is below and high is above
288 double step = high - low;
289 double pt = (high + low) / 2;
290 while (step > prec) {
291 double vmid = at(pt);
292 if (vmid < level) {
293 low = pt;
294 } else {
295 high = pt;
296 }
297 step = high - low;
298 pt = (high + low) / 2;
299 }
300 return pt;
301 }
double at(double time) const
Measure the voltage at the input time.

References at().

Referenced by ldmx::HgcrocEmulator::digitize().

◆ hits()

const std::vector< std::pair< double, double > > & ldmx::HgcrocEmulator::CompositePulse::hits ( ) const
inline

Get list of individual pulses that are entering the chip.

Definition at line 334 of file HgcrocEmulator.h.

334{ return hits_; }

References hits_.

Referenced by ldmx::HgcrocEmulator::digitize().

◆ operator()()

double ldmx::HgcrocEmulator::CompositePulse::operator() ( double time) const
inline

Evaluating this object as a function gives the same result as at.

See also
at

Definition at line 315 of file HgcrocEmulator.h.

315{ return at(time); }

References at().

◆ setGainPedestal()

void ldmx::HgcrocEmulator::CompositePulse::setGainPedestal ( double gain,
double pedestal )
inline

Configure the pulses for the current chip.

Definition at line 304 of file HgcrocEmulator.h.

304 {
305 gain_ = gain;
307 }
double pedestal(const int &id) const
Pedestal [ADC Counts] for input channel.
double gain(const int &channelID) const
Gain for input channel.

References ldmx::HgcrocEmulator::gain(), gain_, ldmx::HgcrocEmulator::pedestal(), and pedestal_.

Member Data Documentation

◆ gain_

double ldmx::HgcrocEmulator::CompositePulse::gain_
private

gain for current chip we are emulating

Definition at line 348 of file HgcrocEmulator.h.

Referenced by at(), and setGainPedestal().

◆ hits_

std::vector<std::pair<double, double> > ldmx::HgcrocEmulator::CompositePulse::hits_
private

pulses entering the chip

The pair is {voltage amplitude [mV], time of peak [ns]}

Definition at line 342 of file HgcrocEmulator.h.

Referenced by addOrMerge(), at(), and hits().

◆ pedestal_

double ldmx::HgcrocEmulator::CompositePulse::pedestal_
private

pedestal for current chip we are emulating

Definition at line 351 of file HgcrocEmulator.h.

Referenced by at(), and setGainPedestal().

◆ pulseFunc_

TF1& ldmx::HgcrocEmulator::CompositePulse::pulseFunc_
private

reference to pulse shape function shared by all pulses

Definition at line 345 of file HgcrocEmulator.h.

Referenced by at().


The documentation for this class was generated from the following file: