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' }} diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index d90cf01b2b..b6a11a1ab1 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,18 +86,22 @@ 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); } } 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 = sim_hit.getEDep() * dd4hep::GeV / dd4hep::eV / raw_hit.getCharge(); + } + hitassoc.setWeight(weight); hitassoc.setRawHit(item.second); hitassoc.setSimHit(sim_hit); } diff --git a/src/algorithms/tracking/TrackerHitReconstruction.cc b/src/algorithms/tracking/TrackerHitReconstruction.cc index 2a4de11247..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() / 1.0e6), // 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); } }