LDMX Software
Public Member Functions | Private Attributes | List of all members
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 236 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 245 of file HgcrocEmulator.h.

246 : 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 258 of file HgcrocEmulator.h.

258 {
259 auto imerge{hits_.begin()};
260 for (; imerge != hits_.end(); imerge++)
261 if (fabs(imerge->second - hit.second) < hit_merge_ns) break;
262 if (imerge == hits_.end()) { // didn't find a match, add to the list
263 hits_.push_back(hit);
264 } else { // merge hits, shifting time to average
265 imerge->second =
266 (imerge->second * imerge->first + hit.first * hit.second);
267 imerge->first += hit.first;
268 imerge->second /= imerge->first;
269 }
270 }
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 325 of file HgcrocEmulator.h.

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

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 284 of file HgcrocEmulator.h.

285 {
286 // use midpoint algorithm, assumes low is below and high is above
287 double step = high - low;
288 double pt = (high + low) / 2;
289 while (step > prec) {
290 double vmid = at(pt);
291 if (vmid < level) {
292 low = pt;
293 } else {
294 high = pt;
295 }
296 step = high - low;
297 pt = (high + low) / 2;
298 }
299 return pt;
300 }
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 333 of file HgcrocEmulator.h.

333{ 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 314 of file HgcrocEmulator.h.

314{ 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 303 of file HgcrocEmulator.h.

303 {
304 gain_ = gain;
306 }
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 347 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 341 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 350 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 344 of file HgcrocEmulator.h.

Referenced by at().


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