117 const auto& hcalGeometry = getCondition<ldmx::HcalGeometry>(
121 const auto& the_conditions{
124 std::vector<ldmx::HcalHit> hcalRecHits;
130 unsigned int iSOI = hcalDigis.getSampleOfInterestIndex();
134 while (iDigi < numDigiHits) {
135 auto digi_posend = hcalDigis.getDigi(iDigi);
142 auto position = hcalGeometry.getStripCenterPosition(
id);
143 double half_total_width =
144 hcalGeometry.getHalfTotalWidth(
id.section(),
id.layer());
145 double ecal_dx = hcalGeometry.getEcalDx();
146 double ecal_dy = hcalGeometry.getEcalDy();
152 float distance_posend, distance_negend, distance_ecal;
153 if (
id.section() == ldmx::HcalID::HcalSection::BACK) {
154 distance_posend = half_total_width;
155 distance_negend = half_total_width;
157 if ((
id.section() == ldmx::HcalID::HcalSection::TOP) ||
158 (
id.section() == ldmx::HcalID::HcalSection::BOTTOM))
159 distance_ecal = ecal_dx;
161 distance_ecal = ecal_dy;
162 distance_posend = 2 * half_total_width - distance_ecal / 2.;
163 distance_negend = distance_ecal / 2.;
168 double voltage_min(0.);
172 double amplT_posend(0.), amplTm1_posend(0.);
173 double amplT_negend(0.), amplTm1_negend(0.);
176 if (
id.section() == ldmx::HcalID::HcalSection::BACK) {
177 auto digi_negend = hcalDigis.getDigi(iDigi + 1);
180 double voltage_posend, voltage_negend;
181 if (digi_posend.isTOT()) {
183 (digi_posend.tot() - the_conditions.totCalib(id_posend, 0)) *
184 the_conditions.totCalib(id_posend, 1);
186 (digi_negend.tot() - the_conditions.totCalib(id_negend, 0)) *
187 the_conditions.totCalib(id_negend, 1);
190 digi_posend.soi().adc_t() - the_conditions.adcPedestal(id_posend);
192 digi_posend.soi().adc_tm1() - the_conditions.adcPedestal(id_posend);
194 digi_negend.soi().adc_t() - the_conditions.adcPedestal(id_negend);
196 digi_negend.soi().adc_tm1() - the_conditions.adcPedestal(id_negend);
207 voltage_posend = amplT_posend * the_conditions.adcGain(id_posend, 0);
208 voltage_negend = amplT_negend * the_conditions.adcGain(id_negend, 0);
213 getTOA(digi_posend, the_conditions.adcPedestal(id_posend), iSOI);
215 getTOA(digi_negend, the_conditions.adcPedestal(id_negend), iSOI);
218 int position_bar_sign = (TOA_posend - TOA_negend) > 0 ? 1 : -1;
233 double position_bar =
234 position_bar_sign * fabs(TOA_posend - TOA_negend) * v / 2;
242 exp(-1. * ((distance_posend - position_bar) / 1000.) /
attlength_);
244 exp(-1. * ((distance_negend + position_bar) / 1000.) /
attlength_);
247 voltage = (voltage_posend + voltage_negend);
248 voltage_min = std::min(voltage_posend, voltage_negend);
251 amplT = (amplT_posend / att_posend + amplT_negend / att_negend) / 2;
253 const auto orientation{hcalGeometry.getScintillatorOrientation(
id)};
256 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
257 position.SetX(position_bar);
259 position.SetY(position_bar);
265 hitTime = fabs(TOA_posend + TOA_negend) / 2;
272 if (digi_posend.isTOT()) {
281 voltage_i = (digi_posend.tot() - the_conditions.totCalib(id_posend)) *
282 the_conditions.totCalib(id_posend);
288 digi_posend.soi().adc_t() - the_conditions.adcPedestal(id_posend);
290 digi_posend.soi().adc_tm1() - the_conditions.adcPedestal(id_posend);
291 voltage_i = amplT_posend * the_conditions.adcGain(id_posend);
296 double distance_end =
297 id_posend.
isNegativeEnd() ? distance_negend : distance_posend;
298 double att = exp(-1. * ((distance_end - fabs(half_total_width)) / 1000.) /
303 voltage_min = voltage_i;
306 amplT = amplT_posend / att;
310 getTOA(digi_posend, the_conditions.adcPedestal(id_posend), iSOI);
322 double energy_deposited = num_mips_equivalent *
mip_energy_;
342 double reconstructed_energy = energy_deposited;
349 recHit.
setID(
id.raw());
361 hcalRecHits.push_back(recHit);
369 std::set<int> real_hits;
370 for (
auto const& sim_hit : hcalSimHits) real_hits.insert(sim_hit.getID());
371 for (
auto& hit : hcalRecHits)
372 hit.setNoise(real_hits.find(hit.getID()) == real_hits.end());