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"
8#include "Recon/Event/CompositePulse.h"
10#include "Recon/Event/HgcrocPulseTruth.h"
13
14//----------//
15// ROOT //
16//----------//
17#include "TF1.h"
18#include "TRandom3.h"
19
20namespace ldmx {
21
43 public:
50
53
58 bool hasSeed() const { return noise_injector_.get() != nullptr; }
59
64 void seedGenerator(uint64_t seed);
65
76 // reset cache of column numbers if table changes
77 if (&table != chip_conditions_) condition_names_to_index_.clear();
78 chip_conditions_ = &table;
79 }
80
154 bool digitize(
155 const int& channelID,
156 std::vector<std::pair<double, double>>& arriving_pulses,
157 std::vector<ldmx::HgcrocDigiCollection::Sample>& digiToAdd) const;
158
179 std::vector<ldmx::HgcrocDigiCollection::Sample> noiseDigi(
180 const int& channel, const double& soi_amplitude = 0) const;
181
188 double noise(const int& channelID) const {
189 return noise_injector_->Gaus(
190 0, getCondition(channelID, "NOISE") * gain(channelID));
191 };
192
194 double gain(const int& channelID) const {
195 return getCondition(channelID, "GAIN");
196 }
197
199 double pedestal(const int& id) const { return getCondition(id, "PEDESTAL"); }
200
202 double readoutThreshold(const int& id) const {
203 return getCondition(id, "READOUT_THRESHOLD");
204 }
205
206 bool save_pulse_truth_info_{false};
207 ldmx::HgcrocPulseTruthCollection* pulse_truth_coll_;
208
209 private:
219 double getCondition(int id, const std::string& name) const {
220 // check if emulator has been passed a table of conditions
221 if (!chip_conditions_) {
222 EXCEPTION_RAISE("HgcrocCond",
223 "HGC ROC Emulator was not given a conditions table.");
224 }
225
226 // cache column index for the input name
227 if (condition_names_to_index_.count(name) == 0)
229
230 // get condition
231 return chip_conditions_->get(id, condition_names_to_index_.at(name));
232 }
233
234 private:
235 /**************************************************************************************
236 * Parameters Identical for all Chips
237 *************************************************************************************/
238
240 bool noise_{true};
241
244
247
250
253
255 double ns_;
256
259
262
265
268
271
274
275 /**************************************************************************************
276 * Chip-Dependent Parameters (Conditions)
277 *************************************************************************************/
278
286
293 mutable std::map<std::string, int> condition_names_to_index_;
294
295 /**************************************************************************************
296 * Helpful Member Objects
297 *************************************************************************************/
298
300 std::unique_ptr<TRandom3> noise_injector_;
301
322 mutable TF1 pulse_func_;
323
325 enableLogging("HgcrocEmulator")
326}; // HgcrocEmulator
327
328} // namespace ldmx
329
330#endif // TOOLS_HGCROCEMULATOR_H
Base classes for all user event processing components to extend.
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.
Definition Parameters.h:29
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].