LDMX Software
|
Emulate the digitization procedure performed by the HGCROC. More...
#include <HgcrocEmulator.h>
Classes | |
class | CompositePulse |
CompositePulse. More... | |
Public Member Functions | |
HgcrocEmulator (const framework::config::Parameters &ps) | |
Constructor. | |
~HgcrocEmulator () | |
Destructor. | |
bool | hasSeed () const |
Check if emulator has been seeded. | |
void | seedGenerator (uint64_t seed) |
Seed the emulator for random number generation. | |
void | condition (const conditions::DoubleTableCondition &table) |
Set Conditions. | |
bool | digitize (const int &channelID, std::vector< std::pair< double, double > > &arriving_pulses, std::vector< ldmx::HgcrocDigiCollection::Sample > &digiToAdd) const |
Digitize the signals from the simulated hits. | |
std::vector< ldmx::HgcrocDigiCollection::Sample > | noiseDigi (const int &channel, const double &soi_amplitude=0) const |
Generate a digi of pure noise. | |
double | noise (const int &channelID) const |
Get random noise amplitdue for input channel [mV]. | |
double | gain (const int &channelID) const |
Gain for input channel. | |
double | pedestal (const int &id) const |
Pedestal [ADC Counts] for input channel. | |
double | readoutThreshold (const int &id) const |
Readout Threshold (ADC Counts) | |
Private Member Functions | |
double | getCondition (int id, const std::string &name) const |
Get condition for input chip ID, condition name, and default value. | |
Private Attributes | |
bool | noise_ {true} |
Put noise in channels, only configure to false if testing. | |
int | nADCs_ |
Depth of ADC buffer. | |
int | iSOI_ |
Index for the Sample Of Interest in the list of digi samples. | |
double | clockCycle_ |
Time interval for chip clock [ns]. | |
double | timingJitter_ |
Jitter of timing mechanism in the chip [ns]. | |
double | ns_ |
Conversion from time [ns] to counts. | |
double | rateUpSlope_ |
Rate of Up Slope in Pulse Shape [1/ns]. | |
double | timeUpSlope_ |
Time of Up Slope relative to Pulse Shape Fit [ns]. | |
double | rateDnSlope_ |
Rate of Down Slope in Pulse Shape [1/ns]. | |
double | timeDnSlope_ |
Time of Down Slope relative to Pulse Shape Fit [ns]. | |
double | timePeak_ |
Time of Peak relative to pulse shape fit [ns]. | |
double | hit_merge_ns_ |
Hit merging time [ns]. | |
const conditions::DoubleTableCondition * | chipConditions_ {nullptr} |
Handle to table of chip-dependent conditions. | |
std::map< std::string, int > | conditionNamesToIndex_ |
Map of condition names to column numbers. | |
std::unique_ptr< TRandom3 > | noiseInjector_ |
Generates Gaussian noise on top of real hits. | |
TF1 | pulseFunc_ |
Functional shape of signal pulse in time. | |
Emulate the digitization procedure performed by the HGCROC.
This object emulates how the chip converts the analog signal into DIGI samples. With that in mind, the digitize method converts a set of voltages and times into the DIGI.
This object does not do everything related to subsystem information. It does not simulate noise within the empty channels, and it does not convert simulated energy depositions into voltages. These tasks depend on the detector construction, so they are left to the individual subsystem producers.
@TODO time phase setting relative to target t=0ns using electronic IDs
@TODO accurately model recovering from saturation (TOT Mode). Currently, we just have all the samples after the sample triggering TOT mode rail.
Definition at line 39 of file HgcrocEmulator.h.
ldmx::HgcrocEmulator::HgcrocEmulator | ( | const framework::config::Parameters & | ps | ) |
Constructor.
Configures the chip emulator using the passed parameters.
Definition at line 6 of file HgcrocEmulator.cxx.
References clockCycle_, framework::config::Parameters::getParameter(), hit_merge_ns_, iSOI_, nADCs_, noise_, ns_, pulseFunc_, rateDnSlope_, rateUpSlope_, timeDnSlope_, timePeak_, timeUpSlope_, and timingJitter_.
|
inline |
|
inline |
Set Conditions.
Passes the chips conditions to be cached here and used later in digitization.
table | conditions::DoubleTableConditions to be used for chip parameters |
Definition at line 72 of file HgcrocEmulator.h.
References chipConditions_, and conditionNamesToIndex_.
bool ldmx::HgcrocEmulator::digitize | ( | const int & | channelID, |
std::vector< std::pair< double, double > > & | arriving_pulses, | ||
std::vector< ldmx::HgcrocDigiCollection::Sample > & | digiToAdd | ||
) | const |
Digitize the signals from the simulated hits.
This is where the hefty amount of work is done.
0. Prepare for Emulation
Combine input simulated hits into one CompositePulse to digitize.
Add a timing jitter TODO
Here, we measure the height of the pulse once per clock cycle. This leaves us with nADCs_ samples for each digitized hit. The voltage measurements are converted to ADC counts using the parameter gain_.
The time of arrival (TOA) is zero unless the amplitude is greater than toaThreshold_. Then the TOA is set to the point the pulse crosses the toaThreshold_ with respect to the current clock window. The time measurements are converted to clock counts using 2^10=1024 and clockCycle_.
Both the tot_complete_ and tot_progress_ flags are set to false for all the samples.
Here, we measure how long the chip is in saturation. This is calculated using the drain rate and assuming a linear drain of the charge off of the chip.
The charge deposited on the chip is converted from the pulse triggering TOT without including the pedestal. The pedestal is included in the pulse when determining if the pulse should enter TOT mode.
Thus, TOT = charge deposited / drain rate and TOA is calculated as before, seeing when the pulse crossed the TOA threshold.
All "measurements" of the pulse use the object CompositePulse. This function incorporates the pedestal_ and linearly adds all the pulses at a variety of times. The pulses at different times are "merged" upon addition to the composite pulse depending on how close they are. This is done in a single pass, so we might end up with pulses closer than the provided separation time.
[in] | channelID | raw integer ID for this readout channel |
[in] | arriving_pulses | pairs of (voltage,time) of hits arriving at the chip |
[out] | digiToAdd | digi that will be filled with the samples from the chip |
the time here is nominal (zero gives peak if hit.second is zero)
Definition at line 45 of file HgcrocEmulator.cxx.
References ldmx::HgcrocEmulator::CompositePulse::addOrMerge(), clockCycle_, ldmx::HgcrocEmulator::CompositePulse::findCrossing(), gain(), getCondition(), hit_merge_ns_, ldmx::HgcrocEmulator::CompositePulse::hits(), iSOI_, nADCs_, noise(), noise_, ns_, pedestal(), pulseFunc_, and readoutThreshold().
|
inline |
Gain for input channel.
Definition at line 191 of file HgcrocEmulator.h.
References getCondition().
Referenced by digitize(), noise(), noiseDigi(), and ldmx::HgcrocEmulator::CompositePulse::setGainPedestal().
|
inlineprivate |
Get condition for input chip ID, condition name, and default value.
[in] | id | chip global integer ID used in condition table |
[in] | name | std::string name of chip parameter in table |
[in] | def | default value for parameter if not found in table (or table not set) |
Definition at line 213 of file HgcrocEmulator.h.
References chipConditions_, conditionNamesToIndex_, conditions::HomogenousTableCondition< T >::get(), and conditions::BaseTableCondition::getColumnNumber().
Referenced by digitize(), gain(), noise(), pedestal(), and readoutThreshold().
|
inline |
Check if emulator has been seeded.
Definition at line 55 of file HgcrocEmulator.h.
References noiseInjector_.
|
inline |
Get random noise amplitdue for input channel [mV].
[in] | channelID |
Definition at line 185 of file HgcrocEmulator.h.
References gain(), getCondition(), and noiseInjector_.
Referenced by digitize(), and noiseDigi().
std::vector< ldmx::HgcrocDigiCollection::Sample > ldmx::HgcrocEmulator::noiseDigi | ( | const int & | channel, |
const double & | soi_amplitude = 0 |
||
) | const |
Generate a digi of pure noise.
The (optional) input soi amplitude is added on-top of pedestal in the SOI after being divided by the gain. This is designed to be close to the output amplitudes generated by the noise generator.
We set the TOA for each of the samples created to 0 (or "not found"), so this also indirectly assumes we are below the TOA threshold as well as below the TOT threshold.
[in] | channel | raw integer ID for this readout channel |
[in] | soi_amplitude | amplitude of noise "pulse" in mV |
Definition at line 221 of file HgcrocEmulator.cxx.
References gain(), iSOI_, nADCs_, noise(), and pedestal().
|
inline |
Pedestal [ADC Counts] for input channel.
Definition at line 196 of file HgcrocEmulator.h.
References getCondition().
Referenced by digitize(), noiseDigi(), and ldmx::HgcrocEmulator::CompositePulse::setGainPedestal().
|
inline |
Readout Threshold (ADC Counts)
Definition at line 199 of file HgcrocEmulator.h.
References getCondition().
Referenced by digitize().
void ldmx::HgcrocEmulator::seedGenerator | ( | uint64_t | seed | ) |
Seed the emulator for random number generation.
[in] | seed | integer to use as random seed |
Definition at line 41 of file HgcrocEmulator.cxx.
References noiseInjector_.
|
private |
Handle to table of chip-dependent conditions.
The defaults are listed below and are separate parameters passed through the python configuration.
Definition at line 405 of file HgcrocEmulator.h.
Referenced by condition(), and getCondition().
|
private |
Time interval for chip clock [ns].
Definition at line 369 of file HgcrocEmulator.h.
Referenced by digitize(), and HgcrocEmulator().
|
mutableprivate |
Map of condition names to column numbers.
mutable so that we can update the cached column values in getCondition during processing.
Definition at line 413 of file HgcrocEmulator.h.
Referenced by condition(), and getCondition().
|
private |
Hit merging time [ns].
Definition at line 393 of file HgcrocEmulator.h.
Referenced by digitize(), and HgcrocEmulator().
|
private |
Index for the Sample Of Interest in the list of digi samples.
Definition at line 366 of file HgcrocEmulator.h.
Referenced by digitize(), HgcrocEmulator(), and noiseDigi().
|
private |
Depth of ADC buffer.
Definition at line 363 of file HgcrocEmulator.h.
Referenced by digitize(), HgcrocEmulator(), and noiseDigi().
|
private |
Put noise in channels, only configure to false if testing.
Definition at line 360 of file HgcrocEmulator.h.
Referenced by digitize(), and HgcrocEmulator().
|
private |
Generates Gaussian noise on top of real hits.
Definition at line 420 of file HgcrocEmulator.h.
Referenced by hasSeed(), noise(), and seedGenerator().
|
private |
Conversion from time [ns] to counts.
Definition at line 375 of file HgcrocEmulator.h.
Referenced by digitize(), and HgcrocEmulator().
|
mutableprivate |
Functional shape of signal pulse in time.
Shape parameters are hardcoded into the function currently. Pulse Shape: [0]*((1.0+exp([1]*(-[2]+[3])))*(1.0+exp([5]*(-[6]+[3]))))/((1.0+exp([1]*(x-[2]+[3]-[4])))*(1.0+exp([5]*(x-[6]+[3]-[4])))) p[0] = amplitude (height of peak in mV) p[1] = rate of up slope - rateUpSlope_ p[2] = time of up slope relative to shape fit - timeUpSlope_ p[3] = time of peak relative to shape fit - timePeak_ p[4] = peak time (related to time of hit [ns]) p[5] = rate of down slope - rateDnSlope_ p[6] = time of down slope relative to shape fit - timeDnSlope_
Definition at line 442 of file HgcrocEmulator.h.
Referenced by digitize(), and HgcrocEmulator().
|
private |
Rate of Down Slope in Pulse Shape [1/ns].
Definition at line 384 of file HgcrocEmulator.h.
Referenced by HgcrocEmulator().
|
private |
Rate of Up Slope in Pulse Shape [1/ns].
Definition at line 378 of file HgcrocEmulator.h.
Referenced by HgcrocEmulator().
|
private |
Time of Down Slope relative to Pulse Shape Fit [ns].
Definition at line 387 of file HgcrocEmulator.h.
Referenced by HgcrocEmulator().
|
private |
Time of Peak relative to pulse shape fit [ns].
Definition at line 390 of file HgcrocEmulator.h.
Referenced by HgcrocEmulator().
|
private |
Time of Up Slope relative to Pulse Shape Fit [ns].
Definition at line 381 of file HgcrocEmulator.h.
Referenced by HgcrocEmulator().
|
private |
Jitter of timing mechanism in the chip [ns].
Definition at line 372 of file HgcrocEmulator.h.
Referenced by HgcrocEmulator().