diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index 5087591147e9feb704306183ac42c4283794866a..14f9e0306fb7cd6793710c5699fc625c55a20003 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -25,6 +25,7 @@ set(SRCS ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaSearchWindow.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaStation.cxx ${CMAKE_CURRENT_SOURCE_DIR}/pars/CaStationInitializer.cxx + ${CMAKE_CURRENT_SOURCE_DIR}/utils/CaUtils.cxx ${CMAKE_CURRENT_SOURCE_DIR}/tracking/CaCloneMerger.cxx ${CMAKE_CURRENT_SOURCE_DIR}/tracking/CaFramework.cxx ${CMAKE_CURRENT_SOURCE_DIR}/tracking/CaTrackExtender.cxx @@ -107,6 +108,8 @@ install( utils/CaTimer.h utils/CaVector.h utils/CaDefines.h + utils/CaUtils.h + tracking/CaCloneMerger.h tracking/CaFramework.h tracking/CaTrackExtender.h diff --git a/algo/ca/core/tracking/CaTrackExtender.cxx b/algo/ca/core/tracking/CaTrackExtender.cxx index 09123e020823c81d2842c04318b7ce35bdf9d170..e9e8138facad5cb4346fbb6cba1f3c040919b728 100644 --- a/algo/ca/core/tracking/CaTrackExtender.cxx +++ b/algo/ca/core/tracking/CaTrackExtender.cxx @@ -12,6 +12,7 @@ #include "CaInputData.h" #include "CaTrack.h" #include "CaTrackFit.h" +#include "CaUtils.h" #include "CaVector.h" #include "KfTrackParam.h" @@ -118,7 +119,7 @@ void TrackExtender::FitBranchFast(const ca::Branch& t, TrackParamV& Tout, const const ca::Station<fvec>& sta = fParameters.GetStation(ista); fit.Extrapolate(hit.Z(), fld); - fit.FilterHit(hit, fmask(sta.timeInfo)); + ca::utils::FilterHit(fit, hit, fmask(sta.timeInfo)); auto radThick = fParameters.GetMaterialThickness(ista, T.X(), T.Y()); fit.MultipleScattering(radThick); fit.EnergyLossCorrection(radThick, direction); @@ -270,7 +271,7 @@ void TrackExtender::FindMoreHits(ca::Branch& t, TrackParamV& Tout, const FitDire newHits.push_back(iHit_best); fit.Extrapolate(hit.Z(), fld); - fit.FilterHit(hit, fmask(sta.timeInfo)); + ca::utils::FilterHit(fit, hit, fmask(sta.timeInfo)); auto radThick = fParameters.GetMaterialThickness(ista, tr.X(), tr.Y()); fit.MultipleScattering(radThick); fit.EnergyLossCorrection(radThick, direction); diff --git a/algo/ca/core/tracking/CaTrackFit.cxx b/algo/ca/core/tracking/CaTrackFit.cxx index ed1f12f1247cf3df458524759bc860cbafc92844..f79e4fdb7e65138d4113383e9d234acaac4d51c9 100644 --- a/algo/ca/core/tracking/CaTrackFit.cxx +++ b/algo/ca/core/tracking/CaTrackFit.cxx @@ -4,8 +4,6 @@ #include "CaTrackFit.h" -#include "CaHit.h" -#include "CaStation.h" #include "KfMeasurementU.h" #include "KfMeasurementXy.h" @@ -327,25 +325,10 @@ namespace cbm::algo::ca fTr.C66() -= K60 * F60 + K61 * F61; } - template<typename DataT> - void TrackFit<DataT>::FilterHit(const ca::Hit& hit, const DataTmask& timeInfo) - { - kf::MeasurementXy<DataT> m; - m.SetDx2(hit.dX2()); - m.SetDy2(hit.dY2()); - m.SetDxy(hit.dXY()); - m.SetX(hit.X()); - m.SetY(hit.Y()); - m.SetNdfX(DataT(1.)); - m.SetNdfY(DataT(1.)); - FilterXY(m); - FilterTime(hit.T(), hit.dT2(), timeInfo); - } - template<typename DataT> void TrackFit<DataT>::FilterExtrapolatedXY(const kf::MeasurementXy<DataT>& m, DataT extrX, DataT extrY, - const std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jx, - const std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jy) + const std::array<DataT, kf::TrackParamBase<DataT>::kNtrackParam>& Jx, + const std::array<DataT, kf::TrackParamBase<DataT>::kNtrackParam>& Jy) { // add a 2-D measurenent (x,y) at some z, that differs from fTr.GetZ() // extrX, extrY are extrapolated track parameters at z, Jx, Jy are derivatives of the extrapolation @@ -433,7 +416,7 @@ namespace cbm::algo::ca // measure velocity using measured qp // assuming particle mass == fMass; - const DataT kClightNsInv = DataT(constants::phys::SpeedOfLightInv); + const DataT kClightNsInv = kf::defs::SpeedOfLightInv<DataT>; DataT zeta, HCH; DataT F0, F1, F2, F3, F4, F5, F6; @@ -673,8 +656,11 @@ namespace cbm::algo::ca // //======================================================================== + // TODO: check the units, where does 1.e-5 factor come? + // c_light = 0.000299792458; // [(GeV/c)/kG/cm] + // c_light_ns = 29.9792458 [cm/ns] - cnst c_light = 0.000299792458; + cnst c_light = DataT(1.e-5 * kf::defs::SpeedOfLight<double>); //---------------------------------------------------------------- @@ -752,12 +738,11 @@ namespace cbm::algo::ca F[step][5][6] = L; } else { - DataT vi = sqrt(DataT(1.) + fMass2 * fQp0 * fQp0) * DataT(constants::phys::SpeedOfLightInv); + DataT vi = sqrt(DataT(1.) + fMass2 * fQp0 * fQp0) * kf::defs::SpeedOfLightInv<DataT>; f[step][5] = vi * L; F[step][5][2] = vi * tx / L; F[step][5][3] = vi * ty / L; - F[step][5][4] = - fMass2 * fQp0 * L / sqrt(DataT(1.) + fMass2 * fQp0 * fQp0) * DataT(constants::phys::SpeedOfLightInv); + F[step][5][4] = fMass2 * fQp0 * L / sqrt(DataT(1.) + fMass2 * fQp0 * fQp0) * kf::defs::SpeedOfLightInv<DataT>; F[step][5][5] = 0.; F[step][5][6] = 0.; } @@ -1163,8 +1148,8 @@ namespace cbm::algo::ca template<typename DataT> void TrackFit<DataT>::GetExtrapolatedXYline(DataT z, const kf::FieldRegion<DataT>& F, DataT& extrX, DataT& extrY, - std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jx, - std::array<DataT, TrackParamBase<DataT>::kNtrackParam>& Jy) const + std::array<DataT, kf::TrackParamBase<DataT>::kNtrackParam>& Jx, + std::array<DataT, kf::TrackParamBase<DataT>::kNtrackParam>& Jy) const { // extrapolate track assuming it is straight (qp==0) // return the extrapolated X, Y and the derivatives of the extrapolated X and Y @@ -1221,7 +1206,7 @@ namespace cbm::algo::ca // Add the target constraint to a straight line track DataT eX, eY; - std::array<DataT, TrackParamV::kNtrackParam> Jx, Jy; + std::array<DataT, kf::TrackParamV::kNtrackParam> Jx, Jy; GetExtrapolatedXYline(targZ, F, eX, eY, Jx, Jy); FilterExtrapolatedXY(targXY, eX, eY, Jx, Jy); } @@ -1498,11 +1483,11 @@ namespace cbm::algo::ca fTr.Qp() = -L * c_light_i / sqrt(txtx1 + fTr.Ty() * fTr.Ty()); fTr.Time() = time; fTr.Z() = trackZ; - fTr.Vi() = constants::phys::SpeedOfLightInv; + fTr.Vi() = kf::defs::SpeedOfLightInv<DataT>; fQp0 = fTr.Qp(); } - template class TrackFit<fvec>; + template class TrackFit<kf::fvec>; template class TrackFit<float>; template class TrackFit<double>; diff --git a/algo/ca/core/tracking/CaTrackFit.h b/algo/ca/core/tracking/CaTrackFit.h index 21a2dafe36e44966b985e4a5a3e191d0d0e902ab..0328be57b618f93149fdac9a896b66fb267a3177 100644 --- a/algo/ca/core/tracking/CaTrackFit.h +++ b/algo/ca/core/tracking/CaTrackFit.h @@ -10,7 +10,6 @@ #pragma once // include this header only once per compilation unit -#include "CaSimd.h" #include "KfFieldRegion.h" #include "KfMeasurementTime.h" #include "KfMeasurementU.h" @@ -112,9 +111,6 @@ namespace cbm::algo::ca /// filter the track with the time measurement void FilterTime(kf::MeasurementTime<DataT> mt) { FilterTime(mt.T(), mt.Dt2(), DataTmask(mt.NdfT() > DataT(0.))); } - /// filter the track with the hit - void FilterHit(const ca::Hit& h, const DataTmask& timeInfo); - /// filter the inverse speed void FilterVi(DataT vi); diff --git a/algo/ca/core/utils/CaUtils.cxx b/algo/ca/core/utils/CaUtils.cxx new file mode 100644 index 0000000000000000000000000000000000000000..5d54e6a509e215d38e15da6248e76a43c0d248cb --- /dev/null +++ b/algo/ca/core/utils/CaUtils.cxx @@ -0,0 +1,11 @@ +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +#include "CaUtils.h" + +/// Namespace contains compile-time constants definition for the CA tracking algorithm +/// +namespace cbm::algo::ca::utils +{ +} // namespace cbm::algo::ca::utils diff --git a/algo/ca/core/utils/CaUtils.h b/algo/ca/core/utils/CaUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..2334616ab778f425aedd8231cfd52b40c76b9a2d --- /dev/null +++ b/algo/ca/core/utils/CaUtils.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Sergey Gorbunov, Sergei Zharko [committer] */ + +/// \file CaUtils.h +/// \brief Compile-time constants definition for the CA tracking algorithm +/// \since 02.06.2022 +/// \author S.Zharko <s.zharko@gsi.de> + +#pragma once // include this header only once per compilation unit + +#include "CaHit.h" +#include "CaTrackFit.h" +#include "KfDefs.h" +#include "KfMeasurementTime.h" +#include "KfMeasurementXy.h" +#include "KfSimd.h" + + +namespace cbm::algo::ca::utils +{ + + template<typename T> + inline void FilterHit(ca::TrackFit<T>& fit, const ca::Hit& hit, const kf::utils::masktype<T>& timeInfo) + { + kf::MeasurementXy<T> m; + m.SetDx2(hit.dX2()); + m.SetDy2(hit.dY2()); + m.SetDxy(hit.dXY()); + m.SetX(hit.X()); + m.SetY(hit.Y()); + m.SetNdfX(T(1.)); + m.SetNdfY(T(1.)); + fit.FilterXY(m); + fit.FilterTime(hit.T(), hit.dT2(), timeInfo); + } + +} // namespace cbm::algo::ca::utils