From cdda38ba18d9470907dd1c45b7c043184de1fb0d Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 2 Apr 2024 15:55:30 -0400 Subject: [PATCH 01/21] First draft of bucketing hits in time --- src/algorithms/digi/SiliconTrackerDigi.cc | 60 +++++++++++-------- .../digi/SiliconTrackerDigiConfig.h | 2 +- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index daefa12ee2..d8d25496bf 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -39,12 +39,12 @@ void SiliconTrackerDigi::process( auto [raw_hits] = output; // A map of unique cellIDs with temporary structure RawHit - std::unordered_map cell_hit_map; - + std::unordered_map> cell_hit_map; for (const auto& sim_hit : *sim_hits) { // time smearing + // TODO: remove or revisit smearing after time is properly bucketed instead double time_smearing = m_gauss(); double result_time = sim_hit.getTime() + time_smearing; auto hit_time_stamp = (std::int32_t) (result_time * 1e3); @@ -66,31 +66,43 @@ void SiliconTrackerDigi::process( continue; } - if (cell_hit_map.count(sim_hit.getCellID()) == 0) { - // This cell doesn't have hits - cell_hit_map[sim_hit.getCellID()] = { + bool bucket_found = false; + if (cell_hit_map.count(sim_hit.getCellID()) == 1) { + // Update an existing hit? + for (auto& hit : cell_hit_map[sim_hit.getCellID()]) { + auto existing_time = hit.getTimeStamp(); + // TODO: edge cases? + if ( hit_time_stamp >= existing_time && hit_time_stamp <= existing_time + m_cfg.timeResolution ) { + // There is already a hit within the same time window + m_log->debug(" Hit already exists in cell ID={}, within the same time bucket. Time stamp: {}, bucket from {} to {}", + sim_hit.getCellID(), hit.getTimeStamp(), existing_time, existing_time + m_cfg.timeResolution); + // sum deposited energy + auto charge = hit.getCharge(); + hit.setCharge(charge + (std::int32_t) std::llround(sim_hit.getEDep() * 1e6)); + bucket_found = true; + break; + } // time bucket found + } // loop over existing hits + } // cellID found + + if (!bucket_found) { + // There is no hit in the same time bucket + m_log->debug(" No pre-existing hit in cell ID={} in the same time bucket. Time stamp: {}", + sim_hit.getCellID(), sim_hit.getTime()); + cell_hit_map[sim_hit.getCellID()].push_back( + edm4eic::MutableRawTrackerHit{ sim_hit.getCellID(), (std::int32_t) std::llround(sim_hit.getEDep() * 1e6), - hit_time_stamp // ns->ps - }; - } else { - // There is previous values in the cell - auto& hit = cell_hit_map[sim_hit.getCellID()]; - m_log->debug(" Hit already exists in cell ID={}, prev. hit time: {}", sim_hit.getCellID(), hit.getTimeStamp()); - - // keep earliest time for hit - auto time_stamp = hit.getTimeStamp(); - hit.setTimeStamp(std::min(hit_time_stamp, hit.getTimeStamp())); - - // sum deposited energy - auto charge = hit.getCharge(); - hit.setCharge(charge + (std::int32_t) std::llround(sim_hit.getEDep() * 1e6)); - } - } - + hit_time_stamp // ns->ps <-- TODO: what does this comment mean?! + } ); + } // bucket found + } // loop over sim hits + for (auto item : cell_hit_map) { - raw_hits->push_back(item.second); + for (auto& hit : item.second) { + raw_hits->push_back(hit); + } } -} +} // process } // namespace eicrecon diff --git a/src/algorithms/digi/SiliconTrackerDigiConfig.h b/src/algorithms/digi/SiliconTrackerDigiConfig.h index fb66db252b..fa3d286570 100644 --- a/src/algorithms/digi/SiliconTrackerDigiConfig.h +++ b/src/algorithms/digi/SiliconTrackerDigiConfig.h @@ -11,7 +11,7 @@ namespace eicrecon { // sub-systems should overwrite their own // NB: be aware of thresholds in npsim! E.g. https://github.com/eic/npsim/pull/9/files double threshold = 0 * dd4hep::keV; - double timeResolution = 8; /// TODO 8 of what units??? Same TODO in juggler. Probably [ns] + double timeResolution = 8; /// same unit as sim_hit.getTime, probably [ns] }; } // eicrecon From cb882b9bef2bbe8ee1581aac1cc8488b117e2d70 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 20:02:12 +0000 Subject: [PATCH 02/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/digi/SiliconTrackerDigi.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index d8d25496bf..bc8e8e4fef 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -44,7 +44,7 @@ void SiliconTrackerDigi::process( for (const auto& sim_hit : *sim_hits) { // time smearing - // TODO: remove or revisit smearing after time is properly bucketed instead + // TODO: remove or revisit smearing after time is properly bucketed instead double time_smearing = m_gauss(); double result_time = sim_hit.getTime() + time_smearing; auto hit_time_stamp = (std::int32_t) (result_time * 1e3); @@ -87,9 +87,9 @@ void SiliconTrackerDigi::process( if (!bucket_found) { // There is no hit in the same time bucket - m_log->debug(" No pre-existing hit in cell ID={} in the same time bucket. Time stamp: {}", + m_log->debug(" No pre-existing hit in cell ID={} in the same time bucket. Time stamp: {}", sim_hit.getCellID(), sim_hit.getTime()); - cell_hit_map[sim_hit.getCellID()].push_back( + cell_hit_map[sim_hit.getCellID()].push_back( edm4eic::MutableRawTrackerHit{ sim_hit.getCellID(), (std::int32_t) std::llround(sim_hit.getEDep() * 1e6), @@ -97,7 +97,7 @@ void SiliconTrackerDigi::process( } ); } // bucket found } // loop over sim hits - + for (auto item : cell_hit_map) { for (auto& hit : item.second) { raw_hits->push_back(hit); From ddbcbca827c7496fa065a8c4408c5c0b8deb625f Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 2 Apr 2024 16:20:43 -0400 Subject: [PATCH 03/21] iwyu --- src/algorithms/digi/SiliconTrackerDigi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index bc8e8e4fef..10a40bdad6 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include From 7d9df30298a6b98bd104e2517cbfa960fcf9dbfa Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 2 Apr 2024 16:22:06 -0400 Subject: [PATCH 04/21] add .DS_STORE to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9161794416..ac4a6c34f4 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,8 @@ install/* *.out *.m_app +# Apple stuff +.DS_Store ##### i g n o r i n g I D E s ##### From eaa89ef9176fc8a5faf22890c5cc8433d94657f0 Mon Sep 17 00:00:00 2001 From: kkauder Date: Wed, 10 Apr 2024 10:34:43 -0400 Subject: [PATCH 05/21] Update src/algorithms/digi/SiliconTrackerDigi.cc Co-authored-by: Dmitry Kalinkin --- src/algorithms/digi/SiliconTrackerDigi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 10a40bdad6..02177b3ed0 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -93,7 +93,7 @@ void SiliconTrackerDigi::process( edm4eic::MutableRawTrackerHit{ sim_hit.getCellID(), (std::int32_t) std::llround(sim_hit.getEDep() * 1e6), - hit_time_stamp // ns->ps <-- TODO: what does this comment mean?! + hit_time_stamp } ); } // bucket found } // loop over sim hits From c35ce0b3e42f8b08ef66077d22ba7034bf283af3 Mon Sep 17 00:00:00 2001 From: kkauder Date: Wed, 10 Apr 2024 10:35:21 -0400 Subject: [PATCH 06/21] Update src/algorithms/digi/SiliconTrackerDigiConfig.h Co-authored-by: Dmitry Kalinkin --- src/algorithms/digi/SiliconTrackerDigiConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigiConfig.h b/src/algorithms/digi/SiliconTrackerDigiConfig.h index fa3d286570..db9336beaf 100644 --- a/src/algorithms/digi/SiliconTrackerDigiConfig.h +++ b/src/algorithms/digi/SiliconTrackerDigiConfig.h @@ -11,7 +11,7 @@ namespace eicrecon { // sub-systems should overwrite their own // NB: be aware of thresholds in npsim! E.g. https://github.com/eic/npsim/pull/9/files double threshold = 0 * dd4hep::keV; - double timeResolution = 8; /// same unit as sim_hit.getTime, probably [ns] + double timeResolution = 8 * edm4eic::unit::ns; }; } // eicrecon From dc11cb732348aca40cc0681f89c35860ed8f4638 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Wed, 10 Apr 2024 11:05:30 -0400 Subject: [PATCH 07/21] ignore vscode --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ac4a6c34f4..abe552d5b4 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,7 @@ install/* # The same to vscode .vscode/* +.vscode # CMake CLion style cmake-build-*/ From 077aabfa0e87c550d72415532af49daf695e5f58 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Wed, 10 Apr 2024 11:13:32 -0400 Subject: [PATCH 08/21] bugfix --- src/algorithms/digi/SiliconTrackerDigiConfig.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/algorithms/digi/SiliconTrackerDigiConfig.h b/src/algorithms/digi/SiliconTrackerDigiConfig.h index db9336beaf..169002fb43 100644 --- a/src/algorithms/digi/SiliconTrackerDigiConfig.h +++ b/src/algorithms/digi/SiliconTrackerDigiConfig.h @@ -4,6 +4,8 @@ #pragma once #include +#include + namespace eicrecon { From d0341050076bc3dccbcfa04507e7124a371be8cb Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Wed, 24 Apr 2024 15:43:38 +0200 Subject: [PATCH 09/21] Updated timeResolution values from digitization spreadsheet --- src/algorithms/digi/SiliconTrackerDigi.cc | 1 - .../digi/SiliconTrackerDigiConfig.h | 2 +- src/detectors/B0TRK/B0TRK.cc | 4 ++-- src/detectors/BTOF/BTOF.cc | 4 ++-- src/detectors/BTRK/BTRK.cc | 5 ++++- src/detectors/BVTX/BVTX.cc | 5 ++++- src/detectors/ECTOF/ECTOF.cc | 5 +++-- src/detectors/ECTRK/ECTRK.cc | 5 ++++- src/detectors/FOFFMTRK/FOFFMTRK.cc | 4 ++-- src/detectors/LOWQ2/LOWQ2.cc | 2 +- src/detectors/MPGD/MPGD.cc | 20 +++++++++---------- src/detectors/RPOTS/RPOTS.cc | 4 ++-- 12 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 02177b3ed0..8ac657b684 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -44,7 +44,6 @@ void SiliconTrackerDigi::process( for (const auto& sim_hit : *sim_hits) { // time smearing - // TODO: remove or revisit smearing after time is properly bucketed instead double time_smearing = m_gauss(); double result_time = sim_hit.getTime() + time_smearing; auto hit_time_stamp = (std::int32_t) (result_time * 1e3); diff --git a/src/algorithms/digi/SiliconTrackerDigiConfig.h b/src/algorithms/digi/SiliconTrackerDigiConfig.h index 169002fb43..d928df5095 100644 --- a/src/algorithms/digi/SiliconTrackerDigiConfig.h +++ b/src/algorithms/digi/SiliconTrackerDigiConfig.h @@ -13,7 +13,7 @@ namespace eicrecon { // sub-systems should overwrite their own // NB: be aware of thresholds in npsim! E.g. https://github.com/eic/npsim/pull/9/files double threshold = 0 * dd4hep::keV; - double timeResolution = 8 * edm4eic::unit::ns; + double timeResolution = 8 * edm4eic::unit::ns; // Source? This is arbitrary --> however, it should be >0, maybe large, to not distort the fitter by default }; } // eicrecon diff --git a/src/detectors/B0TRK/B0TRK.cc b/src/detectors/B0TRK/B0TRK.cc index a6f0473391..7468847d7e 100644 --- a/src/detectors/B0TRK/B0TRK.cc +++ b/src/detectors/B0TRK/B0TRK.cc @@ -25,7 +25,7 @@ void InitPlugin(JApplication *app) { {"B0TrackerRawHits"}, { .threshold = 10.0 * dd4hep::keV, - .timeResolution = 8, + .timeResolution = 0.015 * dd4hep::ns, }, app )); @@ -36,7 +36,7 @@ void InitPlugin(JApplication *app) { {"B0TrackerRawHits"}, {"B0TrackerRecHits"}, { - .timeResolution = 8, + .timeResolution = 0.015 * dd4hep::ns, }, app )); diff --git a/src/detectors/BTOF/BTOF.cc b/src/detectors/BTOF/BTOF.cc index 113912c8c8..80f0b0ebab 100644 --- a/src/detectors/BTOF/BTOF.cc +++ b/src/detectors/BTOF/BTOF.cc @@ -25,7 +25,7 @@ void InitPlugin(JApplication *app) { {"TOFBarrelRawHit"}, { .threshold = 6.0 * dd4hep::keV, - .timeResolution = 0.025, // [ns] + .timeResolution = 0.02 * dd4hep::ns, }, app )); @@ -36,7 +36,7 @@ void InitPlugin(JApplication *app) { {"TOFBarrelRawHit"}, // Input data collection tags {"TOFBarrelRecHit"}, // Output data tag { - .timeResolution = 10, + .timeResolution = 0.02 * dd4hep::ns, }, app )); // Hit reco default config for factories diff --git a/src/detectors/BTRK/BTRK.cc b/src/detectors/BTRK/BTRK.cc index 18693f5c81..1f6e18e903 100644 --- a/src/detectors/BTRK/BTRK.cc +++ b/src/detectors/BTRK/BTRK.cc @@ -25,6 +25,7 @@ void InitPlugin(JApplication *app) { {"SiBarrelRawHits"}, { .threshold = 0.54 * dd4hep::keV, + .timeResolution = 2000 * dd4hep::ns, }, app )); @@ -35,7 +36,9 @@ void InitPlugin(JApplication *app) { "SiBarrelTrackerRecHits", {"SiBarrelRawHits"}, {"SiBarrelTrackerRecHits"}, - {}, // default config + { + .timeResolution = 2000 * dd4hep::ns, + }, app )); diff --git a/src/detectors/BVTX/BVTX.cc b/src/detectors/BVTX/BVTX.cc index 4c60d8d240..78d9f59edf 100644 --- a/src/detectors/BVTX/BVTX.cc +++ b/src/detectors/BVTX/BVTX.cc @@ -25,6 +25,7 @@ void InitPlugin(JApplication *app) { {"SiBarrelVertexRawHits"}, { .threshold = 0.54 * dd4hep::keV, + .timeResolution = 2000 * dd4hep::ns, }, app )); @@ -34,7 +35,9 @@ void InitPlugin(JApplication *app) { "SiBarrelVertexRecHits", {"SiBarrelVertexRawHits"}, {"SiBarrelVertexRecHits"}, - {}, // default config + { + .timeResolution = 2000 * dd4hep::ns, + }, app )); diff --git a/src/detectors/ECTOF/ECTOF.cc b/src/detectors/ECTOF/ECTOF.cc index e26a1caf63..6189af957f 100644 --- a/src/detectors/ECTOF/ECTOF.cc +++ b/src/detectors/ECTOF/ECTOF.cc @@ -25,7 +25,8 @@ void InitPlugin(JApplication *app) { {"TOFEndcapRawHits"}, { .threshold = 6.0 * dd4hep::keV, - .timeResolution = 0.025, + .timeResolution = 0.02 * dd4hep::ns, + }, app )); @@ -36,7 +37,7 @@ void InitPlugin(JApplication *app) { {"TOFEndcapRawHits"}, // Input data collection tags {"TOFEndcapRecHits"}, // Output data tag { - .timeResolution = 0.025, + .timeResolution = 0.02 * dd4hep::ns, }, app )); diff --git a/src/detectors/ECTRK/ECTRK.cc b/src/detectors/ECTRK/ECTRK.cc index 621e665c53..58f575c6b0 100644 --- a/src/detectors/ECTRK/ECTRK.cc +++ b/src/detectors/ECTRK/ECTRK.cc @@ -25,6 +25,7 @@ void InitPlugin(JApplication *app) { {"SiEndcapTrackerRawHits"}, { .threshold = 0.54 * dd4hep::keV, + .timeResolution = 2000 * dd4hep::ns, }, app )); @@ -34,7 +35,9 @@ void InitPlugin(JApplication *app) { "SiEndcapTrackerRecHits", {"SiEndcapTrackerRawHits"}, {"SiEndcapTrackerRecHits"}, - {}, // default config + { + .timeResolution = 2000 * dd4hep::ns, + }, app )); diff --git a/src/detectors/FOFFMTRK/FOFFMTRK.cc b/src/detectors/FOFFMTRK/FOFFMTRK.cc index 4fea2aa927..d3aed24d83 100644 --- a/src/detectors/FOFFMTRK/FOFFMTRK.cc +++ b/src/detectors/FOFFMTRK/FOFFMTRK.cc @@ -28,7 +28,7 @@ void InitPlugin(JApplication *app) { {"ForwardOffMTrackerRawHits"}, { .threshold = 10.0 * dd4hep::keV, - .timeResolution = 8, + .timeResolution = 0.015 * dd4hep::ns, }, app )); @@ -38,7 +38,7 @@ void InitPlugin(JApplication *app) { {"ForwardOffMTrackerRawHits"}, {"ForwardOffMTrackerRecHits"}, { - .timeResolution = 8, + .timeResolution = 0.015 * dd4hep::ns, }, app )); diff --git a/src/detectors/LOWQ2/LOWQ2.cc b/src/detectors/LOWQ2/LOWQ2.cc index 361b780d5f..8027276cee 100644 --- a/src/detectors/LOWQ2/LOWQ2.cc +++ b/src/detectors/LOWQ2/LOWQ2.cc @@ -31,7 +31,7 @@ extern "C" { {"TaggerTrackerRawHits"}, { .threshold = 1.5 * dd4hep::keV, - .timeResolution = 2 * dd4hep::ns, + .timeResolution = 0.195 * dd4hep::ns, }, app )); diff --git a/src/detectors/MPGD/MPGD.cc b/src/detectors/MPGD/MPGD.cc index 8cb695596c..b252d16d13 100644 --- a/src/detectors/MPGD/MPGD.cc +++ b/src/detectors/MPGD/MPGD.cc @@ -25,7 +25,7 @@ void InitPlugin(JApplication *app) { {"MPGDBarrelRawHits"}, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -36,7 +36,7 @@ void InitPlugin(JApplication *app) { {"MPGDBarrelRawHits"}, // Input data collection tags {"MPGDBarrelRecHits"}, // Output data tag { - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -48,7 +48,7 @@ void InitPlugin(JApplication *app) { {"MPGDDIRCRawHits"}, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 10, + .timeResolution = 10, // no information in the digitization spreadsheet! }, app )); @@ -59,7 +59,7 @@ void InitPlugin(JApplication *app) { {"MPGDDIRCRawHits"}, // Input data collection tags {"MPGDDIRCRecHits"}, // Output data tag { - .timeResolution = 10, + .timeResolution = 10, // no information in the digitization spreadsheet! }, app )); @@ -72,7 +72,7 @@ void InitPlugin(JApplication *app) { {"OuterMPGDBarrelRawHits"}, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -83,7 +83,7 @@ void InitPlugin(JApplication *app) { {"OuterMPGDBarrelRawHits"}, // Input data collection tags {"OuterMPGDBarrelRecHits"}, // Output data tag { - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -95,7 +95,7 @@ void InitPlugin(JApplication *app) { {"BackwardMPGDEndcapRawHits"}, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -106,7 +106,7 @@ void InitPlugin(JApplication *app) { {"BackwardMPGDEndcapRawHits"}, // Input data collection tags {"BackwardMPGDEndcapRecHits"}, // Output data tag { - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -118,7 +118,7 @@ void InitPlugin(JApplication *app) { {"ForwardMPGDEndcapRawHits"}, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); @@ -129,7 +129,7 @@ void InitPlugin(JApplication *app) { {"ForwardMPGDEndcapRawHits"}, // Input data collection tags {"ForwardMPGDEndcapRecHits"}, // Output data tag { - .timeResolution = 10, + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); diff --git a/src/detectors/RPOTS/RPOTS.cc b/src/detectors/RPOTS/RPOTS.cc index 89c85215af..bad6f71876 100644 --- a/src/detectors/RPOTS/RPOTS.cc +++ b/src/detectors/RPOTS/RPOTS.cc @@ -28,7 +28,7 @@ void InitPlugin(JApplication *app) { {"ForwardRomanPotRawHits"}, { .threshold = 10.0 * dd4hep::keV, - .timeResolution = 8, + .timeResolution = 0.015 * dd4hep::ns, }, app )); @@ -38,7 +38,7 @@ void InitPlugin(JApplication *app) { {"ForwardRomanPotRawHits"}, {"ForwardRomanPotRecHits"}, { - .timeResolution = 8, + .timeResolution = 0.015 * dd4hep::ns, }, app )); From 680eca540c5fac87fdada2bba6ee0c0cf335f3c0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 2 May 2024 18:38:58 +0000 Subject: [PATCH 10/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/digi/SiliconTrackerDigi.cc | 2 +- src/detectors/BVTX/BVTX.cc | 2 +- src/detectors/MPGD/MPGD.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 0b3f2fe485..78a8181baa 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -122,7 +122,7 @@ void SiliconTrackerDigi::process( } //hits } // cell_hit_map - + } // process } // namespace eicrecon diff --git a/src/detectors/BVTX/BVTX.cc b/src/detectors/BVTX/BVTX.cc index 12a7e09ea1..fa6cb42147 100644 --- a/src/detectors/BVTX/BVTX.cc +++ b/src/detectors/BVTX/BVTX.cc @@ -42,7 +42,7 @@ void InitPlugin(JApplication *app) { {"SiBarrelVertexRecHits"}, { .timeResolution = 2000 * dd4hep::ns, - }, + }, app )); diff --git a/src/detectors/MPGD/MPGD.cc b/src/detectors/MPGD/MPGD.cc index fe3ba83090..6393ebb513 100644 --- a/src/detectors/MPGD/MPGD.cc +++ b/src/detectors/MPGD/MPGD.cc @@ -30,7 +30,7 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) }, app )); From 21178292ebfe9af0a9b2fc26afb293cd4d2d2897 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Thu, 2 May 2024 15:21:13 -0400 Subject: [PATCH 11/21] Allow prepopulation of cellhitMap for MAPS --- src/algorithms/digi/SiliconTrackerDigi.cc | 27 ++++++++++++++++--- .../digi/SiliconTrackerDigiConfig.h | 3 ++- src/detectors/BTRK/BTRK.cc | 1 + src/detectors/BVTX/BVTX.cc | 1 + src/detectors/ECTRK/ECTRK.cc | 1 + 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 0b3f2fe485..2191325f4b 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -44,9 +44,29 @@ void SiliconTrackerDigi::process( auto hit_time_stamp_err = (std::int32_t) (m_cfg.timeResolution * 1e3); + // Some detectors have a steady pulse of hits - generate empty time buckets for those + // Conundrum: We can't know the number of buckets without knowing the timeSlice length + // Assuming this is only used for MAPS, and that the time slice length is <= 1ms, + // we need at most 1ms / 2000ns = 500 buckets + // Let's use 1000, and pad with over and underflow to allow smearing out of range + if ( m_cfg.prepopulate ) { + for (auto cell : cell_hit_map) { + auto& hits = cell.second; + for (int i = -1; i <= 1001; i++) { + hits.push_back( + edm4eic::MutableRawTrackerHit{ + cell.first, + 0, + 0 + } ); + } + } + } for (const auto& sim_hit : *sim_hits) { // time smearing + // Note: In the current setup, we can have hits outside the time slice + // Up to the analyzer to decide what to do with them double time_smearing = m_gauss(); double result_time = sim_hit.getTime() + time_smearing; auto hit_time_stamp = (std::int32_t) (result_time * 1e3); @@ -91,7 +111,6 @@ void SiliconTrackerDigi::process( m_log->debug(" No pre-existing hit in cell ID={} in the same time bucket. Time stamp: {}", sim_hit.getCellID(), sim_hit.getTime()); - // Create a new hit cell_hit_map[sim_hit.getCellID()].push_back( edm4eic::MutableRawTrackerHit{ @@ -102,12 +121,12 @@ void SiliconTrackerDigi::process( } // bucket found } // loop over sim hits - for (auto item : cell_hit_map) { - for (auto& hit : item.second) { + for (auto cell : cell_hit_map) { + for (auto& hit : cell.second) { raw_hits->push_back(hit); for (const auto& sim_hit : *sim_hits) { - if (item.first == sim_hit.getCellID()) { + if (cell.first == sim_hit.getCellID()) { // set association auto hitassoc = associations->create(); hitassoc.setWeight(1.0); diff --git a/src/algorithms/digi/SiliconTrackerDigiConfig.h b/src/algorithms/digi/SiliconTrackerDigiConfig.h index d928df5095..6a6630cd96 100644 --- a/src/algorithms/digi/SiliconTrackerDigiConfig.h +++ b/src/algorithms/digi/SiliconTrackerDigiConfig.h @@ -13,7 +13,8 @@ namespace eicrecon { // sub-systems should overwrite their own // NB: be aware of thresholds in npsim! E.g. https://github.com/eic/npsim/pull/9/files double threshold = 0 * dd4hep::keV; - double timeResolution = 8 * edm4eic::unit::ns; // Source? This is arbitrary --> however, it should be >0, maybe large, to not distort the fitter by default + double timeResolution = 2000 * edm4eic::unit::ns; // Source for 8? This is arbitrary --> however, it should be >0, maybe large, to not distort the fitter by default. Choosing 2us for now. + bool prepopulate = false; // prepopulate cellHit map with empty hits, for MAPS }; } // eicrecon diff --git a/src/detectors/BTRK/BTRK.cc b/src/detectors/BTRK/BTRK.cc index dc9159c5b9..f0d054ba31 100644 --- a/src/detectors/BTRK/BTRK.cc +++ b/src/detectors/BTRK/BTRK.cc @@ -31,6 +31,7 @@ void InitPlugin(JApplication *app) { { .threshold = 0.54 * dd4hep::keV, .timeResolution = 2000 * dd4hep::ns, + .prepopulate = true, // for MAPS, initialize digitization with a "pulse" of empty hits }, app )); diff --git a/src/detectors/BVTX/BVTX.cc b/src/detectors/BVTX/BVTX.cc index 12a7e09ea1..f5ce5d6d2f 100644 --- a/src/detectors/BVTX/BVTX.cc +++ b/src/detectors/BVTX/BVTX.cc @@ -31,6 +31,7 @@ void InitPlugin(JApplication *app) { { .threshold = 0.54 * dd4hep::keV, .timeResolution = 2000 * dd4hep::ns, + .prepopulate = true, // for MAPS, initialize digitization with a "pulse" of empty hits }, app )); diff --git a/src/detectors/ECTRK/ECTRK.cc b/src/detectors/ECTRK/ECTRK.cc index 36feb881da..893446dccf 100644 --- a/src/detectors/ECTRK/ECTRK.cc +++ b/src/detectors/ECTRK/ECTRK.cc @@ -31,6 +31,7 @@ void InitPlugin(JApplication *app) { { .threshold = 0.54 * dd4hep::keV, .timeResolution = 2000 * dd4hep::ns, + .prepopulate = true, // for MAPS, initialize digitization with a "pulse" of empty hits }, app )); From 27d2ae6e933931e3dfa418cbed5d42266a6c8fc5 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 7 May 2024 08:45:07 -0400 Subject: [PATCH 12/21] use uncertainty = resolution/2; TODO text added --- src/algorithms/digi/SiliconTrackerDigi.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 4d0141377a..77e9a59156 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -93,7 +93,7 @@ void SiliconTrackerDigi::process( for (auto& hit : cell_hit_map[sim_hit.getCellID()]) { auto existing_time = hit.getTimeStamp(); // TODO: edge cases? - if ( hit_time_stamp >= existing_time - hit_time_stamp_err && hit_time_stamp <= existing_time + hit_time_stamp_err ) { + if ( hit_time_stamp >= existing_time - 0.5*hit_time_stamp_err && hit_time_stamp <= existing_time + 0.5*hit_time_stamp_err ) { // There is already a hit within the same time window m_log->debug(" Hit already exists in cell ID={}, within the same time bucket. Time stamp: {}, bucket from {} to {}", sim_hit.getCellID(), hit.getTimeStamp(), existing_time - hit_time_stamp_err, existing_time + hit_time_stamp_err); @@ -112,6 +112,13 @@ void SiliconTrackerDigi::process( sim_hit.getCellID(), sim_hit.getTime()); // Create a new hit + // Note: time uncertainty in the TrackerHitReconstruction is set independently + // It would probably be better to move it into the RawTrackerHit class + // (same for spatial uncertainty, actually) + // Note 2: It's possible to not fall into a bucket but still be close enough to one or + // more that uncertainties overlap. Cannot be avoided in the current setup. + // It could lead to ambiguity which bucket is chosen for a third hit in this area. + // In reality, this is probably more like dead time; revisit later. cell_hit_map[sim_hit.getCellID()].push_back( edm4eic::MutableRawTrackerHit{ sim_hit.getCellID(), From 49d4ee47d0a7a0185a18d8fa00a198c29f469291 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 May 2024 12:45:20 +0000 Subject: [PATCH 13/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/digi/SiliconTrackerDigi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 77e9a59156..c58f5321fd 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -115,7 +115,7 @@ void SiliconTrackerDigi::process( // Note: time uncertainty in the TrackerHitReconstruction is set independently // It would probably be better to move it into the RawTrackerHit class // (same for spatial uncertainty, actually) - // Note 2: It's possible to not fall into a bucket but still be close enough to one or + // Note 2: It's possible to not fall into a bucket but still be close enough to one or // more that uncertainties overlap. Cannot be avoided in the current setup. // It could lead to ambiguity which bucket is chosen for a third hit in this area. // In reality, this is probably more like dead time; revisit later. From 6267e03fee2fe7785912d5de9834cdc436976ea6 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Fri, 17 May 2024 12:03:42 -0400 Subject: [PATCH 14/21] Added integration window, updated time resolution for silicon hits --- src/detectors/B0TRK/B0TRK.cc | 7 +++++-- src/detectors/BTOF/BTOF.cc | 7 +++++-- src/detectors/BTRK/BTRK.cc | 7 +++++-- src/detectors/BVTX/BVTX.cc | 7 +++++-- src/detectors/ECTOF/ECTOF.cc | 7 +++++-- src/detectors/ECTRK/ECTRK.cc | 7 +++++-- src/detectors/FOFFMTRK/FOFFMTRK.cc | 7 +++++-- src/detectors/LOWQ2/LOWQ2.cc | 13 ++++++++----- src/detectors/MPGD/MPGD.cc | 28 ++++++++++++++++++++-------- src/detectors/RPOTS/RPOTS.cc | 13 ++++++++----- 10 files changed, 71 insertions(+), 32 deletions(-) diff --git a/src/detectors/B0TRK/B0TRK.cc b/src/detectors/B0TRK/B0TRK.cc index 464ad081ca..9a57681357 100644 --- a/src/detectors/B0TRK/B0TRK.cc +++ b/src/detectors/B0TRK/B0TRK.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto B0TrackerTimeResolution = 0.02 * dd4hep::ns; // 15-20 ps + auto B0TrackerIntegrationWindow = 0.750 * dd4hep::ns; // 750 ps shaping time app->Add(new JOmniFactoryGeneratorT( "B0TrackerRawHits", { @@ -30,7 +32,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 10.0 * dd4hep::keV, - .timeResolution = 0.015 * dd4hep::ns, + .timeResolution = B0TrackerTimeResolution, + .integrationWindow = B0TrackerIntegrationWindow, }, app )); @@ -41,7 +44,7 @@ void InitPlugin(JApplication *app) { {"B0TrackerRawHits"}, {"B0TrackerRecHits"}, { - .timeResolution = 0.015 * dd4hep::ns, + .timeResolution = B0TrackerTimeResolution, }, app )); diff --git a/src/detectors/BTOF/BTOF.cc b/src/detectors/BTOF/BTOF.cc index 2fd687a85e..d4c09238d8 100644 --- a/src/detectors/BTOF/BTOF.cc +++ b/src/detectors/BTOF/BTOF.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto BTOFBarrelTimeResolution = 0.02 * dd4hep::ns; // 20 ps bin width + auto BTOFBarrelIntegrationWindow = 5.0 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "TOFBarrelRawHit", { @@ -30,7 +32,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 6.0 * dd4hep::keV, - .timeResolution = 0.02 * dd4hep::ns, + .timeResolution = BTOFBarrelTimeResolution, + .integrationWindow = BTOFBarrelIntegrationWindow, }, app )); @@ -41,7 +44,7 @@ void InitPlugin(JApplication *app) { {"TOFBarrelRawHit"}, // Input data collection tags {"TOFBarrelRecHit"}, // Output data tag { - .timeResolution = 0.02 * dd4hep::ns, + .timeResolution = BTOFBarrelTimeResolution, }, app )); // Hit reco default config for factories diff --git a/src/detectors/BTRK/BTRK.cc b/src/detectors/BTRK/BTRK.cc index f0d054ba31..b1bd0e377a 100644 --- a/src/detectors/BTRK/BTRK.cc +++ b/src/detectors/BTRK/BTRK.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto BTRKBarrelTimeResolution = 2000 * dd4hep::ns; + auto BTRKBarrelIntegrationWindow = 2000 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "SiBarrelRawHits", { @@ -30,7 +32,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.54 * dd4hep::keV, - .timeResolution = 2000 * dd4hep::ns, + .timeResolution = BTRKBarrelTimeResolution, + .integrationWindow = BTRKBarrelIntegrationWindow, .prepopulate = true, // for MAPS, initialize digitization with a "pulse" of empty hits }, app @@ -43,7 +46,7 @@ void InitPlugin(JApplication *app) { {"SiBarrelRawHits"}, {"SiBarrelTrackerRecHits"}, { - .timeResolution = 2000 * dd4hep::ns, + .timeResolution = BTRKBarrelTimeResolution, }, app )); diff --git a/src/detectors/BVTX/BVTX.cc b/src/detectors/BVTX/BVTX.cc index b7ca9d7bb4..e05c4d8e9f 100644 --- a/src/detectors/BVTX/BVTX.cc +++ b/src/detectors/BVTX/BVTX.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto SiBarrelVertexTimeResolution = 2000 * dd4hep::ns; + auto SiBarrelVertexIntegrationWindow = 2000 * dd4hep::ns; app->Add(new JOmniFactoryGeneratorT( "SiBarrelVertexRawHits", { @@ -30,7 +32,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.54 * dd4hep::keV, - .timeResolution = 2000 * dd4hep::ns, + .timeResolution = SiBarrelVertexTimeResolution, + .integrationWindow = SiBarrelVertexIntegrationWindow, .prepopulate = true, // for MAPS, initialize digitization with a "pulse" of empty hits }, app @@ -42,7 +45,7 @@ void InitPlugin(JApplication *app) { {"SiBarrelVertexRawHits"}, {"SiBarrelVertexRecHits"}, { - .timeResolution = 2000 * dd4hep::ns, + .timeResolution = SiBarrelVertexTimeResolution, }, app )); diff --git a/src/detectors/ECTOF/ECTOF.cc b/src/detectors/ECTOF/ECTOF.cc index aee4a41152..ec776393cf 100644 --- a/src/detectors/ECTOF/ECTOF.cc +++ b/src/detectors/ECTOF/ECTOF.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto TOFEndcapTimeResolution = 20.0 * dd4hep::ns; // 20 ps bin width + auto TOFEndcapIntegrationWindow = 5.0 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "TOFEndcapRawHits", { @@ -29,7 +31,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 6.0 * dd4hep::keV, - .timeResolution = 0.02 * dd4hep::ns, + .timeResolution = TOFEndcapTimeResolution, + .integrationWindow = TOFEndcapIntegrationWindow, }, app @@ -41,7 +44,7 @@ void InitPlugin(JApplication *app) { {"TOFEndcapRawHits"}, // Input data collection tags {"TOFEndcapRecHits"}, // Output data tag { - .timeResolution = 0.02 * dd4hep::ns, + .timeResolution = TOFEndcapTimeResolution, }, app )); diff --git a/src/detectors/ECTRK/ECTRK.cc b/src/detectors/ECTRK/ECTRK.cc index 893446dccf..225e65f8f9 100644 --- a/src/detectors/ECTRK/ECTRK.cc +++ b/src/detectors/ECTRK/ECTRK.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto SiEndcapTrackerTimeResolution = 2000. * dd4hep::ns; + auto SiEndcapTrackerIntegrationWindow = 2000. * dd4hep::ns; app->Add(new JOmniFactoryGeneratorT( "SiEndcapTrackerRawHits", { @@ -30,7 +32,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.54 * dd4hep::keV, - .timeResolution = 2000 * dd4hep::ns, + .timeResolution = SiEndcapTrackerTimeResolution, + .integrationWindow = SiEndcapTrackerIntegrationWindow, .prepopulate = true, // for MAPS, initialize digitization with a "pulse" of empty hits }, app @@ -42,7 +45,7 @@ void InitPlugin(JApplication *app) { {"SiEndcapTrackerRawHits"}, {"SiEndcapTrackerRecHits"}, { - .timeResolution = 2000 * dd4hep::ns, + .timeResolution = SiEndcapTrackerTimeResolution, }, app )); diff --git a/src/detectors/FOFFMTRK/FOFFMTRK.cc b/src/detectors/FOFFMTRK/FOFFMTRK.cc index 68a84a0293..7b0c7ab505 100644 --- a/src/detectors/FOFFMTRK/FOFFMTRK.cc +++ b/src/detectors/FOFFMTRK/FOFFMTRK.cc @@ -22,6 +22,8 @@ void InitPlugin(JApplication *app) { MatrixTransferStaticConfig recon_cfg; //Digitized hits, especially for thresholds + auto ForwardOffMTrackerTimeResolution = 0.015 * dd4hep::ns; // 15-20 ps + auto ForwardOffMTrackerIntegrationWindow = 0.750 * dd4hep::ns; // 750 ps shaping time app->Add(new JOmniFactoryGeneratorT( "ForwardOffMTrackerRawHits", { @@ -33,7 +35,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 10.0 * dd4hep::keV, - .timeResolution = 0.015 * dd4hep::ns, + .timeResolution = ForwardOffMTrackerTimeResolution, + .integrationWindow = ForwardOffMTrackerIntegrationWindow, }, app )); @@ -43,7 +46,7 @@ void InitPlugin(JApplication *app) { {"ForwardOffMTrackerRawHits"}, {"ForwardOffMTrackerRecHits"}, { - .timeResolution = 0.015 * dd4hep::ns, + .timeResolution = ForwardOffMTrackerTimeResolution, }, app )); diff --git a/src/detectors/LOWQ2/LOWQ2.cc b/src/detectors/LOWQ2/LOWQ2.cc index e539c3d4f2..d679cd3640 100644 --- a/src/detectors/LOWQ2/LOWQ2.cc +++ b/src/detectors/LOWQ2/LOWQ2.cc @@ -28,18 +28,21 @@ extern "C" { using namespace eicrecon; // Digitization of silicon hits + auto TaggerTrackerTimeResolution = 0.195 * dd4hep::ns; + auto TaggerTrackerIntegrationWindow = 5.0 * dd4hep::ns; app->Add(new JOmniFactoryGeneratorT( "TaggerTrackerRawHits", { - "TaggerTrackerHits" + "TaggerTrackerHits" }, { - "TaggerTrackerRawHits", - "TaggerTrackerHitAssociations" + "TaggerTrackerRawHits", + "TaggerTrackerHitAssociations" }, { - .threshold = 1.5 * dd4hep::keV, - .timeResolution = 0.195 * dd4hep::ns, + .threshold = 1.5 * dd4hep::keV, + .timeResolution = TaggerTrackerTimeResolution, + .integrationWindow = TaggerTrackerIntegrationWindow, }, app )); diff --git a/src/detectors/MPGD/MPGD.cc b/src/detectors/MPGD/MPGD.cc index 6393ebb513..df119f1be2 100644 --- a/src/detectors/MPGD/MPGD.cc +++ b/src/detectors/MPGD/MPGD.cc @@ -19,6 +19,8 @@ void InitPlugin(JApplication *app) { using namespace eicrecon; // Digitization + auto MPGDBarrelTimeResolution = 20.0 * dd4hep::ns; // 1 / (50 MHz) + auto MPGDBarrelIntegrationWindow = 500.0 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "MPGDBarrelRawHits", { @@ -30,7 +32,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = MPGDBarrelTimeResolution, + .integrationWindow = MPGDBarrelIntegrationWindow, }, app )); @@ -41,12 +44,14 @@ void InitPlugin(JApplication *app) { {"MPGDBarrelRawHits"}, // Input data collection tags {"MPGDBarrelRecHits"}, // Output data tag { - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = MPGDBarrelTimeResolution, }, app )); // Digitization + auto OuterMPGDBarrelTimeResolution = 20.0 * dd4hep::ns; // 1 / (50 MHz) + auto OuterMPGDBarrelIntegrationWindow = 500.0 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "OuterMPGDBarrelRawHits", { @@ -58,7 +63,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = OuterMPGDBarrelTimeResolution, + .integrationWindow = OuterMPGDBarrelIntegrationWindow, }, app )); @@ -69,12 +75,14 @@ void InitPlugin(JApplication *app) { {"OuterMPGDBarrelRawHits"}, // Input data collection tags {"OuterMPGDBarrelRecHits"}, // Output data tag { - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = OuterMPGDBarrelTimeResolution, }, app )); // Digitization + auto BackwardMPGDEndcapTimeResolution = 20.0 * dd4hep::ns; // 1 / (50 MHz) + auto BackwardMPGDEndcapIntegrationWindow = 500.0 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "BackwardMPGDEndcapRawHits", { @@ -86,7 +94,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = BackwardMPGDEndcapTimeResolution, + .integrationWindow = BackwardMPGDEndcapIntegrationWindow, }, app )); @@ -97,12 +106,14 @@ void InitPlugin(JApplication *app) { {"BackwardMPGDEndcapRawHits"}, // Input data collection tags {"BackwardMPGDEndcapRecHits"}, // Output data tag { - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = BackwardMPGDEndcapTimeResolution, }, app )); // Digitization + auto ForwardMPGDEndcapTimeResolution = 20.0 * dd4hep::ns; // 1 / (50 MHz) + auto ForwardMPGDEndcapIntegrationWindow = 500.0 * dd4hep::ns; // shaping time app->Add(new JOmniFactoryGeneratorT( "ForwardMPGDEndcapRawHits", { @@ -114,7 +125,8 @@ void InitPlugin(JApplication *app) { }, { .threshold = 0.25 * dd4hep::keV, - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = ForwardMPGDEndcapTimeResolution, + .integrationWindow = ForwardMPGDEndcapIntegrationWindow, }, app )); @@ -125,7 +137,7 @@ void InitPlugin(JApplication *app) { {"ForwardMPGDEndcapRawHits"}, // Input data collection tags {"ForwardMPGDEndcapRecHits"}, // Output data tag { - .timeResolution = 20 * dd4hep::ns, // 1 / (50 MHz) + .timeResolution = ForwardMPGDEndcapTimeResolution, }, app )); diff --git a/src/detectors/RPOTS/RPOTS.cc b/src/detectors/RPOTS/RPOTS.cc index a37428ec89..9d30add179 100644 --- a/src/detectors/RPOTS/RPOTS.cc +++ b/src/detectors/RPOTS/RPOTS.cc @@ -22,18 +22,21 @@ void InitPlugin(JApplication *app) { MatrixTransferStaticConfig recon_cfg; //Digitized hits, especially for thresholds + auto ForwardRomanPotTimeResolution = 0.015 * dd4hep::ns; // 15-20 ps + auto ForwardRomanPotIntegrationWindow = 0.750 * dd4hep::ns; // 750 ps shaping time app->Add(new JOmniFactoryGeneratorT( "ForwardRomanPotRawHits", { - "ForwardRomanPotHits" + "ForwardRomanPotHits" }, { - "ForwardRomanPotRawHits", - "ForwardRomanPotHitAssociations" + "ForwardRomanPotRawHits", + "ForwardRomanPotHitAssociations" }, { .threshold = 10.0 * dd4hep::keV, - .timeResolution = 0.015 * dd4hep::ns, + .timeResolution = ForwardRomanPotTimeResolution, + .integrationWindow = ForwardRomanPotIntegrationWindow, }, app )); @@ -43,7 +46,7 @@ void InitPlugin(JApplication *app) { {"ForwardRomanPotRawHits"}, {"ForwardRomanPotRecHits"}, { - .timeResolution = 0.015 * dd4hep::ns, + .timeResolution = ForwardRomanPotTimeResolution, }, app )); From 79d867dc9eb293d3a66d05a7577a030c9d5d9734 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 21 May 2024 13:50:10 -0400 Subject: [PATCH 15/21] timeResolution is a double --- src/algorithms/tracking/TrackerHitReconstructionConfig.h | 3 ++- src/factories/tracking/TrackerHitReconstruction_factory.h | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/algorithms/tracking/TrackerHitReconstructionConfig.h b/src/algorithms/tracking/TrackerHitReconstructionConfig.h index 35d81adbe4..0e1c06f97c 100644 --- a/src/algorithms/tracking/TrackerHitReconstructionConfig.h +++ b/src/algorithms/tracking/TrackerHitReconstructionConfig.h @@ -2,9 +2,10 @@ // Copyright (C) 2022 Whitney Armstrong, Sylvester Joosten, Wouter Deconinck, Dmitry Romanov #pragma once +#include namespace eicrecon { struct TrackerHitReconstructionConfig { - float timeResolution = 10; + double timeResolution = 2000 * edm4eic::unit::ns; // It should be >0, maybe large, to not distort the fitter by default. Choosing 2us for now. }; } diff --git a/src/factories/tracking/TrackerHitReconstruction_factory.h b/src/factories/tracking/TrackerHitReconstruction_factory.h index ad59096931..eb27b57d1a 100644 --- a/src/factories/tracking/TrackerHitReconstruction_factory.h +++ b/src/factories/tracking/TrackerHitReconstruction_factory.h @@ -7,7 +7,6 @@ #include "services/geometry/dd4hep/DD4hep_service.h" #include "extensions/jana/JOmniFactory.h" - namespace eicrecon { class TrackerHitReconstruction_factory : @@ -18,7 +17,7 @@ public JOmniFactory m_raw_hits_input {this}; PodioOutput m_rec_hits_output {this}; - ParameterRef m_timeResolution {this, "timeResolution", config().timeResolution}; + ParameterRef m_timeResolution {this, "timeResolution", config().timeResolution}; Service m_geoSvc {this}; From 0e377fb2f22f8d6bf1832b3a1c4defddb3373ff3 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 21 May 2024 13:51:25 -0400 Subject: [PATCH 16/21] WS Cleanup --- src/detectors/BTRK/BTRK.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/detectors/BTRK/BTRK.cc b/src/detectors/BTRK/BTRK.cc index b1bd0e377a..6c6aea7fed 100644 --- a/src/detectors/BTRK/BTRK.cc +++ b/src/detectors/BTRK/BTRK.cc @@ -1,7 +1,5 @@ // Copyright 2022, Dmitry Romanov // Subject to the terms in the LICENSE file found in the top-level directory. -// -// #include #include @@ -38,8 +36,7 @@ void InitPlugin(JApplication *app) { }, app )); - - + // Convert raw digitized hits into hits with geometry info (ready for tracking) app->Add(new JOmniFactoryGeneratorT( "SiBarrelTrackerRecHits", From 9ebdc110df6a2da779725cd2e2f237bcebc0a696 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 21 May 2024 13:53:06 -0400 Subject: [PATCH 17/21] Added integrationWindow parameter --- src/algorithms/digi/SiliconTrackerDigiConfig.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigiConfig.h b/src/algorithms/digi/SiliconTrackerDigiConfig.h index 6a6630cd96..456aa32235 100644 --- a/src/algorithms/digi/SiliconTrackerDigiConfig.h +++ b/src/algorithms/digi/SiliconTrackerDigiConfig.h @@ -13,7 +13,8 @@ namespace eicrecon { // sub-systems should overwrite their own // NB: be aware of thresholds in npsim! E.g. https://github.com/eic/npsim/pull/9/files double threshold = 0 * dd4hep::keV; - double timeResolution = 2000 * edm4eic::unit::ns; // Source for 8? This is arbitrary --> however, it should be >0, maybe large, to not distort the fitter by default. Choosing 2us for now. + double timeResolution = 2000 * edm4eic::unit::ns; // Source for 8? This is arbitrary --> however, it should be >0, maybe large, to not distort the fitter by default. Choosing 2us for now. + double integrationWindow = 2000 * edm4eic::unit::ns; // Source for 8? This is arbitrary --> however, it should be >0, maybe large, to not distort the fitter by default. Choosing 2us for now. bool prepopulate = false; // prepopulate cellHit map with empty hits, for MAPS }; From ab22a197d9980845561a2e7a45e088502399ca4a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 21 May 2024 17:53:18 +0000 Subject: [PATCH 18/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/detectors/BTRK/BTRK.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/BTRK/BTRK.cc b/src/detectors/BTRK/BTRK.cc index 6c6aea7fed..0cd2c53ca5 100644 --- a/src/detectors/BTRK/BTRK.cc +++ b/src/detectors/BTRK/BTRK.cc @@ -36,7 +36,7 @@ void InitPlugin(JApplication *app) { }, app )); - + // Convert raw digitized hits into hits with geometry info (ready for tracking) app->Add(new JOmniFactoryGeneratorT( "SiBarrelTrackerRecHits", From 5bc417126984f67b48fe55ce0e054c256f70f5c8 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 25 Jun 2024 10:47:30 -0400 Subject: [PATCH 19/21] Digitzing with resolution and integration time --- src/algorithms/digi/SiliconTrackerDigi.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index c58f5321fd..52f4267cf9 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -31,6 +31,9 @@ void SiliconTrackerDigi::init(std::shared_ptr& logger) { }; } +// Logic: timeResolution is the smearing of the time. +// Smeared time marks the beginning of a bucket. If another hit falls within the same bucket, +// the energy is summed up. If not, a new hit is created. void SiliconTrackerDigi::process( const SiliconTrackerDigi::Input& input, @@ -42,7 +45,7 @@ void SiliconTrackerDigi::process( // A map of unique cellIDs with temporary structure RawHit std::unordered_map> cell_hit_map; - auto hit_time_stamp_err = (std::int32_t) (m_cfg.timeResolution * 1e3); + auto bucket_width = (std::int32_t) (m_cfg.integrationWindow * 1e3); // Some detectors have a steady pulse of hits - generate empty time buckets for those // Conundrum: We can't know the number of buckets without knowing the timeSlice length @@ -62,11 +65,9 @@ void SiliconTrackerDigi::process( } } } + for (const auto& sim_hit : *sim_hits) { - // time smearing - // Note: In the current setup, we can have hits outside the time slice - // Up to the analyzer to decide what to do with them double time_smearing = m_gauss(); double result_time = sim_hit.getTime() + time_smearing; auto hit_time_stamp = (std::int32_t) (result_time * 1e3); @@ -93,10 +94,10 @@ void SiliconTrackerDigi::process( for (auto& hit : cell_hit_map[sim_hit.getCellID()]) { auto existing_time = hit.getTimeStamp(); // TODO: edge cases? - if ( hit_time_stamp >= existing_time - 0.5*hit_time_stamp_err && hit_time_stamp <= existing_time + 0.5*hit_time_stamp_err ) { + if ( hit_time_stamp >= existing_time && hit_time_stamp <= existing_time + bucket_width ) { // There is already a hit within the same time window m_log->debug(" Hit already exists in cell ID={}, within the same time bucket. Time stamp: {}, bucket from {} to {}", - sim_hit.getCellID(), hit.getTimeStamp(), existing_time - hit_time_stamp_err, existing_time + hit_time_stamp_err); + sim_hit.getCellID(), hit.getTimeStamp(), existing_time, existing_time + bucket_width); // sum deposited energy auto charge = hit.getCharge(); hit.setCharge(charge + (std::int32_t) std::llround(sim_hit.getEDep() * 1e6)); From 474b95495ab52c181a73a832f5262c8007b42e35 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:47:06 +0000 Subject: [PATCH 20/21] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/algorithms/digi/SiliconTrackerDigi.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/digi/SiliconTrackerDigi.cc b/src/algorithms/digi/SiliconTrackerDigi.cc index 7df9d304a1..7c1cc87cba 100644 --- a/src/algorithms/digi/SiliconTrackerDigi.cc +++ b/src/algorithms/digi/SiliconTrackerDigi.cc @@ -62,7 +62,7 @@ void SiliconTrackerDigi::process( } } } - + for (const auto& sim_hit : *sim_hits) { // time smearing double time_smearing = m_gauss(); From 09b1f4917fc299c0ad83cb3afa87393e0062f94d Mon Sep 17 00:00:00 2001 From: kkauder Date: Tue, 25 Jun 2024 15:55:57 -0400 Subject: [PATCH 21/21] Update src/detectors/LOWQ2/LOWQ2.cc Co-authored-by: Simon Gardner --- src/detectors/LOWQ2/LOWQ2.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detectors/LOWQ2/LOWQ2.cc b/src/detectors/LOWQ2/LOWQ2.cc index 99b7e553f7..7cc71cad72 100644 --- a/src/detectors/LOWQ2/LOWQ2.cc +++ b/src/detectors/LOWQ2/LOWQ2.cc @@ -36,7 +36,7 @@ extern "C" { // Digitization of silicon hits auto TaggerTrackerTimeResolution = 0.195 * dd4hep::ns; - auto TaggerTrackerIntegrationWindow = 5.0 * dd4hep::ns; + auto TaggerTrackerIntegrationWindow = 25.0 * dd4hep::ns; app->Add(new JOmniFactoryGeneratorT( "TaggerTrackerRawHits", {