Skip to content
Open
Changes from 2 commits
Commits
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
10 changes: 7 additions & 3 deletions src/algorithms/digi/SiliconTrackerDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove these magic numbers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why the rounding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by "magic number" I guess you mean the times 10 for rounding?

In line 72 will fill the charge with (std::int32_t)std::llround(sim_hit.getEDep() * 1e6). one could use exactly this formula. I wanted to use rounding to make sure it will return 1 instead of 0.99999 for example, and I assume we don't care about too much about precision. Would times 100 (two decimal digits) be better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't round.

Other magical number is the 1e6.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1e6 is the unit conversion. Can you suggest some alternative?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I changed to use eV for rawhit.charge so it's always integer. It was keV with the magic number of 1e6, which is not the best choice because our detector threshold is often <1keV.
We can have a separate discussion later on whether it makes sense to declare RawTrackerHit.charge as int32_t.

}
hitassoc.setWeight(weight);
hitassoc.setRawHit(item.second);
hitassoc.setSimHit(sim_hit);
}
Expand Down
Loading