From 5447a13ed762a81d0cb3b6a2793f016d76f51f9f Mon Sep 17 00:00:00 2001 From: ShujieL Date: Wed, 3 Sep 2025 00:26:18 -0700 Subject: [PATCH 1/5] fix the weight calculation in raw to sim hits association The weight was set to 1 manually regardless of how many sim hits on the same cell. This update should provide a rough but more correct weight. --- src/algorithms/digi/SiliconTrackerDigi.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index d90cf01b2b..6163ca1888 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -88,13 +88,17 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, } for (auto item : cell_hit_map) { - raw_hits->push_back(item.second); - + auto raw_hit=item.second; + raw_hits->push_back(raw_hit); for (const auto& sim_hit : *sim_hits) { if (item.first == sim_hit.getCellID()) { // set association auto hitassoc = associations->create(); - hitassoc.setWeight(1.0); + double weight = 0.0; + if (raw_hit.getCharge() > 0) { + weight = std::round((sim_hit.getEDep() * 1e6 / raw_hit.getCharge()) * 10.0) / 10.0; + } + hitassoc.setWeight(weight); hitassoc.setRawHit(item.second); hitassoc.setSimHit(sim_hit); } From 9789b95b1ec69c58d3c5d6dda033a1e41234b26c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 3 Sep 2025 07:27:19 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/digi/SiliconTrackerDigi.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 6163ca1888..2e4889ccf0 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -88,7 +88,7 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, } for (auto item : cell_hit_map) { - auto raw_hit=item.second; + auto raw_hit = item.second; raw_hits->push_back(raw_hit); for (const auto& sim_hit : *sim_hits) { if (item.first == sim_hit.getCellID()) { @@ -96,7 +96,7 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, auto hitassoc = associations->create(); double weight = 0.0; if (raw_hit.getCharge() > 0) { - weight = std::round((sim_hit.getEDep() * 1e6 / raw_hit.getCharge()) * 10.0) / 10.0; + weight = std::round((sim_hit.getEDep() * 1e6 / raw_hit.getCharge()) * 10.0) / 10.0; } hitassoc.setWeight(weight); hitassoc.setRawHit(item.second); From 351f392feaaa566c8b45ead86277a59b576a238d Mon Sep 17 00:00:00 2001 From: Shujie Li Date: Wed, 3 Sep 2025 22:22:32 -0700 Subject: [PATCH 3/5] use eV instead of keV for the charge in RawTrackerHit. --- src/algorithms/digi/SiliconTrackerDigi.cc | 11 +++++++---- src/algorithms/tracking/TrackerHitReconstruction.cc | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 2e4889ccf0..39b7470972 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -65,11 +65,14 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, debug(" edep is below threshold of {:.2f} [keV]", m_cfg.threshold / dd4hep::keV); continue; } - + // the charge in RawTrackerHit is defined as int32_t to mimic ADC value. + // because our energy threshold is often sub-keV, it's better to save charge as eV. + // allowed range of int32_t would be eV to ~2GeV which should be sufficient. + int32_t sim_hit_charge=sim_hit.getEDep() * dd4hep::GeV/dd4hep::eV; if (!cell_hit_map.contains(sim_hit.getCellID())) { // This cell doesn't have hits cell_hit_map[sim_hit.getCellID()] = { - sim_hit.getCellID(), (std::int32_t)std::llround(sim_hit.getEDep() * 1e6), + sim_hit.getCellID(), sim_hit_charge, hit_time_stamp // ns->ps }; } else { @@ -83,7 +86,7 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, // sum deposited energy auto charge = hit.getCharge(); - hit.setCharge(charge + (std::int32_t)std::llround(sim_hit.getEDep() * 1e6)); + hit.setCharge(charge + sim_hit_charge); } } @@ -96,7 +99,7 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, auto hitassoc = associations->create(); double weight = 0.0; if (raw_hit.getCharge() > 0) { - weight = std::round((sim_hit.getEDep() * 1e6 / raw_hit.getCharge()) * 10.0) / 10.0; + weight = sim_hit.getEDep() * dd4hep::GeV/dd4hep::eV / raw_hit.getCharge(); } hitassoc.setWeight(weight); hitassoc.setRawHit(item.second); diff --git a/src/algorithms/tracking/TrackerHitReconstruction.cc b/src/algorithms/tracking/TrackerHitReconstruction.cc index 2a4de11247..7481af5e23 100644 --- a/src/algorithms/tracking/TrackerHitReconstruction.cc +++ b/src/algorithms/tracking/TrackerHitReconstruction.cc @@ -68,7 +68,7 @@ void TrackerHitReconstruction::process(const Input& input, const Output& output) std::size(dim) > 2 ? get_variance(dim[2] / mm) : 0.}, static_cast((double)(raw_hit.getTimeStamp()) / 1000.0), // ns m_cfg.timeResolution, // in ns - static_cast(raw_hit.getCharge() / 1.0e6), // Collected energy (GeV) + static_cast(raw_hit.getCharge()* dd4hep::eV/dd4hep::GeV), // Collected energy (GeV) 0.0F); // Error on the energy rec_hit.setRawHit(raw_hit); } From f42f33378c63fdf6df96db7ecee73891d8270f50 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 4 Sep 2025 05:22:43 +0000 Subject: [PATCH 4/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/digi/SiliconTrackerDigi.cc | 6 +++--- src/algorithms/tracking/TrackerHitReconstruction.cc | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 39b7470972..b6a11a1ab1 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -65,10 +65,10 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, debug(" edep is below threshold of {:.2f} [keV]", m_cfg.threshold / dd4hep::keV); continue; } - // the charge in RawTrackerHit is defined as int32_t to mimic ADC value. + // the charge in RawTrackerHit is defined as int32_t to mimic ADC value. // because our energy threshold is often sub-keV, it's better to save charge as eV. // allowed range of int32_t would be eV to ~2GeV which should be sufficient. - int32_t sim_hit_charge=sim_hit.getEDep() * dd4hep::GeV/dd4hep::eV; + int32_t sim_hit_charge = sim_hit.getEDep() * dd4hep::GeV / dd4hep::eV; if (!cell_hit_map.contains(sim_hit.getCellID())) { // This cell doesn't have hits cell_hit_map[sim_hit.getCellID()] = { @@ -99,7 +99,7 @@ void SiliconTrackerDigi::process(const SiliconTrackerDigi::Input& input, auto hitassoc = associations->create(); double weight = 0.0; if (raw_hit.getCharge() > 0) { - weight = sim_hit.getEDep() * dd4hep::GeV/dd4hep::eV / raw_hit.getCharge(); + weight = sim_hit.getEDep() * dd4hep::GeV / dd4hep::eV / raw_hit.getCharge(); } hitassoc.setWeight(weight); hitassoc.setRawHit(item.second); diff --git a/src/algorithms/tracking/TrackerHitReconstruction.cc b/src/algorithms/tracking/TrackerHitReconstruction.cc index 7481af5e23..9fbd9d828c 100644 --- a/src/algorithms/tracking/TrackerHitReconstruction.cc +++ b/src/algorithms/tracking/TrackerHitReconstruction.cc @@ -68,8 +68,9 @@ void TrackerHitReconstruction::process(const Input& input, const Output& output) std::size(dim) > 2 ? get_variance(dim[2] / mm) : 0.}, static_cast((double)(raw_hit.getTimeStamp()) / 1000.0), // ns m_cfg.timeResolution, // in ns - static_cast(raw_hit.getCharge()* dd4hep::eV/dd4hep::GeV), // Collected energy (GeV) - 0.0F); // Error on the energy + static_cast(raw_hit.getCharge() * dd4hep::eV / + dd4hep::GeV), // Collected energy (GeV) + 0.0F); // Error on the energy rec_hit.setRawHit(raw_hit); } } From dbc31c519ac151e290a767b4a5f5f1c631444485 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Fri, 5 Sep 2025 13:53:07 -0500 Subject: [PATCH 5/5] ci: don't fail pragma once check when no headers changed --- .github/workflows/linux-eic-shell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index eea39e2489..89580a79e4 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -220,7 +220,7 @@ jobs: - name: Check for pragma once in changed files if: ${{ github.event_name == 'pull_request' }} run: | - missing_pragma_headers=$(git diff --name-only ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} | grep "\.h$" | xargs -n 1 grep -L 'pragma once') + missing_pragma_headers=$(git diff --name-only ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }} | grep "\.h$" | xargs -n 1 -r grep -L 'pragma once') test -z "${missing_pragma_headers}" - name: Check for pragma once in all files if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}