Skip to content

MCParticle: provide reference point

Simon Spannagel requested to merge mcp_reference into master

The MC truth position of a particle is an essential information for comparison with reconstructed cluster positions. This MR cleans up the currently taken approach to calculate this reference point.

Up to now, simply the center of the entry and exit point of the particle has been taken as MC truth, e.g. in the DetectorHistogrammer module

auto particlePos = (static_cast<XYZVector>(particle->getLocalStartPoint()) + particle->getLocalEndPoint()) / 2.0;

This works fine as long as the particle always enters at the bottom and leaves at the top of the sensor. In any other circumstance this will produce wrong results:

  • Particle leaves at sensor size
  • Particle doesn't leave sensor but is absorbed
  • Particle is a secondary, produced somewhere within the sensor

I therefore implemented a different approach in the form of a new member function of the MCParticle class, getLocalReferencePoint():

We take the start and end point of the MCParticle, produce a parametric equation for the line between those two and evaluate this equation at z = 0, i.e. the center (reference) plane of the sensor. This produces correct results for all cases listed above.

ROOT::Math::XYZPoint MCParticle::getLocalReferencePoint() const {
    // Direction for parametric equation of line through start/end points
    auto direction =
        static_cast<ROOT::Math::XYZVector>(local_end_point_) - static_cast<ROOT::Math::XYZVector>(local_start_point_);
    // Calculate parameter for line intersection with plane at z = 0, local coordinates
    auto t = -1 * local_start_point_.z() / direction.z();
    // Calculate reference point at z = 0 from parametric line equation
    return (direction * t + local_start_point_);
}

Only when a particle does not cross the reference plane at all, the reference point will not be between start and eend point - but in this case there really is little we can do. And the information about start and end (as well as parent particles) is still available to check for these corner cases.

Merge request reports