Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bucket silicon raw hits in time #1359

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cdda38b
First draft of bucketing hits in time
kkauder Apr 2, 2024
cb882b9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 2, 2024
ddbcbca
iwyu
kkauder Apr 2, 2024
7d9df30
add .DS_STORE to gitignore
kkauder Apr 2, 2024
eaa89ef
Update src/algorithms/digi/SiliconTrackerDigi.cc
kkauder Apr 10, 2024
c35ce0b
Update src/algorithms/digi/SiliconTrackerDigiConfig.h
kkauder Apr 10, 2024
dc11cb7
ignore vscode
kkauder Apr 10, 2024
077aabf
bugfix
kkauder Apr 10, 2024
d034105
Updated timeResolution values from digitization spreadsheet
kkauder Apr 24, 2024
d3b14c9
Merged main for associations
kkauder May 2, 2024
680eca5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 2, 2024
2117829
Allow prepopulation of cellhitMap for MAPS
kkauder May 2, 2024
664a8d5
Merge branch 'time_buckets' of github.com:eic/EICrecon into time_buckets
kkauder May 2, 2024
27d2ae6
use uncertainty = resolution/2; TODO text added
kkauder May 7, 2024
49d4ee4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 7, 2024
6267e03
Added integration window, updated time resolution for silicon hits
kkauder May 17, 2024
71d04ff
Merge branch 'time_buckets' of github.com:eic/EICrecon into time_buckets
kkauder May 17, 2024
79d867d
timeResolution is a double
kkauder May 21, 2024
0e377fb
WS Cleanup
kkauder May 21, 2024
9ebdc11
Added integrationWindow parameter
kkauder May 21, 2024
ab22a19
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 21, 2024
5bc4171
Digitzing with resolution and integration time
kkauder Jun 25, 2024
b001b18
Merge branch 'time_buckets' of github.com:eic/EICrecon into time_buckets
kkauder Jun 25, 2024
775c308
merged main
kkauder Jun 25, 2024
474b954
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 25, 2024
09b1f49
Update src/detectors/LOWQ2/LOWQ2.cc
kkauder Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ install/*
*.out
*.m_app

# Apple stuff
.DS_Store

##### i g n o r i n g I D E s #####

Expand Down
60 changes: 36 additions & 24 deletions src/algorithms/digi/SiliconTrackerDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <edm4hep/Vector3d.h>
#include <edm4hep/Vector3f.h>
#include <fmt/core.h>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdint>
#include <gsl/pointers>
Expand Down Expand Up @@ -39,12 +39,12 @@ void SiliconTrackerDigi::process(
auto [raw_hits] = output;

// A map of unique cellIDs with temporary structure RawHit
std::unordered_map<std::uint64_t, edm4eic::MutableRawTrackerHit> cell_hit_map;

std::unordered_map<std::uint64_t, std::vector<edm4eic::MutableRawTrackerHit>> 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);
Expand All @@ -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) {
veprbl marked this conversation as resolved.
Show resolved Hide resolved
// 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?!
kkauder marked this conversation as resolved.
Show resolved Hide resolved
} );
} // 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
2 changes: 1 addition & 1 deletion src/algorithms/digi/SiliconTrackerDigiConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]
kkauder marked this conversation as resolved.
Show resolved Hide resolved
};

} // eicrecon
Loading