Commit dd23206b authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Merge branch 'histogrammerEfficiencyFix_backport' into 'v2.3-stable'

[v2.3-stable] Fixing efficiency in [DetectorHistogrammer] when sensor excess is present

See merge request allpix-squared/allpix-squared!861
parents b194e6a4 b2145aa5
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -270,6 +270,9 @@ void DetectorHistogrammerModule::run(Event* event) {
    std::shared_ptr<PixelHitMessage> pixels_message{nullptr};
    auto mcparticle_message = messenger_->fetchMessage<MCParticleMessage>(this, event);

    // Fetch detector model
    auto model = detector_->getModel();

    // Check that we actually received pixel hits - we might have none and just received MCParticles!
    try {
        pixels_message = messenger_->fetchMessage<PixelHitMessage>(this, event);
@@ -334,7 +337,7 @@ void DetectorHistogrammerModule::run(Event* event) {

        LOG(TRACE) << "Matching primaries: " << intersection.size();
        for(const auto& particle : intersection) {
            auto pitch = detector_->getModel()->getPixelSize();
            auto pitch = model->getPixelSize();

            auto particlePos = particle->getLocalReferencePoint() + track_smearing(track_resolution_);
            LOG(DEBUG) << "MCParticle at " << Units::display(particlePos, {"mm", "um"});
@@ -389,10 +392,20 @@ void DetectorHistogrammerModule::run(Event* event) {

    // Calculate efficiency: search for matching clusters for all primary MCParticles
    for(auto& particle : primary_particles) {
        auto pitch = detector_->getModel()->getPixelSize();
        auto pitch = model->getPixelSize();

        // Calculate 2D local position of particle:
        auto particlePos = particle->getLocalReferencePoint() + track_smearing(track_resolution_);

        auto pixels = model->getNPixels();

        if(particlePos.x() < -pitch.x() / 2 || particlePos.x() > pixels.x() * pitch.x() - pitch.x() / 2 ||
           particlePos.y() < -pitch.y() / 2 || particlePos.y() > pixels.y() * pitch.y() - pitch.y() / 2) {
            LOG(DEBUG) << "Particle at local coordinate " << Units::display(particlePos, {"mm", "um"})
                       << " hit in the sensor excess; removing from efficiency calculation.";
            continue;
        }

        auto inPixelPos = XYVector(std::fmod(particlePos.x() + pitch.x() / 2, pitch.x()),
                                   std::fmod(particlePos.y() + pitch.y() / 2, pitch.y()));
        auto inPixel_um_x = static_cast<double>(Units::convert(inPixelPos.x(), "um"));
+2 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ If the PixelHit is free-standing, a new cluster is created.

This module serves as a quick "mini-analysis" and creates the histograms listed below.
The Monte Carlo truth position provided by the `MCParticle` objects is used as track reference position.
An additional uncertainty can be added by configuring a track resolution, with which every cluster residual is convolved.
For technical reasons, this offset is drawn randomly from a Gauss distribution independently for the resolution and the efficiency measurement.
An additional uncertainty can be added by configuring a track resolution, with which every cluster residual is convolved. This makes it possible to perform a quick test beam-like analysis.
For technical reasons, this offset is drawn randomly from a Gaussian distribution independently for the resolution and the efficiency measurement. **Note:** If a non-zero track resolution is used, pixel matrix edge effects may appear as particles hit the sensor excess.

* A hitmap of all pixels in the pixel grid, displaying the number of times a pixel has been hit during the simulation run.
* A cluster map indicating the cluster positions for the whole simulation run.