2#ifndef TOOLS_HGCROCEMULATOR_H
3#define TOOLS_HGCROCEMULATOR_H
5#include "Conditions/SimpleTableCondition.h"
6#include "Framework/Configure/Parameters.h"
152 const int& channelID,
153 std::vector<std::pair<double, double>>& arriving_pulses,
154 std::vector<ldmx::HgcrocDigiCollection::Sample>& digiToAdd)
const;
176 std::vector<ldmx::HgcrocDigiCollection::Sample>
noiseDigi(
177 const int& channel,
const double& soi_amplitude = 0)
const;
185 double noise(
const int& channelID)
const {
191 double gain(
const int& channelID)
const {
216 EXCEPTION_RAISE(
"HgcrocCond",
217 "HGC ROC Emulator was not given a conditions table.");
258 void addOrMerge(
const std::pair<double, double>& hit,
double hit_merge_ns) {
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()) {
263 hits_.push_back(hit);
266 (imerge->second * imerge->first + hit.first * hit.second);
267 imerge->first += hit.first;
268 imerge->second /= imerge->first;
285 double prec = 0.01) {
287 double step = high - low;
288 double pt = (high + low) / 2;
289 while (step > prec) {
290 double vmid =
at(pt);
297 pt = (high + low) / 2;
325 double at(
double time)
const {
327 for (
auto hit :
hits_)
328 signal += hit.first *
pulseFunc_.Eval(time - hit.second);
333 const std::vector<std::pair<double, double>>&
hits()
const {
return hits_; }
341 std::vector<std::pair<double, double>>
hits_;
Class that represents a digitized hit in a calorimeter cell readout by an HGCROC.
Utility used to generate noise hits.
Class which stores simulated calorimeter hit information.
unsigned int getColumnNumber(const std::string &colname) const
Get a the column number for the given column name.
T get(unsigned int id, unsigned int col) const
Get an entry by DetectorId and number.
Class encapsulating parameters for configuring a processor.
void setGainPedestal(double gain, double pedestal)
Configure the pulses for the current chip.
std::vector< std::pair< double, double > > hits_
pulses entering the chip
const std::vector< std::pair< double, double > > & hits() const
Get list of individual pulses that are entering the chip.
double at(double time) const
Measure the voltage at the input time.
double pedestal_
pedestal for current chip we are emulating
double gain_
gain for current chip we are emulating
double findCrossing(double low, double high, double level, double prec=0.01)
Find the time at which we cross the input level.
double operator()(double time) const
Evaluating this object as a function gives the same result as at.
TF1 & pulseFunc_
reference to pulse shape function shared by all pulses
void addOrMerge(const std::pair< double, double > &hit, double hit_merge_ns)
Put another hit into this composite pulse.
CompositePulse(TF1 &func, const double &g, const double &p)
Constructore.
Emulate the digitization procedure performed by the HGCROC.
void condition(const conditions::DoubleTableCondition &table)
Set Conditions.
double readoutThreshold(const int &id) const
Readout Threshold (ADC Counts)
double rateUpSlope_
Rate of Up Slope in Pulse Shape [1/ns].
void seedGenerator(uint64_t seed)
Seed the emulator for random number generation.
double noise(const int &channelID) const
Get random noise amplitdue for input channel [mV].
bool hasSeed() const
Check if emulator has been seeded.
double pedestal(const int &id) const
Pedestal [ADC Counts] for input channel.
const conditions::DoubleTableCondition * chipConditions_
Handle to table of chip-dependent conditions.
double getCondition(int id, const std::string &name) const
Get condition for input chip ID, condition name, and default value.
double hit_merge_ns_
Hit merging time [ns].
double timeUpSlope_
Time of Up Slope relative to Pulse Shape Fit [ns].
double timePeak_
Time of Peak relative to pulse shape fit [ns].
int iSOI_
Index for the Sample Of Interest in the list of digi samples.
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::unique_ptr< TRandom3 > noiseInjector_
Generates Gaussian noise on top of real hits.
std::map< std::string, int > conditionNamesToIndex_
Map of condition names to column numbers.
double gain(const int &channelID) const
Gain for input channel.
~HgcrocEmulator()
Destructor.
double timingJitter_
Jitter of timing mechanism in the chip [ns].
int nADCs_
Depth of ADC buffer.
bool noise_
Put noise in channels, only configure to false if testing.
double timeDnSlope_
Time of Down Slope relative to Pulse Shape Fit [ns].
TF1 pulseFunc_
Functional shape of signal pulse in time.
double clockCycle_
Time interval for chip clock [ns].
std::vector< ldmx::HgcrocDigiCollection::Sample > noiseDigi(const int &channel, const double &soi_amplitude=0) const
Generate a digi of pure noise.
double rateDnSlope_
Rate of Down Slope in Pulse Shape [1/ns].
double ns_
Conversion from time [ns] to counts.