Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:10:00

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 #pragma once
0009 
0010 #include "Acts/EventData/MultiTrajectory.hpp"
0011 #include "Acts/EventData/TrackContainer.hpp"
0012 
0013 namespace Acts {
0014 
0015 /// Helper function to calculate a number of track level quantities and store
0016 /// them on the track itself
0017 /// @note The input track needs to be mutable, so @c ReadOnly=false
0018 /// @tparam track_container_t the track container backend
0019 /// @tparam track_state_container_t the track state container backend
0020 /// @tparam holder_t the holder type for the track container backends
0021 /// @param track A mutable track proxy to operate on
0022 template <typename track_container_t, typename track_state_container_t,
0023           template <typename> class holder_t>
0024 void calculateTrackQuantities(
0025     Acts::TrackProxy<track_container_t, track_state_container_t, holder_t,
0026                      false>
0027         track) {
0028   track.chi2() = 0;
0029   track.nDoF() = 0;
0030 
0031   track.nHoles() = 0;
0032   track.nMeasurements() = 0;
0033   track.nSharedHits() = 0;
0034   track.nOutliers() = 0;
0035 
0036   for (const auto& trackState : track.trackStatesReversed()) {
0037     auto typeFlags = trackState.typeFlags();
0038 
0039     if (typeFlags.test(Acts::TrackStateFlag::MeasurementFlag)) {
0040       if (typeFlags.test(Acts::TrackStateFlag::SharedHitFlag)) {
0041         track.nSharedHits()++;
0042       }
0043 
0044       track.nMeasurements()++;
0045       track.chi2() += trackState.chi2();
0046       track.nDoF() += trackState.calibratedSize();
0047     } else if (typeFlags.test(Acts::TrackStateFlag::OutlierFlag)) {
0048       track.nOutliers()++;
0049     } else if (typeFlags.test(Acts::TrackStateFlag::HoleFlag)) {
0050       track.nHoles()++;
0051     }
0052   }
0053 }
0054 }  // namespace Acts