25 hgcroc_ = std::make_unique<ldmx::HgcrocEmulator>(hgcroc_params);
27 n_adcs_ = hgcroc_params.get<
int>(
"n_adcs");
28 i_soi_ = hgcroc_params.get<
int>(
"i_soi");
29 noise_ = hgcroc_params.get<
bool>(
"noise");
69 rseed.getSeed(
"EcalDigiProducer::NoiseGenerator"));
71 rng_.seed(rseed.getSeed(
"EcalDigiProducer"));
73 hgcroc_->seedGenerator(rseed.getSeed(
"EcalDigiProducer::HgcrocEmulator"));
85 std::set<unsigned int> filled_det_i_ds;
104 for (
auto const& sim_hit : ecal_sim_hits) {
105 std::vector<std::pair<double, double>> pulses_at_chip;
106 for (
int i_contrib = 0; i_contrib < sim_hit.getNumberOfContribs();
117 pulses_at_chip.emplace_back(
118 sim_hit.getContrib(i_contrib).edep_ *
mev_,
119 sim_hit.getContrib(i_contrib).time_
120 - sim_hit.getPosition().at(2) /
125 unsigned int hit_id = sim_hit.getID();
126 filled_det_i_ds.insert(hit_id);
128 ldmx_log(debug) <<
" Emulation of hitID = " << hit_id
129 <<
" with energy = " << sim_hit.getEdep()
131 << sim_hit.getTime() -
132 sim_hit.getPosition().at(2) / 299.702547;
136 std::vector<ldmx::HgcrocDigiCollection::Sample> digi_to_add;
137 if (
hgcroc_->digitize(hit_id, pulses_at_chip, digi_to_add)) {
138 ldmx_log(debug) <<
" --> The HGCROC will read-out this hit!";
139 ecal_digis.
addDigi(hit_id, digi_to_add);
153 ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME);
154 int n_ecal_layers = geom.getNumLayers();
155 int n_modules_per_layer = geom.getNumModulesPerLayer();
156 int n_cells_per_module = geom.getNumCellsPerModule();
157 int num_empty_channels =
158 n_ecal_layers * n_modules_per_layer * n_cells_per_module -
162 std::uniform_int_distribution<int> layer_dist(0, n_ecal_layers - 1);
163 std::uniform_int_distribution<int> module_dist(0, n_modules_per_layer - 1);
164 std::uniform_int_distribution<int> cell_dist(0, n_cells_per_module - 1);
169 auto noise_hit_amplitudes{
171 std::vector<std::pair<double, double>> fake_pulse(1, {0., 0.});
172 for (
double noise_hit : noise_hit_amplitudes) {
175 unsigned int noise_id;
177 int layer_id = layer_dist(
rng_);
178 int module_id = module_dist(
rng_);
179 int cell_id = cell_dist(
rng_);
180 auto det_id =
ldmx::EcalID(layer_id, module_id, cell_id);
181 noise_id = det_id.raw();
182 }
while (filled_det_i_ds.find(noise_id) != filled_det_i_ds.end());
183 filled_det_i_ds.insert(noise_id);
189 (
hgcroc_->readoutThreshold(noise_id) -
hgcroc_->pedestal(noise_id));
192 ecal_digis.
addDigi(noise_id,
hgcroc_->noiseDigi(noise_id, noise_hit));
197 for (
int layer{0}; layer < n_ecal_layers; layer++) {
198 for (
int module{0};
module < n_modules_per_layer;
module++) {
199 for (int cell{0}; cell < n_cells_per_module; cell++) {
202 if (filled_det_i_ds.find(channel) != filled_det_i_ds.end())
212 event.add(digi_coll_name_, ecal_digis);
Class that performs basic ECal digitization.
Class that translates raw positions of ECal module hits into cells in a hexagonal readout.
Class that defines an ECal detector ID with a cell number.
#define DECLARE_PRODUCER(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Class that represents a digitized hit in a calorimeter cell readout by an HGCROC.
Conditions object for random number seeds.
Class which stores simulated calorimeter hit information.
Performs basic ECal digitization.
std::unique_ptr< ldmx::NoiseGenerator > noise_generator_
Generates noise hits based off of number of cells that are not hit.
std::string input_pass_name_
input pass name
double noise_rms_
Noise RMS.
bool noise_
Put noise into empty channels, not configurable, only helpful in development.
std::mt19937 rng_
Generates random numbers for which channels to fill up with noise.
double readout_threshold_
Read out threshold.
virtual void produce(framework::Event &event) override
Simulates measurement of pulse and creates digi collection for input event.
double pedestal_
Read out pedestal.
double mev_
Conversion from energy in MeV to voltage in mV.
virtual void configure(framework::config::Parameters &) override
Configure this producer from the python configuration.
int i_soi_
Index for the Sample Of Interest in the list of digi samples.
double clock_cycle_
Time interval for chip clock in ns.
double ns_
Conversion from time in ns to ticks of the internal clock.
std::string digi_coll_name_
output hit collection name
virtual void onNewRun(const ldmx::RunHeader &runHeader) override
Set up random number / noise generation.
int n_adcs_
Depth of ADC buffer.
std::string input_coll_name_
input hit collection name
std::unique_ptr< ldmx::HgcrocEmulator > hgcroc_
Hgcroc Emulator to digitize analog voltage signals.
bool zero_suppression_
When emulating noise in empty channels, do we zero suppress?
const T & getCondition(const std::string &condition_name)
Access a conditions object for the current event.
Implements an event buffer system for storing event data.
static const std::string CONDITIONS_OBJECT_NAME
Conditions object name.
Class encapsulating parameters for configuring a processor.
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Extension of DetectorID providing access to ECal layers and cell numbers in a hex grid.
Represents a collection of the digi hits readout by an HGCROC.
void setNumSamplesPerDigi(unsigned int n)
Set number of samples for each digi.
void setSampleOfInterestIndex(unsigned int n)
Set index of sample of interest.
void addDigi(unsigned int id, const std::vector< Sample > &digi)
Add samples to collection.
unsigned int getNumDigis() const
Get total number of digis.
Stores simulated calorimeter hit information.