Skip to content

Emulating detector efficiency in DDPlanarDigi #27

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 11 additions & 1 deletion k4Reco/DDPlanarDigi/components/DDPlanarDigi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ StatusCode DDPlanarDigi::initialize() {
m_mask = (static_cast<std::uint64_t>(1) << m_cellIDBits) - 1;
}

if (m_efficiency > 1.0) {
throw std::runtime_error(fmt::format("DDPlanarDigi Error: Efficiency cannot be greater than 1.0 (provided: {})", m_efficiency.value()));
}

return StatusCode::SUCCESS;
}

Expand All @@ -104,6 +108,7 @@ std::tuple<edm4hep::TrackerHitPlaneCollection, edm4hep::TrackerHitSimTrackerHitL

int nCreatedHits = 0;
int nDismissedHits = 0;
int nEfficiencyCutHits = 0;

auto trkhitVec = edm4hep::TrackerHitPlaneCollection();
auto thsthcol = edm4hep::TrackerHitSimTrackerHitLinkCollection();
Expand All @@ -117,6 +122,11 @@ std::tuple<edm4hep::TrackerHitPlaneCollection, edm4hep::TrackerHitSimTrackerHitL
for (const auto& hit : simTrackerHits) {
++(*m_histograms[hitE])[hit.getEDep() * (dd4hep::GeV / dd4hep::keV)];

double rand_num = m_engine.Uniform(0.0, 1.0);
if (rand_num > m_efficiency) {
continue; //skip (1-efficiency) of the hits "Eficiency cut".
}

if (hit.getEDep() < m_minEnergy) {
debug() << "Hit with insufficient energy " << hit.getEDep() * (dd4hep::GeV / dd4hep::keV) << " keV" << endmsg;
continue;
Expand Down Expand Up @@ -315,7 +325,7 @@ std::tuple<edm4hep::TrackerHitPlaneCollection, edm4hep::TrackerHitSimTrackerHitL
float accFraction = nSimHits > 0 ? float(nCreatedHits) / float(nSimHits) * 100.0 : 0.0;
++(*m_histograms[hitsAccepted])[accFraction];

debug() << "Created " << nCreatedHits << " hits, " << nDismissedHits << " hits dismissed" << endmsg;
debug() << "Created " << nCreatedHits << " hits, " << nDismissedHits << " hits dismissed, " << nEfficiencyCutHits << " hits dropped due to efficiency cut." << endmsg;

return std::make_tuple(std::move(trkhitVec), std::move(thsthcol));
}
2 changes: 2 additions & 0 deletions k4Reco/DDPlanarDigi/components/DDPlanarDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ struct DDPlanarDigi final
{-1},
"Resolution in the direction of t; either one per layer or one for all layers. If the single entry is negative, "
"disable time smearing. "};
Gaudi::Property<double> m_efficiency{
this, "Efficiency", 1.00, "Efficiency of the chamber to detect the charged particle"};
Gaudi::Property<bool> m_forceHitsOntoSurface{this, "ForceHitsOntoSurface", false,
"Project hits onto the surfoce in case they are not yet on the surface"};
Gaudi::Property<double> m_minEnergy{this, "MinEnergy", 0.0, "Minimum energy (GeV) of SimTrackerHit to be digitized"};
Expand Down
Loading