LDMX Software
ldmx::CompositePulse Class Reference

CompositePulse. More...

#include <CompositePulse.h>

Public Member Functions

 CompositePulse (TF1 func, const double &gain, const double &pedestal)
 Constructore.
 
void clear ()
 
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 Member Functions

 ClassDef (CompositePulse, 2)
 

Private Attributes

std::vector< std::pair< double, double > > hits_
 pulses entering the chip
 
TF1 pulse_func_
 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 18 of file CompositePulse.h.

Constructor & Destructor Documentation

◆ CompositePulse()

ldmx::CompositePulse::CompositePulse ( TF1 func,
const double & gain,
const double & pedestal )
inline

Constructore.

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

Definition at line 27 of file CompositePulse.h.

28 : pulse_func_{func}, gain_{gain}, pedestal_{pedestal} {}
double gain_
gain for current chip we are emulating
TF1 pulse_func_
reference to pulse shape function shared by all pulses
double pedestal_
pedestal for current chip we are emulating

Member Function Documentation

◆ addOrMerge()

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

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 6 of file CompositePulse.cxx.

7 {
8 auto imerge{hits_.begin()};
9 for (; imerge != hits_.end(); imerge++)
10 if (fabs(imerge->second - hit.second) < hit_merge_ns) break;
11 if (imerge == hits_.end()) { // didn't find a match, add to the list
12 hits_.push_back(hit);
13 } else { // merge hits_, shifting time to average
14 imerge->second = (imerge->second * imerge->first + hit.first * hit.second);
15 imerge->first += hit.first;
16 imerge->second /= imerge->first;
17 }
18}
std::vector< std::pair< double, double > > hits_
pulses entering the chip

References hits_.

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

◆ at()

double ldmx::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 86 of file CompositePulse.h.

86 {
87 double signal = gain_ * pedestal_;
88 for (auto hit : hits_)
89 signal += hit.first * pulse_func_.Eval(time - hit.second);
90 return signal;
91 };

References gain_, hits_, pedestal_, and pulse_func_.

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

◆ clear()

void ldmx::CompositePulse::clear ( )
inline

Definition at line 34 of file CompositePulse.h.

34{};

◆ findCrossing()

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

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 20 of file CompositePulse.cxx.

21 {
22 // use midpoint algorithm, assumes low is below and high is above
23 double step = high - low;
24 double pt = (high + low) / 2;
25 while (step > prec) {
26 double vmid = at(pt);
27 if (vmid < level) {
28 low = pt;
29 } else {
30 high = pt;
31 }
32 step = high - low;
33 pt = (high + low) / 2;
34 }
35 return pt;
36}
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::CompositePulse::hits ( ) const
inline

Get list of individual pulses that are entering the chip.

Definition at line 94 of file CompositePulse.h.

94{ return hits_; }

References hits_.

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

◆ operator()()

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

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

See also
at

Definition at line 75 of file CompositePulse.h.

75{ return at(time); }

References at().

◆ setGainPedestal()

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

Configure the pulses for the current chip.

Definition at line 64 of file CompositePulse.h.

64 {
65 gain_ = gain;
66 pedestal_ = pedestal;
67 }

References gain_, and pedestal_.

Member Data Documentation

◆ gain_

double ldmx::CompositePulse::gain_
private

gain for current chip we are emulating

Definition at line 108 of file CompositePulse.h.

Referenced by at(), and setGainPedestal().

◆ hits_

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

pulses entering the chip

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

Definition at line 102 of file CompositePulse.h.

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

◆ pedestal_

double ldmx::CompositePulse::pedestal_
private

pedestal for current chip we are emulating

Definition at line 111 of file CompositePulse.h.

Referenced by at(), and setGainPedestal().

◆ pulse_func_

TF1 ldmx::CompositePulse::pulse_func_
private

reference to pulse shape function shared by all pulses

Definition at line 105 of file CompositePulse.h.

Referenced by at().


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