17void TrigScintQIEDigiProducer::configure(
20 strips_per_array_ = parameters.
get<
int>(
"number_of_strips");
22 mean_noise_ = parameters.
get<
double>(
"mean_noise");
23 mev_per_mip_ = parameters.
get<
double>(
"mev_per_mip");
24 pe_per_mip_ = parameters.
get<
double>(
"pe_per_mip");
25 input_collection_ = parameters.
get<std::string>(
"input_collection");
26 input_pass_name_ = parameters.
get<std::string>(
"input_pass_name");
27 output_collection_ = parameters.
get<std::string>(
"output_collection");
28 sim_particles_coll_name_ =
29 parameters.
get<std::string>(
"sim_particles_coll_name");
30 sim_particles_passname_ =
31 parameters.
get<std::string>(
"sim_particles_passname");
34 maxts_ = parameters.
get<
int>(
"maxts");
35 toff_overall_ = parameters.
get<
double>(
"toff_overall");
36 input_pulse_shape_ = parameters.
get<std::string>(
"input_pulse_shape");
37 tdc_thr_ = parameters.
get<
double>(
"tdc_thr");
38 pedestal_ = parameters.
get<
double>(
"pedestal");
39 elec_noise_ = parameters.
get<
double>(
"elec_noise");
40 sipm_gain_ = parameters.
get<
double>(
"sipm_gain");
41 s_freq_ = parameters.
get<
double>(
"qie_sf");
42 zero_supp_cut_ = parameters.
get<
double>(
"zero_supp_in_pe");
44 if (input_pulse_shape_ ==
"Expo") {
45 pulse_params_.clear();
46 pulse_params_.push_back(parameters.
get<
double>(
"expo_k"));
47 pulse_params_.push_back(parameters.
get<
double>(
"expo_tmax"));
49 ldmx_log(debug) <<
"expo_k =" << pulse_params_[0];
50 ldmx_log(debug) <<
"expo_tmax =" << pulse_params_[1];
54 ldmx_log(debug) <<
"maxts_ =" << maxts_;
55 ldmx_log(debug) <<
"toff_overall_ =" << toff_overall_;
56 ldmx_log(debug) <<
"input_pulse_shape_ =" << input_pulse_shape_;
57 ldmx_log(debug) <<
"tdc_thr =" << tdc_thr_;
58 ldmx_log(debug) <<
"pedestal =" << pedestal_;
59 ldmx_log(debug) <<
"elec_noise =" << elec_noise_;
60 ldmx_log(debug) <<
"sipm_gain =" << sipm_gain_;
61 ldmx_log(debug) <<
"qie_sf =" << s_freq_;
62 ldmx_log(debug) <<
"zero_supp_in_pe =" << zero_supp_cut_;
63 ldmx_log(debug) <<
"pe_per_mip =" << pe_per_mip_;
64 ldmx_log(debug) <<
"mev_per_mip =" << mev_per_mip_;
69 if (!event.
exists(input_collection_, input_pass_name_)) {
70 ldmx_log(warn) <<
"No input collection " << input_collection_ <<
"_"
71 << input_pass_name_ <<
" found; skipping";
76 if (random_.get() ==
nullptr) {
77 const auto& rseed = getCondition<framework::RandomNumberSeedService>(
79 const auto& rseed2 = getCondition<framework::RandomNumberSeedService>(
82 random_ = std::make_unique<TRandom3>(rseed.getSeed(output_collection_));
86 smq_ =
new SimQIE(pedestal_, elec_noise_,
87 rseed2.getSeed(output_collection_ +
"SimQIE"));
89 smq_->setGain(sipm_gain_);
90 smq_->setFreq(s_freq_);
91 smq_->setNTimeSamples(maxts_);
92 smq_->setTDCThreshold(tdc_thr_);
97 std::vector<float> true_edep(strips_per_array_, 0.);
100 std::vector<float> beam_edep(strips_per_array_, 0.);
103 std::vector<Expo*> ex(strips_per_array_,
nullptr);
104 for (
int i = 0; i < strips_per_array_; i++) {
106 ex[i] =
new Expo(pulse_params_[0], pulse_params_[1]);
112 input_collection_, input_pass_name_)};
113 const bool has_sim_particles{
114 event.exists(sim_particles_coll_name_, sim_particles_passname_)};
115 if (!has_sim_particles) {
116 ldmx_log(debug) <<
"No " << sim_particles_coll_name_
117 <<
" found; beamEfrac set to -1";
119 const auto particle_map{
121 sim_particles_coll_name_, sim_particles_passname_)
122 : std::map<int, ldmx::SimParticle>{}};
124 for (
const auto& sim_hit : sim_hits) {
127 ldmx_log(debug) <<
"Processing sim hit with bar ID: " <<
id.bar();
130 for (
int i = 0; i < sim_hit.getNumberOfContribs(); i++) {
131 const auto contrib{sim_hit.getContrib(i)};
132 const auto particle{particle_map.find(contrib.track_id_)};
133 if (particle == particle_map.end())
continue;
135 ldmx_log(trace) <<
"contrib " << i <<
" trackID: " << contrib.track_id_
136 <<
" pdgID: " << contrib.pdg_code_
137 <<
" edep: " << contrib.edep_;
138 ldmx_log(trace) <<
"\t particle id: " << particle->second.getPdgID()
139 <<
" particle status: "
140 << particle->second.getGenStatus();
142 if (particle->second.getPdgID() == 11 &&
143 particle->second.getGenStatus() == 1) {
144 beam_edep[
id.bar()] += contrib.edep_;
152 random_->Poisson(sim_hit.getEdep() / mev_per_mip_ * pe_per_mip_);
156 ex[
id.bar()]->addPulse(toff_overall_ + sim_hit.getTime(), pulse_amp);
159 true_edep[
id.bar()] += sim_hit.getEdep();
163 std::vector<trigscint::TrigScintQIEDigis> q_digis;
165 double total_noise = mean_noise_ * maxts_;
168 double sampling_time = 1000 / s_freq_;
171 for (
int bar_id = 0; bar_id < strips_per_array_; bar_id++) {
177 int n_noise_pulses = random_->Poisson(total_noise);
178 for (
int i = 0; i < n_noise_pulses; i++) {
179 ex[bar_id]->addPulse(random_->Uniform(0, maxts_ * sampling_time), 1);
183 if (smq_->pulseCut(ex[bar_id], zero_supp_cut_)) {
187 qie_info.
setADC(smq_->outAdc(ex[bar_id]));
188 qie_info.
setTDC(smq_->outTdc(ex[bar_id]));
189 qie_info.
setCID(smq_->capId(ex[bar_id]));
192 if (has_sim_particles) {
194 true_edep[bar_id] > 0 ? beam_edep[bar_id] / true_edep[bar_id] : 0.);
197 q_digis.push_back(qie_info);
200 event.add(output_collection_, q_digis);
Class representing a simulated particle.