Skip to content
Open
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
15 changes: 12 additions & 3 deletions Common/Core/fwdtrackUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef COMMON_CORE_FWDTRACKUTILITIES_H_
#define COMMON_CORE_FWDTRACKUTILITIES_H_

#include <Framework/AnalysisDataModel.h>
#include <Framework/DataTypes.h>
#include <GlobalTracking/MatchGlobalFwd.h>
#include <MCHTracking/TrackExtrap.h>
Expand Down Expand Up @@ -48,22 +47,32 @@
using SMatrix55Std = ROOT::Math::SMatrix<double, 5>;
using SMatrix5 = ROOT::Math::SVector<double, 5>;

template <typename T>
concept is_fwd_track = requires(T t) {
{ t.rAtAbsorberEnd() } -> std::same_as<float>;
};

template <typename T>
concept is_fwd_cov = requires(T t) {
{ t.sigmaX() } -> std::same_as<float>;
};

/// Produce TrackParCovFwds for MFT and FwdTracks, w/ or w/o cov, with z shift
template <typename TFwdTrack, typename... TCovariance>
o2::track::TrackParCovFwd getTrackParCovFwdShift(TFwdTrack const& track, float zshift, TCovariance const&... covOpt)
{
double chi2 = track.chi2();
if constexpr (sizeof...(covOpt) == 0) {
// No covariance passed
if constexpr (std::is_same_v<std::decay_t<TFwdTrack>, aod::FwdTracks::iterator>) {
if constexpr (is_fwd_track<TFwdTrack>) {
if (track.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) {
chi2 = track.chi2() * (2.f * track.nClusters() - 5.f);
}
}
} else {
// Covariance passed
using TCov = std::decay_t<decltype((covOpt, ...))>;
if constexpr (std::is_same_v<TCov, aod::FwdTracksCov::iterator>) {
if constexpr (is_fwd_cov<TCov>) {
if (track.trackType() == o2::aod::fwdtrack::ForwardTrackTypeEnum::MuonStandaloneTrack) {
chi2 = track.chi2() * (2.f * track.nClusters() - 5.f);
}
Expand Down Expand Up @@ -144,7 +153,7 @@
o2::dataformats::GlobalFwdTrack propmuon;
o2::globaltracking::MatchGlobalFwd mMatching;

if (trackType > 2) { // MCH-MID or MCH standalone

Check failure on line 156 in Common/Core/fwdtrackUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
o2::dataformats::GlobalFwdTrack track;
track.setParameters(fwdtrack.getParameters());
track.setZ(fwdtrack.getZ());
Expand All @@ -165,7 +174,7 @@
propmuon.setParameters(proptrack.getParameters());
propmuon.setZ(proptrack.getZ());
propmuon.setCovariances(proptrack.getCovariances());
} else if (trackType < 2) { // MFT-MCH-MID

Check failure on line 177 in Common/Core/fwdtrackUtilities.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
// const double centerMFT[3] = {0, 0, -61.4};
// o2::field::MagneticField* field = static_cast<o2::field::MagneticField*>(TGeoGlobalMagField::Instance()->GetField());
// auto Bz = field->getBz(centerMFT); // Get field at centre of MFT in kG.
Expand Down
Loading