18void TrigScintQIEDigiProducer::configure(
21 strips_per_array_ = parameters.
get<
int>(
"number_of_strips");
23 mean_noise_ = parameters.
get<
double>(
"mean_noise");
24 mev_per_mip_ = parameters.
get<
double>(
"mev_per_mip");
25 pe_per_mip_ = parameters.
get<
double>(
"pe_per_mip");
26 input_collection_ = parameters.
get<std::string>(
"input_collection");
27 input_pass_name_ = parameters.
get<std::string>(
"input_pass_name");
28 output_collection_ = parameters.
get<std::string>(
"output_collection");
29 sim_particles_coll_name_ =
30 parameters.
get<std::string>(
"sim_particles_coll_name");
31 sim_particles_passname_ =
32 parameters.
get<std::string>(
"sim_particles_passname");
35 maxts_ = parameters.
get<
int>(
"maxts");
36 toff_overall_ = parameters.
get<
double>(
"toff_overall");
37 input_pulse_shape_ = parameters.
get<std::string>(
"input_pulse_shape");
38 tdc_thr_ = parameters.
get<
double>(
"tdc_thr");
39 pedestal_ = parameters.
get<
double>(
"pedestal");
40 elec_noise_ = parameters.
get<
double>(
"elec_noise");
41 sipm_gain_ = parameters.
get<
double>(
"sipm_gain");
42 s_freq_ = parameters.
get<
double>(
"qie_sf");
43 zero_supp_cut_ = parameters.
get<
double>(
"zero_supp_in_pe");
45 if (input_pulse_shape_ ==
"Expo") {
46 pulse_params_.clear();
47 pulse_params_.push_back(parameters.
get<
double>(
"expo_k"));
48 pulse_params_.push_back(parameters.
get<
double>(
"expo_tmax"));
50 ldmx_log(debug) <<
"expo_k =" << pulse_params_[0];
51 ldmx_log(debug) <<
"expo_tmax =" << pulse_params_[1];
55 ldmx_log(debug) <<
"maxts_ =" << maxts_;
56 ldmx_log(debug) <<
"toff_overall_ =" << toff_overall_;
57 ldmx_log(debug) <<
"input_pulse_shape_ =" << input_pulse_shape_;
58 ldmx_log(debug) <<
"tdc_thr =" << tdc_thr_;
59 ldmx_log(debug) <<
"pedestal =" << pedestal_;
60 ldmx_log(debug) <<
"elec_noise =" << elec_noise_;
61 ldmx_log(debug) <<
"sipm_gain =" << sipm_gain_;
62 ldmx_log(debug) <<
"qie_sf =" << s_freq_;
63 ldmx_log(debug) <<
"zero_supp_in_pe =" << zero_supp_cut_;
64 ldmx_log(debug) <<
"pe_per_mip =" << pe_per_mip_;
65 ldmx_log(debug) <<
"mev_per_mip =" << mev_per_mip_;
70 if (!event.
exists(input_collection_, input_pass_name_)) {
71 ldmx_log(warn) <<
"No input collection " << input_collection_ <<
"_"
72 << input_pass_name_ <<
" found; skipping";
77 if (random_.get() ==
nullptr) {
78 const auto& rseed = getCondition<framework::RandomNumberSeedService>(
80 const auto& rseed2 = getCondition<framework::RandomNumberSeedService>(
83 random_ = std::make_unique<TRandom3>(rseed.getSeed(output_collection_));
87 smq_ =
new SimQIE(pedestal_, elec_noise_,
88 rseed2.getSeed(output_collection_ +
"SimQIE"));
90 smq_->setGain(sipm_gain_);
91 smq_->setFreq(s_freq_);
92 smq_->setNTimeSamples(maxts_);
93 smq_->setTDCThreshold(tdc_thr_);
98 std::vector<float> true_edep(strips_per_array_, 0.);
101 std::vector<float> beam_edep(strips_per_array_, 0.);
104 std::vector<Expo*> ex(strips_per_array_,
nullptr);
105 for (
int i = 0; i < strips_per_array_; i++) {
107 ex[i] =
new Expo(pulse_params_[0], pulse_params_[1]);
113 input_collection_, input_pass_name_)};
114 const bool has_sim_particles{
115 event.exists(sim_particles_coll_name_, sim_particles_passname_)};
116 if (!has_sim_particles) {
117 ldmx_log(debug) <<
"No " << sim_particles_coll_name_
118 <<
" found; beamEfrac set to -1";
120 const auto particle_map{
122 sim_particles_coll_name_, sim_particles_passname_)
123 : std::map<int, ldmx::SimParticle>{}};
125 for (
const auto& sim_hit : sim_hits) {
128 ldmx_log(debug) <<
"Processing sim hit with bar ID: " <<
id.bar();
131 for (
int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
132 const auto contrib{sim_hit.getContrib(i)};
133 const auto particle{particle_map.find(contrib.track_id_)};
134 if (particle == particle_map.end())
continue;
136 ldmx_log(trace) <<
"contrib " << i <<
" trackID: " << contrib.track_id_
137 <<
" pdgID: " << contrib.pdg_code_
138 <<
" edep: " << contrib.edep_;
139 ldmx_log(trace) <<
"\t particle id: " << particle->second.getPdgID()
140 <<
" particle status: "
141 << particle->second.getGenStatus();
143 if (particle->second.getPdgID() == 11 &&
144 particle->second.getGenStatus() == 1) {
145 beam_edep[
id.bar()] += contrib.edep_;
153 random_->Poisson(sim_hit.getEdep() / mev_per_mip_ * pe_per_mip_);
157 ex[
id.bar()]->addPulse(toff_overall_ + sim_hit.getTime(), pulse_amp);
160 true_edep[
id.bar()] += sim_hit.getEdep();
164 std::vector<trigscint::TrigScintQIEDigis> q_digis;
166 double total_noise = mean_noise_ * maxts_;
169 double sampling_time = 1000 / s_freq_;
172 for (
int bar_id = 0; bar_id < strips_per_array_; bar_id++) {
178 int n_noise_pulses = random_->Poisson(total_noise);
179 for (
int i = 0; i < n_noise_pulses; i++) {
180 ex[bar_id]->addPulse(random_->Uniform(0, maxts_ * sampling_time), 1);
184 if (smq_->pulseCut(ex[bar_id], zero_supp_cut_)) {
188 qie_info.
setADC(smq_->outAdc(ex[bar_id]));
189 qie_info.
setTDC(smq_->outTdc(ex[bar_id]));
190 qie_info.
setCID(smq_->capId(ex[bar_id]));
193 if (has_sim_particles) {
195 true_edep[bar_id] > 0 ? beam_edep[bar_id] / true_edep[bar_id] : 0.);
198 q_digis.push_back(qie_info);
201 event.add(output_collection_, q_digis);
Class representing a simulated particle.