LDMX Software
HgcrocEmulator.h
1
2#ifndef TOOLS_HGCROCEMULATOR_H
3#define TOOLS_HGCROCEMULATOR_H
4
5#include "Conditions/SimpleTableCondition.h"
6#include "Framework/Configure/Parameters.h"
7#include "Framework/Logger.h"
9#include "Recon/Event/HgcrocPulseTruth.h"
10
11//----------//
12// ROOT //
13//----------//
14#include "TF1.h"
15#include "TRandom3.h"
16
17namespace ldmx {
18
40 public:
47
50
55 bool hasSeed() const { return noise_injector_.get() != nullptr; }
56
61 void seedGenerator(uint64_t seed);
62
73 // reset cache of column numbers if table changes
74 if (&table != chip_conditions_) condition_names_to_index_.clear();
75 chip_conditions_ = &table;
76 }
77
151 bool digitize(
152 const int& channelID,
153 std::vector<std::pair<double, double>>& arriving_pulses,
154 std::vector<ldmx::HgcrocDigiCollection::Sample>& digiToAdd) const;
155
176 std::vector<ldmx::HgcrocDigiCollection::Sample> noiseDigi(
177 const int& channel, const double& soi_amplitude = 0) const;
178
185 double noise(const int& channelID) const {
186 return noise_injector_->Gaus(
187 0, getCondition(channelID, "NOISE") * gain(channelID));
188 };
189
191 double gain(const int& channelID) const {
192 return getCondition(channelID, "GAIN");
193 }
194
196 double pedestal(const int& id) const { return getCondition(id, "PEDESTAL"); }
197
199 double readoutThreshold(const int& id) const {
200 return getCondition(id, "READOUT_THRESHOLD");
201 }
202
203 bool save_pulse_truth_info_{false};
204 ldmx::HgcrocPulseTruthCollection* pulse_truth_coll_;
205
206 private:
216 double getCondition(int id, const std::string& name) const {
217 // check if emulator has been passed a table of conditions
218 if (!chip_conditions_) {
219 EXCEPTION_RAISE("HgcrocCond",
220 "HGC ROC Emulator was not given a conditions table.");
221 }
222
223 // cache column index for the input name
224 if (condition_names_to_index_.count(name) == 0)
226
227 // get condition
228 return chip_conditions_->get(id, condition_names_to_index_.at(name));
229 }
230
231 private:
232 /**************************************************************************************
233 * Parameters Identical for all Chips
234 *************************************************************************************/
235
237 bool noise_{true};
238
241
244
247
250
252 double ns_;
253
256
259
262
265
268
271
272 /**************************************************************************************
273 * Chip-Dependent Parameters (Conditions)
274 *************************************************************************************/
275
283
290 mutable std::map<std::string, int> condition_names_to_index_;
291
292 /**************************************************************************************
293 * Helpful Member Objects
294 *************************************************************************************/
295
297 std::unique_ptr<TRandom3> noise_injector_;
298
319 mutable TF1 pulse_func_;
320
322 enableLogging("HgcrocEmulator")
323}; // HgcrocEmulator
324
325} // namespace ldmx
326
327#endif // TOOLS_HGCROCEMULATOR_H
Class that represents a digitized hit in a calorimeter cell readout by an HGCROC.
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.
Definition Parameters.h:26
Emulate the digitization procedure performed by the HGCROC.
void condition(const conditions::DoubleTableCondition &table)
Set Conditions.
std::unique_ptr< TRandom3 > noise_injector_
Generates Gaussian noise on top of real hits_.
double readoutThreshold(const int &id) const
Readout Threshold (ADC Counts)
double clock_cycle_
Time interval for chip clock [ns].
void seedGenerator(uint64_t seed)
Seed the emulator for random number generation.
int n_ad_cs_
Depth of ADC buffer.
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.
double timing_jitter_
Jitter of timing mechanism in the chip [ns].
double getCondition(int id, const std::string &name) const
Get condition for input chip ID, condition name, and default value.
double time_up_slope_
Time of Up Slope relative to Pulse Shape Fit [ns].
double hit_merge_ns_
Hit merging time [ns].
std::map< std::string, int > condition_names_to_index_
Map of condition names to column numbers.
double rate_dn_slope_
Rate of Down Slope in Pulse Shape [1/ns].
int i_soi_
Index for the Sample Of Interest in the list of digi samples.
double time_dn_slope_
Time of Down Slope relative to Pulse Shape Fit [ns].
TF1 pulse_func_
Functional shape of signal pulse in time.
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_.
double gain(const int &channelID) const
Gain for input channel.
~HgcrocEmulator()
Destructor.
const conditions::DoubleTableCondition * chip_conditions_
Handle to table of chip-dependent conditions.
bool noise_
Put noise in channels, only configure to false if testing.
double time_peak_
Time of Peak relative to pulse shape fit [ns].
std::vector< ldmx::HgcrocDigiCollection::Sample > noiseDigi(const int &channel, const double &soi_amplitude=0) const
Generate a digi of pure noise.
HgcrocEmulator(const framework::config::Parameters &ps)
Constructor.
double ns_
Conversion from time [ns] to counts.
double rate_up_slope_
Rate of Up Slope in Pulse Shape [1/ns].