18 const auto& hcalGeometry = getCondition<ldmx::HcalGeometry>(
21 const auto& conditions{
26 std::vector<ldmx::HcalHit> doubleHcalRecHits;
29 std::map<ldmx::HcalID, std::vector<ldmx::HcalHit>> hitsByID;
30 for (
auto const& hit : hcalRecHits) {
31 ldmx::HcalID id(hit.getSection(), hit.getLayer(), hit.getStrip());
33 auto idh = hitsByID.find(
id);
34 if (idh == hitsByID.end()) {
35 hitsByID[id] = std::vector<ldmx::HcalHit>(1, hit);
37 idh->second.push_back(hit);
44 std::map<ldmx::HcalID, std::pair<int, int>> indicesByID;
45 for (
auto const& hcalBar : hitsByID) {
46 auto id = hcalBar.first;
48 std::pair<int, int> indices(-1, -1);
50 while (iHit < hcalBar.second.size()) {
51 auto hit = hcalBar.second.at(iHit);
56 indices.second = iHit;
63 indicesByID[id] = indices;
67 for (
auto const& hcalBar : hitsByID) {
68 auto id = hcalBar.first;
71 auto position = hcalGeometry.getStripCenterPosition(
id);
72 const auto orientation{hcalGeometry.getScintillatorOrientation(
id)};
75 if (
id.section() != ldmx::HcalID::HcalSection::BACK)
continue;
78 auto hitPosEnd = hcalBar.second.at(indicesByID[
id].first);
79 auto hitNegEnd = hcalBar.second.at(indicesByID[
id].second);
83 hitPosEnd.getStrip(), hitPosEnd.getEnd());
85 hitNegEnd.getStrip(), hitNegEnd.getEnd());
86 double mean_shift = conditions.toaCalib(digi_id_neg.
raw(), 1);
88 double pos_time = hitPosEnd.getTime();
89 double neg_time = hitNegEnd.getTime();
90 if (pos_time != 0 || neg_time != 0) {
91 neg_time = neg_time - mean_shift;
97 double hitTimeDiff = pos_time - neg_time;
106 int position_bar_sign = hitTimeDiff > 0 ? 1 : -1;
107 double position_unchanged = 0;
109 double position_bar = position_bar_sign * fabs(hitTimeDiff) * v / 2;
111 ldmx::HcalGeometry::ScintillatorOrientation::horizontal) {
112 position_unchanged = position.X();
114 position.SetX(position_bar);
116 position_unchanged = position.Y();
118 position.SetY(position_bar);
125 [[maybe_unused]]
double hitTime =
126 (hitPosEnd.getTime() + hitNegEnd.getTime());
129 double num_mips_equivalent =
130 (hitPosEnd.getAmplitude() + hitNegEnd.getAmplitude());
131 double PEs = (hitPosEnd.getPE() + hitNegEnd.getPE());
132 double reconstructed_energy =
137 recHit.
setID(
id.raw());
145 recHit.
setMinPE(std::min(hitPosEnd.getPE(), hitNegEnd.getPE()));
153 recHit.
setTimeDiff(hitPosEnd.getTime() - hitNegEnd.getTime());
155 doubleHcalRecHits.push_back(recHit);