diff --git a/algo/ca/core/CMakeLists.txt b/algo/ca/core/CMakeLists.txt index 26fe08f9084fa4acf26806b0d6a620d113277e7f..75e67fb76bf1d56f0b1bc3a91ccac030992386c2 100644 --- a/algo/ca/core/CMakeLists.txt +++ b/algo/ca/core/CMakeLists.txt @@ -6,6 +6,7 @@ set(INCLUDE_DIRECTORIES ) set(SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrackParam.cxx ${CMAKE_CURRENT_SOURCE_DIR}/data/CaTrack.cxx ) @@ -20,9 +21,16 @@ target_include_directories(CaCore target_compile_definitions(CaCore PUBLIC NO_ROOT) target_link_libraries(CaCore - Vc::Vc + Vc::Vc Boost::serialization - #external::fles_logging # conflicting with FairLogger in libL1.so + Boost::program_options + Boost::filesystem + Boost::headers + OnlineDataLog +# external::yaml-cpp # not needed + external::fles_logging + external::fles_ipc + external::fles_monitoring ) install(TARGETS CaCore DESTINATION lib) @@ -32,12 +40,14 @@ install(DIRECTORY pars TYPE INCLUDE FILES_MATCHING PATTERN "*.h") install( FILES + data/CaTrackParam.h data/CaTrack.h pars/CaConstants.h utils/CaSimd.h utils/CaSimdVc.h utils/CaSimdPseudo.h utils/CaVector.h + utils/CaUtils.h DESTINATION include/ ) diff --git a/algo/ca/core/data/CaTrack.h b/algo/ca/core/data/CaTrack.h index ce49832536c5a9de4bb8fb39e55db2c0eda90659..37f919c345fb7550a9c397f88ab614d782bc6bea 100644 --- a/algo/ca/core/data/CaTrack.h +++ b/algo/ca/core/data/CaTrack.h @@ -2,24 +2,24 @@ SPDX-License-Identifier: GPL-3.0-only Authors: Ivan Kisel, Sergey Gorbunov, Maksym Zyzak, Igor Kulakov [committer], Sergei Zharko */ - /// \file CaTrack.h /// \brief header file for the ca::Track class /// \since 02.06.2022 /// \author S.Zharko <s.zharko@gsi.de> -#ifndef CBM_ALGO_CA_TRACK -#define CBM_ALGO_CA_TRACK 1 +#ifndef CaTrack_h +#define CaTrack_h 1 #include <boost/serialization/access.hpp> #include "CaConstants.h" #include "CaSimd.h" +#include "CaTrackParam.h" namespace cbm::algo::ca { - /// @class cbm::algo::ca::Track - /// @brief Class representing an output track in the CA tracking algorithm + /// \class cbm::algo::ca::Track + /// \brief Class representing an output track in the CA tracking algorithm /// /// Track parameters vector: {x, y, tx, ty, q/p, z, t, vi} /// Covariation matrix: C[20] (C55) corresponds to the time variance @@ -28,49 +28,25 @@ namespace cbm::algo::ca public: friend class boost::serialization::access; - Track() - { - fParFirst.fill(constants::undef::Fscal); - fParLast.fill(constants::undef::Fscal); - fParPV.fill(constants::undef::Fscal); - fCovFirst.fill(constants::undef::Fscal); - fCovLast.fill(constants::undef::Fscal); - fCovPV.fill(constants::undef::Fscal); - } + Track() = default; template<class Archive> void serialize(Archive& ar, const unsigned int /*version*/) { ar& fNofHits; - for (int i = 0; i < NparTr; ++i) { - ar& fParFirst[i]; - ar& fParLast[i]; - ar& fParPV[i]; - } - for (int i = 0; i < NparCov; ++i) { - ar& fCovFirst[i]; - ar& fCovLast[i]; - ar& fCovPV[i]; - } - ar& fChi2; - ar& fNDF; + ar& fParFirst; + ar& fParLast; + ar& fParPV; } public: - static constexpr int NparTr {8}; - static constexpr int NparCov {28}; + int fNofHits {constants::Undef<int>}; ///< Number of hits in track - int fNofHits {constants::undef::Int}; ///< Number of hits in track - - std::array<fscal, NparTr> fParFirst; ///< Track parameters on the first station - std::array<fscal, NparCov> fCovFirst; ///< Track parameter covariation matrix elements on the first station - std::array<fscal, NparTr> fParLast; ///< Track parameters on the last station - std::array<fscal, NparCov> fCovLast; ///< Track parameter covariation matrix elements on the second station - std::array<fscal, NparTr> fParPV; ///< Track parameters in the primary vertex - std::array<fscal, NparCov> fCovPV; ///< Track parameter covariation matrix elements in the primary vertex - fscal fChi2 {constants::undef::Fscal}; ///< Track fit chi-square value - int fNDF {constants::undef::Int}; ///< Track fit NDF value + TrackParamS fParFirst; ///< Track parameters on the first station + TrackParamS fParLast; ///< Track parameters on the last station + TrackParamS fParPV; ///< Track parameters in the primary vertex }; + } // namespace cbm::algo::ca -#endif // CBM_ALGO_CA_TRACK +#endif // CaTrack_h diff --git a/algo/ca/core/data/CaTrackParam.cxx b/algo/ca/core/data/CaTrackParam.cxx new file mode 100644 index 0000000000000000000000000000000000000000..7122793a3f5524f3b0812fdc0b9074a1897f4692 --- /dev/null +++ b/algo/ca/core/data/CaTrackParam.cxx @@ -0,0 +1,327 @@ +/* Copyright (C) 2007-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Igor Kulakov [committer], Maksym Zyzak */ + +#include "CaTrackParam.h" + +#include <iomanip> +#include <iostream> + +#include "AlgoFairloggerCompat.h" +#include "CaUtils.h" + +namespace cbm::algo::ca +{ + template<typename DataT> + std::string TrackParamBase<DataT>::ToString(int i) const + { + std::stringstream s; + s.setf(std::ios::scientific, std::ios::floatfield); + + // print only one component of the SIMD vector + if constexpr (std::is_same_v<DataT, fvec>) { + if (i >= 0) { + s << "T = "; + s << " x " << GetX()[i]; + s << " y " << GetY()[i]; + s << " tx " << GetTx()[i]; + s << " ty " << GetTy()[i]; + s << " qp " << GetQp()[i]; + s << " t " << GetTime()[i]; + s << " vi " << GetVi()[i]; + + s << " z " << GetZ()[i] << std::endl; + s << "C = "; + s << " c00 " << C00()[i]; + s << " c11 " << C11()[i]; + s << " c22 " << C22()[i]; + s << " c33 " << C33()[i]; + s << " c44 " << C44()[i] << std::endl; + s << " c55 " << C55()[i] << std::endl; + s << " c66 " << C66()[i] << std::endl; + s << ToStringCorrelations(i); + return s.str(); + } + } + + { // print all SIMD values + s << "T = " << std::endl; + s << " x " << GetX() << std::endl; + s << " y " << GetY() << std::endl; + s << " tx " << GetTx() << std::endl; + s << " ty " << GetTy() << std::endl; + s << " qp " << GetQp() << std::endl; + s << " t " << GetTime() << std::endl; + s << " vi " << GetVi() << std::endl; + s << " z " << GetZ() << std::endl; + s << "C = " << std::endl; + s << " c00 " << C00() << std::endl; + s << " c11 " << C11() << std::endl; + s << " c22 " << C22() << std::endl; + s << " c33 " << C33() << std::endl; + s << " c44 " << C44() << std::endl; + s << " c55 " << C55() << std::endl; + s << " c66 " << C66() << std::endl; + s << ToStringCorrelations(i); + } + return s.str(); + } + + template<typename DataT> + std::string TrackParamBase<DataT>::ToStringCorrelations(int i) const + { + std::stringstream s; + s << std::setprecision(6); + + // print only one component of the SIMD vector + if constexpr (std::is_same_v<DataT, fvec>) { + if (i >= 0) { + float s0 = sqrt(C00()[i]); + float s1 = sqrt(C11()[i]); + float s2 = sqrt(C22()[i]); + float s3 = sqrt(C33()[i]); + float s4 = sqrt(C44()[i]); + float s5 = sqrt(C55()[i]); + float s6 = sqrt(C66()[i]); + + s << "K = " << std::endl; + s << " " << C10()[i] / s1 / s0 << std::endl; + s << " " << C20()[i] / s2 / s0 << " " << C21()[i] / s2 / s1 << std::endl; + s << " " << C30()[i] / s3 / s0 << " " << C31()[i] / s3 / s1 << " " << C32()[i] / s3 / s2 << std::endl; + s << " " << C40()[i] / s4 / s0 << " " << C41()[i] / s4 / s1 << " " << C42()[i] / s4 / s2 << " " + << C43()[i] / s4 / s3 << std::endl; + s << " " << C50()[i] / s5 / s0 << " " << C51()[i] / s5 / s1 << " " << C52()[i] / s5 / s2 << " " + << C53()[i] / s5 / s3 << " " << C54()[i] / s5 / s4 << std::endl; + s << " " << C60()[i] / s6 / s0 << " " << C61()[i] / s6 / s1 << " " << C62()[i] / s6 / s2 << " " + << C63()[i] / s6 / s3 << " " << C64()[i] / s6 / s4 << " " << C65()[i] / s6 / s5 << std::endl; + return s.str(); + } + } + + // print all SIMD values + { + DataT s0 = sqrt(C00()); + DataT s1 = sqrt(C11()); + DataT s2 = sqrt(C22()); + DataT s3 = sqrt(C33()); + DataT s4 = sqrt(C44()); + DataT s5 = sqrt(C55()); + DataT s6 = sqrt(C66()); + + s << "K = " << std::endl; + s << " k10 " << C10() / s1 / s0 << std::endl; + + s << "\n k20 " << C20() / s2 / s0 << std::endl; + s << " k21 " << C21() / s2 / s1 << std::endl; + + s << "\n k30 " << C30() / s3 / s0 << std::endl; + s << " k31 " << C31() / s3 / s1 << std::endl; + s << " k32 " << C32() / s3 / s2 << std::endl; + + s << "\n k40 " << C40() / s4 / s0 << std::endl; + s << " k41 " << C41() / s4 / s1 << std::endl; + s << " k42 " << C42() / s4 / s2 << std::endl; + s << " k43 " << C43() / s4 / s3 << std::endl; + + s << "\n k50 " << C50() / s5 / s0 << std::endl; + s << " k51 " << C51() / s5 / s1 << std::endl; + s << " k52 " << C52() / s5 / s2 << std::endl; + s << " k53 " << C53() / s5 / s3 << std::endl; + s << " k54 " << C54() / s5 / s4 << std::endl; + + s << "\n k60 " << C60() / s6 / s0 << std::endl; + s << " k61 " << C61() / s6 / s1 << std::endl; + s << " k62 " << C62() / s6 / s2 << std::endl; + s << " k63 " << C63() / s6 / s3 << std::endl; + s << " k64 " << C64() / s6 / s4 << std::endl; + s << " k65 " << C65() / s6 / s5 << std::endl; + } + + return s.str(); + } + + template<typename DataT> + double GetEntry(DataT v, int) + { + return (double) v; + } + + template<> + double GetEntry<fvec>(fvec v, int k) + { + return (double) v[k]; + } + + template<typename DataT> + bool TrackParamBase<DataT>::IsFinite(bool printWhenWrong) const + { + // verify that all the numbers in the object are valid floats + bool ret = true; + + auto check = [&](const std::string& s, DataT val) { + if (!utils::IsFinite(val)) { + ret = false; + if (printWhenWrong) { LOG(warning) << " TrackParam parameter " << s << " is undefined: " << val; } + } + }; + + check("x", fX); + check("y", fY); + check("tx", fTx); + check("ty", fTy); + check("qp", fQp); + check("t", fT); + check("vi", fVi); + check("z", fZ); + check("chi2", fChiSq); + check("ndf", fNdf); + check("chi2time", fChiSqTime); + check("ndfTime", fNdfTime); + + for (int i = 0; i < kNtrackParam; i++) { + for (int j = 0; j <= i; j++) { + DataT val = C(i, j); + if (!utils::IsFinite(val)) { + ret = false; + if (printWhenWrong) { + LOG(warning) << " TrackParam Cov matrix element (" << i << "," << j << ") is undefined: " << val; + } + } + } + } + + return ret; + } + + template<typename DataT> + bool TrackParamBase<DataT>::IsEntryConsistent(bool printWhenWrong, int k) const + { + // verify that all the numbers in the object are valid floats + + bool ok = true; + + auto check = [&](const std::string& s, DataT val) { + double dval = GetEntry(val, k); + if (!std::isfinite(dval)) { + ok = false; + if (printWhenWrong) { + LOG(warning) << " TrackParam parameter " << s << ", vector entry " << k << " is not finite: " << dval; + } + } + }; + + check("x", fX); + check("y", fY); + check("tx", fTx); + check("ty", fTy); + check("qp", fQp); + check("t", fT); + check("vi", fVi); + check("z", fZ); + check("chi2", fChiSq); + check("ndf", fNdf); + check("chi2time", fChiSqTime); + check("ndfTime", fNdfTime); + + // verify diagonal elements. + // Cii is a squared dispersion of i-th parameter, it must be positive + + for (int i = 0; i < 7; i++) { + double val = GetEntry(C(i, i), k); + if (val <= 0.) { + ok = false; + if (printWhenWrong) { + LOG(warning) << " TrackParam: C[" << i << "," << i << "], vec entry " << k << " is not positive: " << val + << std::endl; + } + } + } + + // verify non-diagonal elements. + // Cij/sqrt(Cii*Cjj) is a correlation between i-th and j-th parameter, + // it must belong to [-1,1] + + for (int i = 1; i < 7; i++) { + for (int j = 0; j < i; j++) { + double tolerance = 1.0; + double cij = GetEntry(C(i, j), k); + double cii = GetEntry(C(i, i), k); + double cjj = GetEntry(C(j, j), k); + if (cij * cij > tolerance * (cii * cjj)) { + ok = false; + if (printWhenWrong) { + LOG(warning) << " TrackParam: correlation [" << i << "," << j << "], vec entry " << k + << " is too large: " << cij / sqrt(cii * cjj) << std::endl; + } + } + } + } + + // verify triplets of correlations + // Kxy * Kxy + Kxz * Kxz + Kyz * Kyz <= 1 + 2 * Kxy * Kxz * Kyz + + for (int i = 2; i < 7; i++) { + for (int j = 1; j < i; j++) { + for (int m = 0; m < j; m++) { + double tolerance = 1.0; + double Cxx = GetEntry(C(i, i), k); + double Cyy = GetEntry(C(j, j), k); + double Czz = GetEntry(C(m, m), k); + double Cxy = GetEntry(C(i, j), k); + double Cxz = GetEntry(C(i, m), k); + double Cyz = GetEntry(C(j, m), k); + if (Cxx * Cyz * Cyz + Cyy * Cxz * Cxz + Czz * Cxy * Cxy + > tolerance * (Cxx * Cyy * Czz + 2. * Cxy * Cyz * Cxz)) { + ok = false; + if (printWhenWrong) { + double Kxy = Cxy / sqrt(Cxx * Cyy); + double Kxz = Cxz / sqrt(Cxx * Czz); + double Kyz = Cyz / sqrt(Cyy * Czz); + LOG(warning) << " TrackParam: correlations between parametetrs " << i << ", " << j << ", " << m + << ", vec entry " << k << " are wrong: " << Kxy << " " << Kxz << " " << Kyz << std::endl + << " inequation: " << Kxy * Kxy + Kxz * Kxz + Kyz * Kyz << " > " << 1 + 2 * Kxy * Kxz * Kyz + << std::endl; + } + } + } + } + } + + if (!ok && printWhenWrong) { + LOG(warning) << "TrackParam parameters are not consistent: " << std::endl; + LOG(warning) << ToString(k); + } + return ok; + } + + template<typename DataT> + bool TrackParamBase<DataT>::IsConsistent(bool printWhenWrong, int nFilled) const + { + int size = 1; + + if constexpr (std::is_same_v<DataT, fvec>) { size = fvec::size(); } + + assert(nFilled <= size); + if (nFilled < 0) { nFilled = size; } + + bool ok = true; + for (int i = 0; i < nFilled; ++i) { + ok = ok && IsEntryConsistent(printWhenWrong, i); + } + + if (!ok && printWhenWrong) { + LOG(warning) << "TrackParam parameters are not consistent: " << std::endl; + if (nFilled == size) { LOG(warning) << " All vector elements are filled " << std::endl; } + else { + LOG(warning) << " Only first " << nFilled << " vector elements are filled " << std::endl; + } + LOG(warning) << ToString(-1); + } + return ok; + } + + template class TrackParamBase<fvec>; + template class TrackParamBase<float>; + template class TrackParamBase<double>; + +} // namespace cbm::algo::ca diff --git a/algo/ca/core/data/CaTrackParam.h b/algo/ca/core/data/CaTrackParam.h new file mode 100644 index 0000000000000000000000000000000000000000..1902b044af7027a14ce1ec184f0f9d4810ffb5a6 --- /dev/null +++ b/algo/ca/core/data/CaTrackParam.h @@ -0,0 +1,723 @@ +/* Copyright (C) 2007-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt + SPDX-License-Identifier: GPL-3.0-only + Authors: Igor Kulakov [committer], Maksym Zyzak, Sergei Zharko */ + + +/// \file CaTrackParam.h +/// \brief header file for the ca::TrackParam class +/// \since 02.06.2022 +/// \author Sergey Gorbunov + +#ifndef CaTrackParam_h +#define CaTrackParam_h 1 + +#include <boost/serialization/access.hpp> + +#include <string> + +#include "CaConstants.h" +#include "CaSimd.h" +#include "CaUtils.h" + +namespace cbm::algo::ca +{ + /// \class cbm::algo::ca:: TrackParamBase + /// \brief Class represents track parameters in the CA tracking algorithm + /// + /// This is a template that can be instantiated for different floating point types. + /// Track parameters: variable parameterts {x, y, tx, ty, q/p, t, vi} at fixed z + /// Covariation matrix: low-diagopnal C[28] + /// + template<typename DataT> + class TrackParamBase { + + public: + friend class boost::serialization::access; + + static constexpr int kNtrackParam {7}; ///< N of variable track parameters: {x, y, tx, ty, q/p, t, vi} + static constexpr int kNcovParam {(kNtrackParam) * (kNtrackParam + 1) / 2}; ///< N of covariance matrix parameters + + typedef std::array<DataT, kNcovParam> CovMatrix_t; ///< covariance matrix type + + TrackParamBase() = default; + + template<typename T> + TrackParamBase(const TrackParamBase<T>& tr) + { + Set(tr); + } + + /// Set all SIMD entries from all SIMD entries of the other class + /// It works for scalar and fvec types, + /// except of the case when DataT is scalar and TdataB is fvec. + template<typename TdataB> + void Set(const TrackParamBase<TdataB>& Tb) + { + CopyBase<TdataB, true, true>(0, Tb, 0); + } + + /// Set all SIMD entries from one SIMD entry of the other class + /// It also works when DataT is scalar + void Set(const TrackParamBase<fvec>& Tb, const int ib) { CopyBase<fvec, true, false>(0, Tb, ib); } + + /// Set one SIMD entry from one SIMD entry of the other class + /// It only works when DataT is fvec, TdataB is scalar + template<typename TdataB> + void SetOneEntry(const int ia, const TrackParamBase<TdataB>& Tb) + { + CopyBase<TdataB, false, true>(ia, Tb, 0); + } + + /// Set one SIMD entry from one SIMD entry of the other class + /// It only works when DataT is fvec, TdataB is fvec + void SetOneEntry(const int ia, const TrackParamBase<fvec>& Tb, const int ib) + { + CopyBase<fvec, false, false>(ia, Tb, ib); + } + + /// --------------------------------------------------------------------------------------------------------------------- + /// Getters without 'Get' prefix to ease the math formulae + /// + + /// \brief Gets z position [cm] + DataT Z() const { return fZ; } + + /// \brief Gets x position [cm] + DataT X() const { return fX; } + + /// \brief Gets y position [cm] + DataT Y() const { return fY; } + + /// \brief Gets slope along x-axis + DataT Tx() const { return fTx; } + + /// \brief Gets slope along y-axis + DataT Ty() const { return fTy; } + + /// \brief Gets charge over momentum [ec/GeV] + DataT Qp() const { return fQp; } + + /// \brief Gets time [ns] + DataT Time() const { return fT; } + + /// \brief Gets inverse velocity [ns/cm] + DataT Vi() const { return fVi; } + + /// \brief Gets Chi-square of track fit model + DataT ChiSq() const { return fChiSq; } + + /// \brief Gets NDF of track fit model + DataT Ndf() const { return fNdf; } + + /// \brief Gets Chi-square of time measurements + DataT ChiSqTime() const { return fChiSqTime; } + + /// \brief Gets NDF of time measurements + DataT NdfTime() const { return fNdfTime; } + + /// \brief Get covariance matrix element + /// \param i row + /// \param j column + /// \return covariance matrix element + DataT C(int i, int j) const + { + int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; + return fCovMatrix[ind]; + } + + /// \brief Get covariance matrix element when indices are known at compile time + /// \param i row + /// \param j column + /// \return matrix element + template<int i, int j> + DataT C() const + { + constexpr int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; + return fCovMatrix[ind]; + } + + /// \brief Individual getters for covariance matrix elements + /// \return covariance matrix element + /// + DataT C00() const { return C<0, 0>(); } + DataT C10() const { return C<1, 0>(); } + DataT C11() const { return C<1, 1>(); } + DataT C20() const { return C<2, 0>(); } + DataT C21() const { return C<2, 1>(); } + DataT C22() const { return C<2, 2>(); } + DataT C30() const { return C<3, 0>(); } + DataT C31() const { return C<3, 1>(); } + DataT C32() const { return C<3, 2>(); } + DataT C33() const { return C<3, 3>(); } + DataT C40() const { return C<4, 0>(); } + DataT C41() const { return C<4, 1>(); } + DataT C42() const { return C<4, 2>(); } + DataT C43() const { return C<4, 3>(); } + DataT C44() const { return C<4, 4>(); } + DataT C50() const { return C<5, 0>(); } + DataT C51() const { return C<5, 1>(); } + DataT C52() const { return C<5, 2>(); } + DataT C53() const { return C<5, 3>(); } + DataT C54() const { return C<5, 4>(); } + DataT C55() const { return C<5, 5>(); } + DataT C60() const { return C<6, 0>(); } + DataT C61() const { return C<6, 1>(); } + DataT C62() const { return C<6, 2>(); } + DataT C63() const { return C<6, 3>(); } + DataT C64() const { return C<6, 4>(); } + DataT C65() const { return C<6, 5>(); } + DataT C66() const { return C<6, 6>(); } + + /// --------------------------------------------------------------------------------------------------------------------- + /// Getters with 'Get' prefix + /// Some of them involve calculations + + /// \brief Gets z position [cm] + DataT GetZ() const { return fZ; } + + /// \brief Gets x position [cm] + DataT GetX() const { return fX; } + + /// \brief Gets x position error [cm] + DataT GetXError() const { return sqrt(C00()); } + + /// \brief Gets y position [cm] + DataT GetY() const { return fY; } + + /// \brief Gets y position error [cm] + DataT GetYError() const { return sqrt(C11()); } + + /// \brief Gets slope along x-axis + DataT GetTx() const { return fTx; } + + /// \brief Gets error of slope along x-axis + DataT GetTxError() const { return sqrt(C22()); } + + /// \brief Gets slope along y-axis + DataT GetTy() const { return fTy; } + + /// \brief Gets error of slope along y-axis + DataT GetTyError() const { return sqrt(C33()); } + + /// \brief Gets charge over momentum [ec/GeV] + DataT GetQp() const { return fQp; } + + /// \brief Gets error of charge over momentum [ec/GeV] + DataT GetQpError() const { return sqrt(C44()); } + + /// \brief Gets time [ns] + DataT GetTime() const { return fT; } + + /// \brief Gets time error [ns] + DataT GetTimeError() const { return sqrt(C55()); } + + /// \brief Gets inverse velocity [ns/cm] in downstream direction + DataT GetVi() const { return fVi; } + + /// \brief Gets inverse velocity error [ns/cm] + DataT GetViError() const { return sqrt(C66()); } + + /// \brief Gets covariance matrix + const CovMatrix_t& GetCovMatrix() const { return fCovMatrix; } + + /// \brief Get covariance matrix element + /// \param i row + /// \param j column + /// \return covariance matrix element + DataT GetCovariance(int i, int j) const { return C(i, j); } + + /// Gets Chi-square of track fit model + DataT GetChiSq() const { return fChiSq; } + + /// Gets NDF of track fit model + DataT GetNdf() const { return fNdf; } + + /// Gets Chi-square of time measurements + DataT GetChiSqTime() const { return fChiSqTime; } + + /// Gets NDF of time measurements + DataT GetNdfTime() const { return fNdfTime; } + + /// Gets charge + DataT GetCharge() const { return utils::iif(GetQp() > DataT(0.), DataT(1.), DataT(-1.)); } + + /// \brief Gets azimuthal angle [rad] + DataT GetPhi() const { return atan2(GetTy(), GetTx()); } + + /// \brief Gets azimuthal angle error [rad] + DataT GetPhiError() const; + + /// \brief Gets polar angle [rad] + DataT GetTheta() const { return atan(sqrt(GetTx() * GetTx() + GetTy() * GetTy())); } + + /// \brief Gets polar angle error [rad] + DataT GetThetaError() const; + + /// Gets momentum [GeV/ec]. For the straight tracks returns 1.e4 [GeV/ec] + DataT GetP() const + { + return utils::iif(utils::fabs(GetQp()) > DataT(1.e-4), DataT(1.) / utils::fabs(GetQp()), DataT(1.e4)); + } + + /// Gets z-component of the momentum [GeV/ec] + DataT GetPz() const { return GetP() / sqrt(DataT(1.) + GetTx() * GetTx() + GetTy() * GetTy()); } + + /// Gets x-component of the momentum [GeV/ec] + DataT GetPx() const { return GetPz() * GetTx(); } + + /// Gets y-component of the momentum [GeV/ec] + DataT GetPy() const { return GetPz() * GetTy(); } + + /// Gets transverse momentum + DataT GetPt() const + { + DataT t2 = GetTx() * GetTx() + GetTy() * GetTy(); + return GetP() * sqrt(t2 / (DataT(1.) + t2)); + } + + /// --------------------------------------------------------------------------------------------------------------------- + /// Parameter setters + /// + + /// \brief Sets z position [cm] + void SetZ(DataT v) { fZ = v; } + + /// \brief Sets x position [cm] + void SetX(DataT v) { fX = v; } + + /// \brief Sets y position [cm] + void SetY(DataT v) { fY = v; } + + /// \brief Sets slope along x-axis + void SetTx(DataT v) { fTx = v; } + + /// \brief Sets slope along y-axis + void SetTy(DataT v) { fTy = v; } + + /// \brief Sets charge over momentum [ec/GeV] + void SetQp(DataT v) { fQp = v; } + + /// \brief Sets time [ns] + void SetTime(DataT v) { fT = v; } + + /// \brief Sets inverse velocity [ns/cm] + void SetVi(DataT v) { fVi = v; } + + /// \brief Sets Chi-square of track fit model + void SetChiSq(DataT v) { fChiSq = v; } + + /// \brief Sets NDF of track fit model + void SetNdf(DataT v) { fNdf = v; } + + /// \brief Sets Chi-square of time measurements + void SetChiSqTime(DataT v) { fChiSqTime = v; } + + /// \brief Sets NDF of time measurements + void SetNdfTime(DataT v) { fNdfTime = v; } + + /// \brief Sets covariance matrix + void SetCovMatrix(const CovMatrix_t& val) { fCovMatrix = val; } + + /// \brief Get covariance matrix element + /// \param i row + /// \param j column + /// \param val covariance matrix element + void SetCovariance(int i, int j, DataT val) + { + int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; + fCovMatrix[ind] = val; + } + + /// \brief Get covariance matrix element when indices are known at compile time + /// \param i row + /// \param j column + /// \param val matrix element + template<int i, int j> + void SetCovariance(DataT val) + { + constexpr int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; + fCovMatrix[ind] = val; + } + + /// \brief Individual setters for covariance matrix elements + /// + void SetC00(DataT val) { SetCovariance<0, 0>(val); } + void SetC10(DataT val) { SetCovariance<1, 0>(val); } + void SetC11(DataT val) { SetCovariance<1, 1>(val); } + void SetC20(DataT val) { SetCovariance<2, 0>(val); } + void SetC21(DataT val) { SetCovariance<2, 1>(val); } + void SetC22(DataT val) { SetCovariance<2, 2>(val); } + void SetC30(DataT val) { SetCovariance<3, 0>(val); } + void SetC31(DataT val) { SetCovariance<3, 1>(val); } + void SetC32(DataT val) { SetCovariance<3, 2>(val); } + void SetC33(DataT val) { SetCovariance<3, 3>(val); } + void SetC40(DataT val) { SetCovariance<4, 0>(val); } + void SetC41(DataT val) { SetCovariance<4, 1>(val); } + void SetC42(DataT val) { SetCovariance<4, 2>(val); } + void SetC43(DataT val) { SetCovariance<4, 3>(val); } + void SetC44(DataT val) { SetCovariance<4, 4>(val); } + void SetC50(DataT val) { SetCovariance<5, 0>(val); } + void SetC51(DataT val) { SetCovariance<5, 1>(val); } + void SetC52(DataT val) { SetCovariance<5, 2>(val); } + void SetC53(DataT val) { SetCovariance<5, 3>(val); } + void SetC54(DataT val) { SetCovariance<5, 4>(val); } + void SetC55(DataT val) { SetCovariance<5, 5>(val); } + void SetC60(DataT val) { SetCovariance<6, 0>(val); } + void SetC61(DataT val) { SetCovariance<6, 1>(val); } + void SetC62(DataT val) { SetCovariance<6, 2>(val); } + void SetC63(DataT val) { SetCovariance<6, 3>(val); } + void SetC64(DataT val) { SetCovariance<6, 4>(val); } + void SetC65(DataT val) { SetCovariance<6, 5>(val); } + void SetC66(DataT val) { SetCovariance<6, 6>(val); } + + ///--------------------------------------------------------------------------------------------------------------------- + /// References to parameters to ease the math formulae + /// They are especially useful for masked SIMD operations like: X()( mask ) = fvec(1.); + /// + + /// \brief Reference to z position [cm] + DataT& Z() { return fZ; } + + /// \brief Reference to x position [cm] + DataT& X() { return fX; } + + /// \brief Reference to y position [cm] + DataT& Y() { return fY; } + + /// \brief Reference to slope along x-axis + DataT& Tx() { return fTx; } + + /// \brief Reference to slope along y-axis + DataT& Ty() { return fTy; } + + /// \brief Reference to charge over momentum [ec/GeV] + DataT& Qp() { return fQp; } + + /// \brief Reference to time [ns] + DataT& Time() { return fT; } + + /// \brief Reference to inverse velocity [ns/cm] + DataT& Vi() { return fVi; } + + /// \brief Reference to covariance matrix + CovMatrix_t& CovMatrix() { return fCovMatrix; } + + /// \brief Reference to Chi-square of track fit model + DataT& ChiSq() { return fChiSq; } + + /// \brief Reference to NDF of track fit model + DataT& Ndf() { return fNdf; } + + /// \brief Reference to Chi-square of time measurements + DataT& ChiSqTime() { return fChiSqTime; } + + /// \brief Reference to NDF of time measurements + DataT& NdfTime() { return fNdfTime; } + + /// \brief Get a reference to the covariance matrix element + /// \param i row + /// \param j column + /// \return matrix element + DataT& C(int i, int j) + { + int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; + return fCovMatrix[ind]; + } + + /// \brief Get a reference to the covariance matrix element when indices are known at compile time + /// \param i row + /// \param j column + /// \param val matrix element + template<int i, int j> + DataT& C() + { + constexpr int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; + return fCovMatrix[ind]; + } + + /// \brief Individual references to covariance matrix elements + /// + DataT& C00() { return C<0, 0>(); } + DataT& C10() { return C<1, 0>(); } + DataT& C11() { return C<1, 1>(); } + DataT& C20() { return C<2, 0>(); } + DataT& C21() { return C<2, 1>(); } + DataT& C22() { return C<2, 2>(); } + DataT& C30() { return C<3, 0>(); } + DataT& C31() { return C<3, 1>(); } + DataT& C32() { return C<3, 2>(); } + DataT& C33() { return C<3, 3>(); } + DataT& C40() { return C<4, 0>(); } + DataT& C41() { return C<4, 1>(); } + DataT& C42() { return C<4, 2>(); } + DataT& C43() { return C<4, 3>(); } + DataT& C44() { return C<4, 4>(); } + DataT& C50() { return C<5, 0>(); } + DataT& C51() { return C<5, 1>(); } + DataT& C52() { return C<5, 2>(); } + DataT& C53() { return C<5, 3>(); } + DataT& C54() { return C<5, 4>(); } + DataT& C55() { return C<5, 5>(); } + DataT& C60() { return C<6, 0>(); } + DataT& C61() { return C<6, 1>(); } + DataT& C62() { return C<6, 2>(); } + DataT& C63() { return C<6, 3>(); } + DataT& C64() { return C<6, 4>(); } + DataT& C65() { return C<6, 5>(); } + DataT& C66() { return C<6, 6>(); } + + + ///--------------------------------------------------------------------------------------------------------------------- + /// Other methods + + /// \brief Resets variances of track parameters and chi2, ndf values + /// \param c00 Variance of x-position [cm2] + /// \param c11 Variance of y-position [cm2] + /// \param c22 Variance of slope along x-axis + /// \param c33 Variance of slope along y-axis + /// \param c44 Variance of charge over momentum [(ec/GeV)2] + /// \param c55 Variance of time [ns2] + /// \param c66 Variance of inverse velocity [1/c2] + void ResetErrors(DataT c00, DataT c11, DataT c22, DataT c33, DataT c44, DataT c55, DataT c66); + + /// \brief Prints parameters to a string + /// \param i Index of SIMD vector element (when i== -1, the entire vector is printed) + std::string ToString(int i = -1) const; + + /// \brief Prints correlations to a string + /// \param i Index of SIMD vector element (when i== -1, the entire vector is printed) + std::string ToStringCorrelations(int i = -1) const; + + /// \brief Checks whether some parameters are finite + bool IsFinite(bool printWhenWrong) const; + + /// \brief Checks whether SIMD entry i is consistent + bool IsEntryConsistent(bool printWhenWrong, int i) const; + + /// \brief Checks whether first nFilled SIMD entries are consistent + bool IsConsistent(bool printWhenWrong, int nFilled) const; + + /// \brief Initializes inverse velocity range + void InitVelocityRange(fscal minP); + + + ///--------------------------------------------------------------------------------------------------------------------- + /// Serialization + /// + template<class Archive> + void serialize(Archive& ar, const unsigned int /*version*/) + { + ar& fX; + ar& fY; + ar& fTx; + ar& fTy; + ar& fQp; + ar& fZ; + ar& fT; + ar& fVi; + ar& fCovMatrix; + ar& fChiSq; + ar& fNdf; + ar& fChiSqTime; + ar& fNdfTime; + } + + private: + /// \brief Copies all/one entries from the other class + /// \tparam TdataB Type of the other class + /// \tparam TDoAllA If true, all entries of the current class must be set + /// \tparam TDoAllB If true, all entries of the other class must be used + /// \param ia Index of SIMD vector element of the current class + /// \param Tb Other class + /// \param ib Index of SIMD vector element of the other class + template<typename TdataB, bool TDoAllA, bool TDoAllB> + void CopyBase(const int ia, const TrackParamBase<TdataB>& Tb, const int ib); + + + private: + /// --------------------------------------------------------------------------------------------------------------------- + /// Class members + + // ! CI tests are failing by timeout when using undef values + // TODO: fix it and uncomment the line below + //static constexpr auto kUndef = cbm::algo::ca::constants::Undef<DataT>; + static constexpr auto kUndef = 0.; + + CovMatrix_t fCovMatrix {kUndef}; ///< covariance matrix + + DataT fX {kUndef}; ///< x-position [cm] + DataT fY {kUndef}; ///< y-position [cm] + DataT fZ {kUndef}; ///< z-position [cm] + DataT fTx {kUndef}; ///< slope along x-axis + DataT fTy {kUndef}; ///< slope along y-axis + DataT fQp {kUndef}; ///< charge over momentum [ec/GeV] + DataT fT {kUndef}; ///< time [ns] + DataT fVi {kUndef}; ///< inverse velocity in downstream direction [ns/cm] + + DataT fChiSq {kUndef}; ///< chi^2 of track fit, spatial measurements + DataT fNdf {kUndef}; ///< NDF of track fit, spatial measurements + DataT fChiSqTime {kUndef}; ///< chi^2 of track fit, time measurements + DataT fNdfTime {kUndef}; ///< NDF of track fit, time measurements + + } _fvecalignment; // class TrackParamBase + + + /// \class cbm::algo::ca:: TrackParamBaseScalar + /// \brief Scalar version of TrackParamBase + /// + /// It contains extra methods that are difficult to implement in SIMD version + template<typename DataT> + class TrackParamBaseScalar : public TrackParamBase<DataT> { + public: + /// \brief Gets pseudo-rapidity + DataT GetEta() const { return -log(tan(this->GetTheta() * DataT(0.5))); } + + } _fvecalignment; + + // --------------------------------------------------------------------------------------------------------------------- + /// TrackParam classes of different types + + typedef TrackParamBase<fvec> TrackParamV; + typedef TrackParamBaseScalar<fscal> TrackParamS; + typedef TrackParamBaseScalar<double> TrackParamD; + + + /// --------------------------------------------------------------------------------------------------------------------- + /// Inline and template function implementation + + + /// --------------------------------------------------------------------------------------------------------------------- + /// + template<typename DataT> + inline DataT TrackParamBase<DataT>::GetPhiError() const + { + // phi = atan( tx / ty ); } + + DataT phiDdenom = GetTx() * GetTx() + GetTy() * GetTy(); + DataT phiDTx = -GetTy() / phiDdenom; // partial derivative of phi over Tx + DataT phiDTy = +GetTx() / phiDdenom; // partial derivative of phi over Ty + + DataT varTx = C22(); // variance of Tx + DataT varTy = C33(); // variance of Ty + DataT covTxTy = C32(); // covariance of Tx and Ty + + DataT varPhi = phiDTx * phiDTx * varTx + phiDTy * phiDTy * varTy + DataT(2.) * phiDTx * phiDTy * covTxTy; + return sqrt(varPhi); + } + + + /// --------------------------------------------------------------------------------------------------------------------- + /// + template<typename DataT> + inline DataT TrackParamBase<DataT>::GetThetaError() const + { + // theta = atan(sqrt( tx * tx + ty * ty) ) + + DataT sumSqSlopes = GetTx() * GetTx() + GetTy() * GetTy(); + DataT thetaDdenom = sqrt(sumSqSlopes) * (DataT(1.) + sumSqSlopes); + DataT thetaDTx = GetTx() / thetaDdenom; + DataT thetaDTy = GetTy() / thetaDdenom; + + DataT varTx = C22(); // variance of Tx + DataT varTy = C33(); // variance of Ty + DataT covTxTy = C32(); // covariance of Tx and Ty + + DataT varTheta = + thetaDTx * thetaDTx * varTx + thetaDTy * thetaDTy * varTy + DataT(2.) * thetaDTx * thetaDTy * covTxTy; + + return sqrt(varTheta); + } + + + // --------------------------------------------------------------------------------------------------------------------- + // + template<typename TdataA> + template<typename TdataB, bool TDoAllA, bool TDoAllB> + inline void TrackParamBase<TdataA>::CopyBase(const int ia, const TrackParamBase<TdataB>& Tb, const int ib) + { + auto copy = [&](TdataA& a, const TdataB& b) { + if constexpr (TDoAllA || !std::is_same<TdataA, fvec>::value) { + // set all entries or TdataA is a scalar + if constexpr (TDoAllB || !std::is_same<TdataB, fvec>::value) { + // set all entries or TdataB is a scalar + a = b; + } + else { + // TdataB is a vector + a = b[ib]; + } + } + else { + // set only one entry and TdataA is a vector + if constexpr (TDoAllB || !std::is_same<TdataB, fvec>::value) { + // set all entries or TdataB is a scalar + a[ia] = b; + } + else { + // TdataB is a vector + a[ia] = b[ib]; + } + } + }; + + copy(fX, Tb.GetX()); + copy(fY, Tb.GetY()); + copy(fTx, Tb.GetTx()); + copy(fTy, Tb.GetTy()); + copy(fQp, Tb.GetQp()); + copy(fZ, Tb.GetZ()); + copy(fT, Tb.GetTime()); + copy(fVi, Tb.GetVi()); + + for (int i = 0; i < kNcovParam; ++i) { + copy(fCovMatrix[i], Tb.GetCovMatrix()[i]); + } + + copy(fChiSq, Tb.GetChiSq()); + copy(fNdf, Tb.GetNdf()); + copy(fChiSqTime, Tb.GetChiSqTime()); + copy(fNdfTime, Tb.GetNdfTime()); + + } // CopyBase + + + // --------------------------------------------------------------------------------------------------------------------- + // + template<typename DataT> + inline void TrackParamBase<DataT>::ResetErrors(DataT c00, DataT c11, DataT c22, DataT c33, DataT c44, DataT c55, + DataT c66) + { + fCovMatrix.fill(0.); + + SetC00(c00); + SetC11(c11); + SetC22(c22); + SetC33(c33); + SetC44(c44); + SetC55(c55); + SetC66(c66); + + SetChiSq(0.); + SetNdf(-5.); + SetChiSqTime(0.); + SetNdfTime(-2.); + } + + // --------------------------------------------------------------------------------------------------------------------- + // + template<typename DataT> + inline void TrackParamBase<DataT>::InitVelocityRange(fscal minP) + { + // initialise the velocity range with respect to the minimal momentum minP {GeV/c} + namespace phys = constants::phys; + fscal maxVi = sqrt(1. + (phys::ProtonMassD / minP) * (phys::ProtonMassD / minP)) * phys::SpeedOfLightInvD; + fscal minVi = phys::SpeedOfLightInvD; + fscal vmean = minVi + 0.4 * (maxVi - minVi); + fscal dvi = (maxVi - vmean) / 3.; + SetVi(vmean); + SetC66(dvi * dvi); + } + +} // namespace cbm::algo::ca + +#endif // CaTrackParam_h diff --git a/algo/ca/core/pars/CaConstants.h b/algo/ca/core/pars/CaConstants.h index 0e233fbebcec0988f73c0e74cc6930328765bd11..f9d30e7be1ed3dbf0451fbb928fc5420c6c7ffa5 100644 --- a/algo/ca/core/pars/CaConstants.h +++ b/algo/ca/core/pars/CaConstants.h @@ -7,8 +7,8 @@ /// \since 02.06.2022 /// \author S.Zharko <s.zharko@gsi.de> -#ifndef CA_CORE_CONSTANTS -#define CA_CORE_CONSTANTS 1 +#ifndef CaConstants_h +#define CaConstants_h 1 #include <limits> @@ -63,17 +63,23 @@ namespace cbm::algo::ca::constants /// Physics constants namespace phys { - /// Particle masses used for track fit - constexpr float MuonMass = 0.10565800f; ///< Muon mass [GeV/c2] !! TODO: discrepancy in last two digits - constexpr float PionMass = 0.13957039f; ///< Pion mass [GeV/c2] - constexpr float KaonMass = 0.493677f; ///< Kaon mass [GeV/c2] (PDG 22.08.2023) - constexpr float ElectronMass = 0.000511f; ///< Electron mass [GeV/c2] - constexpr float ProtonMass = 0.93827209f; ///< Proton mass [GeV/c2] (0.93827208816 - PDG 11.08.2022) - constexpr double SpeedOfLight = 29.9792458; ///< Speed of light [cm/ns] - constexpr float SpeedOfLightF = 29.9792; ///< Speed of light [cm/ns] (single precision) - - constexpr double SpeedOfLightInv = 1 / SpeedOfLight; ///< Inverse speed of light [cm/ns] - constexpr float SpeedOfLightInvF = 1 / SpeedOfLightF; ///< Inverse speed of light [cm/ns] (single precision) + /// Particle masses etc used for the track fit, double precision + constexpr double MuonMassD = 0.105658375523; ///< Muon mass [GeV/c2] + constexpr double PionMassD = 0.1395703918; ///< Pion mass [GeV/c2] + constexpr double KaonMassD = 0.493677f; ///< Kaon mass [GeV/c2] (PDG 22.08.2023) + constexpr double ElectronMassD = 0.0005109989500015; ///< Electron mass [GeV/c2] + constexpr double ProtonMassD = 0.93827208816; ///< Proton mass [GeV/c2] (PDG 11.08.2022) + constexpr double SpeedOfLightD = 29.9792458; ///< Speed of light [cm/ns] + constexpr double SpeedOfLightInvD = 1. / SpeedOfLightD; ///< Inverse speed of light [ns/cm] + + /// Particle masses etc used for the track fit, fscal precision + constexpr fscal MuonMass = MuonMassD; ///< Muon mass [GeV/c2] + constexpr fscal PionMass = PionMassD; ///< Pion mass [GeV/c2] + constexpr fscal KaonMass = KaonMassD; ///< Kaon mass [GeV/c2] (PDG 22.08.2023) + constexpr fscal ElectronMass = ElectronMassD; ///< Electron mass [GeV/c2] + constexpr fscal ProtonMass = ProtonMassD; ///< Proton mass [GeV/c2] (PDG 11.08.2022) + constexpr fscal SpeedOfLight = SpeedOfLightD; ///< Speed of light [cm/ns] + constexpr fscal SpeedOfLightInv = SpeedOfLightInvD; ///< Inverse speed of light [ns/cm] } // namespace phys @@ -89,32 +95,28 @@ namespace cbm::algo::ca::constants constexpr int AssertionLevel = 0; ///< Assertion level constexpr int Alignment = 16; ///< Default alignment of data (bytes) } // namespace misc - // Colors of terminal log - /// Undefined values for different types - namespace undef - { - constexpr int Int = std::numeric_limits<int>::min(); - constexpr unsigned Uint = std::numeric_limits<unsigned>::max(); - constexpr float Float = std::numeric_limits<float>::signaling_NaN(); - constexpr double Double = std::numeric_limits<double>::signaling_NaN(); - constexpr fscal Fscal = std::numeric_limits<fscal>::signaling_NaN(); - - /// Checks whether a variable of a particular type defined - template<typename T> - bool IsUndefined(T val) - { - if constexpr (std::is_same_v<T, int>) { return val == undef::Int; } - if constexpr (std::is_same_v<T, unsigned>) { return val == undef::Uint; } - if constexpr (std::is_same_v<T, float>) { return std::isnan(val); } - if constexpr (std::is_same_v<T, double>) { return std::isnan(val); } - if constexpr (std::is_same_v<T, fscal>) { return std::isnan(val); } - if constexpr (std::is_same_v<T, fvec>) { return isnan(val).isNotEmpty(); } - return true; - } - - } // namespace undef + /// \brief Undefined values + template<typename T1, typename T2 = T1> + constexpr T2 Undef; + + template<> + inline constexpr int Undef<int> = std::numeric_limits<int>::min(); + + template<> + inline constexpr unsigned Undef<unsigned> = std::numeric_limits<unsigned>::max(); + + template<> + inline constexpr float Undef<float> = std::numeric_limits<float>::signaling_NaN(); + + template<> + inline constexpr double Undef<double> = std::numeric_limits<double>::signaling_NaN(); + template<> + inline constexpr fscal Undef<fvec> = std::numeric_limits<fscal>::signaling_NaN(); + + + /// Colors of terminal log messages namespace clrs { // NOTE: To be used first, because different users may have different console bg and fg colors @@ -215,10 +217,7 @@ namespace cbm::algo::ca::constants constexpr char GYbr[] = "\e[1;7;37m"; ///< bold-reverse grey constexpr char WTbr[] = "\e[1;7;38m"; ///< bold-reverse white } // namespace clrs -} // namespace cbm::algo::ca::constants - -/// TEMPORARY !!!! -using namespace cbm::algo::ca; +} // namespace cbm::algo::ca::constants -#endif // CA_CORE_CONSTANTS +#endif // CaConstants_h diff --git a/algo/ca/core/utils/CaSimd.h b/algo/ca/core/utils/CaSimd.h index 28ce54fd13eae6014bd87ad2805903bc026560d7..4c5406445d1067be6884bfca8f58ee76e7625096 100644 --- a/algo/ca/core/utils/CaSimd.h +++ b/algo/ca/core/utils/CaSimd.h @@ -3,7 +3,7 @@ Authors: Sergey Gorbunov [committer]*/ #ifndef Ca_CaSimd_H -#define Ca_CaSimd_H +#define Ca_CaSimd_H 1 #include "CaSimdVc.h" //#include "CaSimdPseudo.h" diff --git a/algo/ca/core/utils/CaSimdPseudo.h b/algo/ca/core/utils/CaSimdPseudo.h index f1cdd98c3132ccd59b9b42a8b1aa031a037222eb..9bbd745d58ebc7dd5f89e67a38b984c17acfe39e 100644 --- a/algo/ca/core/utils/CaSimdPseudo.h +++ b/algo/ca/core/utils/CaSimdPseudo.h @@ -3,7 +3,7 @@ Authors: Igor Kulakov [committer] */ #ifndef Ca_CaSimdPseudo_H -#define Ca_CaSimdPseudo_H +#define Ca_CaSimdPseudo_H 1 #include <boost/serialization/access.hpp> diff --git a/algo/ca/core/utils/CaUtils.h b/algo/ca/core/utils/CaUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..a75a067e54410d6305b1fd8adf52ca62b7308367 --- /dev/null +++ b/algo/ca/core/utils/CaUtils.h @@ -0,0 +1,77 @@ +/* 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> + +#ifndef CaUtils_h +#define CaUtils_h 1 + +#include "CaConstants.h" +#include "CaSimd.h" + +/// Namespace contains compile-time constants definition for the CA tracking algorithm +/// +namespace cbm::algo::ca::utils +{ + + inline fvec iif(const fmask& m, const fvec& t, const fvec& f) { return Vc::iif(m, t, f); } + inline fvec fabs(const fvec& v) { return Vc::abs(v); } + + template<typename T> + inline T iif(bool b, T t, T f) + { + return b ? t : f; + } + + template<typename T> + inline T fabs(const T& v) + { + return std::fabs(v); + } + + /// Checks whether a variable of a particular type defined + template<typename T> + inline bool IsUndefined(T val) + { + if constexpr (std::is_same_v<T, float>) { return std::isnan(val); } + else if constexpr (std::is_same_v<T, double>) { + return std::isnan(val); + } + else if constexpr (std::is_same_v<T, fscal>) { + return std::isnan(val); + } + else if constexpr (std::is_same_v<T, fvec>) { + return isnan(val).isNotEmpty(); + } + else { + return val == cbm::algo::ca::constants::Undef<T>; + } + } + + /// Checks whether a variable of a particular type is finite + template<typename T> + inline bool IsFinite(T val) + { + if constexpr (std::is_same_v<T, float>) { return std::isfinite(val); } + else if constexpr (std::is_same_v<T, double>) { + return std::isfinite(val); + } + else if constexpr (std::is_same_v<T, fscal>) { + return std::isfinite(val); + } + else if constexpr (std::is_same_v<T, fvec>) { + return isfinite(val).isFull(); + } + else { + return val != cbm::algo::ca::constants::Undef<T>; + } + } + +} // namespace cbm::algo::ca::utils + + +#endif // CaUtils_h diff --git a/core/data/CbmTrack.h b/core/data/CbmTrack.h index a6355625588b8f9573d63083426f9eafa2d75063..fb8aa723779a6e20c5539a93fac24b8f75171238 100644 --- a/core/data/CbmTrack.h +++ b/core/data/CbmTrack.h @@ -81,6 +81,8 @@ public: void SetPreviousTrackId(int32_t previousTrackId) { fPreviousTrackId = previousTrackId; } void SetParamFirst(const FairTrackParam* par) { fParamFirst = *par; } void SetParamLast(const FairTrackParam* par) { fParamLast = *par; } + void SetParamFirst(const FairTrackParam& par) { fParamFirst = par; } + void SetParamLast(const FairTrackParam& par) { fParamLast = par; } void SetMatch(CbmMatch* match); void SetStartTime(double time) { fStartTime = time; } void SetStartTimeError(double error) { fStartTimeError = error; } diff --git a/core/data/global/CbmGlobalTrack.h b/core/data/global/CbmGlobalTrack.h index 2e730c8d2fceff160c78f083d5f46906d44c0aac..de58e76f19aeb719a756bd08caa80456b4b2623a 100644 --- a/core/data/global/CbmGlobalTrack.h +++ b/core/data/global/CbmGlobalTrack.h @@ -66,6 +66,8 @@ public: void SetTofTrackIndex(int32_t iTofTrack) { fTofTrack = iTofTrack; } void SetParamFirst(const FairTrackParam* parFirst) { fParamFirst = *parFirst; } void SetParamLast(const FairTrackParam* parLast) { fParamLast = *parLast; } + void SetParamFirst(const FairTrackParam& parFirst) { fParamFirst = parFirst; } + void SetParamLast(const FairTrackParam& parLast) { fParamLast = parLast; } void SetParamPrimaryVertex(const FairTrackParam* parPV) { fParamPrimaryVertex.Set(*parPV); } void SetPidHypo(int32_t iPid) { fPidHypo = iPid; } void SetChi2(double chi2) { fChi2 = chi2; } diff --git a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx index 37f26dfaa2e0049ee4a86d5671a45cf02b4ebe4e..8d2dadc30520684a0c67bdd71a656976ab501125 100644 --- a/reco/KF/ParticleFitter/CbmL1PFFitter.cxx +++ b/reco/KF/ParticleFitter/CbmL1PFFitter.cxx @@ -34,13 +34,13 @@ #include "TDatabasePDG.h" +#include "CaTrackParam.h" #include "KFParticleDatabase.h" #include "L1Algo.h" // Also defines L1Parameters #include "L1Def.h" #include "L1Field.h" #include "L1Fit.h" #include "L1Station.h" -#include "L1TrackPar.h" //typedef L1Fit1 L1Fit; @@ -138,14 +138,15 @@ inline int CbmL1PFFitter::GetStsStationIndex(const CbmStsHit* hit) void FilterFirst(L1Fit& fit, fvec& x, fvec& y, fvec& t, L1XYMeasurementInfo& cov, fvec& dt2) { - L1TrackPar& tr = fit.Tr(); + TrackParamV& tr = fit.Tr(); tr.ResetErrors(cov.C00, cov.C11, 1., 1., 1., dt2, 1.e2); - tr.C10 = cov.C10; - tr.x = x; - tr.y = y; - tr.t = t; - tr.vi = 0.; - tr.NDF = -3.0; + tr.C10() = cov.C10; + tr.X() = x; + tr.Y() = y; + tr.Time() = t; + tr.Vi() = 0.; + tr.Ndf() = -3.; + tr.NdfTime() = -2.; } void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmMvdHit>& vMvdHits, @@ -159,13 +160,12 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM // fld.SetUseOriginalField(); static int nHits = CbmL1::Instance()->fpAlgo->GetParameters()->GetNstationsActive(); - int iVec = 0, i = 0; int nTracks_SIMD = fvec::size(); L1Fit fit; fit.SetParticleMass(CbmL1::Instance()->fpAlgo->GetDefaultParticleMass()); - L1TrackPar& T = fit.Tr(); // fitting parametr coresponding to current track + TrackParamV& T = fit.Tr(); // fitting parametr coresponding to current track CbmStsTrack* tr[fvec::size()] {nullptr}; @@ -200,56 +200,47 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM for (unsigned short itrack = 0; itrack < N_vTracks; itrack += fvec::size()) { - T.t = 0.; - T.vi = 0.; + T.Time() = 0.; + T.Vi() = 0.; T.ResetErrors(1.e2, 1.e2, 1., 1., 1., 1.e6, 1.e2); if (N_vTracks - itrack < static_cast<unsigned short>(fvec::size())) nTracks_SIMD = N_vTracks - itrack; - for (i = 0; i < nTracks_SIMD; i++) { - tr[i] = &Tracks[itrack + i]; // current track - T.x[i] = tr[i]->GetParamFirst()->GetX(); - T.y[i] = tr[i]->GetParamFirst()->GetY(); - T.tx[i] = tr[i]->GetParamFirst()->GetTx(); - T.ty[i] = tr[i]->GetParamFirst()->GetTy(); - T.qp[i] = tr[i]->GetParamFirst()->GetQp(); - T.t[i] = 0.; - T.vi[i] = 0.; - T.z[i] = tr[i]->GetParamFirst()->GetZ(); - T.C00[i] = tr[i]->GetParamFirst()->GetCovariance(0, 0); - T.C10[i] = tr[i]->GetParamFirst()->GetCovariance(1, 0); - T.C11[i] = tr[i]->GetParamFirst()->GetCovariance(1, 1); - T.C20[i] = tr[i]->GetParamFirst()->GetCovariance(2, 0); - T.C21[i] = tr[i]->GetParamFirst()->GetCovariance(2, 1); - T.C22[i] = tr[i]->GetParamFirst()->GetCovariance(2, 2); - T.C30[i] = tr[i]->GetParamFirst()->GetCovariance(3, 0); - T.C31[i] = tr[i]->GetParamFirst()->GetCovariance(3, 1); - T.C32[i] = tr[i]->GetParamFirst()->GetCovariance(3, 2); - T.C33[i] = tr[i]->GetParamFirst()->GetCovariance(3, 3); - T.C40[i] = tr[i]->GetParamFirst()->GetCovariance(4, 0); - T.C41[i] = tr[i]->GetParamFirst()->GetCovariance(4, 1); - T.C42[i] = tr[i]->GetParamFirst()->GetCovariance(4, 1); - T.C43[i] = tr[i]->GetParamFirst()->GetCovariance(4, 3); - T.C44[i] = tr[i]->GetParamFirst()->GetCovariance(4, 4); - - int pid = pidHypo[itrack + i]; + for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { + tr[iVec] = &Tracks[itrack + iVec]; // current track + T.X()[iVec] = tr[iVec]->GetParamFirst()->GetX(); + T.Y()[iVec] = tr[iVec]->GetParamFirst()->GetY(); + T.Tx()[iVec] = tr[iVec]->GetParamFirst()->GetTx(); + T.Ty()[iVec] = tr[iVec]->GetParamFirst()->GetTy(); + T.Qp()[iVec] = tr[iVec]->GetParamFirst()->GetQp(); + T.Time()[iVec] = 0.; + T.Vi()[iVec] = 0.; + T.Z()[iVec] = tr[iVec]->GetParamFirst()->GetZ(); + + for (int i = 0; i < 5; i++) { + for (int j = 0; j <= i; j++) { + T.C(i, j)[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(i, j); + } + } + + int pid = pidHypo[itrack + iVec]; if (pid == -1) pid = 211; // mass[i] = TDatabasePDG::Instance()->GetParticle(pid)->Mass(); - mass[i] = KFParticleDatabase::Instance()->GetMass(pid); + mass[iVec] = KFParticleDatabase::Instance()->GetMass(pid); } fit.SetParticleMass(mass); // get hits of current track - for (i = 0; i < nHits; i++) { + for (int i = 0; i < nHits; i++) { w[i] = fmask::Zero(); z[i] = sta[i].fZ; } - for (iVec = 0; iVec < nTracks_SIMD; iVec++) { + for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { int nHitsTrackMvd = tr[iVec]->GetNofMvdHits(); int nHitsTrackSts = tr[iVec]->GetNofStsHits(); int nHitsTrack = nHitsTrackMvd + nHitsTrackSts; - for (i = 0; i < nHitsTrack; i++) { + for (int i = 0; i < nHitsTrack; i++) { const CbmPixelHit* hit; if (i < nHitsTrackMvd) { @@ -309,23 +300,23 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM // fit forward - i = 0; + int i = 0; FilterFirst(fit, x_first, y_first, t_first, cov_first, dt2_first); - fit.SetQp0(fit.Tr().qp); + fit.SetQp0(fit.Tr().Qp()); z1 = z[i]; - sta[i].fieldSlice.GetFieldValue(T.x, T.y, b1); + sta[i].fieldSlice.GetFieldValue(T.X(), T.Y(), b1); b1.Combine(fB[i], w[i]); z2 = z[i + 2]; dz = z2 - z1; - sta[i].fieldSlice.GetFieldValue(T.x + T.tx * dz, T.y + T.ty * dz, b2); + sta[i].fieldSlice.GetFieldValue(T.X() + T.Tx() * dz, T.Y() + T.Ty() * dz, b2); b2.Combine(fB[i + 2], w[i + 2]); fld.Set(b2, z2, b1, z1, b0, z0); for (++i; i < nHits; i++) { z0 = z[i]; dz = (z1 - z0); - sta[i].fieldSlice.GetFieldValue(T.x - T.tx * dz, T.y - T.ty * dz, b0); + sta[i].fieldSlice.GetFieldValue(T.X() - T.Tx() * dz, T.Y() - T.Ty() * dz, b0); b0.Combine(fB[i], w[i]); fld.Set(b0, z0, b1, z1, b2, z2); @@ -333,7 +324,7 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM fit.SetMask(initialised); fit.Extrapolate(z[i], fld); - auto radThick = CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, fit.Tr().x, fit.Tr().y); + auto radThick = CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, fit.Tr().X(), fit.Tr().Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, -fvec::One()); @@ -347,55 +338,46 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM z1 = z0; } - L1TrackPar Tout = T; - for (iVec = 0; iVec < nTracks_SIMD; iVec++) { + TrackParamV Tout = T; + for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { FairTrackParam par; - par.SetX(T.x[iVec]); - par.SetY(T.y[iVec]); - par.SetTx(T.tx[iVec]); - par.SetTy(T.ty[iVec]); - par.SetQp(T.qp[iVec]); - par.SetZ(T.z[iVec]); - - par.SetCovariance(0, 0, Tout.C00[iVec]); - par.SetCovariance(1, 0, Tout.C10[iVec]); - par.SetCovariance(1, 1, Tout.C11[iVec]); - par.SetCovariance(2, 0, Tout.C20[iVec]); - par.SetCovariance(2, 1, Tout.C21[iVec]); - par.SetCovariance(2, 2, Tout.C22[iVec]); - par.SetCovariance(3, 0, Tout.C30[iVec]); - par.SetCovariance(3, 1, Tout.C31[iVec]); - par.SetCovariance(3, 2, Tout.C32[iVec]); - par.SetCovariance(3, 3, Tout.C33[iVec]); - par.SetCovariance(4, 0, Tout.C40[iVec]); - par.SetCovariance(4, 1, Tout.C41[iVec]); - par.SetCovariance(4, 2, Tout.C42[iVec]); - par.SetCovariance(4, 3, Tout.C43[iVec]); - par.SetCovariance(4, 4, Tout.C44[iVec]); + par.SetX(T.X()[iVec]); + par.SetY(T.Y()[iVec]); + par.SetTx(T.Tx()[iVec]); + par.SetTy(T.Ty()[iVec]); + par.SetQp(T.Qp()[iVec]); + par.SetZ(T.Z()[iVec]); + + for (int k = 0; k < 5; k++) { + for (int j = 0; j <= k; j++) { + par.SetCovariance(k, j, Tout.C(k, j)[iVec]); + } + } + tr[iVec]->SetParamLast(&par); } // fit backward - fit.SetQp0(T.qp); + fit.SetQp0(T.Qp()); i = nHits - 1; FilterFirst(fit, x_last, y_last, t_last, cov_last, dt2_last); z1 = z[i]; - sta[i].fieldSlice.GetFieldValue(T.x, T.y, b1); + sta[i].fieldSlice.GetFieldValue(T.X(), T.Y(), b1); b1.Combine(fB[i], w[i]); z2 = z[i - 2]; dz = z2 - z1; - sta[i].fieldSlice.GetFieldValue(T.x + T.tx * dz, T.y + T.ty * dz, b2); + sta[i].fieldSlice.GetFieldValue(T.X() + T.Tx() * dz, T.Y() + T.Ty() * dz, b2); b2.Combine(fB[i - 2], w[i - 2]); fld.Set(b2, z2, b1, z1, b0, z0); for (--i; i >= 0; i--) { z0 = z[i]; dz = (z1 - z0); - sta[i].fieldSlice.GetFieldValue(T.x - T.tx * dz, T.y - T.ty * dz, b0); + sta[i].fieldSlice.GetFieldValue(T.X() - T.Tx() * dz, T.Y() - T.Ty() * dz, b0); b0.Combine(fB[i], w[i]); fld.Set(b0, z0, b1, z1, b2, z2); @@ -403,7 +385,7 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM fit.SetMask(initialised); fit.Extrapolate(z[i], fld); - auto radThick = CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, fit.Tr().x, fit.Tr().y); + auto radThick = CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(i, fit.Tr().X(), fit.Tr().Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec::One()); @@ -417,34 +399,25 @@ void CbmL1PFFitter::Fit(std::vector<CbmStsTrack>& Tracks, const std::vector<CbmM z1 = z0; } - for (iVec = 0; iVec < nTracks_SIMD; iVec++) { + for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { FairTrackParam par; - par.SetX(T.x[iVec]); - par.SetY(T.y[iVec]); - par.SetTx(T.tx[iVec]); - par.SetTy(T.ty[iVec]); - par.SetQp(T.qp[iVec]); - par.SetZ(T.z[iVec]); - - par.SetCovariance(0, 0, T.C00[iVec]); - par.SetCovariance(1, 0, T.C10[iVec]); - par.SetCovariance(1, 1, T.C11[iVec]); - par.SetCovariance(2, 0, T.C20[iVec]); - par.SetCovariance(2, 1, T.C21[iVec]); - par.SetCovariance(2, 2, T.C22[iVec]); - par.SetCovariance(3, 0, T.C30[iVec]); - par.SetCovariance(3, 1, T.C31[iVec]); - par.SetCovariance(3, 2, T.C32[iVec]); - par.SetCovariance(3, 3, T.C33[iVec]); - par.SetCovariance(4, 0, T.C40[iVec]); - par.SetCovariance(4, 1, T.C41[iVec]); - par.SetCovariance(4, 2, T.C42[iVec]); - par.SetCovariance(4, 3, T.C43[iVec]); - par.SetCovariance(4, 4, T.C44[iVec]); + par.SetX(T.X()[iVec]); + par.SetY(T.Y()[iVec]); + par.SetTx(T.Tx()[iVec]); + par.SetTy(T.Ty()[iVec]); + par.SetQp(T.Qp()[iVec]); + par.SetZ(T.Z()[iVec]); + + for (int k = 0; k < 5; k++) { + for (int j = 0; j <= k; j++) { + par.SetCovariance(k, j, T.C(k, j)[iVec]); + } + } + tr[iVec]->SetParamFirst(&par); - tr[iVec]->SetChiSq(T.chi2[iVec]); - tr[iVec]->SetNDF(static_cast<int>(T.NDF[iVec])); + tr[iVec]->SetChiSq(T.ChiSq()[iVec]); + tr[iVec]->SetNDF(static_cast<int>(T.Ndf()[iVec])); } } } @@ -483,7 +456,7 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRe int nTracks_SIMD = fvec::size(); L1Fit fit; - L1TrackPar& T = fit.Tr(); // fitting parametr coresponding to current track + TrackParamV& T = fit.Tr(); // fitting parametr coresponding to current track CbmStsTrack* tr[fvec::size()] {nullptr}; @@ -508,28 +481,20 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRe fvec mass2; for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { - tr[iVec] = &Tracks[itrack + iVec]; // current track - T.x[iVec] = tr[iVec]->GetParamFirst()->GetX(); - T.y[iVec] = tr[iVec]->GetParamFirst()->GetY(); - T.tx[iVec] = tr[iVec]->GetParamFirst()->GetTx(); - T.ty[iVec] = tr[iVec]->GetParamFirst()->GetTy(); - T.qp[iVec] = tr[iVec]->GetParamFirst()->GetQp(); - T.z[iVec] = tr[iVec]->GetParamFirst()->GetZ(); - T.C00[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(0, 0); - T.C10[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(1, 0); - T.C11[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(1, 1); - T.C20[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(2, 0); - T.C21[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(2, 1); - T.C22[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(2, 2); - T.C30[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(3, 0); - T.C31[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(3, 1); - T.C32[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(3, 2); - T.C33[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(3, 3); - T.C40[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(4, 0); - T.C41[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(4, 1); - T.C42[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(4, 1); - T.C43[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(4, 3); - T.C44[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(4, 4); + tr[iVec] = &Tracks[itrack + iVec]; // current track + T.X()[iVec] = tr[iVec]->GetParamFirst()->GetX(); + T.Y()[iVec] = tr[iVec]->GetParamFirst()->GetY(); + T.Tx()[iVec] = tr[iVec]->GetParamFirst()->GetTx(); + T.Ty()[iVec] = tr[iVec]->GetParamFirst()->GetTy(); + T.Qp()[iVec] = tr[iVec]->GetParamFirst()->GetQp(); + T.Z()[iVec] = tr[iVec]->GetParamFirst()->GetZ(); + + for (int i = 0; i < 5; i++) { + for (int j = 0; j <= i; j++) { + T.C(i, j)[iVec] = tr[iVec]->GetParamFirst()->GetCovariance(i, j); + } + } + // float mass = TDatabasePDG::Instance()->GetParticle(tr[iVec]->GetPidHypo())->Mass(); const float mass = KFParticleDatabase::Instance()->GetMass(tr[iVec]->GetPidHypo()); mass2[iVec] = mass * mass; @@ -576,12 +541,12 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRe field.emplace_back(fld, i); } - fit.SetQp0(fit.Tr().qp); + fit.SetQp0(fit.Tr().Qp()); for (int iSt = nStations - 4; iSt >= 0; iSt--) { - fit.SetMask(T.z > zSta[iSt] + fvec(2.5)); + fit.SetMask(T.Z() > zSta[iSt] + fvec(2.5)); fit.Extrapolate(zSta[iSt], fld); - auto radThick = CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(iSt, fit.Tr().x, fit.Tr().y); + auto radThick = CbmL1::Instance()->fpAlgo->GetParameters()->GetMaterialThickness(iSt, fit.Tr().X(), fit.Tr().Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec::One()); } @@ -592,9 +557,9 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRe Double_t Cv[3] = {primVtx.GetCovMatrix()[0], primVtx.GetCovMatrix()[1], primVtx.GetCovMatrix()[2]}; - fvec dx = T.x - fvec(primVtx.GetRefX()); - fvec dy = T.y - fvec(primVtx.GetRefY()); - fvec c[3] = {T.C00, T.C10, T.C11}; + fvec dx = T.X() - fvec(primVtx.GetRefX()); + fvec dy = T.Y() - fvec(primVtx.GetRefY()); + fvec c[3] = {T.C00(), T.C10(), T.C11()}; c[0] += fvec(Cv[0]); c[1] += fvec(Cv[1]); c[2] += fvec(Cv[2]); @@ -610,28 +575,19 @@ void CbmL1PFFitter::GetChiToVertex(vector<CbmStsTrack>& Tracks, vector<PFFieldRe for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { if (chi[iVec] < chiPrim) { FairTrackParam par; - par.SetX(T.x[iVec]); - par.SetY(T.y[iVec]); - par.SetTx(T.tx[iVec]); - par.SetTy(T.ty[iVec]); - par.SetQp(T.qp[iVec]); - par.SetZ(T.z[iVec]); - - par.SetCovariance(0, 0, T.C00[iVec]); - par.SetCovariance(1, 0, T.C10[iVec]); - par.SetCovariance(1, 1, T.C11[iVec]); - par.SetCovariance(2, 0, T.C20[iVec]); - par.SetCovariance(2, 1, T.C21[iVec]); - par.SetCovariance(2, 2, T.C22[iVec]); - par.SetCovariance(3, 0, T.C30[iVec]); - par.SetCovariance(3, 1, T.C31[iVec]); - par.SetCovariance(3, 2, T.C32[iVec]); - par.SetCovariance(3, 3, T.C33[iVec]); - par.SetCovariance(4, 0, T.C40[iVec]); - par.SetCovariance(4, 1, T.C41[iVec]); - par.SetCovariance(4, 2, T.C42[iVec]); - par.SetCovariance(4, 3, T.C43[iVec]); - par.SetCovariance(4, 4, T.C44[iVec]); + par.SetX(T.X()[iVec]); + par.SetY(T.Y()[iVec]); + par.SetTx(T.Tx()[iVec]); + par.SetTy(T.Ty()[iVec]); + par.SetQp(T.Qp()[iVec]); + par.SetZ(T.Z()[iVec]); + + for (int i = 0; i < 5; i++) { + for (int j = 0; j <= i; j++) { + par.SetCovariance(i, j, T.C(i, j)[iVec]); + } + } + tr[iVec]->SetParamFirst(&par); } } @@ -649,7 +605,7 @@ void CbmL1PFFitter::CalculateFieldRegion(vector<CbmStsTrack>& Tracks, vector<PFF L1FieldRegion fld _fvecalignment; int nTracks_SIMD = fvec::size(); - L1TrackPar T; // fitting parametr coresponding to current track + TrackParamV T; // fitting parametr coresponding to current track CbmStsTrack* tr[fvec::size()]; @@ -720,7 +676,7 @@ void CbmL1PFFitter::CalculateFieldRegionAtLastPoint(vector<CbmStsTrack>& Tracks, L1FieldRegion fld _fvecalignment; int nTracks_SIMD = fvec::size(); - L1TrackPar T; // fitting parametr coresponding to current track + TrackParamV T; // fitting parametr coresponding to current track CbmStsTrack* tr[fvec::size()]; diff --git a/reco/L1/CMakeLists.txt b/reco/L1/CMakeLists.txt index 1ad447ddd20eb68ea5437e2cbc166ed5ecd75ebe..f0856280793041ed02048396127920f528c8e38d 100644 --- a/reco/L1/CMakeLists.txt +++ b/reco/L1/CMakeLists.txt @@ -12,7 +12,6 @@ set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/L1Algo ${CMAKE_CURRENT_SOURCE_DIR}/OffLineInterface -# ${CMAKE_CURRENT_SOURCE_DIR}/ParticleFinder ${CMAKE_CURRENT_SOURCE_DIR}/qa ${CMAKE_CURRENT_SOURCE_DIR}/L1Algo/utils ${CMAKE_CURRENT_SOURCE_DIR}/catools @@ -32,7 +31,6 @@ set(SRCS OffLineInterface/CbmL1GlobalFindTracksEvents.cxx L1Algo/utils/CaAlgoRandom.cxx L1Algo/L1Algo.cxx - L1Algo/L1TrackPar.cxx L1Algo/L1TripletConstructor.cxx L1Algo/L1CaTrackFinder.cxx L1Algo/L1CaTrackFinderSlice.cxx @@ -106,7 +104,6 @@ set(HEADERS CbmL1MCPoint.h CbmL1Hit.h CbmL1Track.h - CbmL1TrackPar.h CbmL1Vtx.h L1Algo/L1Def.h L1Algo/L1EArray.h @@ -212,7 +209,6 @@ install(FILES CbmL1Counters.h L1Algo/L1ObjectInitController.h #L1Algo/L1Constants.h L1Algo/L1Utils.h - L1Algo/L1TrackPar.h utils/CbmCaIdealHitProducer.h utils/CbmCaIdealHitProducerDet.h L1Algo/utils/CaUvConverter.h diff --git a/reco/L1/CbmCaMCModule.cxx b/reco/L1/CbmCaMCModule.cxx index 5cd92cd0e9078671fa2ff1217fbe919703875318..47e7d3e5fa2b950d07b25a37656b3e5a5275691d 100644 --- a/reco/L1/CbmCaMCModule.cxx +++ b/reco/L1/CbmCaMCModule.cxx @@ -54,7 +54,8 @@ using cbm::ca::tools::MCTrack; // bool MCModule::InitRun() try { - LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... "; + + if (fVerbose > 0) { LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... "; } // Detector interfaces if (fvbUseDet[L1DetectorID::kMvd]) { fvpDetInterface[L1DetectorID::kMvd] = CbmMvdTrackingInterface::Instance(); } @@ -119,12 +120,14 @@ try { fMonitor.SetRatioKeys({EMonitorKey::kRecoNevents}); - LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... \033[1;32mDone!\033[0m"; + if (fVerbose > 0) { + LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... \033[1;32mDone!\033[0m"; + } return true; } catch (const std::logic_error& error) { - LOG(info) << "CA MC Module: initializing CA tracking Monte-Carlo module... \033[1;31mFailed\033[0m\nReason: " - << error.what(); + LOG(error) << "CA MC Module: initializing CA tracking Monte-Carlo module... \033[1;31mFailed\033[0m\nReason: " + << error.what(); return false; } @@ -425,7 +428,7 @@ void MCModule::ReadMCPoints() int nPointsEstimated = 5 * fpMCData->GetNofTracks() * fpParameters->GetNstationsActive(); fpMCData->ReserveNofPoints(nPointsEstimated); - DetIdArr_t<int> vNofPointsDet = {0}; + DetIdArr_t<int> vNofPointsDet = {{0}}; for (const auto& [iFile, iEvent] : fFileEventIDs) { for (int iD = 0; iD < static_cast<int>(vNofPointsDet.size()); ++iD) { if (fvbUseDet[iD]) { vNofPointsDet[iD] = fvpBrPoints[iD]->Size(iFile, iEvent); } diff --git a/reco/L1/CbmCaMCModule.h b/reco/L1/CbmCaMCModule.h index 9e1090c2e0e7ac6e4c7b8ea7a182ed2153313845..910c99ced3379b64249fe3b76d272a2f872b4de1 100644 --- a/reco/L1/CbmCaMCModule.h +++ b/reco/L1/CbmCaMCModule.h @@ -64,7 +64,7 @@ namespace cbm::ca /// @brief Constructor /// @param verbosity Verbosity level /// @param perfMode Performance mode (defines cut on number of consecutive stations with hit or point) - MCModule(int verb = 0, int perfMode = 1) : fVerbose(verb), fPerformanceMode(perfMode) + MCModule(int verb = 1, int perfMode = 1) : fVerbose(verb), fPerformanceMode(perfMode) { LOG(info) << "cbm::ca::MCModule: performance mode = " << fPerformanceMode; } @@ -160,6 +160,9 @@ namespace cbm::ca /// @param vQaHits Reference to debug hit container void RegisterQaHitContainer(ca::Vector<CbmL1HitDebugInfo>& vQaHits) { fpvQaHits = &vQaHits; } + /// @brief Gets verbosity level + int GetVerbosity() const { return fVerbose; } + private: /// @brief Check class initialization /// @note The function throws std::logic_error, if initialization is incomplete @@ -230,7 +233,7 @@ namespace cbm::ca // ------ Flags DetIdArr_t<bool> fvbUseDet = {{false}}; ///< Flag: is detector subsystem used bool fbLegacyEventMode = false; ///< if tracking uses events instead of time-slices (back compatibility) - int fVerbose = 0; ///< Verbosity level + int fVerbose = 1; ///< Verbosity level int fPerformanceMode = -1; ///< Mode of performance std::shared_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to tracking parameters object diff --git a/reco/L1/CbmCaTimeSliceReader.cxx b/reco/L1/CbmCaTimeSliceReader.cxx index e63cc0b62cff134f3e018c97b7c35789a213c09d..9a2cd9e21dfd99de97050da98bc4183dd68e3536 100644 --- a/reco/L1/CbmCaTimeSliceReader.cxx +++ b/reco/L1/CbmCaTimeSliceReader.cxx @@ -195,16 +195,17 @@ void TimeSliceReader::ReadRecoTracks() for (int iT = 0; iT < nTracks; ++iT) { auto* pInputTrack = static_cast<CbmStsTrack*>(fpBrRecoTracks->At(iT)); auto& track = (*fpvTracks)[iT]; - cbm::L1Util::CopyTrackParam2TC(pInputTrack->GetParamFirst(), track.T, track.C); - cbm::L1Util::CopyTrackParam2TC(pInputTrack->GetParamLast(), track.TLast, track.CLast); - track.chi2 = pInputTrack->GetChiSq(); - track.NDF = pInputTrack->GetNDF(); - track.Tpv[6] = pInputTrack->GetStartTime(); - track.Cpv[20] = pInputTrack->GetStartTimeError(); - track.T[6] = pInputTrack->GetFirstHitTime(); - track.C[20] = pInputTrack->GetFirstHitTimeError(); - track.TLast[6] = pInputTrack->GetLastHitTime(); - track.CLast[20] = pInputTrack->GetLastHitTimeError(); + + track.Set(cbm::L1Util::ConvertTrackParam(*pInputTrack->GetParamFirst())); + track.TLast = cbm::L1Util::ConvertTrackParam(*pInputTrack->GetParamLast()); + track.ChiSq() = pInputTrack->GetChiSq(); + track.Ndf() = pInputTrack->GetNDF(); + track.Tpv.Time() = pInputTrack->GetStartTime(); + track.Tpv.C55() = pInputTrack->GetStartTimeError(); + track.Time() = pInputTrack->GetFirstHitTime(); + track.C55() = pInputTrack->GetFirstHitTimeError(); + track.TLast.Time() = pInputTrack->GetLastHitTime(); + track.TLast.C55() = pInputTrack->GetLastHitTimeError(); track.Hits.clear(); track.Hits.reserve(pInputTrack->GetNofHits()); for (int iH = 0; iH < pInputTrack->GetNofMvdHits(); ++iH) { @@ -226,10 +227,10 @@ void TimeSliceReader::ReadRecoTracks() for (int iT = 0; iT < nTracks; ++iT) { auto* pInputTrack = static_cast<CbmGlobalTrack*>(fpBrRecoTracks->At(iT)); auto& track = (*fpvTracks)[iT]; - cbm::L1Util::CopyTrackParam2TC(pInputTrack->GetParamFirst(), track.T, track.C); - cbm::L1Util::CopyTrackParam2TC(pInputTrack->GetParamLast(), track.TLast, track.CLast); - track.chi2 = pInputTrack->GetChi2(); - track.NDF = pInputTrack->GetNDF(); + track.Set(cbm::L1Util::ConvertTrackParam(*pInputTrack->GetParamFirst())); + track.TLast = cbm::L1Util::ConvertTrackParam(*pInputTrack->GetParamLast()); + track.ChiSq() = pInputTrack->GetChi2(); + track.Ndf() = pInputTrack->GetNDF(); // ** Fill information from local tracks ** // STS tracks (+ MVD) diff --git a/reco/L1/CbmCaTimeSliceReader.h b/reco/L1/CbmCaTimeSliceReader.h index 01e260936158e26653fe1887a6f079de74df6780..ec9df62fe6f67eda4b964c15c2d074cbc5b76e5f 100644 --- a/reco/L1/CbmCaTimeSliceReader.h +++ b/reco/L1/CbmCaTimeSliceReader.h @@ -159,8 +159,6 @@ namespace cbm::ca /// Stores recorded hit information into registered hit containers void StoreHitRecord(const tools::HitRecord& hitRecord); - bool fbReadTracks = true; ///< flag to read reconstructed tracks from reco.root - /// @brief Pointers to the tracking detector interfaces for each subsystem DetIdArr_t<const CbmTrackingDetectorInterfaceBase*> fvpDetInterface = {{nullptr}}; diff --git a/reco/L1/CbmL1.cxx b/reco/L1/CbmL1.cxx index 9a0b09c8a2b56e67f9c9b84a00a7d0b17b2215b3..dfd4108e7c2a9e315a192072d6a45fd564120b0c 100644 --- a/reco/L1/CbmL1.cxx +++ b/reco/L1/CbmL1.cxx @@ -771,25 +771,10 @@ void CbmL1::Reconstruct(CbmEvent* event) for (auto it = fpAlgo->fRecoTracks.begin(); it != fpAlgo->fRecoTracks.end(); trackFirstHit += it->fNofHits, it++) { CbmL1Track t; - - for (int i = 0; i < L1TrackPar::kNparTr; i++) { - t.T[i] = it->fParFirst[i]; - t.TLast[i] = it->fParLast[i]; - t.Tpv[i] = it->fParPV[i]; - } - - for (int i = 0; i < L1TrackPar::kNparCov; ++i) { - t.C[i] = it->fCovFirst[i]; - t.CLast[i] = it->fCovLast[i]; - t.Cpv[i] = it->fCovPV[i]; - } - - t.chi2 = it->fChi2; - t.NDF = it->fNDF; + t.Set(it->fParFirst); + t.TLast.Set(it->fParLast); + t.Tpv.Set(it->fParPV); t.Hits.clear(); - t.mass = fpAlgo->fDefaultMass; // muon mass - t.is_electron = 0; - t.SetId(fvRecoTracks.size()); for (int i = 0; i < it->fNofHits; i++) { int caHitId = fpAlgo->fRecoHits[trackFirstHit + i]; @@ -1047,13 +1032,13 @@ void CbmL1::IdealTrackFinder() fpAlgo->fRecoHits.push_back(hitI); } - algoTr.fParFirst[0] = MC.x; - algoTr.fParFirst[1] = MC.y; - algoTr.fParFirst[2] = MC.px / MC.pz; - algoTr.fParFirst[3] = MC.py / MC.pz; - algoTr.fParFirst[4] = MC.q / MC.p; - algoTr.fParFirst[5] = MC.z; - + algoTr.fParFirst.X() = MC.x; + algoTr.fParFirst.Y() = MC.y; + algoTr.fParFirst.Z() = MC.z; + algoTr.fParFirst.Tx() = MC.px / MC.pz; + algoTr.fParFirst.Ty() = MC.py / MC.pz; + algoTr.fParFirst.Qp() = MC.q / MC.p; + algoTr.fParFirst.Time() = MC.time; fpAlgo->fRecoTracks.push_back(algoTr); } } // void CbmL1::IdealTrackFinder() diff --git a/reco/L1/CbmL1.h b/reco/L1/CbmL1.h index 7f5f70e38f29f511faa677010b3b7ef204e7f970..55df90294d27021eb8c7b21eb7ef24cbe1b4d21c 100644 --- a/reco/L1/CbmL1.h +++ b/reco/L1/CbmL1.h @@ -413,7 +413,7 @@ private: /// \note Should be called only after CbmL1::Performance() void TrackFitPerformance(); - void FillFitHistos(L1TrackPar& tr, const CbmL1MCPoint& mc, bool isTimeFitted, TH1F* h[]); + void FillFitHistos(TrackParamV& tr, const CbmL1MCPoint& mc, bool isTimeFitted, TH1F* h[]); /// Fills performance histograms void HistoPerformance(); diff --git a/reco/L1/CbmL1DetectorID.h b/reco/L1/CbmL1DetectorID.h index 75979dbbcbc24559c35b227cf98e15aa4894774c..9c7e42a49eb3d2adffbbe85e4ce89380bfd52a30 100644 --- a/reco/L1/CbmL1DetectorID.h +++ b/reco/L1/CbmL1DetectorID.h @@ -17,10 +17,10 @@ namespace cbm::ca { - namespace phys = cbm::algo::ca::constants::phys; - namespace undef = cbm::algo::ca::constants::undef; - namespace clrs = cbm::algo::ca::constants::clrs; - namespace ca = cbm::algo::ca; ///< CA core namespace (TO BE USED IN CBM-specific interfaces) + namespace phys = cbm::algo::ca::constants::phys; + namespace constants = cbm::algo::ca::constants; + namespace clrs = cbm::algo::ca::constants::clrs; + namespace ca = cbm::algo::ca; ///< CA core namespace (TO BE USED IN CBM-specific interfaces) } // namespace cbm::ca /// Enumeration for the detector subsystems used in L1 tracking diff --git a/reco/L1/CbmL1Performance.cxx b/reco/L1/CbmL1Performance.cxx index 7248aec1eb7d0d0f7a335a62e41de8425fb5fb6c..831438335a13c0f354f58cdbe5bc25633f39b1bb 100644 --- a/reco/L1/CbmL1Performance.cxx +++ b/reco/L1/CbmL1Performance.cxx @@ -53,6 +53,8 @@ #include <map> #include <vector> +#include <cmath> + #include "CaToolsDebugger.h" #include "L1Algo/L1Algo.h" #include "L1Algo/L1Def.h" @@ -314,16 +316,15 @@ void CbmL1::EfficienciesPerformance() ntra.fOutDir = fTableDir; // Setup a pointer for output directory L1_NTRA.fOutDir = fTableDir; // Save average efficiencies - Debugger::Instance().AddNtuple("ghost", "it:ih:p:x:y:z:t:dx:dy"); + cbm::ca::tools::Debugger::Instance().AddNtuple("ghost", "it:ih:p:x:y:z:t:dx:dy"); static int statNghost = 0; for (vector<CbmL1Track>::iterator rtraIt = fvRecoTracks.begin(); rtraIt != fvRecoTracks.end(); ++rtraIt) { ntra.ghosts += rtraIt->IsGhost(); if (0 && rtraIt->IsGhost()) { // Debug. - L1TrackPar tr; - tr.copyFromArrays(rtraIt->T, rtraIt->C); + TrackParamV tr(*rtraIt); - cout << " L1: ghost track: nhits " << rtraIt->GetNOfHits() << " p " << 1. / rtraIt->T[4] << " purity " + cout << " L1: ghost track: nhits " << rtraIt->GetNofHits() << " p " << 1. / rtraIt->GetQp() << " purity " << rtraIt->GetMaxPurity() << " | hits "; for (map<int, int>::iterator posIt = rtraIt->hitMap.begin(); posIt != rtraIt->hitMap.end(); posIt++) { cout << " (" << posIt->second << " " << posIt->first << ") "; @@ -338,9 +339,10 @@ void CbmL1::EfficienciesPerformance() const L1Hit& h = fpAlgo->fInputData.GetHit(rtraIt->Hits[i]); const CbmL1HitDebugInfo& s = fvHitDebugInfo[rtraIt->Hits[i]]; cout << " x y z t " << s.x << " " << s.y << " " << h.z << " dx " << s.dx << " dy " << s.dy << std::endl; - Debugger::Instance().FillNtuple("ghost", statNghost, i, fabs(1. / tr.qp[0]), s.x, s.y, h.z, h.t, s.dx, s.dy); + cbm::ca::tools::Debugger::Instance().FillNtuple("ghost", statNghost, i, fabs(1. / tr.GetQp()[0]), s.x, s.y, h.z, + h.t, s.dx, s.dy); } - tr.Print(0); + std::cout << tr.ToString(0); statNghost++; } } @@ -365,10 +367,10 @@ void CbmL1::EfficienciesPerformance() // is track killed. At least one hit of it belong to some recoTrack const bool killed = !reco && mtra.IsDisturbed(); // ration length for current mcTrack - auto& rTracks = mtra.GetRecoTracks(); // for length calculations - double ratio_length = 0; - double ratio_fakes = 0; - double mc_length_hits = mtra.NStations(); + auto& rTracks = mtra.GetRecoTracks(); // for length calculations + double ratio_length = 0; + double ratio_fakes = 0; + double mc_length_hits = mtra.NStations(); int mc_length = mtra.NMCStations(); @@ -825,13 +827,13 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitFa CbmL1Track* prtra = &(*rtraIt); if ((prtra->Hits).size() < 1) continue; { // fill histos - if (fabs(prtra->T[4]) > 1.e-10) + if (fabs(prtra->GetQp()) > 1.e-10) h_reco_mom->Fill( - fabs(1.0 / prtra->T[4])); // TODO: Is it a right precision? In FairTrackParam it is 1.e-4 (S.Zharko) + fabs(1.0 / prtra->GetQp())); // TODO: Is it a right precision? In FairTrackParam it is 1.e-4 (S.Zharko) // NOTE: p = (TMath::Abs(fQp) > 1.e-4) ? 1. / TMath::Abs(fQp) : 1.e4; // FairTrackParam::Momentum(TVector3) // h_reco_mom->Fill(TMath::Abs(prtra->T[4] > 1.e-4) ? 1. / TMath::Abs(prtra->T[4]) : 1.e+4); // this should be correct - h_reco_phi->Fill(TMath::ATan2(-prtra->T[3], -prtra->T[2])); // TODO: What is precision? + h_reco_phi->Fill(prtra->GetPhi()); // TODO: What is precision? h_reco_nhits->Fill((prtra->Hits).size()); CbmL1HitDebugInfo& mh = fvHitDebugInfo[prtra->Hits[0]]; h_reco_station->Fill(mh.iStation); @@ -855,19 +857,19 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitFa h_reco_purity->Fill(100 * prtra->GetMaxPurity()); - if (prtra->NDF > 0) { + if (prtra->GetNdf() > 0) { if (prtra->IsGhost()) { - h_ghost_chi2->Fill(prtra->chi2 / prtra->NDF); - h_ghost_prob->Fill(TMath::Prob(prtra->chi2, prtra->NDF)); + h_ghost_chi2->Fill(prtra->GetChiSq() / prtra->GetNdf()); + h_ghost_prob->Fill(TMath::Prob(prtra->GetChiSq(), prtra->GetNdf())); } else if (prtra->GetNMCTracks() > 0) { if (prtra->GetMCTrack()[0].IsReconstructable()) { - h_reco_chi2->Fill(prtra->chi2 / prtra->NDF); - h_reco_prob->Fill(TMath::Prob(prtra->chi2, prtra->NDF)); + h_reco_chi2->Fill(prtra->GetChiSq() / prtra->GetNdf()); + h_reco_prob->Fill(TMath::Prob(prtra->GetChiSq(), prtra->GetNdf())); } else { - // h_rest_chi2->Fill(prtra->chi2/prtra->NDF); - h_rest_prob->Fill(TMath::Prob(prtra->chi2, prtra->NDF)); + // h_rest_chi2->Fill(prtra->GetChiSq()/prtra->NDF); + h_rest_prob->Fill(TMath::Prob(prtra->GetChiSq(), prtra->GetNdf())); } } } @@ -877,10 +879,10 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitFa if (prtra->IsGhost()) { fMonitor.Increment(EMonitorKey::kGhostTrack); h_ghost_purity->Fill(100 * prtra->GetMaxPurity()); - if (fabs(prtra->T[4]) > 1.e-10) { - h_ghost_mom->Fill(fabs(1.0 / prtra->T[4])); - h_ghost_phi->Fill(atan(prtra->T[3] / prtra->T[2])); // phi = atan(py / px) = atan(ty / tx) - h_ghost_Rmom->Fill(fabs(1.0 / prtra->T[4])); + if (fabs(prtra->GetQp()) > 1.e-10) { + h_ghost_mom->Fill(prtra->GetP()); + h_ghost_phi->Fill(prtra->GetPhi()); // phi = atan(py / px) = atan(ty / tx) + h_ghost_Rmom->Fill(prtra->GetP()); } h_ghost_nhits->Fill((prtra->Hits).size()); CbmL1HitDebugInfo& h1 = fvHitDebugInfo[prtra->Hits[0]]; @@ -894,10 +896,12 @@ void CbmL1::HistoPerformance() // TODO: check if works correctly. Change vHitFa h_ghost_ty->Fill((h2.y - h1.y) / (z2 - z1)); } - if (fabs(prtra->T[4]) > 1.e-10) h2_ghost_nhits_vs_mom->Fill(fabs(1.0 / prtra->T[4]), (prtra->Hits).size()); CbmL1HitDebugInfo& hf = fvHitDebugInfo[prtra->Hits[0]]; CbmL1HitDebugInfo& hl = fvHitDebugInfo[prtra->Hits[(prtra->Hits).size() - 1]]; - if (fabs(prtra->T[4]) > 1.e-10) h2_ghost_fstation_vs_mom->Fill(fabs(1.0 / prtra->T[4]), hf.iStation + 1); + if (fabs(prtra->GetQp()) > 1.e-10) { + h2_ghost_nhits_vs_mom->Fill(prtra->GetP(), prtra->Hits.size()); + h2_ghost_fstation_vs_mom->Fill(prtra->GetP(), hf.iStation + 1); + } if (hl.iStation >= hf.iStation) h2_ghost_lstation_vs_fstation->Fill(hf.iStation + 1, hl.iStation + 1); } @@ -1314,17 +1318,16 @@ void CbmL1::TrackFitPerformance() const CbmL1MCPoint& mcP = fvMCPoints[imcPoint]; - L1TrackPar tr; - tr.copyFromArrays(it->T, it->C); + TrackParamV tr(*it); FillFitHistos(tr, mcP, isTimeFitted, h_fit); - double dx = tr.x[0] - mcP.xIn; - double dy = tr.y[0] - mcP.yIn; + double dx = tr.GetX()[0] - mcP.xIn; + double dy = tr.GetY()[0] - mcP.yIn; double dca = sqrt(dx * dx + dy * dy); // make dca distance negative for the half of the tracks to ease the gaussian fit and the rms calculation if (mcTrack.ID % 2) dca = -dca; double pt = sqrt(mcP.px * mcP.px + mcP.py * mcP.py); - double dP = (fabs(1. / tr.qp[0]) - mcP.p) / mcP.p; + double dP = (fabs(1. / tr.GetQp()[0]) - mcP.p) / mcP.p; PRes2D->Fill(mcP.p, 100. * dP); @@ -1358,8 +1361,7 @@ void CbmL1::TrackFitPerformance() int iMC = fvHitBestPointIndices[it->Hits.back()]; // TODO2: adapt to linking if (iMC < 0) continue; CbmL1MCPoint& mcP = fvMCPoints[iMC]; - L1TrackPar tr; - tr.copyFromArrays(it->TLast, it->CLast); + TrackParamV tr(it->TLast); FillFitHistos(tr, mcP, isTimeFitted, h_fitL); } @@ -1368,9 +1370,9 @@ void CbmL1::TrackFitPerformance() if (it->GetNMCTracks() < 1) { break; } CbmL1MCTrack mc = *(it->GetMCTracks()[0]); - fit.SetTrack(it->T, it->C); + fit.SetTrack(*it); - const L1TrackPar& tr = fit.Tr(); + const TrackParamV& tr = fit.Tr(); // if (mc.mother_ID != -1) { // secondary if (!mc.IsPrimary()) { // secondary @@ -1388,16 +1390,16 @@ void CbmL1::TrackFitPerformance() && (dir * (mc.z - fpAlgo->GetParameters()->GetStation(iSta).fZ[0]) > 0); iSta += dir) { // cout << iSta << " " << dir << endl; - auto radThick = fpAlgo->GetParameters()->GetMaterialThickness(iSta, fit.Tr().x, fit.Tr().y); + auto radThick = fpAlgo->GetParameters()->GetMaterialThickness(iSta, fit.Tr().GetX(), fit.Tr().GetY()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec::One()); } } - if (mc.z != tr.z[0]) continue; + if (mc.z != tr.GetZ()[0]) continue; // static int good = 0; // static int bad = 0; - // if (mc.z != tr.z[0]){ + // if (mc.z != tr.GetZ()[0]){ // bad++; // continue; // } @@ -1405,27 +1407,35 @@ void CbmL1::TrackFitPerformance() // cout << "bad\\good" << bad << " " << good << endl; // calculate pulls - //h_fitSV[0]->Fill( (mc.x-tr.x[0]) *1.e4); - //h_fitSV[1]->Fill( (mc.y-tr.y[0]) *1.e4); - h_fitSV[0]->Fill((tr.x[0] - mc.x)); - h_fitSV[1]->Fill((tr.y[0] - mc.y)); - h_fitSV[2]->Fill((tr.tx[0] - mc.px / mc.pz) * 1.e3); - h_fitSV[3]->Fill((tr.ty[0] - mc.py / mc.pz) * 1.e3); - h_fitSV[4]->Fill(100. * (fabs(1. / tr.qp[0]) / mc.p - 1.)); - if (std::isfinite(tr.C00[0]) && tr.C00[0] > 0) { h_fitSV[5]->Fill((tr.x[0] - mc.x) / sqrt(tr.C00[0])); } - if (std::isfinite(tr.C11[0]) && tr.C11[0] > 0) h_fitSV[6]->Fill((tr.y[0] - mc.y) / sqrt(tr.C11[0])); - if (std::isfinite(tr.C22[0]) && tr.C22[0] > 0) h_fitSV[7]->Fill((tr.tx[0] - mc.px / mc.pz) / sqrt(tr.C22[0])); - if (std::isfinite(tr.C33[0]) && tr.C33[0] > 0) h_fitSV[8]->Fill((tr.ty[0] - mc.py / mc.pz) / sqrt(tr.C33[0])); - if (std::isfinite(tr.C44[0]) && tr.C44[0] > 0) h_fitSV[9]->Fill((tr.qp[0] - mc.q / mc.p) / sqrt(tr.C44[0])); - h_fitSV[10]->Fill(tr.qp[0]); + //h_fitSV[0]->Fill( (mc.x-tr.GetX()[0]) *1.e4); + //h_fitSV[1]->Fill( (mc.y-tr.GetY()[0]) *1.e4); + h_fitSV[0]->Fill((tr.GetX()[0] - mc.x)); + h_fitSV[1]->Fill((tr.GetY()[0] - mc.y)); + h_fitSV[2]->Fill((tr.GetTx()[0] - mc.px / mc.pz) * 1.e3); + h_fitSV[3]->Fill((tr.GetTy()[0] - mc.py / mc.pz) * 1.e3); + h_fitSV[4]->Fill(100. * (fabs(1. / tr.GetQp()[0]) / mc.p - 1.)); + if (std::isfinite((fscal) tr.C00()[0]) && tr.C00()[0] > 0) { + h_fitSV[5]->Fill((tr.GetX()[0] - mc.x) / sqrt(tr.C00()[0])); + } + if (std::isfinite((fscal) tr.C11()[0]) && tr.C11()[0] > 0) + h_fitSV[6]->Fill((tr.GetY()[0] - mc.y) / sqrt(tr.C11()[0])); + if (std::isfinite((fscal) tr.C22()[0]) && tr.C22()[0] > 0) + h_fitSV[7]->Fill((tr.GetTx()[0] - mc.px / mc.pz) / sqrt(tr.C22()[0])); + if (std::isfinite((fscal) tr.C33()[0]) && tr.C33()[0] > 0) + h_fitSV[8]->Fill((tr.GetTy()[0] - mc.py / mc.pz) / sqrt(tr.C33()[0])); + if (std::isfinite((fscal) tr.C44()[0]) && tr.C44()[0] > 0) + h_fitSV[9]->Fill((tr.GetQp()[0] - mc.q / mc.p) / sqrt(tr.C44()[0])); + h_fitSV[10]->Fill(tr.GetQp()[0]); h_fitSV[11]->Fill(mc.q / mc.p); if (isTimeFitted) { - h_fitSV[12]->Fill(tr.t[0] - mc.time); - if (std::isfinite(tr.C55[0]) && tr.C55[0] > 0.) { h_fitSV[13]->Fill((tr.t[0] - mc.time) / sqrt(tr.C55[0])); } - double dvi = tr.vi[0] - sqrt(1. + mc.mass * mc.mass / mc.p / mc.p) * L1TrackPar::kClightNsInv; - h_fitSV[14]->Fill(dvi * L1TrackPar::kClightNs); - if (std::isfinite(tr.C66[0]) && tr.C66[0] > 0.) { h_fitSV[15]->Fill(dvi / sqrt(tr.C66[0])); } - h_fitSV[16]->Fill(tr.vi[0] * L1TrackPar::kClightNs); + h_fitSV[12]->Fill(tr.GetTime()[0] - mc.time); + if (std::isfinite((fscal) tr.C55()[0]) && tr.C55()[0] > 0.) { + h_fitSV[13]->Fill((tr.GetTime()[0] - mc.time) / sqrt(tr.C55()[0])); + } + double dvi = tr.GetVi()[0] - sqrt(1. + mc.mass * mc.mass / mc.p / mc.p) * constants::phys::SpeedOfLightInvD; + h_fitSV[14]->Fill(dvi * constants::phys::SpeedOfLightD); + if (std::isfinite((fscal) tr.C66()[0]) && tr.C66()[0] > 0.) { h_fitSV[15]->Fill(dvi / sqrt(tr.C66()[0])); } + h_fitSV[16]->Fill(tr.GetVi()[0] * constants::phys::SpeedOfLightD); } } else { // primary @@ -1446,16 +1456,16 @@ void CbmL1::TrackFitPerformance() iSta += dir) { fit.Extrapolate(fpAlgo->GetParameters()->GetStation(iSta).fZ, fld); - auto radThick = fpAlgo->GetParameters()->GetMaterialThickness(iSta, fit.Tr().x, fit.Tr().y); + auto radThick = fpAlgo->GetParameters()->GetMaterialThickness(iSta, fit.Tr().GetX(), fit.Tr().GetY()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec::One()); } fit.Extrapolate(mc.z, fld); } - if (mc.z != tr.z[0]) continue; + if (mc.z != tr.GetZ()[0]) continue; - double dx = tr.x[0] - mc.x; - double dy = tr.y[0] - mc.y; + double dx = tr.GetX()[0] - mc.x; + double dy = tr.GetY()[0] - mc.y; double dt = sqrt(dx * dx + dy * dy); // make dt distance negative for the half of the tracks to ease the gaussian fit and the rms calculation if (mc.ID % 2) dt = -dt; @@ -1476,30 +1486,37 @@ void CbmL1::TrackFitPerformance() } // calculate pulls - h_fitPV[0]->Fill((mc.x - tr.x[0])); - h_fitPV[1]->Fill((mc.y - tr.y[0])); - h_fitPV[2]->Fill((mc.px / mc.pz - tr.tx[0]) * 1.e3); - h_fitPV[3]->Fill((mc.py / mc.pz - tr.ty[0]) * 1.e3); - h_fitPV[4]->Fill(100. * (fabs(1 / tr.qp[0]) / mc.p - 1.)); - if (std::isfinite(tr.C00[0]) && tr.C00[0] > 0) h_fitPV[5]->Fill((mc.x - tr.x[0]) / sqrt(tr.C00[0])); - if (std::isfinite(tr.C11[0]) && tr.C11[0] > 0) h_fitPV[6]->Fill((mc.y - tr.y[0]) / sqrt(tr.C11[0])); - if (std::isfinite(tr.C22[0]) && tr.C22[0] > 0) h_fitPV[7]->Fill((mc.px / mc.pz - tr.tx[0]) / sqrt(tr.C22[0])); - if (std::isfinite(tr.C33[0]) && tr.C33[0] > 0) h_fitPV[8]->Fill((mc.py / mc.pz - tr.ty[0]) / sqrt(tr.C33[0])); - if (std::isfinite(tr.C44[0]) && tr.C44[0] > 0) h_fitPV[9]->Fill((mc.q / mc.p - tr.qp[0]) / sqrt(tr.C44[0])); - h_fitPV[10]->Fill(tr.qp[0]); + h_fitPV[0]->Fill((mc.x - tr.GetX()[0])); + h_fitPV[1]->Fill((mc.y - tr.GetY()[0])); + h_fitPV[2]->Fill((mc.px / mc.pz - tr.GetTx()[0]) * 1.e3); + h_fitPV[3]->Fill((mc.py / mc.pz - tr.GetTy()[0]) * 1.e3); + h_fitPV[4]->Fill(100. * (fabs(1 / tr.GetQp()[0]) / mc.p - 1.)); + if (std::isfinite((fscal) tr.C00()[0]) && tr.C00()[0] > 0) + h_fitPV[5]->Fill((mc.x - tr.GetX()[0]) / sqrt(tr.C00()[0])); + if (std::isfinite((fscal) tr.C11()[0]) && tr.C11()[0] > 0) + h_fitPV[6]->Fill((mc.y - tr.GetY()[0]) / sqrt(tr.C11()[0])); + if (std::isfinite((fscal) tr.C22()[0]) && tr.C22()[0] > 0) + h_fitPV[7]->Fill((mc.px / mc.pz - tr.GetTx()[0]) / sqrt(tr.C22()[0])); + if (std::isfinite((fscal) tr.C33()[0]) && tr.C33()[0] > 0) + h_fitPV[8]->Fill((mc.py / mc.pz - tr.GetTy()[0]) / sqrt(tr.C33()[0])); + if (std::isfinite((fscal) tr.C44()[0]) && tr.C44()[0] > 0) + h_fitPV[9]->Fill((mc.q / mc.p - tr.GetQp()[0]) / sqrt(tr.C44()[0])); + h_fitPV[10]->Fill(tr.GetQp()[0]); h_fitPV[11]->Fill(mc.q / mc.p); if (isTimeFitted) { - h_fitPV[12]->Fill(tr.t[0] - mc.time); - if (std::isfinite(tr.C55[0]) && tr.C55[0] > 0.) { h_fitPV[13]->Fill((tr.t[0] - mc.time) / sqrt(tr.C55[0])); } - double dvi = tr.vi[0] - sqrt(1. + mc.mass * mc.mass / mc.p / mc.p) * L1TrackPar::kClightNsInv; - h_fitPV[14]->Fill(dvi * L1TrackPar::kClightNs); - if (std::isfinite(tr.C66[0]) && tr.C66[0] > 0.) { h_fitPV[15]->Fill(dvi / sqrt(tr.C66[0])); } - h_fitPV[16]->Fill(tr.vi[0] * L1TrackPar::kClightNs); + h_fitPV[12]->Fill(tr.GetTime()[0] - mc.time); + if (std::isfinite((fscal) tr.C55()[0]) && tr.C55()[0] > 0.) { + h_fitPV[13]->Fill((tr.GetTime()[0] - mc.time) / sqrt(tr.C55()[0])); + } + double dvi = tr.GetVi()[0] - sqrt(1. + mc.mass * mc.mass / mc.p / mc.p) * constants::phys::SpeedOfLightInvD; + h_fitPV[14]->Fill(dvi * constants::phys::SpeedOfLightD); + if (std::isfinite((fscal) tr.C66()[0]) && tr.C66()[0] > 0.) { h_fitPV[15]->Fill(dvi / sqrt(tr.C66()[0])); } + h_fitPV[16]->Fill(tr.GetVi()[0] * constants::phys::SpeedOfLightD); } } } while (0); - h_fit_chi2->Fill(it->chi2 / it->NDF); + h_fit_chi2->Fill(it->GetChiSq() / it->GetNdf()); // last TRD point /* @@ -1523,7 +1540,7 @@ void CbmL1::TrackFitPerformance() } CbmL1MCPoint mcP; if (CbmL1::ReadMCPoint(&mcP, lastP, mcTrack.iFile, mcTrack.iEvent, 3)) { break; } - L1TrackPar tr; + TrackParamV tr; tr.copyFromArrays(it->TLast, it->CLast); FillFitHistos(tr, mcP, isTimeFitted, h_fitTrd); } while (0); // Trd point @@ -1551,7 +1568,7 @@ void CbmL1::TrackFitPerformance() } CbmL1MCPoint mcP; if (CbmL1::ReadMCPoint(&mcP, lastP, mcTrack.iFile, mcTrack.iEvent, 4)) { break; } - L1TrackPar tr; + TrackParamV tr; tr.copyFromArrays(it->TLast, it->CLast); FillFitHistos(tr, mcP, isTimeFitted, h_fitTof); } while (0); // tof point @@ -1561,7 +1578,7 @@ void CbmL1::TrackFitPerformance() } // void CbmL1::TrackFitPerformance() -void CbmL1::FillFitHistos(L1TrackPar& track, const CbmL1MCPoint& mcP, bool isTimeFitted, TH1F* h[]) +void CbmL1::FillFitHistos(TrackParamV& track, const CbmL1MCPoint& mcP, bool isTimeFitted, TH1F* h[]) { L1Fit fit; fit.SetParticleMass(fpAlgo->GetDefaultParticleMass()); @@ -1574,28 +1591,33 @@ void CbmL1::FillFitHistos(L1TrackPar& track, const CbmL1MCPoint& mcP, bool isTim fit.Extrapolate(mcP.zOut, fld); track = fit.Tr(); - const L1TrackPar& tr = track; - - h[0]->Fill((tr.x[0] - mcP.xOut) * 1.e4); - h[1]->Fill((tr.y[0] - mcP.yOut) * 1.e4); - h[2]->Fill((tr.tx[0] - mcP.pxOut / mcP.pzOut) * 1.e3); - h[3]->Fill((tr.ty[0] - mcP.pyOut / mcP.pzOut) * 1.e3); - h[4]->Fill(100. * (fabs(1. / tr.qp[0]) / mcP.p - 1.)); - - if (std::isfinite(tr.C00[0]) && tr.C00[0] > 0) h[5]->Fill((tr.x[0] - mcP.xOut) / sqrt(tr.C00[0])); - if (std::isfinite(tr.C11[0]) && tr.C11[0] > 0) h[6]->Fill((tr.y[0] - mcP.yOut) / sqrt(tr.C11[0])); - if (std::isfinite(tr.C22[0]) && tr.C22[0] > 0) h[7]->Fill((tr.tx[0] - mcP.pxOut / mcP.pzOut) / sqrt(tr.C22[0])); - if (std::isfinite(tr.C33[0]) && tr.C33[0] > 0) h[8]->Fill((tr.ty[0] - mcP.pyOut / mcP.pzOut) / sqrt(tr.C33[0])); - if (std::isfinite(tr.C44[0]) && tr.C44[0] > 0) h[9]->Fill((tr.qp[0] - mcP.q / mcP.p) / sqrt(tr.C44[0])); - h[10]->Fill(tr.qp[0]); + const TrackParamV& tr = track; + + h[0]->Fill((tr.GetX()[0] - mcP.xOut) * 1.e4); + h[1]->Fill((tr.GetY()[0] - mcP.yOut) * 1.e4); + h[2]->Fill((tr.GetTx()[0] - mcP.pxOut / mcP.pzOut) * 1.e3); + h[3]->Fill((tr.GetTy()[0] - mcP.pyOut / mcP.pzOut) * 1.e3); + h[4]->Fill(100. * (fabs(1. / tr.GetQp()[0]) / mcP.p - 1.)); + + if (std::isfinite((fscal) tr.C00()[0]) && tr.C00()[0] > 0) h[5]->Fill((tr.GetX()[0] - mcP.xOut) / sqrt(tr.C00()[0])); + if (std::isfinite((fscal) tr.C11()[0]) && tr.C11()[0] > 0) h[6]->Fill((tr.GetY()[0] - mcP.yOut) / sqrt(tr.C11()[0])); + if (std::isfinite((fscal) tr.C22()[0]) && tr.C22()[0] > 0) + h[7]->Fill((tr.GetTx()[0] - mcP.pxOut / mcP.pzOut) / sqrt(tr.C22()[0])); + if (std::isfinite((fscal) tr.C33()[0]) && tr.C33()[0] > 0) + h[8]->Fill((tr.GetTy()[0] - mcP.pyOut / mcP.pzOut) / sqrt(tr.C33()[0])); + if (std::isfinite((fscal) tr.C44()[0]) && tr.C44()[0] > 0) + h[9]->Fill((tr.GetQp()[0] - mcP.q / mcP.p) / sqrt(tr.C44()[0])); + h[10]->Fill(tr.GetQp()[0]); h[11]->Fill(mcP.q / mcP.p); if (isTimeFitted) { - h[12]->Fill(tr.t[0] - mcP.time); - if (std::isfinite(tr.C55[0]) && tr.C55[0] > 0.) { h[13]->Fill((tr.t[0] - mcP.time) / sqrt(tr.C55[0])); } - double dvi = tr.vi[0] - sqrt(1. + mcP.mass * mcP.mass / mcP.p / mcP.p) * L1TrackPar::kClightNsInv; - h[14]->Fill(dvi * L1TrackPar::kClightNs); - if (std::isfinite(tr.C66[0]) && tr.C66[0] > 0.) { h[15]->Fill(dvi / sqrt(tr.C66[0])); } - h[16]->Fill(tr.vi[0] * L1TrackPar::kClightNs); + h[12]->Fill(tr.GetTime()[0] - mcP.time); + if (std::isfinite((fscal) tr.C55()[0]) && tr.C55()[0] > 0.) { + h[13]->Fill((tr.GetTime()[0] - mcP.time) / sqrt(tr.C55()[0])); + } + double dvi = tr.GetVi()[0] - sqrt(1. + mcP.mass * mcP.mass / mcP.p / mcP.p) * constants::phys::SpeedOfLightInvD; + h[14]->Fill(dvi * constants::phys::SpeedOfLightD); + if (std::isfinite((fscal) tr.C66()[0]) && tr.C66()[0] > 0.) { h[15]->Fill(dvi / sqrt(tr.C66()[0])); } + h[16]->Fill(tr.GetVi()[0] * constants::phys::SpeedOfLightD); } } diff --git a/reco/L1/CbmL1Track.h b/reco/L1/CbmL1Track.h index 509ea0a572a0e2c18b6e3a47c8ef302d94c9f1ee..127938ebff7e816568e12a72d587a7d3a93d497c 100644 --- a/reco/L1/CbmL1Track.h +++ b/reco/L1/CbmL1Track.h @@ -24,7 +24,6 @@ #include "CbmL1Constants.h" #include "CbmL1MCTrack.h" -#include "CbmL1TrackPar.h" #include "TMath.h" @@ -33,6 +32,7 @@ #include <string> #include <vector> +#include "CaTrackParam.h" #include "CaVector.h" namespace @@ -42,9 +42,9 @@ namespace class CbmL1MCTrack; -class CbmL1Track : public CbmL1TrackPar { +class CbmL1Track : public cbm::algo::ca::TrackParamD { public: - CbmL1Track() : Hits(), nStations(0), index(0), fTrackTime(0.), hitMap(), mcTracks(), maxPurity(-1) {} + CbmL1Track() = default; /// Adds pointer to MC track (TODO: remove this and related methods) void AddMCTrack(CbmL1MCTrack* mcTr) { mcTracks.push_back(mcTr); } @@ -63,15 +63,6 @@ public: bool IsGhost() const { return (maxPurity < CbmL1Constants::MinPurity); } - /// Gets charge - int GetCharge() const { return (T[4] > 0) ? 1 : -1; } - - /// Gets Chi-square of track fit model - double GetChiSq() const { return chi2; } - - /// @brief Gets pseudo-rapidity - double GetEta() const { return -std::log(std::tan(GetTheta() * 0.5)); } - /// @brief Gets first hit index int GetFirstHitIndex() const { return Hits.front(); } @@ -81,8 +72,6 @@ public: /// Gets hit indexes const auto& GetHitIndexes() const { return Hits; } - /// Gets NDF of track fit model - int GetNDF() const { return NDF; } /// Gets number of MC tracks // TODO: Remove this method @@ -115,63 +104,28 @@ public: /// Gets number of stations int GetNofStations() const { return nStations; } - /// Gets absolute value of momentum divided by the charge (absolute value) of particle [GeV/ec] - // NOTE: 1.e-10 precision is used in the old performance, but in FairTrackParam the 1.e-4 is used - double GetP() const { return fabs(T[4]) > 1.e-10 ? 1. / fabs(T[4]) : 1.e-10; } - - /// Gets transverse momentum - double GetPt() const { return sqrt(GetP() * GetP() - GetPz() * GetPz()); } - - /// Gets azimuthal angle of the track - double GetPhi() const { return TMath::ATan2(-GetTy(), -GetTx()); } - - /// Gets probability of track fit model - double GetProb() const { return TMath::Prob(chi2, NDF); } - - /// Gets x-component of momentum divided by the charge (absolute value) of particle [GeV/ec] - double GetPx() const { return GetPz() * GetTx(); } - - /// Gets y-component of momentum divided by the charge (absolute value) of particle [GeV/ec] - double GetPy() const { return GetPz() * GetTy(); } - - /// Gets z-component of momentum divided by the charge (absolute value) of particle [GeV/ec] - double GetPz() const { return std::sqrt(GetP() * GetP() / (GetTx() * GetTx() + GetTy() * GetTy() + 1)); } - - /// Gets track polar angle - double GetTheta() const { return std::acos(1. / std::sqrt(GetTx() * GetTx() + GetTy() * GetTy() + 1)); } - - /// Gets track slope along x-axis - double GetTx() const { return T[2]; } - - /// Gets track slope along y-axis - double GetTy() const { return T[3]; } /// Sets max purity /// NOTE: max purity is calculated as a ratio of max number of hits left by an actual track and the /// total number of hits in the track void SetMaxPurity(double maxPurity_) { maxPurity = maxPurity_; } - - static bool compareChi2(const CbmL1Track& a, const CbmL1Track& b) { return (a.chi2 < b.chi2); } - - static bool comparePChi2(const CbmL1Track* a, const CbmL1Track* b) { return (a->chi2 < b->chi2); } + /// Gets probability of track fit model + double GetProb() const { return TMath::Prob(GetChiSq(), GetNdf()); } /// @brief Provides a string representation of object /// @param verbose Verbosity level /// @param header If true, header will be printed std::string ToString(int verbose = 10, bool header = false) const; - std::array<double, L1TrackPar::kNparTr> Tpv; ///< Track parameters at primary vertex - std::array<double, L1TrackPar::kNparCov> Cpv; ///< Track covariance matrix at primary vertex - - std::array<double, L1TrackPar::kNparTr> TLast; ///< Track parameters in the end of the track - std::array<double, L1TrackPar::kNparCov> CLast; ///< Track covariance matrix at the end of the track + cbm::algo::ca::TrackParamD Tpv; ///< Track parameters at primary vertex + cbm::algo::ca::TrackParamD TLast; ///< Track parameters in the end of the track std::vector<int> Hits; ///< Indexes of hits of this track - int nStations; ///< Number of stations with hits of this track - int index; ///< Index of this track (TODO: it seems to be not initialized) + int nStations {0}; ///< Number of stations with hits of this track + int index {0}; ///< Index of this track (TODO: it seems to be not initialized) - double fTrackTime; ///< Time of the track [ns] ??? + double fTrackTime {0.}; ///< Time of the track [ns] ??? std::map<int, int> hitMap; // N hits (second) from each mcTrack (first is a MC track ID) belong to current recoTrack // FIXME: SZh 14.12.2022: map => unordered_map @@ -184,7 +138,7 @@ private: ca::Vector<int> fvMcTrackIndexes = {"CbmL1Track::fvMcTrackIndexes"}; // global indexes of MC tracks // NOTE: mcTracks should be replaced with fvMcTrackIndexes - double maxPurity; ///< Maximum persent of hits, which belong to one mcTrack. + double maxPurity {-1.}; ///< Maximum persent of hits, which belong to one mcTrack. }; #endif diff --git a/reco/L1/CbmL1TrackPar.h b/reco/L1/CbmL1TrackPar.h deleted file mode 100644 index 5d603f57f5af44565d7c72d925734ab3be6c17c8..0000000000000000000000000000000000000000 --- a/reco/L1/CbmL1TrackPar.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2006-2017 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Sergey Gorbunov [committer] */ - -#ifndef CbmL1TrackPar_H -#define CbmL1TrackPar_H - -#include "L1TrackPar.h" - -struct CbmL1TrackPar { -public: - CbmL1TrackPar() : chi2(0), NDF(0), mass(0), is_electron(0) {} - std::array<double, L1TrackPar::kNparTr>& GetTrack() { return T; } - std::array<double, L1TrackPar::kNparCov>& GetCovMatrix() { return C; } - double& GetRefChi2() { return chi2; } - int& GetRefNDF() { return NDF; } - double GetMass() const { return mass; } - bool IsElectron() const { return is_electron; } - - int GetNOfHits() { return (NDF - 5) / 2; } /// Number of hits - - int Id() const { return fId; }; - void SetId(int id) { fId = id; }; - -public: - int fId; - std::array<double, L1TrackPar::kNparTr> T; - std::array<double, L1TrackPar::kNparCov> C; - double chi2; - int NDF; - double mass; // mass hypothesis - bool is_electron; -}; - -#endif diff --git a/reco/L1/CbmL1Util.cxx b/reco/L1/CbmL1Util.cxx index 3f91937ed82023f3456e98df5c9458fba3dd6f34..cb89a9b347550b4a5bde41228c1adbbe72e05080 100644 --- a/reco/L1/CbmL1Util.cxx +++ b/reco/L1/CbmL1Util.cxx @@ -8,40 +8,52 @@ namespace cbm::L1Util { - void CopyTrackParam2TC(const FairTrackParam* par, std::array<double, L1TrackPar::kNparTr>& T, - std::array<double, L1TrackPar::kNparCov>& C) + cbm::algo::ca::TrackParamD ConvertTrackParam(const FairTrackParam& par) { - - T[0] = par->GetX(); - T[1] = par->GetY(); - T[2] = par->GetTx(); - T[3] = par->GetTy(); - T[4] = par->GetQp(); - T[5] = par->GetZ(); - - for (Int_t i = 0, iCov = 0; i < 5; i++) { - for (Int_t j = 0; j <= i; j++, iCov++) { - C[iCov] = par->GetCovariance(i, j); + cbm::algo::ca::TrackParamD t; + t.X() = par.GetX(); + t.Y() = par.GetY(); + t.Tx() = par.GetTx(); + t.Ty() = par.GetTy(); + t.Qp() = par.GetQp(); + t.Z() = par.GetZ(); + t.Time() = 0.; + t.Vi() = cbm::algo::ca::constants::phys::SpeedOfLightInv; + + t.CovMatrix().fill(0.); + + t.ChiSq() = 0.; + t.Ndf() = 0.; + t.ChiSqTime() = 0.; + t.NdfTime() = 0.; + + for (Int_t i = 0; i < 5; i++) { + for (Int_t j = 0; j <= i; j++) { + t.C(i, j) = par.GetCovariance(i, j); } } - } - void CopyTC2TrackParam(FairTrackParam* par, const std::array<double, L1TrackPar::kNparTr>& T, - const std::array<double, L1TrackPar::kNparCov>& C) - { + t.C55() = 1.; + t.C66() = 1.; - par->SetX(T[0]); - par->SetY(T[1]); - par->SetZ(T[5]); - par->SetTx(T[2]); - par->SetTy(T[3]); - par->SetQp(T[4]); + return t; + } - for (Int_t i = 0, iCov = 0; i < 5; i++) { - for (Int_t j = 0; j <= i; j++, iCov++) { - par->SetCovariance(i, j, C[iCov]); + FairTrackParam ConvertTrackParam(const cbm::algo::ca::TrackParamD& t) + { + FairTrackParam par; + par.SetX(t.GetX()); + par.SetY(t.GetY()); + par.SetZ(t.GetZ()); + par.SetTx(t.GetTx()); + par.SetTy(t.GetTy()); + par.SetQp(t.GetQp()); + for (Int_t i = 0; i < 5; i++) { + for (Int_t j = 0; j <= i; j++) { + par.SetCovariance(i, j, t.C(i, j)); } } + return par; } diff --git a/reco/L1/CbmL1Util.h b/reco/L1/CbmL1Util.h index a7479d059305b78715ceb8be30778876cac7ae03..1e6f88c61b394f7c3678de28f5d8ac02b6b9107b 100644 --- a/reco/L1/CbmL1Util.h +++ b/reco/L1/CbmL1Util.h @@ -7,7 +7,7 @@ #include "Rtypes.h" -#include "L1TrackPar.h" +#include "CaTrackParam.h" class FairTrackParam; @@ -17,15 +17,11 @@ class FairTrackParam; namespace cbm::L1Util { - /// copy fair track param to arrays - // TODO: reorganize - void CopyTrackParam2TC(const FairTrackParam* par, std::array<double, L1TrackPar::kNparTr>& T, - std::array<double, L1TrackPar::kNparCov>& C); + /// copy fair track param to Ca track param + cbm::algo::ca::TrackParamD ConvertTrackParam(const FairTrackParam& par); - /// copy arrays to fair track param - // TODO: reorganize - void CopyTC2TrackParam(FairTrackParam* par, const std::array<double, L1TrackPar::kNparTr>& T, - const std::array<double, L1TrackPar::kNparCov>& C); + /// copy Ca track param to fair track param + FairTrackParam ConvertTrackParam(const cbm::algo::ca::TrackParamD& t); } // namespace cbm::L1Util diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 252578e0f329cccd6f56f57632838754d46c48a2..b59f088f3f9694d3d038046486db5fb02baf3cc7 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -30,6 +30,7 @@ class L1AlgoDraw; #include "CaConstants.h" #include "CaTrack.h" +#include "CaTrackParam.h" #include "CaVector.h" #include "L1Branch.h" #include "L1CloneMerger.h" @@ -41,10 +42,11 @@ class L1AlgoDraw; #include "L1InputData.h" #include "L1Parameters.h" #include "L1Station.h" -#include "L1TrackPar.h" #include "L1Triplet.h" #include "L1Utils.h" // ? DEPRECATED ? +using namespace cbm::algo::ca; //TODO: remove + class CbmL1MCTrack; namespace @@ -196,7 +198,7 @@ public: /// \param dir - false - forward, true - backward /// \param qp0 - momentum for extrapolation /// \param initParams - should be params ititialized. 1 - yes. - void BranchFitterFast(const L1Branch& t, L1TrackPar& T, const bool dir, const fvec qp0 = 0., + void BranchFitterFast(const L1Branch& t, TrackParamV& T, const bool dir, const fvec qp0 = 0., const bool initParams = true); /// Fits track. more precise than FitterFast @@ -205,7 +207,7 @@ public: /// \param dir - false - forward, true - backward /// \param qp0 - momentum for extrapolation /// \param initParams - should be params ititialized. 1 - yes. - void BranchFitter(const L1Branch& t, L1TrackPar& T, const bool dir, const fvec qp0 = 0., + void BranchFitter(const L1Branch& t, TrackParamV& T, const bool dir, const fvec qp0 = 0., const bool initParams = true); /// Finds additional hits for already found track @@ -213,7 +215,7 @@ public: /// \param T - track params /// \param dir - 0 - forward, 1 - backward /// \param qp0 - momentum for extrapolation - void FindMoreHits(L1Branch& t, L1TrackPar& T, const bool dir, const fvec qp0 = 0.0); + void FindMoreHits(L1Branch& t, TrackParamV& T, const bool dir, const fvec qp0 = 0.0); /// Find additional hits for existing track /// \return chi2 diff --git a/reco/L1/L1Algo/L1Array.h b/reco/L1/L1Algo/L1Array.h index ed8fd640d36323f7eafe23170d15b0a0d5d5abbe..21f0a5be5612a04740155c4096cc7dfb9518ade5 100644 --- a/reco/L1/L1Algo/L1Array.h +++ b/reco/L1/L1Algo/L1Array.h @@ -18,6 +18,7 @@ // TODO: What is better to be used here - std::size or int. Needs to be tested (S.Zharko) +using namespace cbm::algo::ca; //TODO: remove template<class Tvalue, std::size_t MaxCapacity> class L1Array : private std::array<Tvalue, MaxCapacity> { diff --git a/reco/L1/L1Algo/L1Assert.h b/reco/L1/L1Algo/L1Assert.h index 97f4fc8b39a1a7dbd913950ff68b10e7effe1e33..7effb3cfec4b5d5db12ab097dcb331b9c4859f2f 100644 --- a/reco/L1/L1Algo/L1Assert.h +++ b/reco/L1/L1Algo/L1Assert.h @@ -22,6 +22,8 @@ #include "Logger.h" +using namespace cbm::algo::ca; //TODO: remove + #if defined(NDEBUG) || defined(L1_NO_ASSERT) // TODO: Do we need to add FAST_CODE here? (S.Zharko) #define L1ASSERT(LEVEL, COND) #define L1MASSERT(LEVEL, COND, MSG) diff --git a/reco/L1/L1Algo/L1BranchExtender.cxx b/reco/L1/L1Algo/L1BranchExtender.cxx index ad235dced702f3a9345d8a5146b9c0453e4fc9ca..bcb0f4c0cd3c2168fb882f36fb36857ead647294 100644 --- a/reco/L1/L1Algo/L1BranchExtender.cxx +++ b/reco/L1/L1Algo/L1BranchExtender.cxx @@ -5,12 +5,12 @@ #include <iostream> #include "CaTrack.h" +#include "CaTrackParam.h" #include "CaVector.h" #include "L1Algo.h" #include "L1Branch.h" #include "L1HitArea.h" #include "L1HitPoint.h" -#include "L1TrackPar.h" // using namespace std; using cbm::algo::ca::Vector; // TMP!! @@ -22,7 +22,7 @@ using std::endl; /// T - track params /// qp0 - momentum for extrapolation /// initialize - should be params ititialized. 1 - yes. -void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& Tout, const bool upstream, const fvec qp0, +void L1Algo::BranchFitterFast(const L1Branch& t, TrackParamV& Tout, const bool upstream, const fvec qp0, const bool initParams) { L1_assert(t.NHits >= 3); @@ -31,7 +31,7 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& Tout, const bool up fit.SetParticleMass(GetDefaultParticleMass()); fit.SetMask(fmask::One()); fit.SetTrack(Tout); - L1TrackPar& T = fit.Tr(); + TrackParamV& T = fit.Tr(); // get hits of current track const Vector<L1HitIndex_t>& hits = t.fHits; // array of indeses of hits of current track @@ -64,26 +64,27 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& Tout, const bool up fvec x2 = hit2.x; fvec y2 = hit2.y; - T.x = x0; - T.y = y0; + T.X() = x0; + T.Y() = y0; if (initParams) { fvec dzi = fvec(1.) / (z1 - z0); - T.tx = (x1 - x0) * dzi; - T.ty = (y1 - y0) * dzi; - T.qp = qp0; + T.Tx() = (x1 - x0) * dzi; + T.Ty() = (y1 - y0) * dzi; + T.Qp() = qp0; } fit.SetQp0(qp0); - T.z = z0; - T.t = hit0.t; - T.vi = 0.; + T.Z() = z0; + T.Time() = hit0.t; + T.Vi() = 0.; T.ResetErrors(1., 1., .1, .1, 1., (sta0.timeInfo ? hit0.dt2 : 1.e6), 1.e6); - T.NDF = fvec(2.); + T.Ndf() = fvec(2.); + T.NdfTime() = sta0.timeInfo ? fvec(-1.) : fvec(-2.); - T.C00 = hit0.dx2; - T.C10 = hit0.dxy; - T.C11 = hit0.dy2; + T.C00() = hit0.dx2; + T.C10() = hit0.dxy; + T.C11() = hit0.dy2; L1FieldValue fldB0, fldB1, fldB2 _fvecalignment; L1FieldRegion fld _fvecalignment; @@ -105,7 +106,7 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& Tout, const bool up fit.Extrapolate(hit.z, fld); fit.FilterHit(sta, hit); - auto radThick = fParameters.GetMaterialThickness(ista, T.x, T.y); + auto radThick = fParameters.GetMaterialThickness(ista, T.X(), T.Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec(upstream ? 1. : -1.)); @@ -122,12 +123,12 @@ void L1Algo::BranchFitterFast(const L1Branch& t, L1TrackPar& Tout, const bool up } // void L1Algo::BranchFitterFast /// like BranchFitterFast but more precise -void L1Algo::BranchFitter(const L1Branch& t, L1TrackPar& T, const bool upstream, const fvec qp0, const bool initParams) +void L1Algo::BranchFitter(const L1Branch& t, TrackParamV& T, const bool upstream, const fvec qp0, const bool initParams) { BranchFitterFast(t, T, upstream, qp0, initParams); for (int i = 0; i < 1; i++) { - BranchFitterFast(t, T, !upstream, T.qp, false); - BranchFitterFast(t, T, upstream, T.qp, false); + BranchFitterFast(t, T, !upstream, T.Qp(), false); + BranchFitterFast(t, T, upstream, T.Qp(), false); } } // void L1Algo::BranchFitter @@ -136,7 +137,7 @@ void L1Algo::BranchFitter(const L1Branch& t, L1TrackPar& T, const bool upstream, /// T - track params /// qp0 - momentum for extrapolation /// initialize - should be params ititialized. 1 - yes. -void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& Tout, const bool upstream, const fvec qp0) +void L1Algo::FindMoreHits(L1Branch& t, TrackParamV& Tout, const bool upstream, const fvec qp0) { Vector<L1HitIndex_t> newHits {"L1TrackExtender::newHits"}; newHits.reserve(fParameters.GetNstationsActive()); @@ -199,14 +200,14 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& Tout, const bool upstream, co fscal r2_best = 1e8; // best distance to hit int iHit_best = -1; // index of the best hit - L1TrackPar& tr = fit.Tr(); + TrackParamV& tr = fit.Tr(); - const fscal iz = 1.f / (tr.z[0] - fParameters.GetTargetPositionZ()[0]); + const fscal iz = 1.f / (tr.Z()[0] - fParameters.GetTargetPositionZ()[0]); - L1HitAreaTime area(vGridTime[ista], tr.x[0] * iz, tr.y[0] * iz, - (sqrt(fPickGather * tr.C00) + fMaxRangeX[ista] + fMaxDZ * abs(tr.tx))[0] * iz, - (sqrt(fPickGather * tr.C11) + fMaxRangeY[ista] + fMaxDZ * abs(tr.ty))[0] * iz, tr.t[0], - sqrt(tr.C55[0])); + L1HitAreaTime area(vGridTime[ista], tr.X()[0] * iz, tr.Y()[0] * iz, + (sqrt(fPickGather * tr.C00()) + fMaxRangeX[ista] + fMaxDZ * abs(tr.Tx()))[0] * iz, + (sqrt(fPickGather * tr.C11()) + fMaxRangeY[ista] + fMaxDZ * abs(tr.Ty()))[0] * iz, tr.Time()[0], + sqrt(tr.C55()[0])); for (L1HitIndex_t ih = -1; true;) { // loop over the hits in the area @@ -225,9 +226,9 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& Tout, const bool upstream, co const L1Hit& hit = fGridHits[globalInd]; - if (sta.timeInfo && tr.nTimeMeasurements[0] > 0) { - fscal dt = hit.t - tr.t[0]; - if (fabs(dt) > sqrt(25. * tr.C55[0]) + hit.rangeT) continue; + if (sta.timeInfo && tr.NdfTime()[0] > -2.) { + fscal dt = hit.t - tr.Time()[0]; + if (fabs(dt) > sqrt(25. * tr.C55()[0]) + hit.rangeT) continue; } //if (GetFUsed((*fStripFlag)[hit.f] | (*fStripFlag)[hit.b])) continue; // if used @@ -266,7 +267,7 @@ void L1Algo::FindMoreHits(L1Branch& t, L1TrackPar& Tout, const bool upstream, co fit.Extrapolate(hit.z, fld); fit.FilterHit(sta, hit); - auto radThick = fParameters.GetMaterialThickness(ista, tr.x, tr.y); + auto radThick = fParameters.GetMaterialThickness(ista, tr.X(), tr.Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, upstream ? fvec(1.f) : fvec(-1.f)); @@ -308,7 +309,7 @@ fscal L1Algo::BranchExtender(L1Branch& t) // TODO Simdize { // const unsigned int minNHits = 3; - L1TrackPar T; + TrackParamV T; // downstream bool upstream = 0; @@ -317,14 +318,14 @@ fscal L1Algo::BranchExtender(L1Branch& t) // TODO Simdize // BranchFitterFast (t, T, upstream, 0, true); // if (t.NHits < minNHits) return T.chi2[0]; - FindMoreHits(t, T, upstream, T.qp); + FindMoreHits(t, T, upstream, T.Qp()); // upstream upstream = 1; - BranchFitterFast(t, T, upstream, T.qp, false); + BranchFitterFast(t, T, upstream, T.Qp(), false); - FindMoreHits(t, T, upstream, T.qp); + FindMoreHits(t, T, upstream, T.Qp()); - return T.chi2[0]; + return T.GetChiSq()[0]; } diff --git a/reco/L1/L1Algo/L1CAIteration.cxx b/reco/L1/L1Algo/L1CAIteration.cxx index 7066cbd3f8eb4a771c8ebe66a470ec14798936c7..fa4ae4f863a0cec493853b6d459c1fd679fb4cdc 100644 --- a/reco/L1/L1Algo/L1CAIteration.cxx +++ b/reco/L1/L1Algo/L1CAIteration.cxx @@ -16,6 +16,7 @@ #include "CaConstants.h" +using namespace cbm::algo::ca; //TODO: remove // --------------------------------------------------------------------------------------------------------------------- // diff --git a/reco/L1/L1Algo/L1CaTrackFinder.cxx b/reco/L1/L1Algo/L1CaTrackFinder.cxx index 6e45e6fd4b20aaa6f6983287097cc024a4a2c083..97eb09b4640ef8ddf5bca03e74b00006754db6a0 100644 --- a/reco/L1/L1Algo/L1CaTrackFinder.cxx +++ b/reco/L1/L1Algo/L1CaTrackFinder.cxx @@ -83,10 +83,11 @@ void L1Algo::CaTrackFinder() fscal dz = h.z - targZ; fscal l = sqrt(dx * dx + dy * dy + dz * dz); - fscal timeOfFlightMin = l * L1TrackPar::kClightNsInv; + fscal timeOfFlightMin = l * constants::phys::SpeedOfLightInv; fscal timeOfFlightMax = - 1.5 * l * sqrt(1. + L1TrackPar::kProtonMass * L1TrackPar::kProtonMass / minProtonMomentum / minProtonMomentum) - * L1TrackPar::kClightNsInv; + 1.5 * l + * sqrt(1. + constants::phys::ProtonMassD * constants::phys::ProtonMassD / minProtonMomentum / minProtonMomentum) + * constants::phys::SpeedOfLightInvD; fscal dt = h.rangeT; L1HitTimeInfo& info = fHitTimeInfo[caHitId]; diff --git a/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx b/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx index 5efbf005dbbfb83895db88aeef47eb03f92c29c4..0b9eae26719188526d63a8f72552702f831f5c0a 100644 --- a/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx +++ b/reco/L1/L1Algo/L1CaTrackFinderSlice.cxx @@ -23,6 +23,7 @@ #include "CbmL1MCTrack.h" #include "CaTrack.h" +#include "CaTrackParam.h" #include "L1Algo.h" #include "L1Assert.h" #include "L1Branch.h" @@ -30,7 +31,6 @@ #include "L1Grid.h" #include "L1HitArea.h" #include "L1HitPoint.h" -#include "L1TrackPar.h" #include "L1TripletConstructor.h" #ifdef DRAW #include "utils/L1AlgoDraw.h" @@ -645,7 +645,6 @@ void L1Algo::CaTrackFinderSlice() if (fpCurrentIteration->GetExtendTracksFlag()) { if (tr.NHits != fParameters.GetNstationsActive()) BranchExtender(tr); } - fscal sumTime = 0; for (auto iHit : tr.fHits) { const L1Hit& hit = fInputData.GetHit(iHit); @@ -656,13 +655,6 @@ void L1Algo::CaTrackFinderSlice() fvHitKeyFlags[hit.b] = 1; fSliceRecoHits.push_back(iHit); - - fscal dx = hit.x - fParameters.GetTargetPositionX()[0]; - fscal dy = hit.y - fParameters.GetTargetPositionY()[0]; - fscal dz = hit.z - fParameters.GetTargetPositionZ()[0]; - - fscal timeFlight = sqrt(dx * dx + dy * dy + dz * dz) / 30.f; // c = 30[cm/ns] - sumTime += (hit.t - timeFlight); } Track t; t.fNofHits = tr.NHits; diff --git a/reco/L1/L1Algo/L1CloneMerger.cxx b/reco/L1/L1Algo/L1CloneMerger.cxx index ef106c9536269f1348e2d4bdd81afad05eb71cf0..a033d15082d3bdd509bd3de076cc9472fff47188 100644 --- a/reco/L1/L1Algo/L1CloneMerger.cxx +++ b/reco/L1/L1Algo/L1CloneMerger.cxx @@ -90,8 +90,8 @@ void L1CloneMerger::Exec(Vector<Track>& extTracks, Vector<L1HitIndex_t>& extReco fitF.SetMask(fmask::One()); fitF.SetQp0(fvec(0.)); - L1TrackPar& Tb = fitB.Tr(); - L1TrackPar& Tf = fitF.Tr(); + TrackParamV& Tb = fitB.Tr(); + TrackParamV& Tf = fitF.Tr(); L1FieldValue fBm, fBb, fBf _fvecalignment; L1FieldRegion fld _fvecalignment; @@ -110,22 +110,23 @@ void L1CloneMerger::Exec(Vector<Track>& extTracks, Vector<L1HitIndex_t>& extReco unsigned short stab = firstStation[iTr]; - Tb.copyFromArrays(extTracks[iTr].fParFirst, extTracks[iTr].fCovFirst); - fitB.SetQp0(fitB.Tr().qp); + Tb.Set(extTracks[iTr].fParFirst); + + fitB.SetQp0(fitB.Tr().GetQp()); unsigned short staf = lastStation[jTr]; - Tf.copyFromArrays(extTracks[jTr].fParLast, extTracks[jTr].fCovLast); - fitF.SetQp0(fitF.Tr().qp); + Tf.Set(extTracks[jTr].fParLast); + fitF.SetQp0(fitF.Tr().GetQp()); - if (Tf.nTimeMeasurements[0] > 0 && Tb.nTimeMeasurements[0] > 0) { - if (fabs(Tf.t[0] - Tb.t[0]) > 3 * sqrt(Tf.C55[0] + Tb.C55[0])) continue; + if (Tf.NdfTime()[0] >= 0. && Tb.NdfTime()[0] >= 0.) { + if (fabs(Tf.GetTime()[0] - Tb.GetTime()[0]) > 3 * sqrt(Tf.C55()[0] + Tb.C55()[0])) continue; } unsigned short stam; - frAlgo.GetParameters()->GetStation(staf).fieldSlice.GetFieldValue(Tf.x, Tf.y, fBf); - frAlgo.GetParameters()->GetStation(stab).fieldSlice.GetFieldValue(Tb.x, Tb.y, fBb); + frAlgo.GetParameters()->GetStation(staf).fieldSlice.GetFieldValue(Tf.X(), Tf.Y(), fBf); + frAlgo.GetParameters()->GetStation(stab).fieldSlice.GetFieldValue(Tb.X(), Tb.Y(), fBb); unsigned short dist = firstStation[iTr] - lastStation[jTr]; @@ -134,18 +135,18 @@ void L1CloneMerger::Exec(Vector<Track>& extTracks, Vector<L1HitIndex_t>& extReco stam = staf - 1; fvec zm = frAlgo.GetParameters()->GetStation(stam).fZ; - fvec xm = fvec(0.5) * (Tf.x + Tf.tx * (zm - Tf.z) + Tb.x + Tb.tx * (zm - Tb.z)); - fvec ym = fvec(0.5) * (Tf.y + Tf.ty * (zm - Tf.z) + Tb.y + Tb.ty * (zm - Tb.z)); + fvec xm = fvec(0.5) * (Tf.GetX() + Tf.Tx() * (zm - Tf.Z()) + Tb.GetX() + Tb.Tx() * (zm - Tb.Z())); + fvec ym = fvec(0.5) * (Tf.Y() + Tf.Ty() * (zm - Tf.Z()) + Tb.Y() + Tb.Ty() * (zm - Tb.Z())); frAlgo.GetParameters()->GetStation(stam).fieldSlice.GetFieldValue(xm, ym, fBm); - fld.Set(fBb, Tb.z, fBm, zm, fBf, Tf.z); + fld.Set(fBb, Tb.Z(), fBm, zm, fBf, Tf.Z()); - fvec zMiddle = fvec(0.5) * (Tb.z + Tf.z); + fvec zMiddle = fvec(0.5) * (Tb.Z() + Tf.Z()); fitF.Extrapolate(zMiddle, fld); fitB.Extrapolate(zMiddle, fld); fvec Chi2Tracks(0.); - FilterTracks(&(Tf.x), &(Tf.C00), &(Tb.x), &(Tb.C00), 0, 0, &Chi2Tracks); + FilterTracks(&(Tf.X()), &(Tf.C00()), &(Tb.X()), &(Tb.C00()), 0, 0, &Chi2Tracks); if (Chi2Tracks[0] > 50) continue; if (Chi2Tracks[0] < trackChi2[iTr] || Chi2Tracks[0] < trackChi2[jTr]) { diff --git a/reco/L1/L1Algo/L1CloneMerger.h b/reco/L1/L1Algo/L1CloneMerger.h index de0132f8a217f74e0bd29a06a94b754aadbc4d72..451dcd6da3e792cab305519487de0930b0753c5a 100644 --- a/reco/L1/L1Algo/L1CloneMerger.h +++ b/reco/L1/L1Algo/L1CloneMerger.h @@ -16,6 +16,8 @@ #include "L1Hit.h" // For L1HitIndex_t +using namespace cbm::algo::ca; //TODO: remove + namespace cbm::algo::ca { class Track; diff --git a/reco/L1/L1Algo/L1ConfigRW.cxx b/reco/L1/L1Algo/L1ConfigRW.cxx index 9fa417a9d0e0fd076e42f22502a3d6d2580fadc3..b4450b2dd516e0370a379aabe392c8c04f5164a0 100644 --- a/reco/L1/L1Algo/L1ConfigRW.cxx +++ b/reco/L1/L1Algo/L1ConfigRW.cxx @@ -68,7 +68,7 @@ std::vector<std::string> L1ConfigRW::GetNodeKeys(const YAML::Node& node) const void L1ConfigRW::Read() { { // Init CA iterations in L1InitManager - LOG(info) << "- reading track finder iterations"; + if (fVerbose >= 1) { LOG(info) << "- reading track finder iterations"; } auto iters = this->ReadCAIterationVector(); assert(iters.size()); fpInitManager->ClearCAIterations(); @@ -77,7 +77,7 @@ void L1ConfigRW::Read() } { // Unset inactive tracking stations - LOG(info) << "- unsetting inactive tracking stations"; + if (fVerbose >= 1) { LOG(info) << "- unsetting inactive tracking stations"; } auto inactiveMap = this->ReadInactiveStationMap(); if (std::any_of(inactiveMap.begin(), inactiveMap.end(), [](const auto& s) { return (s.size() != 0); })) { for (auto& station : fpInitManager->GetStationInfo()) { @@ -92,7 +92,9 @@ void L1ConfigRW::Read() } // Init parameters, independnent from the tracking iteration - LOG(info) << "- reading miscellaneous parameters"; + + if (fVerbose >= 1) { LOG(info) << "- reading miscellaneous parameters"; } + fpInitManager->SetRandomSeed( GetNode([](YAML::Node n) { return n["core"]["common"]["random_seed"]; }).as<unsigned int>()); fpInitManager->SetGhostSuppression( @@ -101,7 +103,8 @@ void L1ConfigRW::Read() GetNode([](YAML::Node n) { return n["core"]["track_finder"]["max_doublets_per_singlet"]; }).as<unsigned int>()); fpInitManager->SetMaxTripletPerDoublets( GetNode([](YAML::Node n) { return n["core"]["track_finder"]["max_triplets_per_doublet"]; }).as<unsigned int>()); - LOG(info) << "- reading developement parameters"; + + if (fVerbose >= 1) { LOG(info) << "- reading developement parameters"; } // Dev flags fpInitManager->DevSetIgnoreHitSearchAreas( GetNode([](YAML::Node n) { return n["core"]["dev"]["ignore_hit_search_areas"]; }).as<bool>()); @@ -151,31 +154,33 @@ std::vector<L1CAIteration> L1ConfigRW::ReadCAIterationVector() // Read actual iteration sequence // if (fUserConfigNode) { + if (fVerbose >= 1) { LOG(info) << "- Reading user iterations "; } + auto currentNode = fUserConfigNode["core"]["track_finder"]["iterations"]; if (currentNode) { for (const auto& iterNode : currentNode) { std::string thisIterName = iterNode["name"].as<std::string>(""); std::string baseIterName = iterNode["base_iteration"].as<std::string>(""); - LOG(info) << "- Reading user iteration " << thisIterName << "(" << baseIterName << ")"; + if (fVerbose >= 2) { LOG(info) << "- Reading user iteration " << thisIterName << "(" << baseIterName << ")"; } if (mPossibleIterations.find(thisIterName) != mPossibleIterations.end()) { // This is an update of existing possible iteration - LOG(info) << "- Select A"; + if (fVerbose >= 2) { LOG(info) << "- Select A"; } res.push_back(ReadSingleCAIteration(iterNode, mPossibleIterations.at(thisIterName))); } else if (mPossibleIterations.find(baseIterName) != mPossibleIterations.end()) { // This is a user iteration based on the existing possible iteration - LOG(info) << "- Select B"; + if (fVerbose >= 2) { LOG(info) << "- Select B"; } res.push_back(ReadSingleCAIteration(iterNode, mPossibleIterations.at(baseIterName))); } else { // Try to find a base iteration from user-defined auto itFound = std::find_if(res.begin(), res.end(), [&](auto& i) { return i.GetName() == baseIterName; }); if (itFound != res.end()) { - LOG(info) << "- Select C"; + if (fVerbose >= 2) { LOG(info) << "- Select C"; } res.push_back(ReadSingleCAIteration(iterNode, *itFound)); } else { - LOG(info) << "- Select D"; + if (fVerbose >= 2) { LOG(info) << "- Select D"; } res.push_back(ReadSingleCAIteration(iterNode, L1CAIteration())); } } @@ -339,7 +344,9 @@ void L1ConfigRW::SetMainConfigPath(const std::string& path) try { fsMainConfigPath = path; fMainConfigNode = YAML::LoadFile(fsMainConfigPath)["ca"]; - LOG(info) << "L1ConfigRW: Registering main configuraiton file: \"\033[1;32m" << path << "\033[0m\""; + if (fVerbose >= 1) { + LOG(info) << "L1ConfigRW: Registering main configuraiton file: \"\033[1;32m" << path << "\033[0m\""; + } } catch (const std::exception& err) { LOG(error) << "ERROR: " << err.what(); @@ -355,7 +362,9 @@ void L1ConfigRW::SetUserConfigPath(const std::string& path) try { fsUserConfigPath = path; fUserConfigNode = YAML::LoadFile(fsUserConfigPath)["ca"]; - LOG(info) << "L1ConfigRW: Registering user configuraiton file: \"\033[1;32m" << path << "\033[0m\""; + if (fVerbose >= 1) { + LOG(info) << "L1ConfigRW: Registering user configuraiton file: \"\033[1;32m" << path << "\033[0m\""; + } } catch (const std::exception& err) { LOG(error) << "ERROR: " << err.what(); diff --git a/reco/L1/L1Algo/L1ConfigRW.h b/reco/L1/L1Algo/L1ConfigRW.h index 1137d506dc0e21f70754ac9d88f9ac881a2b2247..d6f1096a756c84e368038a7449db5f28dab1f108 100644 --- a/reco/L1/L1Algo/L1ConfigRW.h +++ b/reco/L1/L1Algo/L1ConfigRW.h @@ -30,7 +30,7 @@ class L1ConfigRW { public: /// @brief Constructor /// @param pInitManager Pointer to the L1InitManager instance - L1ConfigRW(L1InitManager* pInitManager, int verbose = 0); + L1ConfigRW(L1InitManager* pInitManager, int verbose = 1); /// @brief Destructor ~L1ConfigRW() = default; @@ -50,6 +50,12 @@ public: /// @param path Path to user config file void SetUserConfigPath(const std::string& path); + /// @brief Sets verbosity level + void SetVerbosity(int verbose) { fVerbose = verbose; } + + /// @brief Gets verbosity level + int GetVerbosity() const { return fVerbose; } + private: /// @brief Reads inactive tracking station map /// @return A vector of sets of disabled station local indexes vs. the the detector index @@ -77,7 +83,7 @@ private: std::vector<std::string> GetNodeKeys(const YAML::Node& node) const; L1InitManager* fpInitManager = nullptr; ///< Pointer to the L1InitManager instance - int fVerbose = 0; ///< Verbosity level + int fVerbose = 1; ///< Verbosity level std::string fsMainConfigPath = ""; ///< Path to the main config file (mandatory) std::string fsUserConfigPath = ""; ///< Path to the user config file (optional) diff --git a/reco/L1/L1Algo/L1Field.cxx b/reco/L1/L1Algo/L1Field.cxx index 470facb7eeadf3066922b03ca9b2d0d40a29d911..f661795944f8656bc210e40a8564e8bacf991451 100644 --- a/reco/L1/L1Algo/L1Field.cxx +++ b/reco/L1/L1Algo/L1Field.cxx @@ -11,9 +11,11 @@ #include <iostream> #include <sstream> -#include "L1TrackPar.h" +#include "CaTrackParam.h" #include "L1Utils.h" +using namespace cbm::algo::ca; + // // L1FieldValue methods // @@ -61,11 +63,11 @@ std::ostream& operator<<(std::ostream& out, const L1FieldValue& B) L1FieldSlice::L1FieldSlice() { for (int i = 0; i < constants::size::MaxNFieldApproxCoefficients; ++i) { - cx[i] = constants::undef::Fscal; - cy[i] = constants::undef::Fscal; - cz[i] = constants::undef::Fscal; + cx[i] = constants::Undef<fscal>; + cy[i] = constants::Undef<fscal>; + cz[i] = constants::Undef<fscal>; } - z = constants::undef::Fscal; + z = constants::Undef<fscal>; } //---------------------------------------------------------------------------------------------------------------------- @@ -120,10 +122,10 @@ void L1FieldSlice::GetFieldValue(const fvec& x, const fvec& y, L1FieldValue& B) + cz[16] * x4y + cz[17] * x3y2 + cz[18] * x2y3 + cz[19] * xy4 + cz[20] * y5; } -void L1FieldSlice::GetFieldValueForLine(const L1TrackPar& t, L1FieldValue& B) const +void L1FieldSlice::GetFieldValueForLine(const cbm::algo::ca::TrackParamV& t, L1FieldValue& B) const { - fvec dz = z - t.z; - GetFieldValue(t.x + t.tx * dz, t.y + t.ty * dz, B); + fvec dz = z - t.GetZ(); + GetFieldValue(t.GetX() + t.GetTx() * dz, t.GetY() + t.GetTy() * dz, B); } //---------------------------------------------------------------------------------------------------------------------- diff --git a/reco/L1/L1Algo/L1Field.h b/reco/L1/L1Algo/L1Field.h index 4072708740c5a785afd41abc98c6edae3dc4093f..dbbb4e601a3287ce65d7eb6f220c2a676fa51102 100644 --- a/reco/L1/L1Algo/L1Field.h +++ b/reco/L1/L1Algo/L1Field.h @@ -11,10 +11,12 @@ #include "CaConstants.h" #include "CaSimd.h" +#include "CaTrackParam.h" -class L1TrackPar; +using namespace cbm::algo::ca; // TODO: remove class L1FieldValue { + public: fvec x {0.f}; //< x-component of the field fvec y {0.f}; //< y-component of the field @@ -82,7 +84,7 @@ public: /// Gets field value for the intersection with a straight track /// \param t straight track /// \param B the L1FieldValue output - void GetFieldValueForLine(const L1TrackPar& t, L1FieldValue& B) const; + void GetFieldValueForLine(const cbm::algo::ca::TrackParamV& t, L1FieldValue& B) const; /// String representation of class contents /// \param indentLevel number of indent characters in the output @@ -92,12 +94,12 @@ public: // NOTE: We don't use an initialization of arrays here because we cannot be sure // if the underlying type (fvec) has a default constructor, but // we are sure, that it can be initialized with a float. (S.Zharko) - static constexpr auto kMaxNFieldApproxCoefficients = constants::size::MaxNFieldApproxCoefficients; + static constexpr auto kMaxNFieldApproxCoefficients = cbm::algo::ca::constants::size::MaxNFieldApproxCoefficients; fvec cx[kMaxNFieldApproxCoefficients]; ///< Polynomial coefficients for x-component of the field value fvec cy[kMaxNFieldApproxCoefficients]; ///< Polynomial coefficients for y-component of the field value fvec cz[kMaxNFieldApproxCoefficients]; ///< Polynomial coefficients for z-component of the field value - fvec z {constants::undef::Fscal}; ///< z coordinate of the slice + fvec z {constants::Undef<fscal>}; ///< z coordinate of the slice /// Serialization function friend class boost::serialization::access; diff --git a/reco/L1/L1Algo/L1Fit.cxx b/reco/L1/L1Algo/L1Fit.cxx index 8895cc4062c9fe3c3f6e6685789afa29b78d18ec..6a250a9dbcbbb3b3b7c810dfef2d44943b3142d3 100644 --- a/reco/L1/L1Algo/L1Fit.cxx +++ b/reco/L1/L1Algo/L1Fit.cxx @@ -15,19 +15,19 @@ void L1Fit::FilterU(const L1UMeasurementInfo& info, cnst& u, cnst& sigma2) fvec F0, F1, F2, F3, F4, F5, F6; fvec K1, K2, K3, K4, K5, K6; - zeta = info.cos_phi * fTr.x + info.sin_phi * fTr.y - u; + zeta = info.cos_phi * fTr.X() + info.sin_phi * fTr.Y() - u; // F = CH' - F0 = info.cos_phi * fTr.C00 + info.sin_phi * fTr.C10; - F1 = info.cos_phi * fTr.C10 + info.sin_phi * fTr.C11; + F0 = info.cos_phi * fTr.C00() + info.sin_phi * fTr.C10(); + F1 = info.cos_phi * fTr.C10() + info.sin_phi * fTr.C11(); HCH = (F0 * info.cos_phi + F1 * info.sin_phi); - F2 = info.cos_phi * fTr.C20 + info.sin_phi * fTr.C21; - F3 = info.cos_phi * fTr.C30 + info.sin_phi * fTr.C31; - F4 = info.cos_phi * fTr.C40 + info.sin_phi * fTr.C41; - F5 = info.cos_phi * fTr.C50 + info.sin_phi * fTr.C51; - F6 = info.cos_phi * fTr.C60 + info.sin_phi * fTr.C61; + F2 = info.cos_phi * fTr.C20() + info.sin_phi * fTr.C21(); + F3 = info.cos_phi * fTr.C30() + info.sin_phi * fTr.C31(); + F4 = info.cos_phi * fTr.C40() + info.sin_phi * fTr.C41(); + F5 = info.cos_phi * fTr.C50() + info.sin_phi * fTr.C51(); + F6 = info.cos_phi * fTr.C60() + info.sin_phi * fTr.C61(); const fmask maskDoFilter = (HCH < sigma2 * 16.f); //cnst maskDoFilter = _f32vec4_true; @@ -41,9 +41,9 @@ void L1Fit::FilterU(const L1UMeasurementInfo& info, cnst& u, cnst& sigma2) //wi = iif(wi > fvec::Zero(), wi, fvec::Zero()); wi = iif(sigma2 > fvec::Zero(), wi, fvec::Zero()); - // fTr.chi2 += iif( maskDoFilter, zeta * zetawi, fvec::Zero() ); - fTr.chi2 += zeta * zeta * wi; - fTr.NDF += fMaskF; + // fTr.ChiSq() += iif( maskDoFilter, zeta * zetawi, fvec::Zero() ); + fTr.ChiSq() += zeta * zeta * wi; + fTr.Ndf() += fMaskF; K1 = F1 * wi; K2 = F2 * wi; @@ -52,48 +52,48 @@ void L1Fit::FilterU(const L1UMeasurementInfo& info, cnst& u, cnst& sigma2) K5 = F5 * wi; K6 = F6 * wi; - fTr.x -= F0 * zetawi; - fTr.y -= F1 * zetawi; - fTr.tx -= F2 * zetawi; - fTr.ty -= F3 * zetawi; - fTr.qp -= F4 * zetawi; - fTr.t -= F5 * zetawi; - fTr.vi -= F6 * zetawi; - - fTr.C00 -= F0 * F0 * wi; - - fTr.C10 -= K1 * F0; - fTr.C11 -= K1 * F1; - - fTr.C20 -= K2 * F0; - fTr.C21 -= K2 * F1; - fTr.C22 -= K2 * F2; - - fTr.C30 -= K3 * F0; - fTr.C31 -= K3 * F1; - fTr.C32 -= K3 * F2; - fTr.C33 -= K3 * F3; - - fTr.C40 -= K4 * F0; - fTr.C41 -= K4 * F1; - fTr.C42 -= K4 * F2; - fTr.C43 -= K4 * F3; - fTr.C44 -= K4 * F4; - - fTr.C50 -= K5 * F0; - fTr.C51 -= K5 * F1; - fTr.C52 -= K5 * F2; - fTr.C53 -= K5 * F3; - fTr.C54 -= K5 * F4; - fTr.C55 -= K5 * F5; - - fTr.C60 -= K6 * F0; - fTr.C61 -= K6 * F1; - fTr.C62 -= K6 * F2; - fTr.C63 -= K6 * F3; - fTr.C64 -= K6 * F4; - fTr.C65 -= K6 * F5; - fTr.C66 -= K6 * F6; + fTr.X() -= F0 * zetawi; + fTr.Y() -= F1 * zetawi; + fTr.Tx() -= F2 * zetawi; + fTr.Ty() -= F3 * zetawi; + fTr.Qp() -= F4 * zetawi; + fTr.Time() -= F5 * zetawi; + fTr.Vi() -= F6 * zetawi; + + fTr.C00() -= F0 * F0 * wi; + + fTr.C10() -= K1 * F0; + fTr.C11() -= K1 * F1; + + fTr.C20() -= K2 * F0; + fTr.C21() -= K2 * F1; + fTr.C22() -= K2 * F2; + + fTr.C30() -= K3 * F0; + fTr.C31() -= K3 * F1; + fTr.C32() -= K3 * F2; + fTr.C33() -= K3 * F3; + + fTr.C40() -= K4 * F0; + fTr.C41() -= K4 * F1; + fTr.C42() -= K4 * F2; + fTr.C43() -= K4 * F3; + fTr.C44() -= K4 * F4; + + fTr.C50() -= K5 * F0; + fTr.C51() -= K5 * F1; + fTr.C52() -= K5 * F2; + fTr.C53() -= K5 * F3; + fTr.C54() -= K5 * F4; + fTr.C55() -= K5 * F5; + + fTr.C60() -= K6 * F0; + fTr.C61() -= K6 * F1; + fTr.C62() -= K6 * F2; + fTr.C63() -= K6 * F3; + fTr.C64() -= K6 * F4; + fTr.C65() -= K6 * F5; + fTr.C66() -= K6 * F6; } void L1Fit::FilterTime(cnst& t, cnst& dt2, cnst& timeInfo) @@ -101,15 +101,15 @@ void L1Fit::FilterTime(cnst& t, cnst& dt2, cnst& timeInfo) // filter track with a time measurement // F = CH' - fvec F0 = fTr.C50; - fvec F1 = fTr.C51; - fvec F2 = fTr.C52; - fvec F3 = fTr.C53; - fvec F4 = fTr.C54; - fvec F5 = fTr.C55; - fvec F6 = fTr.C65; + fvec F0 = fTr.C50(); + fvec F1 = fTr.C51(); + fvec F2 = fTr.C52(); + fvec F3 = fTr.C53(); + fvec F4 = fTr.C54(); + fvec F5 = fTr.C55(); + fvec F6 = fTr.C65(); - fvec HCH = fTr.C55; + fvec HCH = fTr.C55(); fvec w = fMaskF; @@ -123,11 +123,11 @@ void L1Fit::FilterTime(cnst& t, cnst& dt2, cnst& timeInfo) const fmask maskDoFilter = (HCH < dt2 * 16.f); fvec wi = w / (dt2 + fvec(1.0000001) * HCH); - fvec zeta = fTr.t - t; + fvec zeta = fTr.Time() - t; fvec zetawi = w * zeta / (iif(maskDoFilter, dt2, fvec::Zero()) + HCH); - fTr.chi2(maskDoFilter) += zeta * zeta * wi; - fTr.NDF += w; + fTr.ChiSqTime()(maskDoFilter) += zeta * zeta * wi; + fTr.NdfTime() += w; fvec K1 = F1 * wi; fvec K2 = F2 * wi; @@ -136,50 +136,48 @@ void L1Fit::FilterTime(cnst& t, cnst& dt2, cnst& timeInfo) fvec K5 = F5 * wi; fvec K6 = F6 * wi; - fTr.x -= F0 * zetawi; - fTr.y -= F1 * zetawi; - fTr.tx -= F2 * zetawi; - fTr.ty -= F3 * zetawi; - fTr.qp -= F4 * zetawi; - fTr.t -= F5 * zetawi; - fTr.vi -= F6 * zetawi; - - fTr.nTimeMeasurements += w; - - fTr.C00 -= F0 * F0 * wi; - - fTr.C10 -= K1 * F0; - fTr.C11 -= K1 * F1; - - fTr.C20 -= K2 * F0; - fTr.C21 -= K2 * F1; - fTr.C22 -= K2 * F2; - - fTr.C30 -= K3 * F0; - fTr.C31 -= K3 * F1; - fTr.C32 -= K3 * F2; - fTr.C33 -= K3 * F3; - - fTr.C40 -= K4 * F0; - fTr.C41 -= K4 * F1; - fTr.C42 -= K4 * F2; - fTr.C43 -= K4 * F3; - fTr.C44 -= K4 * F4; - - fTr.C50 -= K5 * F0; - fTr.C51 -= K5 * F1; - fTr.C52 -= K5 * F2; - fTr.C53 -= K5 * F3; - fTr.C54 -= K5 * F4; - fTr.C55 -= K5 * F5; - - fTr.C60 -= K6 * F0; - fTr.C61 -= K6 * F1; - fTr.C62 -= K6 * F2; - fTr.C63 -= K6 * F3; - fTr.C64 -= K6 * F4; - fTr.C65 -= K6 * F5; - fTr.C66 -= K6 * F6; + fTr.X() -= F0 * zetawi; + fTr.Y() -= F1 * zetawi; + fTr.Tx() -= F2 * zetawi; + fTr.Ty() -= F3 * zetawi; + fTr.Qp() -= F4 * zetawi; + fTr.Time() -= F5 * zetawi; + fTr.Vi() -= F6 * zetawi; + + fTr.C00() -= F0 * F0 * wi; + + fTr.C10() -= K1 * F0; + fTr.C11() -= K1 * F1; + + fTr.C20() -= K2 * F0; + fTr.C21() -= K2 * F1; + fTr.C22() -= K2 * F2; + + fTr.C30() -= K3 * F0; + fTr.C31() -= K3 * F1; + fTr.C32() -= K3 * F2; + fTr.C33() -= K3 * F3; + + fTr.C40() -= K4 * F0; + fTr.C41() -= K4 * F1; + fTr.C42() -= K4 * F2; + fTr.C43() -= K4 * F3; + fTr.C44() -= K4 * F4; + + fTr.C50() -= K5 * F0; + fTr.C51() -= K5 * F1; + fTr.C52() -= K5 * F2; + fTr.C53() -= K5 * F3; + fTr.C54() -= K5 * F4; + fTr.C55() -= K5 * F5; + + fTr.C60() -= K6 * F0; + fTr.C61() -= K6 * F1; + fTr.C62() -= K6 * F2; + fTr.C63() -= K6 * F3; + fTr.C64() -= K6 * F4; + fTr.C65() -= K6 * F5; + fTr.C66() -= K6 * F6; } @@ -209,25 +207,25 @@ void L1Fit::FilterXY(const L1XYMeasurementInfo& info, cnst& x, cnst& y) fvec K00, K10, K20, K30, K40, K50, K60; fvec K01, K11, K21, K31, K41, K51, K61; - zeta0 = fTr.x - x; - zeta1 = fTr.y - y; + zeta0 = fTr.X() - x; + zeta1 = fTr.Y() - y; // F = CH' - F00 = fTr.C00; - F10 = fTr.C10; - F20 = fTr.C20; - F30 = fTr.C30; - F40 = fTr.C40; - F50 = fTr.C50; - F60 = fTr.C60; - - F01 = fTr.C10; - F11 = fTr.C11; - F21 = fTr.C21; - F31 = fTr.C31; - F41 = fTr.C41; - F51 = fTr.C51; - F61 = fTr.C61; + F00 = fTr.C00(); + F10 = fTr.C10(); + F20 = fTr.C20(); + F30 = fTr.C30(); + F40 = fTr.C40(); + F50 = fTr.C50(); + F60 = fTr.C60(); + + F01 = fTr.C10(); + F11 = fTr.C11(); + F21 = fTr.C21(); + F31 = fTr.C31(); + F41 = fTr.C41(); + F51 = fTr.C51(); + F61 = fTr.C61(); S00 = F00 + info.C00; S10 = F10 + info.C10; @@ -239,8 +237,8 @@ void L1Fit::FilterXY(const L1XYMeasurementInfo& info, cnst& x, cnst& y) S10 = -si * S10; S11 = si * S00tmp; - fTr.chi2 += zeta0 * zeta0 * S00 + 2.f * zeta0 * zeta1 * S10 + zeta1 * zeta1 * S11; - fTr.NDF += TWO; + fTr.ChiSq() += zeta0 * zeta0 * S00 + 2.f * zeta0 * zeta1 * S10 + zeta1 * zeta1 * S11; + fTr.Ndf() += TWO; K00 = F00 * S00 + F01 * S10; K01 = F00 * S10 + F01 * S11; @@ -263,48 +261,48 @@ void L1Fit::FilterXY(const L1XYMeasurementInfo& info, cnst& x, cnst& y) K60 = F60 * S00 + F61 * S10; K61 = F60 * S10 + F61 * S11; - fTr.x -= K00 * zeta0 + K01 * zeta1; - fTr.y -= K10 * zeta0 + K11 * zeta1; - fTr.tx -= K20 * zeta0 + K21 * zeta1; - fTr.ty -= K30 * zeta0 + K31 * zeta1; - fTr.qp -= K40 * zeta0 + K41 * zeta1; - fTr.t -= K50 * zeta0 + K51 * zeta1; - fTr.vi -= K60 * zeta0 + K61 * zeta1; - - fTr.C00 -= K00 * F00 + K01 * F01; - - fTr.C10 -= K10 * F00 + K11 * F01; - fTr.C11 -= K10 * F10 + K11 * F11; - - fTr.C20 -= K20 * F00 + K21 * F01; - fTr.C21 -= K20 * F10 + K21 * F11; - fTr.C22 -= K20 * F20 + K21 * F21; - - fTr.C30 -= K30 * F00 + K31 * F01; - fTr.C31 -= K30 * F10 + K31 * F11; - fTr.C32 -= K30 * F20 + K31 * F21; - fTr.C33 -= K30 * F30 + K31 * F31; - - fTr.C40 -= K40 * F00 + K41 * F01; - fTr.C41 -= K40 * F10 + K41 * F11; - fTr.C42 -= K40 * F20 + K41 * F21; - fTr.C43 -= K40 * F30 + K41 * F31; - fTr.C44 -= K40 * F40 + K41 * F41; - - fTr.C50 -= K50 * F00 + K51 * F01; - fTr.C51 -= K50 * F10 + K51 * F11; - fTr.C52 -= K50 * F20 + K51 * F21; - fTr.C53 -= K50 * F30 + K51 * F31; - fTr.C54 -= K50 * F40 + K51 * F41; - fTr.C55 -= K50 * F50 + K51 * F51; - - fTr.C60 -= K60 * F00 + K61 * F01; - fTr.C61 -= K60 * F10 + K61 * F11; - fTr.C62 -= K60 * F20 + K61 * F21; - fTr.C63 -= K60 * F30 + K61 * F31; - fTr.C64 -= K60 * F40 + K61 * F41; - fTr.C65 -= K60 * F50 + K61 * F51; - fTr.C66 -= K60 * F60 + K61 * F61; + fTr.X() -= K00 * zeta0 + K01 * zeta1; + fTr.Y() -= K10 * zeta0 + K11 * zeta1; + fTr.Tx() -= K20 * zeta0 + K21 * zeta1; + fTr.Ty() -= K30 * zeta0 + K31 * zeta1; + fTr.Qp() -= K40 * zeta0 + K41 * zeta1; + fTr.Time() -= K50 * zeta0 + K51 * zeta1; + fTr.Vi() -= K60 * zeta0 + K61 * zeta1; + + fTr.C00() -= K00 * F00 + K01 * F01; + + fTr.C10() -= K10 * F00 + K11 * F01; + fTr.C11() -= K10 * F10 + K11 * F11; + + fTr.C20() -= K20 * F00 + K21 * F01; + fTr.C21() -= K20 * F10 + K21 * F11; + fTr.C22() -= K20 * F20 + K21 * F21; + + fTr.C30() -= K30 * F00 + K31 * F01; + fTr.C31() -= K30 * F10 + K31 * F11; + fTr.C32() -= K30 * F20 + K31 * F21; + fTr.C33() -= K30 * F30 + K31 * F31; + + fTr.C40() -= K40 * F00 + K41 * F01; + fTr.C41() -= K40 * F10 + K41 * F11; + fTr.C42() -= K40 * F20 + K41 * F21; + fTr.C43() -= K40 * F30 + K41 * F31; + fTr.C44() -= K40 * F40 + K41 * F41; + + fTr.C50() -= K50 * F00 + K51 * F01; + fTr.C51() -= K50 * F10 + K51 * F11; + fTr.C52() -= K50 * F20 + K51 * F21; + fTr.C53() -= K50 * F30 + K51 * F31; + fTr.C54() -= K50 * F40 + K51 * F41; + fTr.C55() -= K50 * F50 + K51 * F51; + + fTr.C60() -= K60 * F00 + K61 * F01; + fTr.C61() -= K60 * F10 + K61 * F11; + fTr.C62() -= K60 * F20 + K61 * F21; + fTr.C63() -= K60 * F30 + K61 * F31; + fTr.C64() -= K60 * F40 + K61 * F41; + fTr.C65() -= K60 * F50 + K61 * F51; + fTr.C66() -= K60 * F60 + K61 * F61; } void L1Fit::FilterHit(const L1Station& sta, const L1Hit& hit) @@ -320,16 +318,16 @@ void L1Fit::FilterHit(const L1Station& sta, const L1Hit& hit) void L1Fit::FilterExtrapolatedXY(cnst& x, cnst& y, const L1XYMeasurementInfo& info, cnst& extrX, cnst& extrY, cnst Jx[6], cnst Jy[6]) { - // add a 2-D measurenent (x,y) at some z, that differs from fTr.z + // 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 // ! it is assumed that in the track covariance matrix all non-diagonal covariances are 0 // ! except of C10 - L1TrackPar& T = fTr; + TrackParamV& T = fTr; - //zeta0 = T.x + Jx[2]*T.tx + Jx[3]*T.ty + Jx[4]*T.qp - x; - //zeta1 = T.y + Jy[2]*T.tx + Jy[3]*T.ty + Jy[4]*T.qp - y; + //zeta0 = T.x + Jx[2]*T.Tx() + Jx[3]*T.Ty() + Jx[4]*T.qp - x; + //zeta1 = T.y + Jy[2]*T.Tx() + Jy[3]*T.Ty() + Jy[4]*T.qp - y; fvec zeta0 = extrX - x; fvec zeta1 = extrY - y; @@ -338,16 +336,16 @@ void L1Fit::FilterExtrapolatedXY(cnst& x, cnst& y, const L1XYMeasurementInfo& in // 0 1 Jy[2] Jy[3] Jy[4] 0 // F = CH' - fvec F00 = T.C00; - fvec F01 = T.C10; - fvec F10 = T.C10; - fvec F11 = T.C11; - fvec F20 = Jx[2] * T.C22; - fvec F21 = Jy[2] * T.C22; - fvec F30 = Jx[3] * T.C33; - fvec F31 = Jy[3] * T.C33; - fvec F40 = Jx[4] * T.C44; - fvec F41 = Jy[4] * T.C44; + fvec F00 = T.C00(); + fvec F01 = T.C10(); + fvec F10 = T.C10(); + fvec F11 = T.C11(); + fvec F20 = Jx[2] * T.C22(); + fvec F21 = Jy[2] * T.C22(); + fvec F30 = Jx[3] * T.C33(); + fvec F31 = Jy[3] * T.C33(); + fvec F40 = Jx[4] * T.C44(); + fvec F41 = Jy[4] * T.C44(); fvec S00 = info.C00 + F00 + Jx[2] * F20 + Jx[3] * F30 + Jx[4] * F40; fvec S10 = info.C10 + F10 + Jy[2] * F20 + Jy[3] * F30 + Jy[4] * F40; @@ -360,8 +358,8 @@ void L1Fit::FilterExtrapolatedXY(cnst& x, cnst& y, const L1XYMeasurementInfo& in S10 = -si * S10; S11 = si * S00tmp; - T.chi2 += zeta0 * zeta0 * S00 + fvec(2.) * zeta0 * zeta1 * S10 + zeta1 * zeta1 * S11; - T.NDF += fvec(2.); + T.ChiSq() += zeta0 * zeta0 * S00 + fvec(2.) * zeta0 * zeta1 * S10 + zeta1 * zeta1 * S11; + T.Ndf() += fvec(2.); fvec K00 = F00 * S00 + F01 * S10; fvec K01 = F00 * S10 + F01 * S11; @@ -374,27 +372,27 @@ void L1Fit::FilterExtrapolatedXY(cnst& x, cnst& y, const L1XYMeasurementInfo& in fvec K40 = F40 * S00 + F41 * S10; fvec K41 = F40 * S10 + F41 * S11; - T.x -= K00 * zeta0 + K01 * zeta1; - T.y -= K10 * zeta0 + K11 * zeta1; - T.tx -= K20 * zeta0 + K21 * zeta1; - T.ty -= K30 * zeta0 + K31 * zeta1; - T.qp -= K40 * zeta0 + K41 * zeta1; - - T.C00 -= (K00 * F00 + K01 * F01); - T.C10 -= (K10 * F00 + K11 * F01); - T.C11 -= (K10 * F10 + K11 * F11); - T.C20 = -(K20 * F00 + K21 * F01); - T.C21 = -(K20 * F10 + K21 * F11); - T.C22 -= (K20 * F20 + K21 * F21); - T.C30 = -(K30 * F00 + K31 * F01); - T.C31 = -(K30 * F10 + K31 * F11); - T.C32 = -(K30 * F20 + K31 * F21); - T.C33 -= (K30 * F30 + K31 * F31); - T.C40 = -(K40 * F00 + K41 * F01); - T.C41 = -(K40 * F10 + K41 * F11); - T.C42 = -(K40 * F20 + K41 * F21); - T.C43 = -(K40 * F30 + K41 * F31); - T.C44 -= (K40 * F40 + K41 * F41); + T.X() -= K00 * zeta0 + K01 * zeta1; + T.Y() -= K10 * zeta0 + K11 * zeta1; + T.Tx() -= K20 * zeta0 + K21 * zeta1; + T.Ty() -= K30 * zeta0 + K31 * zeta1; + T.Qp() -= K40 * zeta0 + K41 * zeta1; + + T.C00() -= (K00 * F00 + K01 * F01); + T.C10() -= (K10 * F00 + K11 * F01); + T.C11() -= (K10 * F10 + K11 * F11); + T.C20() = -(K20 * F00 + K21 * F01); + T.C21() = -(K20 * F10 + K21 * F11); + T.C22() -= (K20 * F20 + K21 * F21); + T.C30() = -(K30 * F00 + K31 * F01); + T.C31() = -(K30 * F10 + K31 * F11); + T.C32() = -(K30 * F20 + K31 * F21); + T.C33() -= (K30 * F30 + K31 * F31); + T.C40() = -(K40 * F00 + K41 * F01); + T.C41() = -(K40 * F10 + K41 * F11); + T.C42() = -(K40 * F20 + K41 * F21); + T.C43() = -(K40 * F30 + K41 * F31); + T.C44() -= (K40 * F40 + K41 * F41); } @@ -403,7 +401,7 @@ void L1Fit::MeasureVelocityWithQp() // measure velocity using measured qp // assuming particle mass == fMass; - cnst kClightNsInv = fvec(L1TrackPar::kClightNsInv); + cnst kClightNsInv = fvec(constants::phys::SpeedOfLightInv); fvec zeta, HCH; fvec F0, F1, F2, F3, F4, F5, F6; @@ -416,28 +414,28 @@ void L1Fit::MeasureVelocityWithQp() fvec h = fMass2 * fQp0 / sqrt(fvec(1.) + fMass2 * fQp0 * fQp0) * kClightNsInv; - zeta = vi0 + h * (fTr.qp - fQp0) - fTr.vi; + zeta = vi0 + h * (fTr.Qp() - fQp0) - fTr.Vi(); - fTr.vi = vi0; + fTr.Vi() = vi0; // H = (0,0,0,0, h,0, -1) // F = CH' - F0 = h * fTr.C40 - fTr.C60; - F1 = h * fTr.C41 - fTr.C61; - F2 = h * fTr.C42 - fTr.C62; - F3 = h * fTr.C43 - fTr.C63; - F4 = h * fTr.C44 - fTr.C64; - F5 = h * fTr.C54 - fTr.C65; - F6 = h * fTr.C64 - fTr.C66; + F0 = h * fTr.C40() - fTr.C60(); + F1 = h * fTr.C41() - fTr.C61(); + F2 = h * fTr.C42() - fTr.C62(); + F3 = h * fTr.C43() - fTr.C63(); + F4 = h * fTr.C44() - fTr.C64(); + F5 = h * fTr.C54() - fTr.C65(); + F6 = h * fTr.C64() - fTr.C66(); HCH = F4 * h - F6; fvec wi = fMaskF / HCH; fvec zetawi = fMaskF * zeta / HCH; - fTr.chi2 += zeta * zeta * wi; - fTr.NDF += fMaskF; + fTr.ChiSqTime() += zeta * zeta * wi; + fTr.NdfTime() += fMaskF; K1 = F1 * wi; K2 = F2 * wi; @@ -446,50 +444,50 @@ void L1Fit::MeasureVelocityWithQp() K5 = F5 * wi; K6 = F6 * wi; - fTr.x -= F0 * zetawi; - fTr.y -= F1 * zetawi; - fTr.tx -= F2 * zetawi; - fTr.ty -= F3 * zetawi; - fTr.qp -= F4 * zetawi; - fTr.t -= F5 * zetawi; - fTr.vi -= F6 * zetawi; - - fTr.C00 -= F0 * F0 * wi; - - fTr.C10 -= K1 * F0; - fTr.C11 -= K1 * F1; - - fTr.C20 -= K2 * F0; - fTr.C21 -= K2 * F1; - fTr.C22 -= K2 * F2; - - fTr.C30 -= K3 * F0; - fTr.C31 -= K3 * F1; - fTr.C32 -= K3 * F2; - fTr.C33 -= K3 * F3; - - fTr.C40 -= K4 * F0; - fTr.C41 -= K4 * F1; - fTr.C42 -= K4 * F2; - fTr.C43 -= K4 * F3; - fTr.C44 -= K4 * F4; - - fTr.C50 -= K5 * F0; - fTr.C51 -= K5 * F1; - fTr.C52 -= K5 * F2; - fTr.C53 -= K5 * F3; - fTr.C54 -= K5 * F4; - fTr.C55 -= K5 * F5; - - fTr.C60 -= K6 * F0; - fTr.C61 -= K6 * F1; - fTr.C62 -= K6 * F2; - fTr.C63 -= K6 * F3; - fTr.C64 -= K6 * F4; - fTr.C65 -= K6 * F5; - fTr.C66 -= K6 * F6; - - // fTr.vi( fTr.vi < fvec(L1TrackPar::kClightNsInv) ) = fvec(L1TrackPar::kClightNsInv); + fTr.X() -= F0 * zetawi; + fTr.Y() -= F1 * zetawi; + fTr.Tx() -= F2 * zetawi; + fTr.Ty() -= F3 * zetawi; + fTr.Qp() -= F4 * zetawi; + fTr.Time() -= F5 * zetawi; + fTr.Vi() -= F6 * zetawi; + + fTr.C00() -= F0 * F0 * wi; + + fTr.C10() -= K1 * F0; + fTr.C11() -= K1 * F1; + + fTr.C20() -= K2 * F0; + fTr.C21() -= K2 * F1; + fTr.C22() -= K2 * F2; + + fTr.C30() -= K3 * F0; + fTr.C31() -= K3 * F1; + fTr.C32() -= K3 * F2; + fTr.C33() -= K3 * F3; + + fTr.C40() -= K4 * F0; + fTr.C41() -= K4 * F1; + fTr.C42() -= K4 * F2; + fTr.C43() -= K4 * F3; + fTr.C44() -= K4 * F4; + + fTr.C50() -= K5 * F0; + fTr.C51() -= K5 * F1; + fTr.C52() -= K5 * F2; + fTr.C53() -= K5 * F3; + fTr.C54() -= K5 * F4; + fTr.C55() -= K5 * F5; + + fTr.C60() -= K6 * F0; + fTr.C61() -= K6 * F1; + fTr.C62() -= K6 * F2; + fTr.C63() -= K6 * F3; + fTr.C64() -= K6 * F4; + fTr.C65() -= K6 * F5; + fTr.C66() -= K6 * F6; + + // fTr.Vi()( fTr.Vi() < fvec(TrackParamV::kClightNsInv) ) = fvec(TrackParamV::kClightNsInv); } void L1Fit::FilterVi(fvec vi) @@ -500,26 +498,26 @@ void L1Fit::FilterVi(fvec vi) fvec F0, F1, F2, F3, F4, F5, F6; fvec K1, K2, K3, K4, K5, K6; - zeta = fTr.vi - vi; + zeta = fTr.Vi() - vi; // H = (0,0,0,0, 0, 0, 1) // F = CH' - F0 = fTr.C60; - F1 = fTr.C61; - F2 = fTr.C62; - F3 = fTr.C63; - F4 = fTr.C64; - F5 = fTr.C65; - F6 = fTr.C66; + F0 = fTr.C60(); + F1 = fTr.C61(); + F2 = fTr.C62(); + F3 = fTr.C63(); + F4 = fTr.C64(); + F5 = fTr.C65(); + F6 = fTr.C66(); HCH = F6; fvec wi = fMaskF / HCH; fvec zetawi = fMaskF * zeta / HCH; - fTr.chi2 += zeta * zeta * wi; - fTr.NDF += fMaskF; + fTr.ChiSqTime() += zeta * zeta * wi; + fTr.NdfTime() += fMaskF; K1 = F1 * wi; K2 = F2 * wi; @@ -528,56 +526,56 @@ void L1Fit::FilterVi(fvec vi) K5 = F5 * wi; K6 = F6 * wi; - fTr.x -= F0 * zetawi; - fTr.y -= F1 * zetawi; - fTr.tx -= F2 * zetawi; - fTr.ty -= F3 * zetawi; - fTr.qp -= F4 * zetawi; - fTr.t -= F5 * zetawi; - // fTr.vi -= F6 * zetawi; - fTr.vi = vi; - - fTr.C00 -= F0 * F0 * wi; - - fTr.C10 -= K1 * F0; - fTr.C11 -= K1 * F1; - - fTr.C20 -= K2 * F0; - fTr.C21 -= K2 * F1; - fTr.C22 -= K2 * F2; - - fTr.C30 -= K3 * F0; - fTr.C31 -= K3 * F1; - fTr.C32 -= K3 * F2; - fTr.C33 -= K3 * F3; - - fTr.C40 -= K4 * F0; - fTr.C41 -= K4 * F1; - fTr.C42 -= K4 * F2; - fTr.C43 -= K4 * F3; - fTr.C44 -= K4 * F4; - - fTr.C50 -= K5 * F0; - fTr.C51 -= K5 * F1; - fTr.C52 -= K5 * F2; - fTr.C53 -= K5 * F3; - fTr.C54 -= K5 * F4; - fTr.C55 -= K5 * F5; - - //fTr.C60 -= K6 * F0; - //fTr.C61 -= K6 * F1; - //fTr.C62 -= K6 * F2; - //fTr.C63 -= K6 * F3; - //fTr.C64 -= K6 * F4; - //fTr.C65 -= K6 * F5; - //fTr.C66 -= K6 * F6; - fTr.C60 = fvec(0.); - fTr.C61 = fvec(0.); - fTr.C62 = fvec(0.); - fTr.C63 = fvec(0.); - fTr.C64 = fvec(0.); - fTr.C65 = fvec(0.); - fTr.C66 = fvec(1.e-8); // just for a case.. + fTr.X() -= F0 * zetawi; + fTr.Y() -= F1 * zetawi; + fTr.Tx() -= F2 * zetawi; + fTr.Ty() -= F3 * zetawi; + fTr.Qp() -= F4 * zetawi; + fTr.Time() -= F5 * zetawi; + // fTr.Vi() -= F6 * zetawi; + fTr.Vi() = vi; + + fTr.C00() -= F0 * F0 * wi; + + fTr.C10() -= K1 * F0; + fTr.C11() -= K1 * F1; + + fTr.C20() -= K2 * F0; + fTr.C21() -= K2 * F1; + fTr.C22() -= K2 * F2; + + fTr.C30() -= K3 * F0; + fTr.C31() -= K3 * F1; + fTr.C32() -= K3 * F2; + fTr.C33() -= K3 * F3; + + fTr.C40() -= K4 * F0; + fTr.C41() -= K4 * F1; + fTr.C42() -= K4 * F2; + fTr.C43() -= K4 * F3; + fTr.C44() -= K4 * F4; + + fTr.C50() -= K5 * F0; + fTr.C51() -= K5 * F1; + fTr.C52() -= K5 * F2; + fTr.C53() -= K5 * F3; + fTr.C54() -= K5 * F4; + fTr.C55() -= K5 * F5; + + //fTr.C60() -= K6 * F0; + //fTr.C61() -= K6 * F1; + //fTr.C62() -= K6 * F2; + //fTr.C63() -= K6 * F3; + //fTr.C64() -= K6 * F4; + //fTr.C65() -= K6 * F5; + //fTr.C66() -= K6 * F6; + fTr.C60() = fvec(0.); + fTr.C61() = fvec(0.); + fTr.C62() = fvec(0.); + fTr.C63() = fvec(0.); + fTr.C64() = fvec(0.); + fTr.C65() = fvec(0.); + fTr.C66() = fvec(1.e-8); // just for a case.. } void L1Fit::Extrapolate // extrapolates track parameters and returns jacobian for extrapolation of CovMatrix @@ -586,9 +584,9 @@ void L1Fit::Extrapolate // extrapolates track parameters and returns jacobian f { // use Q/p linearisation at fQp0 - fvec sgn = iif(fTr.z < z_out, fvec(1.), fvec(-1.)); - while (!(fMaskF * abs(z_out - fTr.z) <= fvec(1.e-6)).isFull()) { - fvec zNew = fTr.z + sgn * fMaxExtraplationStep; // max. 50 cm step + fvec sgn = iif(fTr.GetZ() < z_out, fvec(1.), fvec(-1.)); + while (!(fMaskF * abs(z_out - fTr.GetZ()) <= fvec(1.e-6)).isFull()) { + fvec zNew = fTr.GetZ() + sgn * fMaxExtraplationStep; // max. 50 cm step zNew(sgn * (z_out - zNew) <= fvec(0.)) = z_out; ExtrapolateStepFull(zNew, F); } @@ -637,19 +635,19 @@ void L1Fit::ExtrapolateStepFull // extrapolates track parameters and returns ja //---------------------------------------------------------------- - cnst zMasked = iif(fMask, zOut, fTr.z); + cnst zMasked = iif(fMask, zOut, fTr.GetZ()); - cnst h = (zMasked - fTr.z); + cnst h = (zMasked - fTr.GetZ()); cnst stepDz[5] = {0., 0., h * fvec(0.5), h * fvec(0.5), h}; fvec f[5][7] = {{0.}}; // ( d*/dz ) [step] - fvec F[5][7][7] = {{0.}}; // ( d *new [step] / d *old ) + fvec F[5][7][7] = {{{0.}}}; // ( d *new [step] / d *old ) // Runge-Kutta steps // - fvec r0[7] = {fTr.x, fTr.y, fTr.tx, fTr.ty, fQp0, fTr.t, fTr.vi}; + fvec r0[7] = {fTr.X(), fTr.Y(), fTr.Tx(), fTr.Ty(), fQp0, fTr.Time(), fTr.Vi()}; fvec R0[7][7] = {{0.}}; for (int i = 0; i < 7; ++i) { R0[i][i] = 1.; @@ -661,7 +659,7 @@ void L1Fit::ExtrapolateStepFull // extrapolates track parameters and returns ja for (int i = 0; i < 7; ++i) { rstep[i] = r0[i] + stepDz[step] * f[step - 1][i]; } - fvec z = fTr.z + stepDz[step]; + fvec z = fTr.GetZ() + stepDz[step]; fvec B[3]; cnst& Bx = B[0]; @@ -711,11 +709,12 @@ void L1Fit::ExtrapolateStepFull // extrapolates track parameters and returns ja F[step][5][6] = L; } else { - fvec vi = sqrt(fvec(1.) + fMass2 * fQp0 * fQp0) * fvec(L1TrackPar::kClightNsInv); + fvec vi = sqrt(fvec(1.) + fMass2 * fQp0 * fQp0) * fvec(constants::phys::SpeedOfLightInv); 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(fvec(1.) + fMass2 * fQp0 * fQp0) * fvec(L1TrackPar::kClightNsInv); + F[step][5][4] = + fMass2 * fQp0 * L / sqrt(fvec(1.) + fMass2 * fQp0 * fQp0) * fvec(constants::phys::SpeedOfLightInv); F[step][5][5] = 0.; F[step][5][6] = 0.; } @@ -738,7 +737,7 @@ void L1Fit::ExtrapolateStepFull // extrapolates track parameters and returns ja } } - fvec dqp = fTr.qp - fQp0; + fvec dqp = fTr.Qp() - fQp0; for (int i = 0; i < 7; i++) { r[i] = r0[i]; @@ -751,16 +750,16 @@ void L1Fit::ExtrapolateStepFull // extrapolates track parameters and returns ja // update parameters - fTr.x = r[0]; - fTr.y = r[1]; - fTr.tx = r[2]; - fTr.ty = r[3]; - fTr.qp = r[4]; - fTr.t = r[5]; - fTr.vi = r[6]; + fTr.X() = r[0]; + fTr.Y() = r[1]; + fTr.Tx() = r[2]; + fTr.Ty() = r[3]; + fTr.Qp() = r[4]; + fTr.Time() = r[5]; + fTr.Vi() = r[6]; - //fTr.vi( fTr.vi < fvec(L1TrackPar::kClightNsInv) ) = fvec(L1TrackPar::kClightNsInv); - fTr.z = zMasked; + //fTr.Vi()( fTr.Vi() < fvec(TrackParamV::kClightNsInv) ) = fvec(TrackParamV::kClightNsInv); + fTr.Z() = zMasked; // covariance matrix transport @@ -832,10 +831,10 @@ void L1Fit::ExtrapolateStep // extrapolates track parameters and returns jacobi //---------------------------------------------------------------- - cnst zMasked = iif(fMask, zOut, fTr.z); + cnst zMasked = iif(fMask, zOut, fTr.GetZ()); - fvec qp_in = fTr.qp; - cnst h = (zMasked - fTr.z); + fvec qp_in = fTr.Qp(); + cnst h = (zMasked - fTr.GetZ()); cnst a[4] = {0., h * fvec(0.5), h * fvec(0.5), h}; cnst c[4] = {h / fvec(6.), h / fvec(3.), h / fvec(3.), h / fvec(6.)}; @@ -850,15 +849,15 @@ void L1Fit::ExtrapolateStep // extrapolates track parameters and returns jacobi fvec f2_ty[4], f3_ty[4], f4_ty[4]; // df* / dty fvec f2_qp[4], f3_qp[4], f4_qp[4]; // df* / dqp - fvec k[5][5] = {0., 0., 0., 0., 0.}; + fvec k[5][5] = {{0.}}; // Runge-Kutta steps for track parameters // { - fvec r0[5] = {fTr.x, fTr.y, fTr.tx, fTr.ty, fTr.t}; + fvec r0[5] = {fTr.X(), fTr.Y(), fTr.Tx(), fTr.Ty(), fTr.Time()}; for (int step = 0; step < 4; ++step) { - fvec z = fTr.z + a[step]; + fvec z = fTr.GetZ() + a[step]; fvec r[5]; for (int i = 0; i < 5; ++i) { if (step == 0) { r[i] = r0[i]; } @@ -914,12 +913,12 @@ void L1Fit::ExtrapolateStep // extrapolates track parameters and returns jacobi k[step + 1][4] = f4[step]; } // end of Runge-Kutta step - fTr.x = r0[0] + (c[0] * k[1][0] + c[1] * k[2][0] + c[2] * k[3][0] + c[3] * k[4][0]); - fTr.y = r0[1] + (c[0] * k[1][1] + c[1] * k[2][1] + c[2] * k[3][1] + c[3] * k[4][1]); - fTr.tx = r0[2] + (c[0] * k[1][2] + c[1] * k[2][2] + c[2] * k[3][2] + c[3] * k[4][2]); - fTr.ty = r0[3] + (c[0] * k[1][3] + c[1] * k[2][3] + c[2] * k[3][3] + c[3] * k[4][3]); - fTr.t = r0[4] + (c[0] * k[1][4] + c[1] * k[2][4] + c[2] * k[3][4] + c[3] * k[4][4]); - fTr.z = zMasked; + fTr.X() = r0[0] + (c[0] * k[1][0] + c[1] * k[2][0] + c[2] * k[3][0] + c[3] * k[4][0]); + fTr.Y() = r0[1] + (c[0] * k[1][1] + c[1] * k[2][1] + c[2] * k[3][1] + c[3] * k[4][1]); + fTr.Tx() = r0[2] + (c[0] * k[1][2] + c[1] * k[2][2] + c[2] * k[3][2] + c[3] * k[4][2]); + fTr.Ty() = r0[3] + (c[0] * k[1][3] + c[1] * k[2][3] + c[2] * k[3][3] + c[3] * k[4][3]); + fTr.Time() = r0[4] + (c[0] * k[1][4] + c[1] * k[2][4] + c[2] * k[3][4] + c[3] * k[4][4]); + fTr.Z() = zMasked; } @@ -996,11 +995,11 @@ void L1Fit::ExtrapolateStep // extrapolates track parameters and returns jacobi { // update parameters fvec dqp = qp_in - fQp0; - fTr.x += Jqp[0] * dqp; - fTr.y += Jqp[1] * dqp; - fTr.tx += Jqp[2] * dqp; - fTr.ty += Jqp[3] * dqp; - fTr.t += Jqp[4] * dqp; + fTr.X() += Jqp[0] * dqp; + fTr.Y() += Jqp[1] * dqp; + fTr.Tx() += Jqp[2] * dqp; + fTr.Ty() += Jqp[3] * dqp; + fTr.Time() += Jqp[4] * dqp; } // covariance matrix transport @@ -1060,74 +1059,74 @@ void L1Fit::ExtrapolateStep // extrapolates track parameters and returns jacobi } else { // unrolled calculations, taking into account that some derivatives are 0 or 1 - fvec JC00 = Jtx[0] * fTr.C20 + Jty[0] * fTr.C30 + Jqp[0] * fTr.C40 + fTr.C00; - //fvec JC01 = Jtx[0] * fTr.C21 + Jty[0] * fTr.C31 + Jqp[0] * fTr.C41 + fTr.C10; - fvec JC02 = Jtx[0] * fTr.C22 + Jty[0] * fTr.C32 + Jqp[0] * fTr.C42 + fTr.C20; - fvec JC03 = Jtx[0] * fTr.C32 + Jty[0] * fTr.C33 + Jqp[0] * fTr.C43 + fTr.C30; - fvec JC04 = Jtx[0] * fTr.C42 + Jty[0] * fTr.C43 + Jqp[0] * fTr.C44 + fTr.C40; - //fvec JC05 = Jtx[0] * fTr.C52 + Jty[0] * fTr.C53 + Jqp[0] * fTr.C54 + fTr.C50; - - fvec JC10 = Jtx[1] * fTr.C20 + Jty[1] * fTr.C30 + Jqp[1] * fTr.C40 + fTr.C10; - fvec JC11 = Jtx[1] * fTr.C21 + Jty[1] * fTr.C31 + Jqp[1] * fTr.C41 + fTr.C11; - fvec JC12 = Jtx[1] * fTr.C22 + Jty[1] * fTr.C32 + Jqp[1] * fTr.C42 + fTr.C21; - fvec JC13 = Jtx[1] * fTr.C32 + Jty[1] * fTr.C33 + Jqp[1] * fTr.C43 + fTr.C31; - fvec JC14 = Jtx[1] * fTr.C42 + Jty[1] * fTr.C43 + Jqp[1] * fTr.C44 + fTr.C41; - //fvec JC15 = Jtx[1] * fTr.C52 + Jty[1] * fTr.C53 + Jqp[1] * fTr.C54 + fTr.C51; - - fvec JC20 = Jtx[2] * fTr.C20 + Jty[2] * fTr.C30 + Jqp[2] * fTr.C40; - fvec JC21 = Jtx[2] * fTr.C21 + Jty[2] * fTr.C31 + Jqp[2] * fTr.C41; - fvec JC22 = Jtx[2] * fTr.C22 + Jty[2] * fTr.C32 + Jqp[2] * fTr.C42; - fvec JC23 = Jtx[2] * fTr.C32 + Jty[2] * fTr.C33 + Jqp[2] * fTr.C43; - fvec JC24 = Jtx[2] * fTr.C42 + Jty[2] * fTr.C43 + Jqp[2] * fTr.C44; - //fvec JC25 = Jtx[2] * fTr.C52 + Jty[2] * fTr.C53 + Jqp[2] * fTr.C54; - - fvec JC30 = Jtx[3] * fTr.C20 + Jty[3] * fTr.C30 + Jqp[3] * fTr.C40; - fvec JC31 = Jtx[3] * fTr.C21 + Jty[3] * fTr.C31 + Jqp[3] * fTr.C41; - fvec JC32 = Jtx[3] * fTr.C22 + Jty[3] * fTr.C32 + Jqp[3] * fTr.C42; - fvec JC33 = Jtx[3] * fTr.C32 + Jty[3] * fTr.C33 + Jqp[3] * fTr.C43; - fvec JC34 = Jtx[3] * fTr.C42 + Jty[3] * fTr.C43 + Jqp[3] * fTr.C44; - //fvec JC35 = Jtx[3] * fTr.C52 + Jty[3] * fTr.C53 + Jqp[3] * fTr.C54; - - fvec JC40 = fTr.C40; - fvec JC41 = fTr.C41; - fvec JC42 = fTr.C42; - fvec JC43 = fTr.C43; - fvec JC44 = fTr.C44; - //fvec JC45 = fTr.C54; - - fvec JC50 = Jtx[4] * fTr.C20 + Jty[4] * fTr.C30 + Jqp[4] * fTr.C40 + fTr.C50; - fvec JC51 = Jtx[4] * fTr.C21 + Jty[4] * fTr.C31 + Jqp[4] * fTr.C41 + fTr.C51; - fvec JC52 = Jtx[4] * fTr.C22 + Jty[4] * fTr.C32 + Jqp[4] * fTr.C42 + fTr.C52; - fvec JC53 = Jtx[4] * fTr.C32 + Jty[4] * fTr.C33 + Jqp[4] * fTr.C43 + fTr.C53; - fvec JC54 = Jtx[4] * fTr.C42 + Jty[4] * fTr.C43 + Jqp[4] * fTr.C44 + fTr.C54; - fvec JC55 = Jtx[4] * fTr.C52 + Jty[4] * fTr.C53 + Jqp[4] * fTr.C54 + fTr.C55; - - fTr.C00 = JC02 * Jtx[0] + JC03 * Jty[0] + JC04 * Jqp[0] + JC00; - - fTr.C10 = JC12 * Jtx[0] + JC13 * Jty[0] + JC14 * Jqp[0] + JC10; - fTr.C11 = JC12 * Jtx[1] + JC13 * Jty[1] + JC14 * Jqp[1] + JC11; - - fTr.C20 = JC22 * Jtx[0] + JC23 * Jty[0] + JC24 * Jqp[0] + JC20; - fTr.C21 = JC22 * Jtx[1] + JC23 * Jty[1] + JC24 * Jqp[1] + JC21; - fTr.C22 = JC22 * Jtx[2] + JC23 * Jty[2] + JC24 * Jqp[2]; - - fTr.C30 = JC32 * Jtx[0] + JC33 * Jty[0] + JC34 * Jqp[0] + JC30; - fTr.C31 = JC32 * Jtx[1] + JC33 * Jty[1] + JC34 * Jqp[1] + JC31; - fTr.C32 = JC32 * Jtx[2] + JC33 * Jty[2] + JC34 * Jqp[2]; - fTr.C33 = JC32 * Jtx[3] + JC33 * Jty[3] + JC34 * Jqp[3]; - - fTr.C40 = JC42 * Jtx[0] + JC43 * Jty[0] + JC44 * Jqp[0] + JC40; - fTr.C41 = JC42 * Jtx[1] + JC43 * Jty[1] + JC44 * Jqp[1] + JC41; - fTr.C42 = JC42 * Jtx[2] + JC43 * Jty[2] + JC44 * Jqp[2]; - fTr.C43 = JC42 * Jtx[3] + JC43 * Jty[3] + JC44 * Jqp[3]; - fTr.C44 = JC44; - - fTr.C50 = JC52 * Jtx[0] + JC53 * Jty[0] + JC54 * Jqp[0] + JC50; - fTr.C51 = JC52 * Jtx[1] + JC53 * Jty[1] + JC54 * Jqp[1] + JC51; - fTr.C52 = JC52 * Jtx[2] + JC53 * Jty[2] + JC54 * Jqp[2]; - fTr.C53 = JC52 * Jtx[3] + JC53 * Jty[3] + JC54 * Jqp[3]; - fTr.C54 = JC54; - fTr.C55 = JC52 * Jtx[4] + JC53 * Jty[4] + JC54 * Jqp[4] + JC55; + fvec JC00 = Jtx[0] * fTr.C20() + Jty[0] * fTr.C30() + Jqp[0] * fTr.C40() + fTr.C00(); + //fvec JC01 = Jtx[0] * fTr.C21() + Jty[0] * fTr.C31() + Jqp[0] * fTr.C41() + fTr.C10(); + fvec JC02 = Jtx[0] * fTr.C22() + Jty[0] * fTr.C32() + Jqp[0] * fTr.C42() + fTr.C20(); + fvec JC03 = Jtx[0] * fTr.C32() + Jty[0] * fTr.C33() + Jqp[0] * fTr.C43() + fTr.C30(); + fvec JC04 = Jtx[0] * fTr.C42() + Jty[0] * fTr.C43() + Jqp[0] * fTr.C44() + fTr.C40(); + //fvec JC05 = Jtx[0] * fTr.C52() + Jty[0] * fTr.C53() + Jqp[0] * fTr.C54() + fTr.C50(); + + fvec JC10 = Jtx[1] * fTr.C20() + Jty[1] * fTr.C30() + Jqp[1] * fTr.C40() + fTr.C10(); + fvec JC11 = Jtx[1] * fTr.C21() + Jty[1] * fTr.C31() + Jqp[1] * fTr.C41() + fTr.C11(); + fvec JC12 = Jtx[1] * fTr.C22() + Jty[1] * fTr.C32() + Jqp[1] * fTr.C42() + fTr.C21(); + fvec JC13 = Jtx[1] * fTr.C32() + Jty[1] * fTr.C33() + Jqp[1] * fTr.C43() + fTr.C31(); + fvec JC14 = Jtx[1] * fTr.C42() + Jty[1] * fTr.C43() + Jqp[1] * fTr.C44() + fTr.C41(); + //fvec JC15 = Jtx[1] * fTr.C52() + Jty[1] * fTr.C53() + Jqp[1] * fTr.C54() + fTr.C51(); + + fvec JC20 = Jtx[2] * fTr.C20() + Jty[2] * fTr.C30() + Jqp[2] * fTr.C40(); + fvec JC21 = Jtx[2] * fTr.C21() + Jty[2] * fTr.C31() + Jqp[2] * fTr.C41(); + fvec JC22 = Jtx[2] * fTr.C22() + Jty[2] * fTr.C32() + Jqp[2] * fTr.C42(); + fvec JC23 = Jtx[2] * fTr.C32() + Jty[2] * fTr.C33() + Jqp[2] * fTr.C43(); + fvec JC24 = Jtx[2] * fTr.C42() + Jty[2] * fTr.C43() + Jqp[2] * fTr.C44(); + //fvec JC25 = Jtx[2] * fTr.C52() + Jty[2] * fTr.C53() + Jqp[2] * fTr.C54(); + + fvec JC30 = Jtx[3] * fTr.C20() + Jty[3] * fTr.C30() + Jqp[3] * fTr.C40(); + fvec JC31 = Jtx[3] * fTr.C21() + Jty[3] * fTr.C31() + Jqp[3] * fTr.C41(); + fvec JC32 = Jtx[3] * fTr.C22() + Jty[3] * fTr.C32() + Jqp[3] * fTr.C42(); + fvec JC33 = Jtx[3] * fTr.C32() + Jty[3] * fTr.C33() + Jqp[3] * fTr.C43(); + fvec JC34 = Jtx[3] * fTr.C42() + Jty[3] * fTr.C43() + Jqp[3] * fTr.C44(); + //fvec JC35 = Jtx[3] * fTr.C52() + Jty[3] * fTr.C53() + Jqp[3] * fTr.C54(); + + fvec JC40 = fTr.C40(); + fvec JC41 = fTr.C41(); + fvec JC42 = fTr.C42(); + fvec JC43 = fTr.C43(); + fvec JC44 = fTr.C44(); + //fvec JC45 = fTr.C54(); + + fvec JC50 = Jtx[4] * fTr.C20() + Jty[4] * fTr.C30() + Jqp[4] * fTr.C40() + fTr.C50(); + fvec JC51 = Jtx[4] * fTr.C21() + Jty[4] * fTr.C31() + Jqp[4] * fTr.C41() + fTr.C51(); + fvec JC52 = Jtx[4] * fTr.C22() + Jty[4] * fTr.C32() + Jqp[4] * fTr.C42() + fTr.C52(); + fvec JC53 = Jtx[4] * fTr.C32() + Jty[4] * fTr.C33() + Jqp[4] * fTr.C43() + fTr.C53(); + fvec JC54 = Jtx[4] * fTr.C42() + Jty[4] * fTr.C43() + Jqp[4] * fTr.C44() + fTr.C54(); + fvec JC55 = Jtx[4] * fTr.C52() + Jty[4] * fTr.C53() + Jqp[4] * fTr.C54() + fTr.C55(); + + fTr.C00() = JC02 * Jtx[0] + JC03 * Jty[0] + JC04 * Jqp[0] + JC00; + + fTr.C10() = JC12 * Jtx[0] + JC13 * Jty[0] + JC14 * Jqp[0] + JC10; + fTr.C11() = JC12 * Jtx[1] + JC13 * Jty[1] + JC14 * Jqp[1] + JC11; + + fTr.C20() = JC22 * Jtx[0] + JC23 * Jty[0] + JC24 * Jqp[0] + JC20; + fTr.C21() = JC22 * Jtx[1] + JC23 * Jty[1] + JC24 * Jqp[1] + JC21; + fTr.C22() = JC22 * Jtx[2] + JC23 * Jty[2] + JC24 * Jqp[2]; + + fTr.C30() = JC32 * Jtx[0] + JC33 * Jty[0] + JC34 * Jqp[0] + JC30; + fTr.C31() = JC32 * Jtx[1] + JC33 * Jty[1] + JC34 * Jqp[1] + JC31; + fTr.C32() = JC32 * Jtx[2] + JC33 * Jty[2] + JC34 * Jqp[2]; + fTr.C33() = JC32 * Jtx[3] + JC33 * Jty[3] + JC34 * Jqp[3]; + + fTr.C40() = JC42 * Jtx[0] + JC43 * Jty[0] + JC44 * Jqp[0] + JC40; + fTr.C41() = JC42 * Jtx[1] + JC43 * Jty[1] + JC44 * Jqp[1] + JC41; + fTr.C42() = JC42 * Jtx[2] + JC43 * Jty[2] + JC44 * Jqp[2]; + fTr.C43() = JC42 * Jtx[3] + JC43 * Jty[3] + JC44 * Jqp[3]; + fTr.C44() = JC44; + + fTr.C50() = JC52 * Jtx[0] + JC53 * Jty[0] + JC54 * Jqp[0] + JC50; + fTr.C51() = JC52 * Jtx[1] + JC53 * Jty[1] + JC54 * Jqp[1] + JC51; + fTr.C52() = JC52 * Jtx[2] + JC53 * Jty[2] + JC54 * Jqp[2]; + fTr.C53() = JC52 * Jtx[3] + JC53 * Jty[3] + JC54 * Jqp[3]; + fTr.C54() = JC54; + fTr.C55() = JC52 * Jtx[4] + JC53 * Jty[4] + JC54 * Jqp[4] + JC55; } } @@ -1148,8 +1147,8 @@ void cnst c1(1.), c2(2.), c3(3.), c4(4.), c6(6.), c9(9.), c15(15.), c18(18.), c45(45.), c2i(1. / 2.), c3i(1. / 3.), c6i(1. / 6.), c12i(1. / 12.); - cnst qp = fTr.qp; - fvec dz = (z_out - fTr.z); + cnst qp = fTr.Qp(); + fvec dz = (z_out - fTr.GetZ()); dz.setZero(!fMask); @@ -1158,8 +1157,8 @@ void // construct coefficients - cnst x = fTr.tx; - cnst y = fTr.ty; + cnst x = fTr.Tx(); + cnst y = fTr.Ty(); cnst xx = x * x; cnst xy = x * y; cnst yy = y * y; @@ -1194,7 +1193,7 @@ void cnst ht = h * t; // get field integrals - cnst ddz = fTr.z - F.z0; + cnst ddz = fTr.GetZ() - F.z0; cnst Fx0 = F.cx0 + F.cx1 * ddz + F.cx2 * ddz * ddz; cnst Fx1 = (F.cx1 + c2 * F.cx2 * ddz) * dz; cnst Fx2 = F.cx2 * dz2; @@ -1314,11 +1313,11 @@ void cnst ht3SA3 = ht3 * SA3; cnst ht3SB3 = ht3 * SB3; - fTr.x += (x + ht1SA1 + ht2SA2 + ht3SA3) * dz; - fTr.y += (y + ht1SB1 + ht2SB2 + ht3SB3) * dz; - fTr.tx += ht1sA1 + ht2sA2 + ht3sA3; - fTr.ty += ht1sB1 + ht2sB2 + ht3sB3; - fTr.z += dz; + fTr.X() += (x + ht1SA1 + ht2SA2 + ht3SA3) * dz; + fTr.Y() += (y + ht1SB1 + ht2SB2 + ht3SB3) * dz; + fTr.Tx() += ht1sA1 + ht2sA2 + ht3sA3; + fTr.Ty() += ht1sB1 + ht2sB2 + ht3sB3; + fTr.Z() += dz; cnst ctdz = c_light * t * dz; cnst ctdz2 = c_light * t * dz2; @@ -1350,51 +1349,51 @@ void // extrapolate inverse momentum - fTr.x += j04 * dqp; - fTr.y += j14 * dqp; - fTr.tx += j24 * dqp; - fTr.ty += j34 * dqp; + fTr.X() += j04 * dqp; + fTr.Y() += j14 * dqp; + fTr.Tx() += j24 * dqp; + fTr.Ty() += j34 * dqp; // covariance matrix transport - cnst c42 = fTr.C42, c43 = fTr.C43; - - cnst cj00 = fTr.C00 + fTr.C20 * j02 + fTr.C30 * j03 + fTr.C40 * j04; - // cnst cj10 = fTr.C10 + fTr.C21*j02 + fTr.C31*j03 + fTr.C41*j04; - cnst cj20 = fTr.C20 + fTr.C22 * j02 + fTr.C32 * j03 + c42 * j04; - cnst cj30 = fTr.C30 + fTr.C32 * j02 + fTr.C33 * j03 + c43 * j04; - - cnst cj01 = fTr.C10 + fTr.C20 * j12 + fTr.C30 * j13 + fTr.C40 * j14; - cnst cj11 = fTr.C11 + fTr.C21 * j12 + fTr.C31 * j13 + fTr.C41 * j14; - cnst cj21 = fTr.C21 + fTr.C22 * j12 + fTr.C32 * j13 + c42 * j14; - cnst cj31 = fTr.C31 + fTr.C32 * j12 + fTr.C33 * j13 + c43 * j14; - - // cnst cj02 = fTr.C20*j22 + fTr.C30*j23 + fTr.C40*j24; - // cnst cj12 = fTr.C21*j22 + fTr.C31*j23 + fTr.C41*j24; - cnst cj22 = fTr.C22 * j22 + fTr.C32 * j23 + c42 * j24; - cnst cj32 = fTr.C32 * j22 + fTr.C33 * j23 + c43 * j24; - - // cnst cj03 = fTr.C20*j32 + fTr.C30*j33 + fTr.C40*j34; - // cnst cj13 = fTr.C21*j32 + fTr.C31*j33 + fTr.C41*j34; - cnst cj23 = fTr.C22 * j32 + fTr.C32 * j33 + c42 * j34; - cnst cj33 = fTr.C32 * j32 + fTr.C33 * j33 + c43 * j34; - - fTr.C40 += c42 * j02 + c43 * j03 + fTr.C44 * j04; // cj40 - fTr.C41 += c42 * j12 + c43 * j13 + fTr.C44 * j14; // cj41 - fTr.C42 = c42 * j22 + c43 * j23 + fTr.C44 * j24; // cj42 - fTr.C43 = c42 * j32 + c43 * j33 + fTr.C44 * j34; // cj43 - - fTr.C00 = cj00 + j02 * cj20 + j03 * cj30 + j04 * fTr.C40; - fTr.C10 = cj01 + j02 * cj21 + j03 * cj31 + j04 * fTr.C41; - fTr.C11 = cj11 + j12 * cj21 + j13 * cj31 + j14 * fTr.C41; - - fTr.C20 = j22 * cj20 + j23 * cj30 + j24 * fTr.C40; - fTr.C30 = j32 * cj20 + j33 * cj30 + j34 * fTr.C40; - fTr.C21 = j22 * cj21 + j23 * cj31 + j24 * fTr.C41; - fTr.C31 = j32 * cj21 + j33 * cj31 + j34 * fTr.C41; - fTr.C22 = j22 * cj22 + j23 * cj32 + j24 * fTr.C42; - fTr.C32 = j32 * cj22 + j33 * cj32 + j34 * fTr.C42; - fTr.C33 = j32 * cj23 + j33 * cj33 + j34 * fTr.C43; + cnst c42 = fTr.C42(), c43 = fTr.C43(); + + cnst cj00 = fTr.C00() + fTr.C20() * j02 + fTr.C30() * j03 + fTr.C40() * j04; + // cnst cj10 = fTr.C10() + fTr.C21()*j02 + fTr.C31()*j03 + fTr.C41()*j04; + cnst cj20 = fTr.C20() + fTr.C22() * j02 + fTr.C32() * j03 + c42 * j04; + cnst cj30 = fTr.C30() + fTr.C32() * j02 + fTr.C33() * j03 + c43 * j04; + + cnst cj01 = fTr.C10() + fTr.C20() * j12 + fTr.C30() * j13 + fTr.C40() * j14; + cnst cj11 = fTr.C11() + fTr.C21() * j12 + fTr.C31() * j13 + fTr.C41() * j14; + cnst cj21 = fTr.C21() + fTr.C22() * j12 + fTr.C32() * j13 + c42 * j14; + cnst cj31 = fTr.C31() + fTr.C32() * j12 + fTr.C33() * j13 + c43 * j14; + + // cnst cj02 = fTr.C20()*j22 + fTr.C30()*j23 + fTr.C40()*j24; + // cnst cj12 = fTr.C21()*j22 + fTr.C31()*j23 + fTr.C41()*j24; + cnst cj22 = fTr.C22() * j22 + fTr.C32() * j23 + c42 * j24; + cnst cj32 = fTr.C32() * j22 + fTr.C33() * j23 + c43 * j24; + + // cnst cj03 = fTr.C20()*j32 + fTr.C30()*j33 + fTr.C40()*j34; + // cnst cj13 = fTr.C21()*j32 + fTr.C31()*j33 + fTr.C41()*j34; + cnst cj23 = fTr.C22() * j32 + fTr.C32() * j33 + c42 * j34; + cnst cj33 = fTr.C32() * j32 + fTr.C33() * j33 + c43 * j34; + + fTr.C40() += c42 * j02 + c43 * j03 + fTr.C44() * j04; // cj40 + fTr.C41() += c42 * j12 + c43 * j13 + fTr.C44() * j14; // cj41 + fTr.C42() = c42 * j22 + c43 * j23 + fTr.C44() * j24; // cj42 + fTr.C43() = c42 * j32 + c43 * j33 + fTr.C44() * j34; // cj43 + + fTr.C00() = cj00 + j02 * cj20 + j03 * cj30 + j04 * fTr.C40(); + fTr.C10() = cj01 + j02 * cj21 + j03 * cj31 + j04 * fTr.C41(); + fTr.C11() = cj11 + j12 * cj21 + j13 * cj31 + j14 * fTr.C41(); + + fTr.C20() = j22 * cj20 + j23 * cj30 + j24 * fTr.C40(); + fTr.C30() = j32 * cj20 + j33 * cj30 + j34 * fTr.C40(); + fTr.C21() = j22 * cj21 + j23 * cj31 + j24 * fTr.C41(); + fTr.C31() = j32 * cj21 + j33 * cj31 + j34 * fTr.C41(); + fTr.C22() = j22 * cj22 + j23 * cj32 + j24 * fTr.C42(); + fTr.C32() = j32 * cj22 + j33 * cj32 + j34 * fTr.C42(); + fTr.C33() = j32 * cj23 + j33 * cj33 + j34 * fTr.C43(); //cout<<"Extrapolation ok"<<endl; } @@ -1419,52 +1418,52 @@ void L1Fit::ExtrapolateLineNoField(cnst& z_out) // cnst c_light(29.9792458); - fvec dz = (z_out - fTr.z); + fvec dz = (z_out - fTr.GetZ()); dz.setZero(!fMask); - L1TrackPar& T = fTr; + TrackParamV& T = fTr; // extrapolate time - fvec L = sqrt(T.tx * T.tx + T.ty * T.ty + fvec(1.)); - T.t += dz * L / c_light; + fvec L = sqrt(T.Tx() * T.Tx() + T.Ty() * T.Ty() + fvec(1.)); + T.Time() += dz * L / c_light; - cnst k1 = dz * T.tx / (c_light * L); - cnst k2 = dz * T.ty / (c_light * L); + cnst k1 = dz * T.Tx() / (c_light * L); + cnst k2 = dz * T.Ty() / (c_light * L); - fvec c52 = T.C52; - fvec c53 = T.C53; + fvec c52 = T.C52(); + fvec c53 = T.C53(); - T.C50 += k1 * T.C20 + k2 * T.C30; - T.C51 += k1 * T.C21 + k2 * T.C31; - T.C52 += k1 * T.C22 + k2 * T.C32; - T.C53 += k1 * T.C32 + k2 * T.C33; - T.C54 += k1 * T.C42 + k2 * T.C43; - T.C55 += k1 * (T.C52 + c52) + k2 * (T.C53 + c53); + T.C50() += k1 * T.C20() + k2 * T.C30(); + T.C51() += k1 * T.C21() + k2 * T.C31(); + T.C52() += k1 * T.C22() + k2 * T.C32(); + T.C53() += k1 * T.C32() + k2 * T.C33(); + T.C54() += k1 * T.C42() + k2 * T.C43(); + T.C55() += k1 * (T.C52() + c52) + k2 * (T.C53() + c53); // extrapolate trajectory - T.x += T.tx * dz; - T.y += T.ty * dz; - T.z += dz; + T.X() += T.Tx() * dz; + T.Y() += T.Ty() * dz; + T.Z() += dz; - cnst dzC32_in = dz * T.C32; + cnst dzC32_in = dz * T.C32(); - T.C21 += dzC32_in; - T.C10 += dz * (T.C21 + T.C30); + T.C21() += dzC32_in; + T.C10() += dz * (T.C21() + T.C30()); - cnst C20_in = T.C20; + cnst C20_in = T.C20(); - T.C20 += dz * T.C22; - T.C00 += dz * (T.C20 + C20_in); + T.C20() += dz * T.C22(); + T.C00() += dz * (T.C20() + C20_in); - cnst C31_in = T.C31; + cnst C31_in = T.C31(); - T.C31 += dz * T.C33; - T.C11 += dz * (T.C31 + C31_in); - T.C30 += dzC32_in; + T.C31() += dz * T.C33(); + T.C11() += dz * (T.C31() + C31_in); + T.C30() += dzC32_in; - T.C40 += dz * T.C42; - T.C41 += dz * T.C43; + T.C40() += dz * T.C42(); + T.C41() += dz * T.C43(); } @@ -1472,8 +1471,8 @@ void L1Fit::AddMsInMaterial(cnst& radThick) { cnst ONE = 1.; - fvec tx = fTr.tx; - fvec ty = fTr.ty; + fvec tx = fTr.Tx(); + fvec ty = fTr.Ty(); fvec txtx = tx * tx; fvec tyty = ty * ty; fvec txtx1 = txtx + ONE; @@ -1488,17 +1487,17 @@ void L1Fit::AddMsInMaterial(cnst& radThick) //fvec a = ( (ONE+mass2*qp0*qp0t)*radThick*s0*s0 ); fvec a = ((t + fMass2 * fQp0 * qp0t) * radThick * s0 * s0); - fTr.C22(fMask) += txtx1 * a; - fTr.C32(fMask) += tx * ty * a; - fTr.C33(fMask) += (ONE + tyty) * a; + fTr.C22()(fMask) += txtx1 * a; + fTr.C32()(fMask) += tx * ty * a; + fTr.C33()(fMask) += (ONE + tyty) * a; } void L1Fit::AddMsInThickMaterial(cnst& radThick, cnst& thickness, bool fDownstream) { cnst ONE = 1.; - fvec tx = fTr.tx; - fvec ty = fTr.ty; + fvec tx = fTr.Tx(); + fvec ty = fTr.Ty(); fvec txtx = tx * tx; fvec tyty = ty * ty; fvec txtx1 = txtx + ONE; @@ -1518,18 +1517,18 @@ void L1Fit::AddMsInThickMaterial(cnst& radThick, cnst& thickness, bool fDownstre fvec T23 = (thickness * thickness) / fvec(3.0); fvec T2 = thickness / fvec(2.0); - fTr.C00(fMask) += txtx1 * a * T23; - fTr.C10(fMask) += tx * ty * a * T23; - fTr.C20(fMask) += txtx1 * a * D * T2; - fTr.C30(fMask) += tx * ty * a * D * T2; + fTr.C00()(fMask) += txtx1 * a * T23; + fTr.C10()(fMask) += tx * ty * a * T23; + fTr.C20()(fMask) += txtx1 * a * D * T2; + fTr.C30()(fMask) += tx * ty * a * D * T2; - fTr.C11(fMask) += (ONE + tyty) * a * T23; - fTr.C21(fMask) += tx * ty * a * D * T2; - fTr.C31(fMask) += (ONE + tyty) * a * D * T2; + fTr.C11()(fMask) += (ONE + tyty) * a * T23; + fTr.C21()(fMask) += tx * ty * a * D * T2; + fTr.C31()(fMask) += (ONE + tyty) * a * D * T2; - fTr.C22(fMask) += txtx1 * a; - fTr.C32(fMask) += tx * ty * a; - fTr.C33(fMask) += (ONE + tyty) * a; + fTr.C22()(fMask) += txtx1 * a; + fTr.C32()(fMask) += tx * ty * a; + fTr.C33()(fMask) += (ONE + tyty) * a; } @@ -1542,7 +1541,7 @@ void L1Fit::EnergyLossCorrection(cnst& radThick, cnst& upstreamDirection) cnst bethe = ApproximateBetheBloch(p2 / fMass2); - fvec tr = sqrt(fvec(1.f) + fTr.tx * fTr.tx + fTr.ty * fTr.ty); + fvec tr = sqrt(fvec(1.f) + fTr.Tx() * fTr.Tx() + fTr.Ty() * fTr.Ty()); cnst dE = bethe * radThick * tr * 2.33f * 9.34961f; @@ -1554,13 +1553,13 @@ void L1Fit::EnergyLossCorrection(cnst& radThick, cnst& upstreamDirection) corr = iif(ok, corr, fvec::One()); fQp0 *= corr; - fTr.qp *= corr; - fTr.C40 *= corr; - fTr.C41 *= corr; - fTr.C42 *= corr; - fTr.C43 *= corr; - fTr.C44 *= corr * corr; - fTr.C54 *= corr; + fTr.Qp() *= corr; + fTr.C40() *= corr; + fTr.C41() *= corr; + fTr.C42() *= corr; + fTr.C43() *= corr; + fTr.C44() *= corr * corr; + fTr.C54() *= corr; } template<int atomicZ> @@ -1578,7 +1577,7 @@ void L1Fit::EnergyLossCorrection(float atomicA, float rho, float radLen, cnst& r cnst bethe = ApproximateBetheBloch(p2 / fMass2, rho, 0.20, 3.00, i, atomicZ / atomicA); - fvec tr = sqrt(fvec(1.f) + fTr.tx * fTr.tx + fTr.ty * fTr.ty); + fvec tr = sqrt(fvec(1.f) + fTr.Tx() * fTr.Tx() + fTr.Ty() * fTr.Ty()); fvec dE = bethe * radThick * tr * radLen * rho; @@ -1588,7 +1587,7 @@ void L1Fit::EnergyLossCorrection(float atomicA, float rho, float radLen, cnst& r corr = iif(ok, corr, fvec::One()); fQp0 *= corr; - fTr.qp *= corr; + fTr.Qp() *= corr; fvec P(sqrt(p2)); // GeV @@ -1618,12 +1617,12 @@ void L1Fit::EnergyLossCorrection(float atomicA, float rho, float radLen, cnst& r fvec P2 = P * P; fvec SDEDX = (E2 * DEDX2) / (P2 * P2 * P2); - // T.fTr.C40 *= corr; - // T.fTr.C41 *= corr; - // T.fTr.C42 *= corr; - // T.fTr.C43 *= corr; - // T.fTr.C44 *= corr*corr; - fTr.C44 += abs(SDEDX); + // T.fTr.C40() *= corr; + // T.fTr.C41() *= corr; + // T.fTr.C42() *= corr; + // T.fTr.C43() *= corr; + // T.fTr.C44() *= corr*corr; + fTr.C44() += abs(SDEDX); } @@ -1663,9 +1662,9 @@ void L1Fit::GetExtrapolatedXYline(cnst& z, const L1FieldRegion& F, fvec& extrX, cnst c_light(0.000299792458), c1(1.), c2i(0.5), c6i(1. / 6.), c12i(1. / 12.); - cnst& tx = fTr.tx; - cnst& ty = fTr.ty; - fvec dz = z - fTr.z; + cnst tx = fTr.GetTx(); + cnst ty = fTr.GetTy(); + fvec dz = z - fTr.GetZ(); fvec dz2 = dz * dz; fvec dzc6i = dz * c6i; @@ -1684,8 +1683,8 @@ void L1Fit::GetExtrapolatedXYline(cnst& z, const L1FieldRegion& F, fvec& extrX, fvec Sy = F.cy0 * c2i + F.cy1 * dzc6i + F.cy2 * dz2c12i; fvec Sz = F.cz0 * c2i + F.cz1 * dzc6i + F.cz2 * dz2c12i; - extrX = fTr.x + tx * dz; - extrY = fTr.y + ty * dz; + extrX = fTr.GetX() + tx * dz; + extrY = fTr.GetY() + ty * dz; Jx[0] = fvec(1.); Jx[1] = fvec(0.); @@ -1971,17 +1970,17 @@ void L1Fit::GuessTrack(const fvec& trackZ, const fvec hitX[], const fvec hitY[], } { // diagonalization row 1 - fTr.tx = a1 / m11; - a0 -= fTr.tx * m01; + fTr.Tx() = a1 / m11; + a0 -= fTr.Tx() * m01; } { // diagonalization row 0 - fTr.x = a0 / m00; + fTr.X() = a0 / m00; } - fvec txtx1 = fvec(1.) + fTr.tx * fTr.tx; + fvec txtx1 = fvec(1.) + fTr.Tx() * fTr.Tx(); L = L / txtx1; - fvec L1 = L * fTr.tx; + fvec L1 = L * fTr.Tx(); A1 = A1 + A3 * L1; A2 = A2 + (A4 + A4 + A5 * L1) * L1; @@ -1993,14 +1992,14 @@ void L1Fit::GuessTrack(const fvec& trackZ, const fvec hitX[], const fvec hitY[], A2 = A0 * A2 - A1 * A1; b1 = A0 * b1 - A1 * b0; - fTr.ty = b1 / A2; - fTr.y = (b0 - A1 * fTr.ty) / A0; + fTr.Ty() = b1 / A2; + fTr.Y() = (b0 - A1 * fTr.Ty()) / A0; - fTr.qp = -L * c_light_i / sqrt(txtx1 + fTr.ty * fTr.ty); - fTr.t = time; - fTr.z = trackZ; - fTr.vi = L1TrackPar::kClightNsInv; - fQp0 = fTr.qp; + fTr.Qp() = -L * c_light_i / sqrt(txtx1 + fTr.Ty() * fTr.Ty()); + fTr.Time() = time; + fTr.Z() = trackZ; + fTr.Vi() = constants::phys::SpeedOfLightInv; + fQp0 = fTr.Qp(); } diff --git a/reco/L1/L1Algo/L1Fit.h b/reco/L1/L1Algo/L1Fit.h index 91817846a05dbc0a3867e6a4f35e464a75ebaf5e..bdd619edb3735b1a79d2487cafd0b28126de1fd0 100644 --- a/reco/L1/L1Algo/L1Fit.h +++ b/reco/L1/L1Algo/L1Fit.h @@ -11,9 +11,9 @@ #ifndef L1Fit_h #define L1Fit_h +#include "CaTrackParam.h" #include "L1Def.h" #include "L1Field.h" -#include "L1TrackPar.h" #include "L1UMeasurementInfo.h" #include "L1XYMeasurementInfo.h" @@ -29,12 +29,12 @@ class L1Fit { public: L1Fit() = default; - L1Fit(const L1TrackPar& t) { SetTrack(t); } + L1Fit(const TrackParamV& t) { SetTrack(t); } template<typename T> - L1Fit(const T* tr, const T* C) + L1Fit(const TrackParamBase<T>& t) { - SetTrack(tr, C); + SetTrack(t); } void SetMask(const fmask& m) @@ -44,21 +44,15 @@ public: } template<typename T> - void SetTrack(const std::array<T, L1TrackPar::kNparTr>& p, const std::array<T, L1TrackPar::kNparCov>& c) + void SetTrack(const TrackParamBase<T>& t) { - fTr.copyFromArrays(p, c); - fQp0 = fTr.qp; - } - - void SetTrack(const L1TrackPar& t) - { - fTr = t; - fQp0 = fTr.qp; + fTr.Set(t); + fQp0 = fTr.GetQp(); } void SetQp0(cnst& qp0) { fQp0 = qp0; } - L1TrackPar& Tr() { return fTr; } + TrackParamV& Tr() { return fTr; } fvec& Qp0() { return fQp0; } @@ -66,7 +60,7 @@ public: void SetOneEntry(const int i0, const L1Fit& T1, const int i1); - void Print(int i = -1); + std::string ToString(int i = -1); //Fit functionality @@ -99,6 +93,7 @@ public: void FilterVi(fvec vi); + void FilterExtrapolatedXY(cnst& x, cnst& y, const L1XYMeasurementInfo& info, cnst& extrX, cnst& extrY, cnst Jx[6], cnst Jy[6]); @@ -155,7 +150,7 @@ private: fmask fMask {fmask::One()}; // mask of active elements in simd vectors fvec fMaskF {fvec::One()}; // floating point representation of fMask - L1TrackPar fTr {}; + TrackParamV fTr {}; fvec fQp0 {0.}; fvec fMass {0.10565800}; // muon mass @@ -172,7 +167,7 @@ private: // ============================================================================================= -inline void L1Fit::Print(int i) { fTr.Print(i); } +inline std::string L1Fit::ToString(int i) { return fTr.ToString(i); } inline void L1Fit::SetOneEntry(const int i0, const L1Fit& T1, const int i1) @@ -183,22 +178,22 @@ inline void L1Fit::SetOneEntry(const int i0, const L1Fit& T1, const int i1) inline void L1Fit::ExtrapolateXC00Line(cnst& z_out, fvec& x, fvec& C00) const { - cnst dz = (z_out - fTr.z); - x = fTr.x + fTr.tx * dz; - C00 = fTr.C00 + dz * (2 * fTr.C20 + dz * fTr.C22); + cnst dz = (z_out - fTr.GetZ()); + x = fTr.GetX() + fTr.GetTx() * dz; + C00 = fTr.C00() + dz * (2 * fTr.C20() + dz * fTr.C22()); } inline void L1Fit::ExtrapolateYC11Line(cnst& z_out, fvec& y, fvec& C11) const { - cnst dz = (z_out - fTr.z); - y = fTr.y + fTr.ty * dz; - C11 = fTr.C11 + dz * (2 * fTr.C31 + dz * fTr.C33); + cnst dz = (z_out - fTr.GetZ()); + y = fTr.GetY() + fTr.GetTy() * dz; + C11 = fTr.C11() + dz * (2 * fTr.C31() + dz * fTr.C33()); } inline void L1Fit::ExtrapolateC10Line(cnst& z_out, fvec& C10) const { - cnst dz = (z_out - fTr.z); - C10 = fTr.C10 + dz * (fTr.C21 + fTr.C30 + dz * fTr.C32); + cnst dz = (z_out - fTr.GetZ()); + C10 = fTr.C10() + dz * (fTr.C21() + fTr.C30() + dz * fTr.C32()); } #undef cnst diff --git a/reco/L1/L1Algo/L1Grid.h b/reco/L1/L1Algo/L1Grid.h index c8189811d78710e8eab8bc25a2a5ef9074177d37..e232e1a6a41c08ec51b2abf67a25ee359f683fde 100644 --- a/reco/L1/L1Algo/L1Grid.h +++ b/reco/L1/L1Algo/L1Grid.h @@ -28,6 +28,7 @@ namespace using cbm::algo::ca::Vector; // TMP!! } +using namespace cbm::algo::ca; //TODO: remove /** * @class L1Grid diff --git a/reco/L1/L1Algo/L1Hit.h b/reco/L1/L1Algo/L1Hit.h index 5db416e2df7ab4d76de34b7f576d0fff6207b7a9..19c2b2ab8cd9983f8e8c9421bf655107bf441640 100644 --- a/reco/L1/L1Algo/L1Hit.h +++ b/reco/L1/L1Algo/L1Hit.h @@ -14,6 +14,9 @@ #include <boost/serialization/access.hpp> +#include "CaSimd.h" + +using namespace cbm::algo::ca; //TODO: remove using L1HitIndex_t = unsigned int; ///< Index of L1Hit using L1StripIndex_t = unsigned int; ///< Index of the station strip diff --git a/reco/L1/L1Algo/L1HitArea.h b/reco/L1/L1Algo/L1HitArea.h index 64c40229c040158b547093949030d49600c05c4f..b9a94a291fb2c71729b47a363239ba26fdaca308 100644 --- a/reco/L1/L1Algo/L1HitArea.h +++ b/reco/L1/L1Algo/L1HitArea.h @@ -11,6 +11,8 @@ class L1Row; class L1SliceData; +using namespace cbm::algo::ca; //TODO: remove + class L1HitArea { public: L1HitArea(const L1Grid& grid, float x, float y, float dx, float dy); diff --git a/reco/L1/L1Algo/L1HitPoint.h b/reco/L1/L1Algo/L1HitPoint.h index 34083cf55cf4973df8d2bc4147abcfab3e16e738..4fb86e34f073b7592d946ced93d989e1fdab246d 100644 --- a/reco/L1/L1Algo/L1HitPoint.h +++ b/reco/L1/L1Algo/L1HitPoint.h @@ -8,6 +8,8 @@ #include "CaConstants.h" #include "L1Hit.h" +using namespace cbm::algo::ca; //TODO: remove + /// contain strips positions and coordinates of the hit struct L1HitPoint { diff --git a/reco/L1/L1Algo/L1IODataManager.h b/reco/L1/L1Algo/L1IODataManager.h index 7b03dc3ca7daaeeb09355205444c0d0f2c46cb43..3056db2dda6124def93de4c7c1efcf4629ef96f8 100644 --- a/reco/L1/L1Algo/L1IODataManager.h +++ b/reco/L1/L1Algo/L1IODataManager.h @@ -13,6 +13,8 @@ #include "CaConstants.h" #include "L1InputData.h" +using namespace cbm::algo::ca; //TODO: remove + class L1Algo; //class L1OutputData; diff --git a/reco/L1/L1Algo/L1InitManager.h b/reco/L1/L1Algo/L1InitManager.h index efd6382249edc7299c1504440f982f1c63215e24..7fee948313cfe55e7397cb80c4e6130e3a9d7786 100644 --- a/reco/L1/L1Algo/L1InitManager.h +++ b/reco/L1/L1Algo/L1InitManager.h @@ -28,6 +28,8 @@ #include "L1Utils.h" +using namespace cbm::algo::ca; //TODO: remove + class L1ConfigRW; class L1Algo; diff --git a/reco/L1/L1Algo/L1Material.cxx b/reco/L1/L1Algo/L1Material.cxx index 3393490ebb2057771a5b5c747d211710507ffd30..b6cee6fb3522800233a9c90ccb4685d9047917d2 100644 --- a/reco/L1/L1Algo/L1Material.cxx +++ b/reco/L1/L1Algo/L1Material.cxx @@ -17,6 +17,7 @@ * L1Material class * ********************/ +using namespace cbm::algo::ca; //------------------------------------------------------------------------------------------------------------------------------------ // diff --git a/reco/L1/L1Algo/L1Material.h b/reco/L1/L1Algo/L1Material.h index d060c37790214b0460ea2bd322a5ee72e27ec8bc..55433989da73cae3aaefda10fbc6b441a37d48e0 100644 --- a/reco/L1/L1Algo/L1Material.h +++ b/reco/L1/L1Algo/L1Material.h @@ -12,8 +12,8 @@ #include <string> #include <vector> -#include "CaConstants.h" #include "CaSimd.h" +#include "CaUtils.h" using namespace cbm::algo::ca; @@ -76,9 +76,9 @@ public: /// Checks, if the fields are NaN bool IsNaN() const { - using namespace cbm::algo::ca::constants; - return undef::IsUndefined(fNbins) || undef::IsUndefined(fXYmax) || undef::IsUndefined(fFactor) - || undef::IsUndefined(fZref) || undef::IsUndefined(fZmin) || undef::IsUndefined(fZmax); + using namespace cbm::algo::ca; + return utils::IsUndefined(fNbins) || utils::IsUndefined(fXYmax) || utils::IsUndefined(fFactor) + || utils::IsUndefined(fZref) || utils::IsUndefined(fZmin) || utils::IsUndefined(fZmax); } /// Verifies class invariant consistency @@ -105,12 +105,12 @@ public: int GetBin(float x, float y) const; private: - int fNbins = constants::undef::Int; ///< Number of rows (== N columns) in the material budget table - float fXYmax = constants::undef::Float; ///< Size of the station in x and y dimensions [cm] - float fFactor = constants::undef::Float; ///< Factor used in the recalculation of point coordinates to row/column id - float fZref = constants::undef::Float; ///< Reference Z of the collected material [cm] - float fZmin = constants::undef::Float; ///< Minimal Z of the collected material [cm] - float fZmax = constants::undef::Float; ///< Minimal Z of the collected material [cm] + int fNbins = constants::Undef<int>; ///< Number of rows (== N columns) in the material budget table + float fXYmax = constants::Undef<float>; ///< Size of the station in x and y dimensions [cm] + float fFactor = constants::Undef<float>; ///< Factor used in the recalculation of point coordinates to row/column id + float fZref = constants::Undef<float>; ///< Reference Z of the collected material [cm] + float fZmin = constants::Undef<float>; ///< Minimal Z of the collected material [cm] + float fZmax = constants::Undef<float>; ///< Minimal Z of the collected material [cm] std::vector<float> fTable {}; ///< Material budget table /// Serialization function diff --git a/reco/L1/L1Algo/L1MaterialMonitor.cxx b/reco/L1/L1Algo/L1MaterialMonitor.cxx index 11b4f72c94801c540ad3a6bc7fe5fbe79eb90c96..d2591d4226ab38ee774d00a30d860d339a642728 100644 --- a/reco/L1/L1Algo/L1MaterialMonitor.cxx +++ b/reco/L1/L1Algo/L1MaterialMonitor.cxx @@ -49,13 +49,13 @@ void L1MaterialMonitor::EvaluateStatistics() fActiveNbins = 0; fPassiveNbins = 0; - fActiveRadThickMin = constants::undef::Double; - fActiveRadThickMax = constants::undef::Double; - fActiveRadThickMean = constants::undef::Double; + fActiveRadThickMin = constants::Undef<double>; + fActiveRadThickMax = constants::Undef<double>; + fActiveRadThickMean = constants::Undef<double>; - fPassiveRadThickMin = constants::undef::Double; - fPassiveRadThickMax = constants::undef::Double; - fPassiveRadThickMean = constants::undef::Double; + fPassiveRadThickMin = constants::Undef<double>; + fPassiveRadThickMax = constants::Undef<double>; + fPassiveRadThickMean = constants::Undef<double>; if (!fMaterial) { return; } diff --git a/reco/L1/L1Algo/L1MaterialMonitor.h b/reco/L1/L1Algo/L1MaterialMonitor.h index 48d3f5977cced39afc7ac0cd1b8d190e9dac90bc..b4d5a92a18484648ad7fd39668a57a5f0b1e108b 100644 --- a/reco/L1/L1Algo/L1MaterialMonitor.h +++ b/reco/L1/L1Algo/L1MaterialMonitor.h @@ -90,15 +90,15 @@ private: std::vector<char> fActiveBinMap {}; ///< Map of active bins in the material map (bins where hits appear) - int fActiveNbins {constants::undef::Int}; ///< Active material: number of bins - double fActiveRadThickMin {constants::undef::Double}; ///< Active material: minimal thickness - double fActiveRadThickMax {constants::undef::Double}; ///< Active material: maximal thickness - double fActiveRadThickMean {constants::undef::Double}; ///< Active material: average thickness - - int fPassiveNbins {constants::undef::Int}; ///< Passive material: number of bins - double fPassiveRadThickMin {constants::undef::Double}; ///< Passive material: minimal thickness - double fPassiveRadThickMax {constants::undef::Double}; ///< Passive material: maximal thickness - double fPassiveRadThickMean {constants::undef::Double}; ///< Passive material: average thickness + int fActiveNbins {constants::Undef<int>}; ///< Active material: number of bins + double fActiveRadThickMin {constants::Undef<double>}; ///< Active material: minimal thickness + double fActiveRadThickMax {constants::Undef<double>}; ///< Active material: maximal thickness + double fActiveRadThickMean {constants::Undef<double>}; ///< Active material: average thickness + + int fPassiveNbins {constants::Undef<int>}; ///< Passive material: number of bins + double fPassiveRadThickMin {constants::Undef<double>}; ///< Passive material: minimal thickness + double fPassiveRadThickMax {constants::Undef<double>}; ///< Passive material: maximal thickness + double fPassiveRadThickMean {constants::Undef<double>}; ///< Passive material: average thickness unsigned long fNhitsTotal {0}; ///< number of hits in statistics unsigned long fNhitsOutside {0}; ///< number of hits outside the material map diff --git a/reco/L1/L1Algo/L1Station.h b/reco/L1/L1Algo/L1Station.h index 78d0d3b579265cc7c5e3d703b64f84b765930840..58c00f5e8d7363f0d39554381dcb6daffb9cdf38 100644 --- a/reco/L1/L1Algo/L1Station.h +++ b/reco/L1/L1Algo/L1Station.h @@ -21,13 +21,13 @@ public: // TODO: SZh 12.05.2022: Rewrite type into L1DetectorID, change detector indexing scheme // TODO: SZh 12.05.2022: Provide getters to stations - int type = cbm::algo::ca::constants::undef::Int; // ? Detector type? - int timeInfo = cbm::algo::ca::constants::undef::Int; ///< flag: if time information can be used + int type = cbm::algo::ca::constants::Undef<int>; // ? Detector type? + int timeInfo = cbm::algo::ca::constants::Undef<int>; ///< flag: if time information can be used int fieldStatus = - cbm::algo::ca::constants::undef::Int; ///< flag: 1 - station is INSIDE the field, 0 - station is OUTSIDE the field - fvec fZ = cbm::algo::ca::constants::undef::Fscal; ///< z position of station [cm] - fvec Xmax = cbm::algo::ca::constants::undef::Fscal; ///< min radius of the station [cm] - fvec Ymax = cbm::algo::ca::constants::undef::Fscal; ///< max radius of the station [cm] + cbm::algo::ca::constants::Undef<int>; ///< flag: 1 - station is INSIDE the field, 0 - station is OUTSIDE the field + fvec fZ = cbm::algo::ca::constants::Undef<fvec>; ///< z position of station [cm] + fvec Xmax = cbm::algo::ca::constants::Undef<fvec>; ///< min radius of the station [cm] + fvec Ymax = cbm::algo::ca::constants::Undef<fvec>; ///< max radius of the station [cm] L1FieldSlice fieldSlice {}; diff --git a/reco/L1/L1Algo/L1TrackFitter.cxx b/reco/L1/L1Algo/L1TrackFitter.cxx index 85fe2146966047041808eb0cfbf69e0823506fe2..590326afb7551f7e2ba9558341ac4bcd5db17675 100644 --- a/reco/L1/L1Algo/L1TrackFitter.cxx +++ b/reco/L1/L1Algo/L1TrackFitter.cxx @@ -5,9 +5,9 @@ #include <iostream> #include <vector> +#include "CaTrackParam.h" #include "L1Algo.h" #include "L1Fit.h" -#include "L1TrackPar.h" using std::cout; using std::endl; @@ -39,7 +39,7 @@ void L1Algo::L1KFTrackFitter() int nTracks_SIMD = fvec::size(); L1Fit fit; // fit parameters coresponding to the current track - L1TrackPar& tr = fit.Tr(); + TrackParamV& tr = fit.Tr(); fit.SetParticleMass(GetDefaultParticleMass()); fit.SetDoFitVelocity(true); @@ -73,7 +73,6 @@ void L1Algo::L1KFTrackFitter() fvec time_last; fvec wtime_last; fvec dt2_last; - // fvec dt2_lst; /// TODO: Why are there two different variables for the time error on the last station? fvec By[constants::size::MaxNstations]; fmask w[constants::size::MaxNstations]; @@ -138,10 +137,10 @@ void L1Algo::L1KFTrackFitter() w[ista][iVec] = true; if (sta[ista].timeInfo) { w_time[ista][iVec] = true; } - x[ista][iVec] = hit.x; //x_temp[iVec]; - y[ista][iVec] = hit.y; //y_temp[iVec]; - time[ista][iVec] = hit.t; - dt2[ista][iVec] = hit.dt2; + x[ista][iVec] = hit.x; //x_temp[iVec]; + y[ista][iVec] = hit.y; //y_temp[iVec]; + time[ista][iVec] = hit.t; + dt2[ista][iVec] = hit.dt2; if (!sta[ista].timeInfo) { dt2[ista][iVec] = 1.e4; } z[ista][iVec] = hit.z; sta[ista].fieldSlice.GetFieldValue(x[ista], y[ista], fB_temp); @@ -185,13 +184,13 @@ void L1Algo::L1KFTrackFitter() fit.GuessTrack(z_end, x, y, z, time, By, w, w_time, nStations); - if (kGlobal == fTrackingMode || kMcbm == fTrackingMode) { tr.qp = fvec(1. / 1.1); } + if (kGlobal == fTrackingMode || kMcbm == fTrackingMode) { tr.Qp() = fvec(1. / 1.1); } - // tr.qp = iif(isFieldPresent, tr.qp, fvec(1. / 0.25)); + // tr.Qp() = iif(isFieldPresent, tr.Qp(), fvec(1. / 0.25)); for (int iter = 0; iter < 2; iter++) { // 1.5 iterations - fit.SetQp0(tr.qp); + fit.SetQp0(tr.Qp()); // fit backward @@ -201,25 +200,24 @@ void L1Algo::L1KFTrackFitter() dt2_last = iif(w_time[ista], dt2_last, fvec(1.e6)); tr.ResetErrors(cov_xy_lst.C00, cov_xy_lst.C11, 0.1, 0.1, 1.0, dt2_last, 1.e-2); - tr.C10 = cov_xy_lst.C10; - tr.x = x_last; - tr.y = y_last; - tr.t = time_last; - tr.vi = L1TrackPar::kClightNsInv; + tr.C10() = cov_xy_lst.C10; + tr.X() = x_last; + tr.Y() = y_last; + tr.Time() = time_last; + tr.Vi() = constants::phys::SpeedOfLightInv; tr.InitVelocityRange(0.5); - tr.NDF = -3.0; - - tr.nTimeMeasurements = wtime_last; + tr.Ndf() = fvec(-5.) + fvec(2.); + tr.NdfTime() = fvec(-2.) + wtime_last; fldZ1 = z[ista]; - sta[ista].fieldSlice.GetFieldValue(tr.x, tr.y, fldB1); + sta[ista].fieldSlice.GetFieldValue(tr.X(), tr.Y(), fldB1); fldB1.Combine(fB[ista], w[ista]); fldZ2 = z[ista - 2]; fvec dz = fldZ2 - fldZ1; - sta[ista].fieldSlice.GetFieldValue(tr.x + tr.tx * dz, tr.y + tr.ty * dz, fldB2); + sta[ista].fieldSlice.GetFieldValue(tr.X() + tr.Tx() * dz, tr.Y() + tr.Ty() * dz, fldB2); fldB2.Combine(fB[ista - 2], w[ista - 2]); fld.Set(fldB2, fldZ2, fldB1, fldZ1, fldB0, fldZ0); @@ -227,7 +225,7 @@ void L1Algo::L1KFTrackFitter() fldZ0 = z[ista]; dz = (fldZ1 - fldZ0); - sta[ista].fieldSlice.GetFieldValue(tr.x - tr.tx * dz, tr.y - tr.ty * dz, fldB0); + sta[ista].fieldSlice.GetFieldValue(tr.X() - tr.Tx() * dz, tr.Y() - tr.Ty() * dz, fldB0); fldB0.Combine(fB[ista], w[ista]); fld.Set(fldB0, fldZ0, fldB1, fldZ1, fldB2, fldZ2); @@ -237,8 +235,8 @@ void L1Algo::L1KFTrackFitter() fit.SetMask(initialised); fit.Extrapolate(z[ista], fld1); - fit.AddMsInMaterial(fParameters.GetMaterialThickness(ista, tr.x, tr.y)); - fit.EnergyLossCorrection(fParameters.GetMaterialThickness(ista, tr.x, tr.y), fvec(1.f)); + fit.AddMsInMaterial(fParameters.GetMaterialThickness(ista, tr.X(), tr.Y())); + fit.EnergyLossCorrection(fParameters.GetMaterialThickness(ista, tr.X(), tr.Y()), fvec(1.f)); fit.SetMask(initialised && w[ista]); fit.FilterXY(cov_xy[ista], x[ista], y[ista]); @@ -264,35 +262,33 @@ void L1Algo::L1KFTrackFitter() if (kGlobal == fTrackingMode) { for (int vtxIter = 0; vtxIter < 2; vtxIter++) { - fitpv.SetQp0(fitpv.Tr().qp); + fitpv.SetQp0(fitpv.Tr().Qp()); fitpv.Tr() = fit.Tr(); - fitpv.Tr().qp = fitpv.Qp0(); + fitpv.Tr().Qp() = fitpv.Qp0(); fitpv.Extrapolate(fParameters.GetTargetPositionZ(), fld); fitpv.FilterXY(vtxInfo, fParameters.GetTargetPositionX(), fParameters.GetTargetPositionY()); } } else { - fitpv.SetQp0(fitpv.Tr().qp); + fitpv.SetQp0(fitpv.Tr().Qp()); fitpv.Extrapolate(fParameters.GetTargetPositionZ(), fld); } } - //fit.SetQp0(tr.qp); + //fit.SetQp0(tr.Qp()); //fit.SetMask(fmask::One()); //fit.MeasureVelocityWithQp(); - //fit.FilterVi(L1TrackPar::kClightNsInv); + //fit.FilterVi(TrackParamV::kClightNsInv); - L1TrackPar Tf = fit.Tr(); - if (kGlobal == fTrackingMode) { Tf.qp = fitpv.Tr().qp; } + TrackParamV Tf = fit.Tr(); + if (kGlobal == fTrackingMode) { Tf.Qp() = fitpv.Tr().Qp(); } for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { - Tf.copyToArrays(iVec, t[iVec]->fParFirst, t[iVec]->fCovFirst); - t[iVec]->fChi2 = Tf.chi2[iVec]; - t[iVec]->fNDF = (int) Tf.NDF[iVec]; + t[iVec]->fParFirst.Set(Tf, iVec); } for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { - fitpv.Tr().copyToArrays(iVec, t[iVec]->fParPV, t[iVec]->fCovPV); + t[iVec]->fParPV.Set(fitpv.Tr(), iVec); } if (iter == 1) { break; } // only 1.5 iterations @@ -302,34 +298,33 @@ void L1Algo::L1KFTrackFitter() ista = 0; tr.ResetErrors(cov_xy_fst.C00, cov_xy_fst.C11, 0.1, 0.1, 1., dt2_first, 1.e-2); - tr.C10 = cov_xy_fst.C10; + tr.C10() = cov_xy_fst.C10; - tr.x = x_first; - tr.y = y_first; - tr.t = time_first; - tr.vi = L1TrackPar::kClightNsInv; + tr.X() = x_first; + tr.Y() = y_first; + tr.Time() = time_first; + tr.Vi() = constants::phys::SpeedOfLightInv; tr.InitVelocityRange(0.5); - tr.NDF = -3.0; - - tr.nTimeMeasurements = wtime_first; + tr.Ndf() = fvec(-5. + 2.); + tr.NdfTime() = fvec(-2.) + wtime_first; - fit.SetQp0(tr.qp); + fit.SetQp0(tr.Qp()); fldZ1 = z[ista]; - sta[ista].fieldSlice.GetFieldValue(tr.x, tr.y, fldB1); + sta[ista].fieldSlice.GetFieldValue(tr.X(), tr.Y(), fldB1); fldB1.Combine(fB[ista], w[ista]); fldZ2 = z[ista + 2]; dz = fldZ2 - fldZ1; - sta[ista].fieldSlice.GetFieldValue(tr.x + tr.tx * dz, tr.y + tr.ty * dz, fldB2); + sta[ista].fieldSlice.GetFieldValue(tr.X() + tr.Tx() * dz, tr.Y() + tr.Ty() * dz, fldB2); fldB2.Combine(fB[ista + 2], w[ista + 2]); fld.Set(fldB2, fldZ2, fldB1, fldZ1, fldB0, fldZ0); for (++ista; ista < nStations; ista++) { fldZ0 = z[ista]; dz = (fldZ1 - fldZ0); - sta[ista].fieldSlice.GetFieldValue(tr.x - tr.tx * dz, tr.y - tr.ty * dz, fldB0); + sta[ista].fieldSlice.GetFieldValue(tr.X() - tr.Tx() * dz, tr.Y() - tr.Ty() * dz, fldB0); fldB0.Combine(fB[ista], w[ista]); fld.Set(fldB0, fldZ0, fldB1, fldZ1, fldB2, fldZ2); @@ -337,8 +332,8 @@ void L1Algo::L1KFTrackFitter() fit.SetMask(initialised); fit.Extrapolate(z[ista], fld); - fit.AddMsInMaterial(fParameters.GetMaterialThickness(ista, tr.x, tr.y)); - fit.EnergyLossCorrection(fParameters.GetMaterialThickness(ista, tr.x, tr.y), fvec(-1.f)); + fit.AddMsInMaterial(fParameters.GetMaterialThickness(ista, tr.X(), tr.Y())); + fit.EnergyLossCorrection(fParameters.GetMaterialThickness(ista, tr.X(), tr.Y()), fvec(-1.f)); fit.SetMask(initialised && w[ista]); fit.FilterXY(cov_xy[ista], x[ista], y[ista]); fit.FilterTime(time[ista], dt2[ista], sta[ista].timeInfo); @@ -349,18 +344,16 @@ void L1Algo::L1KFTrackFitter() fldZ1 = fldZ0; } - //fit.SetQp0(tr.qp); + //fit.SetQp0(tr.Qp()); //fit.SetMask(fmask::One()); //fit.MeasureVelocityWithQp(); - //fit.FilterVi(L1TrackPar::kClightNsInv); + //fit.FilterVi(TrackParamV::kClightNsInv); - L1TrackPar Tl = fit.Tr(); - if (kGlobal == fTrackingMode) { Tl.qp = fitpv.Tr().qp; } + TrackParamV Tl = fit.Tr(); + if (kGlobal == fTrackingMode) { Tl.Qp() = fitpv.Tr().Qp(); } for (int iVec = 0; iVec < nTracks_SIMD; iVec++) { - Tl.copyToArrays(iVec, t[iVec]->fParLast, t[iVec]->fCovLast); - t[iVec]->fChi2 = Tl.chi2[iVec]; - t[iVec]->fNDF = (int) Tl.NDF[iVec]; + t[iVec]->fParLast.Set(Tl, iVec); } } // iter diff --git a/reco/L1/L1Algo/L1TrackPar.cxx b/reco/L1/L1Algo/L1TrackPar.cxx deleted file mode 100644 index 5bc71fb8de151dd5e4288bbae10924761bade891..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1TrackPar.cxx +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright (C) 2007-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer], Maksym Zyzak */ - -#include "L1TrackPar.h" - -#include <iomanip> -#include <iostream> - - -void L1TrackPar::Print(int i) const -{ - std::ios_base::fmtflags coutFlags(std::cout.flags()); - std::cout.setf(std::ios::scientific, std::ios::floatfield); - if (i == -1) { - std::cout << "T = " << std::endl; - std::cout << " x " << x << std::endl; - std::cout << " y " << y << std::endl; - std::cout << " tx " << tx << std::endl; - std::cout << " ty " << ty << std::endl; - std::cout << " qp " << qp << std::endl; - std::cout << " t " << t << std::endl; - std::cout << " v " << fvec(1.) / vi << std::endl; - std::cout << " z " << z << std::endl; - std::cout << "C = " << std::endl; - std::cout << " c00 " << C00 << std::endl; - std::cout << " c11 " << C11 << std::endl; - std::cout << " c22 " << C22 << std::endl; - std::cout << " c33 " << C33 << std::endl; - std::cout << " c44 " << C44 << std::endl; - std::cout << " c55 " << C55 << std::endl; - std::cout << " c66 " << C66 << std::endl; - } - else { - std::cout << "T = "; - std::cout << " x " << x[i]; - std::cout << " y " << y[i]; - std::cout << " tx " << tx[i]; - std::cout << " ty " << ty[i]; - std::cout << " qp " << qp[i]; - std::cout << " t " << t[i]; - std::cout << " v " << 1. / vi[i]; - - std::cout << " z " << z[i] << std::endl; - std::cout << "C = "; - std::cout << " c00 " << C00[i]; - std::cout << " c11 " << C11[i]; - std::cout << " c22 " << C22[i]; - std::cout << " c33 " << C33[i]; - std::cout << " c44 " << C44[i] << std::endl; - std::cout << " c55 " << C55[i] << std::endl; - std::cout << " c66 " << C66[i] << std::endl; - } - PrintCorrelations(i); - std::cout.flags(coutFlags); -} - -void L1TrackPar::PrintCorrelations(int i) const -{ - auto flagSafe = std::cout.flags(); - // std::cout.setf(std::ios::scientific, std::ios::floatfield); - std::cout << std::setprecision(6); - - if (i == -1) { - fvec s0 = sqrt(C00); - fvec s1 = sqrt(C11); - fvec s2 = sqrt(C22); - fvec s3 = sqrt(C33); - fvec s4 = sqrt(C44); - fvec s5 = sqrt(C55); - fvec s6 = sqrt(C66); - - std::cout << "K = " << std::endl; - std::cout << " k10 " << C10 / s1 / s0 << std::endl; - - std::cout << "\n k20 " << C20 / s2 / s0 << std::endl; - std::cout << " k21 " << C21 / s2 / s1 << std::endl; - - std::cout << "\n k30 " << C30 / s3 / s0 << std::endl; - std::cout << " k31 " << C31 / s3 / s1 << std::endl; - std::cout << " k32 " << C32 / s3 / s2 << std::endl; - - std::cout << "\n k40 " << C40 / s4 / s0 << std::endl; - std::cout << " k41 " << C41 / s4 / s1 << std::endl; - std::cout << " k42 " << C42 / s4 / s2 << std::endl; - std::cout << " k43 " << C43 / s4 / s3 << std::endl; - - std::cout << "\n k50 " << C50 / s5 / s0 << std::endl; - std::cout << " k51 " << C51 / s5 / s1 << std::endl; - std::cout << " k52 " << C52 / s5 / s2 << std::endl; - std::cout << " k53 " << C53 / s5 / s3 << std::endl; - std::cout << " k54 " << C54 / s5 / s4 << std::endl; - - std::cout << "\n k60 " << C60 / s6 / s0 << std::endl; - std::cout << " k61 " << C61 / s6 / s1 << std::endl; - std::cout << " k62 " << C62 / s6 / s2 << std::endl; - std::cout << " k63 " << C63 / s6 / s3 << std::endl; - std::cout << " k64 " << C64 / s6 / s4 << std::endl; - std::cout << " k65 " << C65 / s6 / s5 << std::endl; - } - else { - float s0 = sqrt(C00[i]); - float s1 = sqrt(C11[i]); - float s2 = sqrt(C22[i]); - float s3 = sqrt(C33[i]); - float s4 = sqrt(C44[i]); - float s5 = sqrt(C55[i]); - float s6 = sqrt(C66[i]); - - std::cout << "K = " << std::endl; - std::cout << " " << C10[i] / s1 / s0 << std::endl; - std::cout << " " << C20[i] / s2 / s0 << " " << C21[i] / s2 / s1 << std::endl; - std::cout << " " << C30[i] / s3 / s0 << " " << C31[i] / s3 / s1 << " " << C32[i] / s3 / s2 << std::endl; - std::cout << " " << C40[i] / s4 / s0 << " " << C41[i] / s4 / s1 << " " << C42[i] / s4 / s2 << " " - << C43[i] / s4 / s3 << std::endl; - std::cout << " " << C50[i] / s5 / s0 << " " << C51[i] / s5 / s1 << " " << C52[i] / s5 / s2 << " " - << C53[i] / s5 / s3 << " " << C54[i] / s5 / s4 << std::endl; - std::cout << " " << C60[i] / s6 / s0 << " " << C61[i] / s6 / s1 << " " << C62[i] / s6 / s2 << " " - << C63[i] / s6 / s3 << " " << C64[i] / s6 / s4 << " " << C65[i] / s6 / s5 << std::endl; - } - std::cout.flags(flagSafe); -} - -bool L1TrackPar::IsEntryConsistent(bool printWhenWrong, int k) const -{ - bool ok = true; - - // verify that all the numbers in the object are valid floats - const fvec* memberFirst = &x; - const fvec* memberLast = &NDF; - for (int i = 0; i < &memberLast - &memberFirst + 1; i++) { - if (!std::isfinite(memberFirst[i][k])) { - ok = false; - if (printWhenWrong) { - std::cout << " L1TrackPar member N " << i << ", vector entry " << k - << " is not a number: " << memberFirst[i][k]; - } - } - } - - // verify diagonal elements. - // Cii is a squared dispersion of i-th parameter, it must be positive - - for (int i = 0; i < 7; i++) { - if (C(i, i)[k] <= 0.f) { - ok = false; - if (printWhenWrong) { - std::cout << " L1TrackPar: C[" << i << "," << i << "], vec entry " << k << " is not positive: " << C(i, i)[k] - << std::endl; - } - } - } - - // verify non-diagonal elements. - // Cij/sqrt(Cii*Cjj) is a correlation between i-th and j-th parameter, - // it must belong to [-1,1] - - for (int i = 1; i < 7; i++) { - for (int j = 0; j < i; j++) { - double tolerance = 1.0; - if (C(i, j)[k] * C(i, j)[k] > tolerance * (C(i, i)[k] * C(j, j)[k])) { - ok = false; - if (printWhenWrong) { - std::cout << " L1TrackPar: correlation [" << i << "," << j << "], vec entry " << k - << " is too large: " << C(i, i)[k] / sqrt(C(i, i)[k] * C(j, j)[k]) << std::endl; - } - } - } - } - - // verify triplets of correlations - // Kxy * Kxy + Kxz * Kxz + Kyz * Kyz <= 1 + 2 * Kxy * Kxz * Kyz - - for (int i = 2; i < 7; i++) { - for (int j = 1; j < i; j++) { - for (int m = 0; m < j; m++) { - double tolerance = 1.0; - double Cxx = C(i, i)[k]; - double Cyy = C(j, j)[k]; - double Czz = C(m, m)[k]; - double Cxy = C(i, j)[k]; - double Cxz = C(i, m)[k]; - double Cyz = C(j, m)[k]; - if (Cxx * Cyz * Cyz + Cyy * Cxz * Cxz + Czz * Cxy * Cxy - > tolerance * (Cxx * Cyy * Czz + 2. * Cxy * Cyz * Cxz)) { - ok = false; - if (printWhenWrong) { - double Kxy = Cxy / sqrt(Cxx * Cyy); - double Kxz = Cxz / sqrt(Cxx * Czz); - double Kyz = Cyz / sqrt(Cyy * Czz); - std::cout << " L1TrackPar: correlations between parametetrs " << i << ", " << j << ", " << m - << ", vec entry " << k << " are wrong: " << Kxy << " " << Kxz << " " << Kyz << std::endl; - std::cout << " inequation: " << Kxy * Kxy + Kxz * Kxz + Kyz * Kyz << " > " << 1 + 2 * Kxy * Kxz * Kyz - << std::endl; - } - } - } - } - } - - if (!ok && printWhenWrong) { - std::cout << "L1TrackPar parameters are not consistent: " << std::endl; - Print(k); - } - return ok; -} - -bool L1TrackPar::IsConsistent(bool printWhenWrong, int nFilled) const -{ - assert(nFilled <= (int) fvec::size()); - bool ok = true; - if (nFilled < 0) { nFilled = fvec::size(); } - for (int i = 0; i < nFilled; ++i) { - ok = ok && IsEntryConsistent(printWhenWrong, i); - } - - if (!ok && printWhenWrong) { - std::cout << "L1TrackPar parameters are not consistent: " << std::endl; - if (nFilled == (int) fvec::size()) { std::cout << " All vector elements are filled " << std::endl; } - else { - std::cout << " Only first " << nFilled << " vector elements are filled " << std::endl; - } - Print(-1); - } - return ok; -} diff --git a/reco/L1/L1Algo/L1TrackPar.h b/reco/L1/L1Algo/L1TrackPar.h deleted file mode 100644 index 84e5f269b9f9d481a3dfe2900a33a287fa1df95b..0000000000000000000000000000000000000000 --- a/reco/L1/L1Algo/L1TrackPar.h +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright (C) 2007-2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer], Maksym Zyzak, Sergei Zharko */ - -#ifndef L1TrackPar_h -#define L1TrackPar_h 1 - -#include "CaConstants.h" -#include "CaSimd.h" - -using namespace cbm::algo::ca; -using namespace cbm::algo::ca::constants; - -class L1TrackPar { - -public: - static constexpr int kNparTr {8}; - static constexpr int kNparCov {28}; - - fvec x {0.}, y {0.}, tx {0.}, ty {0.}, qp {0.}, z {0.}, t {0.}, vi {0.}; - - fvec C00 {0.}, - - C10 {0.}, C11 {0.}, - - C20 {0.}, C21 {0.}, C22 {0.}, - - C30 {0.}, C31 {0.}, C32 {0.}, C33 {0.}, - - C40 {0.}, C41 {0.}, C42 {0.}, C43 {0.}, C44 {0.}, - - C50 {0.}, C51 {0.}, C52 {0.}, C53 {0.}, C54 {0.}, C55 {0.}, - - C60 {0.}, C61 {0.}, C62 {0.}, C63 {0.}, C64 {0.}, C65 {0.}, C66 {0.}; - - fvec chi2 {0.}, NDF {0.}; - - fvec nTimeMeasurements {0.}; - - L1TrackPar() = default; - - template<typename T> - L1TrackPar(const std::array<T, kNparTr>& p, const std::array<T, kNparCov>& c) - { - copyFromArrays(p, c); - } - - //template<typename T> - //void Set(const T* tr, const T* C); - - void SetOneEntry(const int i0, const L1TrackPar& T1, const int i1); - - fvec C(int i, int j) const - { - const fvec* c = &C00; - int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; - return c[ind]; - } - - fvec& C(int i, int j) - { - fvec* c = &C00; - int ind = (j <= i) ? i * (1 + i) / 2 + j : j * (1 + j) / 2 + i; - return c[ind]; - } - - // ** Parameter getters ** - - /// @brief Gets x position [cm] - fscal GetX() const { return x[0]; } - - /// @brief Gets x position error [cm] - fscal GetXErr() const { return (std::isfinite(C00[0]) && C00[0] > 0) ? std::sqrt(C00[0]) : undef::Fscal; } - - /// @brief Gets y position [cm] - fscal GetY() const { return y[0]; } - - /// @brief Gets y position error [cm] - fscal GetYErr() const { return (std::isfinite(C11[0]) && C11[0] > 0) ? std::sqrt(C11[0]) : undef::Fscal; } - - /// @brief Gets slope along x-axis - fscal GetTx() const { return tx[0]; } - - /// @brief Gets error of slope along x-axis - fscal GetTxErr() const { return (std::isfinite(C22[0]) && C22[0] > 0) ? std::sqrt(C22[0]) : undef::Fscal; } - - /// @brief Gets slope along y-axis - fscal GetTy() const { return ty[0]; } - - /// @brief Gets error of slope along y-axis - fscal GetTyErr() const { return (std::isfinite(C33[0]) && C33[0] > 0) ? std::sqrt(C33[0]) : undef::Fscal; } - - /// @brief Gets charge over momentum [ec/GeV] - fscal GetQp() const { return qp[0]; } - - /// @brief Gets error of charge over momentum [ec/GeV] - fscal GetQpErr() const { return (std::isfinite(C44[0]) && C44[0] > 0) ? std::sqrt(C44[0]) : undef::Fscal; } - - /// @brief Gets time [ns] - fscal GetTime() const { return t[0]; } - - /// @brief Gets time error [ns] - fscal GetTimeErr() const { return (std::isfinite(C55[0]) && C55[0] > 0) ? std::sqrt(C55[0]) : undef::Fscal; } - - /// @brief Gets inverse speed [ns/cm] - fscal GetInvSpeed() const { return vi[0]; } - - /// @brief Gets inverse speed error [ns/cm] - fscal GetInvSpeedErr() const { return (std::isfinite(C66[0]) && C66[0] > 0) ? std::sqrt(C66[0]) : undef::Fscal; } - - /// @brief Gets azimuthal angle [rad] - fscal GetPhi() const { return std::atan2(-GetTy(), -GetTx()); } - - /// @brief Gets azimuthal angle error [rad] - fscal GetPhiErr() const; - - /// @brief Gets polar angle [rad] - fscal GetTheta() const { return std::acos(1. / sqrt(GetTx() * GetTx() + GetTy() * GetTy() + 1.)); } - - /// @brief Gets polar angle error [rad] - fscal GetThetaErr() const; - - /// @brief Resets variances of track parameters - /// @param c00 Variance of x-position [cm2] - /// @param c11 Variance of y-position [cm2] - /// @param c22 Variance of slope along x-axis - /// @param c33 Variance of slope along y-axis - /// @param c44 Variance of charge over momentum [(ec/GeV)2] - /// @param c55 Variance of time [ns2] - /// @param c66 Variance of inverse speed [1/c2] - void ResetErrors(fvec c00, fvec c11, fvec c22, fvec c33, fvec c44, fvec c55, fvec c66); - - /// @brief Prints parameters - /// @param i Index of SIMD vector element (if -1, the whole vector is printed out) - void Print(int i = -1) const; - - void PrintCorrelations(int i = -1) const; - - bool IsEntryConsistent(bool printWhenWrong, int i) const; - - bool IsConsistent(bool printWhenWrong, int nFilled) const; - - template<typename T> - void copyToArrays(const int iVec, std::array<T, kNparTr>& p, std::array<T, kNparCov>& c) const; - - template<typename T> - void copyFromArrays(const int iVec, const std::array<T, kNparTr>& p, const std::array<T, kNparCov>& c); - - template<typename T> - void copyFromArrays(const std::array<T, kNparTr>& p, const std::array<T, kNparCov>& c); - - void InitVelocityRange(fscal minP); - - static constexpr fscal kClightNs {29.9792458}; // the speed of light cm/ns - static constexpr fscal kClightNsInv {1. / 29.9792458}; // inverse speed of light - static constexpr fscal kProtonMass = 0.93827208816; - static constexpr fscal kPionMass = 0.1395703918; - static constexpr fscal kMuonMass = 0.105658375523; - static constexpr fscal kElectronMass = 0.0005109989500015; - -} _fvecalignment; - -// *************************************************** -// ** Inline and template function implementation ** -// *************************************************** - - -// --------------------------------------------------------------------------------------------------------------------- -// -inline fscal L1TrackPar::GetPhiErr() const -{ - fscal phiDFactor = 1. / (GetTx() * GetTx() + GetTy() * GetTy()); - fscal phiDTx = -phiDFactor * GetTy(); // partial derivative of phi over Tx - fscal phiDTy = +phiDFactor * GetTx(); // partial derivative of phi over Ty - - fscal varTx = (std::isfinite(C22[0]) && C22[0] > 0) ? C22[0] : undef::Fscal; // variance of Tx - fscal varTy = (std::isfinite(C33[0]) && C33[0] > 0) ? C33[0] : undef::Fscal; // variance of Ty - fscal covTxTy = std::isfinite(C32[0]) ? C32[0] : undef::Fscal; // covariance of Tx and Ty - - fscal varPhi = phiDTx * phiDTx * varTx + phiDTy * phiDTy * varTy + 2 * phiDTx * phiDTy * covTxTy; - return std::sqrt(varPhi); -} - -// --------------------------------------------------------------------------------------------------------------------- -// -inline fscal L1TrackPar::GetThetaErr() const -{ - fscal sumSqSlopes = GetTx() * GetTx() + GetTy() * GetTy(); - fscal thetaDFactor = 1. / ((sumSqSlopes + 1) * sqrt(sumSqSlopes)); - fscal thetaDTx = thetaDFactor * GetTx(); - fscal thetaDTy = thetaDFactor * GetTy(); - - fscal varTx = (std::isfinite(C22[0]) && C22[0] > 0) ? C22[0] : undef::Fscal; // variance of Tx - fscal varTy = (std::isfinite(C33[0]) && C33[0] > 0) ? C33[0] : undef::Fscal; // variance of Ty - fscal covTxTy = std::isfinite(C32[0]) ? C32[0] : undef::Fscal; // covariance of Tx and Ty - - fscal varTheta = thetaDTx * thetaDTx * varTx + thetaDTy * thetaDTy * varTy + 2 * thetaDTx * thetaDTy * covTxTy; - return std::sqrt(varTheta); -} - -// --------------------------------------------------------------------------------------------------------------------- -// -template<typename T> -inline void L1TrackPar::copyToArrays(const int iVec, std::array<T, kNparTr>& p, std::array<T, kNparCov>& c) const -{ - p[0] = x[iVec]; - p[1] = y[iVec]; - p[2] = tx[iVec]; - p[3] = ty[iVec]; - p[4] = qp[iVec]; - p[5] = z[iVec]; - p[6] = t[iVec]; - p[7] = vi[iVec]; - - const fvec* tC = &(C00); - for (int i = 0; i < kNparCov; i++) { - c[i] = tC[i][iVec]; - } -} - -// --------------------------------------------------------------------------------------------------------------------- -// -template<typename T> -inline void L1TrackPar::copyFromArrays(const int iVec, const std::array<T, kNparTr>& p, - const std::array<T, kNparCov>& c) -{ - x[iVec] = p[0]; - y[iVec] = p[1]; - tx[iVec] = p[2]; - ty[iVec] = p[3]; - qp[iVec] = p[4]; - z[iVec] = p[5]; - t[iVec] = p[6]; - vi[iVec] = p[7]; - - fvec* tC = &(C00); - for (int i = 0; i < kNparCov; i++) { - tC[i][iVec] = c[i]; - } - - chi2 = 0.; - NDF = 0.; -} - -// --------------------------------------------------------------------------------------------------------------------- -// -template<typename T> -inline void L1TrackPar::copyFromArrays(const std::array<T, kNparTr>& p, const std::array<T, kNparCov>& c) -{ - x = p[0]; - y = p[1]; - tx = p[2]; - ty = p[3]; - qp = p[4]; - z = p[5]; - t = p[6]; - vi = p[7]; - - fvec* tC = &(C00); - for (int i = 0; i < kNparCov; i++) { - tC[i] = c[i]; - } - - chi2 = 0.; - NDF = 0.; -} - -// --------------------------------------------------------------------------------------------------------------------- -// -inline void L1TrackPar::SetOneEntry(const int i0, const L1TrackPar& T1, const int i1) -{ - x[i0] = T1.x[i1]; - y[i0] = T1.y[i1]; - tx[i0] = T1.tx[i1]; - ty[i0] = T1.ty[i1]; - qp[i0] = T1.qp[i1]; - z[i0] = T1.z[i1]; - t[i0] = T1.t[i1]; - vi[i0] = T1.vi[i1]; - - C00[i0] = T1.C00[i1]; - C10[i0] = T1.C10[i1]; - C11[i0] = T1.C11[i1]; - C20[i0] = T1.C20[i1]; - C21[i0] = T1.C21[i1]; - C22[i0] = T1.C22[i1]; - C30[i0] = T1.C30[i1]; - C31[i0] = T1.C31[i1]; - C32[i0] = T1.C32[i1]; - C33[i0] = T1.C33[i1]; - C40[i0] = T1.C40[i1]; - C41[i0] = T1.C41[i1]; - C42[i0] = T1.C42[i1]; - C43[i0] = T1.C43[i1]; - C44[i0] = T1.C44[i1]; - C50[i0] = T1.C50[i1]; - C51[i0] = T1.C51[i1]; - C52[i0] = T1.C52[i1]; - C53[i0] = T1.C53[i1]; - C54[i0] = T1.C54[i1]; - C55[i0] = T1.C55[i1]; - C60[i0] = T1.C60[i1]; - C61[i0] = T1.C61[i1]; - C62[i0] = T1.C62[i1]; - C63[i0] = T1.C63[i1]; - C64[i0] = T1.C64[i1]; - C65[i0] = T1.C65[i1]; - C66[i0] = T1.C66[i1]; - - chi2[i0] = T1.chi2[i1]; - NDF[i0] = T1.NDF[i1]; -} // SetOneEntry - -// --------------------------------------------------------------------------------------------------------------------- -// -inline void L1TrackPar::ResetErrors(fvec c00, fvec c11, fvec c22, fvec c33, fvec c44, fvec c55, fvec c66) -{ - C10 = 0.; - C20 = C21 = 0.; - C30 = C31 = C32 = 0.; - C40 = C41 = C42 = C43 = 0.; - C50 = C51 = C52 = C53 = C54 = 0.; - C60 = C61 = C62 = C63 = C64 = C65 = 0.; - - C00 = c00; - C11 = c11; - C22 = c22; - C33 = c33; - C44 = c44; - C55 = c55; - C66 = c66; - - chi2 = 0.; - NDF = -6.; - nTimeMeasurements = 0.; -} - -// --------------------------------------------------------------------------------------------------------------------- -// -inline void L1TrackPar::InitVelocityRange(fscal minP) -{ - // initialise the velocity range with respect to the minimal momentum minP {GeV/c} - - fscal maxVi = sqrt(1. + (kProtonMass / minP) * (kProtonMass / minP)) * kClightNsInv; - fscal minVi = kClightNsInv; - fscal vmean = minVi + 0.4 * (maxVi - minVi); - fscal dvi = (maxVi - vmean) / 3.; - vi = vmean; - C66 = dvi * dvi; -} - -#endif diff --git a/reco/L1/L1Algo/L1TripletConstructor.cxx b/reco/L1/L1Algo/L1TripletConstructor.cxx index 97aa57118a09ec6e7850bb7ca0698a7d4770c646..22622617565b24e3e023ec118339778f9f3063aa 100644 --- a/reco/L1/L1Algo/L1TripletConstructor.cxx +++ b/reco/L1/L1Algo/L1TripletConstructor.cxx @@ -11,13 +11,13 @@ #include <iostream> #include "CaToolsDebugger.h" +#include "CaTrackParam.h" #include "L1Algo.h" #include "L1Assert.h" #include "L1Fit.h" #include "L1Grid.h" #include "L1HitArea.h" #include "L1HitPoint.h" -#include "L1TrackPar.h" using cbm::ca::tools::Debugger; @@ -114,28 +114,27 @@ void L1TripletConstructor::CreateTripletsForHit(int istal, int istam, int istar, const fvec tx = (xl - fAlgo->fTargX) * dzli; const fvec ty = (yl - fAlgo->fTargY) * dzli; - L1TrackPar& T = fFit.Tr(); + TrackParamV& T = fFit.Tr(); - T.x = xl; - T.y = yl; - T.z = zl; - T.tx = tx; - T.ty = ty; - T.qp = fvec(0.); - T.t = time; - T.vi = fvec(0.); + T.X() = xl; + T.Y() = yl; + T.Z() = zl; + T.Tx() = tx; + T.Ty() = ty; + T.Qp() = fvec(0.); + T.Time() = time; + T.Vi() = fvec(0.); fvec txErr2 = fAlgo->fMaxSlopePV * fAlgo->fMaxSlopePV / fvec(9.); fvec qpErr2 = fAlgo->fMaxInvMom * fAlgo->fMaxInvMom / fvec(9.); T.ResetErrors(1., 1., txErr2, txErr2, qpErr2, (staL().timeInfo ? timeEr2 : 1.e6), 1.e2); - T.C00 = hitl.dX2(); - T.C10 = hitl.dXY(); - T.C11 = hitl.dY2(); + T.C00() = hitl.dX2(); + T.C10() = hitl.dXY(); + T.C11() = hitl.dY2(); - T.chi2 = 0.; - T.NDF = (fAlgo->fpCurrentIteration->GetPrimaryFlag()) ? fvec(2.) : fvec(0.); - T.nTimeMeasurements = (staL().timeInfo ? 1 : 0); + T.Ndf() = (fAlgo->fpCurrentIteration->GetPrimaryFlag()) ? fvec(2.) : fvec(0.); + T.NdfTime() = (staL().timeInfo ? -1 : -2); // TODO: iteration parameter: "Starting NDF of track parameters" // NDF = number of track parameters (6: x, y, tx, ty, qp, time) - number of measured parameters (3: x, y, time) on station or (2: x, y) on target @@ -164,7 +163,7 @@ void L1TripletConstructor::CreateTripletsForHit(int istal, int istam, int istar, fFit.AddTargetToLine(fAlgo->fTargX, fAlgo->fTargY, fAlgo->fTargZ, fAlgo->TargetXYInfo, fld0); - fFit.AddMsInMaterial(fAlgo->fParameters.GetMaterialThickness(fIstaL, T.x, T.y)); + fFit.AddMsInMaterial(fAlgo->fParameters.GetMaterialThickness(fIstaL, T.GetX(), T.GetY())); // extrapolate to the middle hit @@ -214,8 +213,8 @@ void L1TripletConstructor::FitDoublets() if (hitm.IsSuppressed()) continue; - L1TrackPar& T2 = fFit.Tr(); - T2 = fTrL; + TrackParamV& T2 = fFit.Tr(); + T2 = fTrL; fFit.SetQp0(fvec(0.f)); fvec x_2 = hitm.X(); @@ -236,36 +235,36 @@ void L1TripletConstructor::FitDoublets() fFit.FilterTime(t_2, dt2_2, staM().timeInfo); - fFit.SetQp0(isMomentumFitted ? fFit.Tr().qp : fAlgo->fMaxInvMom); + fFit.SetQp0(isMomentumFitted ? fFit.Tr().GetQp() : fAlgo->fMaxInvMom); - fFit.AddMsInMaterial(fAlgo->fParameters.GetMaterialThickness(fIstaM, T2.x, T2.y)); + fFit.AddMsInMaterial(fAlgo->fParameters.GetMaterialThickness(fIstaM, T2.GetX(), T2.Y())); - fFit.SetQp0(fFit.Tr().qp); + fFit.SetQp0(fFit.Tr().Qp()); // check if there are other hits close to the doublet on the same station if (L1Algo::kMcbm != fAlgo->fTrackingMode) { // TODO: SG: adjust cuts, put them to parameters - fscal tx = T2.tx[0]; - fscal ty = T2.ty[0]; - fscal tt = T2.vi[0] * sqrt(1. + tx * tx + ty * ty); // dt/dl * dl/dz + fscal tx = T2.Tx()[0]; + fscal ty = T2.Ty()[0]; + fscal tt = T2.Vi()[0] * sqrt(1. + tx * tx + ty * ty); // dt/dl * dl/dz for (unsigned int j2 = i2 + 1; j2 < hitsMtmp.size(); j2++) { L1HitPoint& hitm1 = fHitsM[hitsMtmp[j2]]; - fscal dz = hitm1.Z() - T2.z[0]; + fscal dz = hitm1.Z() - T2.Z()[0]; - if ((staM().timeInfo) && (T2.nTimeMeasurements[0] > 0)) { - fscal dt = T2.t[0] + tt * dz - hitm.T(); - if (fabs(dt) > sqrt(30. * T2.C55[0]) + hitm1.RangeT()) { continue; } + if ((staM().timeInfo) && (T2.NdfTime()[0] > -2)) { + fscal dt = T2.Time()[0] + tt * dz - hitm.T(); + if (fabs(dt) > sqrt(30. * T2.C55()[0]) + hitm1.RangeT()) { continue; } } - fscal dx = T2.x[0] + tx * dz - hitm1.X(); - if (fabs(dx) > 1.3 * (3.5 * sqrt(T2.C00[0]) + hitm1.RangeX())) { continue; } + fscal dx = T2.GetX()[0] + tx * dz - hitm1.X(); + if (fabs(dx) > 1.3 * (3.5 * sqrt(T2.C00()[0]) + hitm1.RangeX())) { continue; } - fscal dy = T2.y[0] + ty * dz - hitm1.Y(); - if (fabs(dy) > 1.6 * (3.5 * sqrt(T2.C11[0]) + hitm1.RangeY())) { continue; } + fscal dy = T2.Y()[0] + ty * dz - hitm1.Y(); + if (fabs(dy) > 1.6 * (3.5 * sqrt(T2.C11()[0]) + hitm1.RangeY())) { continue; } if (fAlgo->fParameters.DevIsSuppressOverlapHitsViaMc()) { int indL = fAlgo->fGridHitStartIndex[fIstaL] + fIhitL; @@ -317,7 +316,7 @@ void L1TripletConstructor::FindRightHit() for (unsigned int i2 = 0; i2 < fHitsM_2.size(); i2++) { fFit.SetTrack(fTracks_2[i2]); - L1TrackPar& T2 = fFit.Tr(); + TrackParamV& T2 = fFit.Tr(); // extrapolate to the right hit station @@ -325,11 +324,11 @@ void L1TripletConstructor::FindRightHit() // ---- Find the triplets(right hit). Reformat data in the portion of triplets. ---- - if (fAlgo->kSts == fAlgo->fTrackingMode && (T2.C44[0] < 0)) { continue; } - if (T2.C00[0] < 0 || T2.C11[0] < 0 || T2.C22[0] < 0 || T2.C33[0] < 0 || T2.C55[0] < 0) continue; + if (fAlgo->kSts == fAlgo->fTrackingMode && (T2.C44()[0] < 0)) { continue; } + if (T2.C00()[0] < 0 || T2.C11()[0] < 0 || T2.C22()[0] < 0 || T2.C33()[0] < 0 || T2.C55()[0] < 0) continue; - if (fabs(T2.tx[0]) > fAlgo->fMaxSlope) continue; - if (fabs(T2.ty[0]) > fAlgo->fMaxSlope) continue; + if (fabs(T2.Tx()[0]) > fAlgo->fMaxSlope) continue; + if (fabs(T2.Ty()[0]) > fAlgo->fMaxSlope) continue; int iMC = -1; if (fAlgo->fParameters.DevIsMatchTripletsViaMc()) { @@ -374,12 +373,12 @@ void L1TripletConstructor::FitTriplets() assert(fHitsM_3.size() == fHitsR_3.size()); fTracks_3.clear(); - fTracks_3.reset(n3, L1TrackPar()); + fTracks_3.reset(n3, TrackParamV()); /// Refit Triplets if (dumpTriplets) { - Debugger::Instance().AddNtuple("triplets", - "ev:iter:i0:x0:y0:z0:i1:x1:y1:z1:i2:x2:y2:z2:mc:sta:p:vx:vy:vz:chi2:ndf"); + cbm::ca::tools::Debugger::Instance().AddNtuple( + "triplets", "ev:iter:i0:x0:y0:z0:i1:x1:y1:z1:i2:x2:y2:z2:mc:sta:p:vx:vy:vz:chi2:ndf:chi2time:ndfTime"); } L1Fit fit; @@ -400,10 +399,9 @@ void L1TripletConstructor::FitTriplets() }; bool isMomentumFitted = ((staL().fieldStatus != 0) || (staM().fieldStatus != 0) || (staR().fieldStatus != 0)); - bool isTimeFitted = ((staL().timeInfo != 0) || (staM().timeInfo != 0) || (staR().timeInfo != 0)); - fvec ndf = -4; // straight line - ndf += isMomentumFitted ? -1 : 0; - ndf += isTimeFitted ? -1 : 0; + + fvec ndfTrackModel = 4; // straight line + ndfTrackModel += isMomentumFitted ? 1 : 0; // track with momentum for (int i3 = 0; i3 < n3; ++i3) { @@ -451,46 +449,47 @@ void L1TripletConstructor::FitTriplets() fld.Set(B[0], sta[0].fZ, B[1], sta[1].fZ, B[2], sta[2].fZ); fldTarget.Set(fAlgo->fTargB, fAlgo->fTargZ, B[0], sta[0].fZ, B[1], sta[1].fZ); - L1TrackPar& T = fit.Tr(); + TrackParamV& T = fit.Tr(); // initial parameters { fvec dz01 = 1. / (z[1] - z[0]); - T.tx = (x[1] - x[0]) * dz01; - T.ty = (y[1] - y[0]) * dz01; - T.qp = 0.; - T.vi = 0.; + T.Tx() = (x[1] - x[0]) * dz01; + T.Ty() = (y[1] - y[0]) * dz01; + T.Qp() = 0.; + T.Vi() = 0.; } // repeat several times in order to improve the precision for (int iiter = 0; iiter < nIterations; ++iiter) { // fit forward { - fit.SetQp0(T.qp); + fit.SetQp0(T.Qp()); fit.Qp0()(fit.Qp0() > fAlgo->GetMaxInvMom()) = fAlgo->GetMaxInvMom(); fit.Qp0()(fit.Qp0() < -fAlgo->GetMaxInvMom()) = -fAlgo->GetMaxInvMom(); - T.qp = 0.; - T.vi = 0.; - int ih0 = 0; - T.x = x[ih0]; - T.y = y[ih0]; - T.z = z[ih0]; - T.t = t[ih0]; + T.Qp() = 0.; + T.Vi() = 0.; + int ih0 = 0; + T.X() = x[ih0]; + T.Y() = y[ih0]; + T.Z() = z[ih0]; + T.Time() = t[ih0]; T.ResetErrors(1., 1., 1., 1., 100., (sta[ih0].timeInfo ? dt2[ih0] : 1.e6), 1.e2); - T.C00 = cov[ih0].C00; - T.C10 = cov[ih0].C10; - T.C11 = cov[ih0].C11; + T.C00() = cov[ih0].C00; + T.C10() = cov[ih0].C10; + T.C11() = cov[ih0].C11; - T.NDF = ndf; + T.Ndf() = -ndfTrackModel + 2; + T.NdfTime() = sta[ih0].timeInfo ? -1 : -2; // add the target constraint fit.AddTargetToLine(fAlgo->fTargX, fAlgo->fTargY, fAlgo->fTargZ, fAlgo->TargetXYInfo, fldTarget); for (int ih = 1; ih < NHits; ++ih) { fit.Extrapolate(z[ih], fld); - auto radThick = fAlgo->fParameters.GetMaterialThickness(ista[ih], T.x, T.y); + auto radThick = fAlgo->fParameters.GetMaterialThickness(ista[ih], T.X(), T.Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec(-1.f)); fit.FilterXY(cov[ih], x[ih], y[ih]); @@ -502,29 +501,29 @@ void L1TripletConstructor::FitTriplets() // fit backward { - fit.SetQp0(T.qp); + fit.SetQp0(T.Qp()); fit.Qp0()(fit.Qp0() > fAlgo->GetMaxInvMom()) = fAlgo->GetMaxInvMom(); fit.Qp0()(fit.Qp0() < -fAlgo->GetMaxInvMom()) = -fAlgo->GetMaxInvMom(); - T.NDF = ndf; - T.qp = 0.; - T.vi = 0.; - int ih0 = NHits - 1; - T.x = x[ih0]; - T.y = y[ih0]; - T.z = z[ih0]; - T.t = t[ih0]; + int ih0 = NHits - 1; + T.X() = x[ih0]; + T.Y() = y[ih0]; + T.Z() = z[ih0]; + T.Time() = t[ih0]; + T.Qp() = 0.; + T.Vi() = 0.; T.ResetErrors(1., 1., 1., 1., 100., (sta[ih0].timeInfo ? dt2[ih0] : 1.e6), 1.e2); - T.C00 = cov[ih0].C00; - T.C10 = cov[ih0].C10; - T.C11 = cov[ih0].C11; + T.C00() = cov[ih0].C00; + T.C10() = cov[ih0].C10; + T.C11() = cov[ih0].C11; - T.NDF = ndf; + T.Ndf() = -ndfTrackModel + 2; + T.NdfTime() = sta[ih0].timeInfo ? -1 : -2; for (int ih = NHits - 2; ih >= 0; --ih) { fit.Extrapolate(z[ih], fld); - auto radThick = fAlgo->fParameters.GetMaterialThickness(ista[ih], T.x, T.y); + auto radThick = fAlgo->fParameters.GetMaterialThickness(ista[ih], T.X(), T.Y()); fit.AddMsInMaterial(radThick); fit.EnergyLossCorrection(radThick, fvec(1.f)); fit.FilterXY(cov[ih], x[ih], y[ih]); @@ -549,9 +548,10 @@ void L1TripletConstructor::FitTriplets() if ((mc1 >= 0) && (mc1 == mc2) && (mc1 == mc3)) { const CbmL1MCTrack& mctr = CbmL1::Instance()->GetMcTracks()[mc1]; - Debugger::Instance().FillNtuple("triplets", mctr.iEvent, fAlgo->isec, ih0, h0.x, h0.y, h0.z, ih1, h1.x, h1.y, - h1.z, ih2, h2.x, h2.y, h2.z, mc1, fIstaL, mctr.p, mctr.x, mctr.y, mctr.z, - (float) T.chi2[0], (float) T.NDF[0]); + cbm::ca::tools::Debugger::Instance().FillNtuple( + "triplets", mctr.iEvent, fAlgo->isec, ih0, h0.x, h0.y, h0.z, ih1, h1.x, h1.y, h1.z, ih2, h2.x, h2.y, h2.z, + mc1, fIstaL, mctr.p, mctr.x, mctr.y, mctr.z, (float) T.GetChiSq()[0], (float) T.Ndf()[0], + (float) T.ChiSqTime()[0], (float) T.NdfTime()[0]); } } } //i3 @@ -573,9 +573,9 @@ void L1TripletConstructor::StoreTriplets() for (Tindex i3 = 0; i3 < n3; ++i3) { - L1TrackPar& T3 = fTracks_3[i3]; + TrackParamV& T3 = fTracks_3[i3]; - fscal chi2 = T3.chi2[0]; // / T3.NDF[0]; + fscal chi2 = T3.GetChiSq()[0]; // / T3.NDF[0]; const L1HitIndex_t ihitl = fIhitL + fAlgo->fGridHitStartIndex[fIstaL]; const L1HitIndex_t ihitm = fHitsM_3[i3] + fAlgo->fGridHitStartIndex[fIstaM]; @@ -592,26 +592,23 @@ void L1TripletConstructor::StoreTriplets() // assert(std::isfinite(chi2) && chi2 > 0); if (!std::isfinite(chi2) || chi2 < 0) { continue; } - //if (!T3.IsEntryConsistent(false, 0)) { continue; } - - fscal qp = T3.qp[0]; - //TODO: why sqrt's? Wouldn't it be faster to skip sqrt() here and - //TODO: compare the squared differences dqr*dqp later? + //if (!T3.IsEntryConsistent(true, 0)) { continue; } - fscal Cqp = T3.C44[0]; + fscal qp = T3.Qp()[0]; + fscal Cqp = T3.C44()[0]; // TODO: SG: a magic correction that comes from the legacy code // removing it leads to a higher ghost ratio Cqp += 0.001; - fTriplets.emplace_back(ihitl, ihitm, ihitr, fIstaL, fIstaM, fIstaR, 0, 0, 0, chi2, qp, Cqp, T3.tx[0], T3.C22[0], - T3.ty[0], T3.C33[0], isMomentumFitted); + fTriplets.emplace_back(ihitl, ihitm, ihitr, fIstaL, fIstaM, fIstaR, 0, 0, 0, chi2, qp, Cqp, T3.Tx()[0], T3.C22()[0], + T3.Ty()[0], T3.C33()[0], isMomentumFitted); } } -void L1TripletConstructor::CollectHits(const L1TrackPar& Tr, const int iSta, const double chi2Cut, const int iMC, +void L1TripletConstructor::CollectHits(const TrackParamV& Tr, const int iSta, const double chi2Cut, const int iMC, Vector<L1HitIndex_t>& collectedHits, int maxNhits) { /// Collect hits on a station @@ -624,20 +621,20 @@ void L1TripletConstructor::CollectHits(const L1TrackPar& Tr, const int iSta, con const L1HitIndex_t nHits = fAlgo->fGridHitStopIndex[iSta] - fAlgo->fGridHitStartIndex[iSta]; fFit.SetTrack(Tr); - L1TrackPar& T = fFit.Tr(); + TrackParamV& T = fFit.Tr(); //std::cout << T.chi2[0] << std::endl; - T.chi2 = 0.; + T.ChiSq() = 0.; // if make it bigger the found hits will be rejected later because of the chi2 cut. - const fvec Pick_m22 = (fvec(chi2Cut) - T.chi2); + const fvec Pick_m22 = (fvec(chi2Cut) - T.GetChiSq()); - const fscal iz = 1.f / (T.z[0] - fAlgo->fParameters.GetTargetPositionZ()[0]); - const fscal timeError2 = T.C55[0]; - const fscal time = T.t[0]; + const fscal iz = 1.f / (T.Z()[0] - fAlgo->fParameters.GetTargetPositionZ()[0]); + const fscal timeError2 = T.C55()[0]; + const fscal time = T.Time()[0]; - L1HitAreaTime areaTime(fAlgo->vGridTime[iSta], T.x[0] * iz, T.y[0] * iz, - (sqrt(Pick_m22 * T.C00) + fAlgo->fMaxRangeX[iSta] + fAlgo->fMaxDZ * abs(T.tx))[0] * iz, - (sqrt(Pick_m22 * T.C11) + fAlgo->fMaxRangeY[iSta] + fAlgo->fMaxDZ * abs(T.ty))[0] * iz, time, - sqrt(timeError2) * 5 + fAlgo->fMaxRangeT[iSta]); + L1HitAreaTime areaTime(fAlgo->vGridTime[iSta], T.X()[0] * iz, T.Y()[0] * iz, + (sqrt(Pick_m22 * T.C00()) + fAlgo->fMaxRangeX[iSta] + fAlgo->fMaxDZ * abs(T.Tx()))[0] * iz, + (sqrt(Pick_m22 * T.C11()) + fAlgo->fMaxRangeY[iSta] + fAlgo->fMaxDZ * abs(T.Ty()))[0] * iz, + time, sqrt(timeError2) * 5 + fAlgo->fMaxRangeT[iSta]); for (L1HitIndex_t ih = 0; (ih < nHits) && ((int) collectedHits.size() < maxNhits); ih++) { // loop over all station hits @@ -655,7 +652,7 @@ void L1TripletConstructor::CollectHits(const L1TrackPar& Tr, const int iSta, con // check y-boundaries //TODO: move hardcoded cuts to parameters - if ((sta.timeInfo) && (T.nTimeMeasurements[0] > 0)) { + if ((sta.timeInfo) && (T.NdfTime()[0] > -2)) { if (fabs(time - hit.T()) > 1.4 * (3.5 * sqrt(timeError2) + hit.RangeT())) continue; if (fabs(time - hit.T()) > 30) continue; } diff --git a/reco/L1/L1Algo/L1TripletConstructor.h b/reco/L1/L1Algo/L1TripletConstructor.h index d3b2d6269f7f742a0382a93b36a3362f7da87790..94aacc43345d6768a4122e8795a1c7db006fb508 100644 --- a/reco/L1/L1Algo/L1TripletConstructor.h +++ b/reco/L1/L1Algo/L1TripletConstructor.h @@ -5,13 +5,13 @@ #ifndef L1TripletConstructor_h #define L1TripletConstructor_h +#include "CaTrackParam.h" #include "CaVector.h" #include "L1Algo.h" #include "L1Field.h" #include "L1Fit.h" #include "L1HitPoint.h" #include "L1Station.h" -#include "L1TrackPar.h" #include "L1Triplet.h" namespace @@ -71,7 +71,7 @@ public: /// Select triplets. Save them into vTriplets. void StoreTriplets(); - void CollectHits(const L1TrackPar& Tr, const int iSta, const double chi2Cut, const int iMC, + void CollectHits(const TrackParamV& Tr, const int iSta, const double chi2Cut, const int iMC, Vector<L1HitIndex_t>& collectedHits, int maxNhits); private: @@ -102,13 +102,13 @@ private: const L1Station* fFld1Sta[3]; // three stations for approximating the field between the left and the right hit L1HitIndex_t fIhitL; - L1TrackPar fTrL; + TrackParamV fTrL; L1FieldRegion fFldL; Vector<L1HitIndex_t> fHitsM_2 {"L1TripletConstructor::fHitsM_2"}; - Vector<L1TrackPar> fTracks_2 {"L1TripletConstructor::fTracks_2"}; + Vector<TrackParamV> fTracks_2 {"L1TripletConstructor::fTracks_2"}; - Vector<L1TrackPar> fTracks_3 {"L1TripletConstructor::fTracks_3"}; + Vector<TrackParamV> fTracks_3 {"L1TripletConstructor::fTracks_3"}; Vector<L1HitIndex_t> fHitsM_3 {"L1TripletConstructor::fHitsM_3"}; Vector<L1HitIndex_t> fHitsR_3 {"L1TripletConstructor::fHitsR_3"}; diff --git a/reco/L1/L1Algo/L1UMeasurementInfo.h b/reco/L1/L1Algo/L1UMeasurementInfo.h index 0a42c8e79401de83d7cf78bab2d57bab0f9cfbf4..2daa40fafe1ef2bebddc6fbbcbd1ba74b61493f1 100644 --- a/reco/L1/L1Algo/L1UMeasurementInfo.h +++ b/reco/L1/L1Algo/L1UMeasurementInfo.h @@ -15,8 +15,8 @@ class L1UMeasurementInfo { public: - cbm::algo::ca::fvec cos_phi = cbm::algo::ca::constants::undef::Fscal; - cbm::algo::ca::fvec sin_phi = cbm::algo::ca::constants::undef::Fscal; + cbm::algo::ca::fvec cos_phi = cbm::algo::ca::constants::Undef<cbm::algo::ca::fvec>; + cbm::algo::ca::fvec sin_phi = cbm::algo::ca::constants::Undef<cbm::algo::ca::fvec>; /// String representation of class contents /// \param indentLevel number of indent characters in the output diff --git a/reco/L1/L1Algo/L1XYMeasurementInfo.h b/reco/L1/L1Algo/L1XYMeasurementInfo.h index 34781242d2153f8ba24fabb990c33ed246093718..a3a3fe7f777de2776d285ab729c9d0c788e69aff 100644 --- a/reco/L1/L1Algo/L1XYMeasurementInfo.h +++ b/reco/L1/L1Algo/L1XYMeasurementInfo.h @@ -9,6 +9,7 @@ #include "CaConstants.h" #include "CaSimd.h" +#include "CaUtils.h" #include "L1Def.h" using namespace cbm::algo::ca; @@ -25,8 +26,8 @@ public: /// Checks, if the fields are NaN bool IsNaN() const { - return constants::undef::IsUndefined(C00) || constants::undef::IsUndefined(C10) - || constants::undef::IsUndefined(C11); + return cbm::algo::ca::utils::IsUndefined(C00) || cbm::algo::ca::utils::IsUndefined(C10) + || cbm::algo::ca::utils::IsUndefined(C11); } /// Serialization function @@ -40,9 +41,9 @@ public: } public: - fvec C00 {constants::undef::Fscal}; - fvec C10 {constants::undef::Fscal}; - fvec C11 {constants::undef::Fscal}; + cbm::algo::ca::fvec C00 {cbm::algo::ca::constants::Undef<cbm::algo::ca::fvec>}; + cbm::algo::ca::fvec C10 {cbm::algo::ca::constants::Undef<cbm::algo::ca::fvec>}; + cbm::algo::ca::fvec C11 {cbm::algo::ca::constants::Undef<cbm::algo::ca::fvec>}; } _fvecalignment; diff --git a/reco/L1/L1Algo/utils/CaUvConverter.h b/reco/L1/L1Algo/utils/CaUvConverter.h index 4e9ca9aa48d7f67d44191afc4971225d09803289..236ab406af46d1b060475743eea88e2fc289869b 100644 --- a/reco/L1/L1Algo/utils/CaUvConverter.h +++ b/reco/L1/L1Algo/utils/CaUvConverter.h @@ -72,17 +72,17 @@ namespace cbm::ca private: - double fcosU {constants::undef::Double}; ///< U coordinate in XY - double fsinU {constants::undef::Double}; + double fcosU {cbm::algo::ca::constants::Undef<double>}; ///< U coordinate in XY + double fsinU {cbm::algo::ca::constants::Undef<double>}; - double fcosV {constants::undef::Double}; ///< V coordinate in XY - double fsinV {constants::undef::Double}; + double fcosV {cbm::algo::ca::constants::Undef<double>}; ///< V coordinate in XY + double fsinV {cbm::algo::ca::constants::Undef<double>}; - double fcosX {constants::undef::Double}; ///< X coordinate in UV - double fsinX {constants::undef::Double}; + double fcosX {cbm::algo::ca::constants::Undef<double>}; ///< X coordinate in UV + double fsinX {cbm::algo::ca::constants::Undef<double>}; - double fcosY {constants::undef::Double}; ///< Y coordinate in UV - double fsinY {constants::undef::Double}; + double fcosY {cbm::algo::ca::constants::Undef<double>}; ///< Y coordinate in UV + double fsinY {cbm::algo::ca::constants::Undef<double>}; }; } // namespace cbm::ca diff --git a/reco/L1/L1Algo/utils/L1AlgoPulls.cxx b/reco/L1/L1Algo/utils/L1AlgoPulls.cxx index c5ac52ef403b4d97db1344f49c9e19b9201d2728..2c5a424102e4550f1f42edbe4981ff72624e90e5 100644 --- a/reco/L1/L1Algo/utils/L1AlgoPulls.cxx +++ b/reco/L1/L1Algo/utils/L1AlgoPulls.cxx @@ -99,32 +99,33 @@ void L1AlgoPulls::Init() } }; -// void L1AlgoPulls::AddVec(L1TrackPar& T_, L1HitIndex_t ih) +// void L1AlgoPulls::AddVec(TrackParamV& T_, L1HitIndex_t ih) // { // for (int i = 0; i < fvecLen; i++) // AddOne(T_,i,ih); // } -void L1AlgoPulls::AddOne(L1TrackPar& T_, int i, L1HitIndex_t ih) +void L1AlgoPulls::AddOne(TrackParamV& T_, int i, L1HitIndex_t ih) { fNAllPulls++; TL1TrackParameters T(T_, i); - if (T_.chi2[i] > csCut * T_.NDF[i]) return; + if (T_.GetChiSq()[i] > csCut * T_.GetNdf()[i]) return; // get error TL1TrackParameters err; - const L1TrackPar& tr = T_; - - if (!(std::isfinite(tr.C00[i]) && tr.C00[i] > 0)) return; - if (!(std::isfinite(tr.C11[i]) && tr.C11[i] > 0)) return; - if (!(std::isfinite(tr.C22[i]) && tr.C22[i] > 0)) return; - if (!(std::isfinite(tr.C33[i]) && tr.C33[i] > 0)) return; - if (!(std::isfinite(tr.C44[i]) && tr.C44[i] > 0)) return; - err.x = sqrt(tr.C00[i]); - err.y = sqrt(tr.C11[i]); - err.tx = sqrt(tr.C22[i]); - err.ty = sqrt(tr.C33[i]); - err.qp = sqrt(tr.C44[i]); + const TrackParamV& tr = T_; + + if (!std::isfinite((fscal) tr.GetXError()[i])) return; + if (!std::isfinite((fscal) tr.GetYError()[i])) return; + if (!std::isfinite((fscal) tr.GetTxError()[i])) return; + if (!std::isfinite((fscal) tr.GetTyError()[i])) return; + if (!std::isfinite((fscal) tr.GetQpError()[i])) return; + + err.x = tr.GetXError()[i]; + err.y = tr.GetYError()[i]; + err.tx = tr.GetTxError()[i]; + err.ty = tr.GetTyError()[i]; + err.qp = tr.GetQpError()[i]; // mc data int iMCP = fL1->GetHitBestMcRefs()[ih]; diff --git a/reco/L1/L1Algo/utils/L1AlgoPulls.h b/reco/L1/L1Algo/utils/L1AlgoPulls.h index 452f9c7114677108ecb12af8347231dbde37989c..9efe5ed209be68c9cb6fcba8f5de27c351f9a018 100644 --- a/reco/L1/L1Algo/utils/L1AlgoPulls.h +++ b/reco/L1/L1Algo/utils/L1AlgoPulls.h @@ -23,9 +23,9 @@ const int NStations = 0; #include <iostream> #include <vector> +#include "CaTrackParam.h" #include "L1Algo.h" #include "L1Def.h" -#include "L1TrackPar.h" using std::cout; using std::endl; @@ -37,7 +37,14 @@ struct TL1TrackParameters { static constexpr int NParameters = 5; TL1TrackParameters() {}; - TL1TrackParameters(L1TrackPar& T, int i) : x(T.x[i]), y(T.y[i]), tx(T.tx[i]), ty(T.ty[i]), qp(T.qp[i]) {}; + + TL1TrackParameters(TrackParamV& T, int i) + : x(T.GetX()[i]) + , y(T.GetY()[i]) + , tx(T.GetTx()[i]) + , ty(T.GetTy()[i]) + , qp(T.GetQp()[i]) {}; + TL1TrackParameters(CbmL1MCPoint& T) : x(T.x), y(T.y), tx(T.px / T.pz), ty(T.py / T.pz), qp(T.q / T.p) {}; double operator[](int i) @@ -83,8 +90,8 @@ public: void Init(); - // void AddVec(L1TrackPar& T, L1HitIndex_t ih); - void AddOne(L1TrackPar& T, int i, L1HitIndex_t ih); + // void AddVec(TrackParamV& T, L1HitIndex_t ih); + void AddOne(TrackParamV& T, int i, L1HitIndex_t ih); void Print(); // fast method to see pulls :) void Build(bool draw = 1); diff --git a/reco/L1/L1Algo/utils/L1CADebug.h b/reco/L1/L1Algo/utils/L1CADebug.h index de5f878e5af540c9ed134c0f9200e661769f0d3e..e6144f242eb495244513b8fbd0728dde7ab79962 100644 --- a/reco/L1/L1Algo/utils/L1CADebug.h +++ b/reco/L1/L1Algo/utils/L1CADebug.h @@ -15,9 +15,9 @@ TH1F *h_pick_res_x[20][3][3], *h_pick_res_y[20][3][3], *h_pick_pull_x[20][3][3], *h_pull_qp[20][3][3]; //TH2F *h_dyvsy[20], *h_dxvsx[20]; -void Pulls(int i, int j, int k, double* mc, L1TrackPar& T, fvec qp0, L1FieldRegion& fld) +void Pulls(int i, int j, int k, double* mc, TrackParamV& T, fvec qp0, L1FieldRegion& fld) { - L1TrackPar tmp_T = T; + TrackParamV tmp_T = T; fvec z = mc[5]; L1Extrapolate(tmp_T, z, qp0, fld); double dx = mc[0] - tmp_T.x[0]; diff --git a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx index 554588137708607a615ce549fd520f50370ed564..4b8d843dc6dd7742a9d449ffd88da4f294881b57 100644 --- a/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx +++ b/reco/L1/OffLineInterface/CbmL1GlobalTrackFinder.cxx @@ -91,15 +91,12 @@ Int_t CbmL1GlobalTrackFinder::CopyL1Tracks(CbmEvent* event) if (event) event->AddData(ECbmDataType::kGlobalTrack, globalTrackIndex); CbmGlobalTrack* t = L1_DYNAMIC_CAST<CbmGlobalTrack*>(fGlobalTracks->At(globalTrackIndex++)); t->SetFlag(0); - FairTrackParam fpar(*t->GetParamFirst()), lpar(*t->GetParamLast()); - cbm::L1Util::CopyTC2TrackParam(&fpar, T.T, T.C); - cbm::L1Util::CopyTC2TrackParam(&lpar, T.TLast, T.CLast); - t->SetParamFirst(&fpar); - t->SetParamLast(&lpar); - t->SetChi2(T.chi2); + t->SetParamFirst(cbm::L1Util::ConvertTrackParam(T)); + t->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast)); + t->SetChi2(T.GetChiSq()); // t->SetLength(T.length); - t->SetNDF(T.NDF); - t->SetPidHypo(T.T[4] >= 0 ? 211 : -211); + t->SetNDF(T.GetNdf()); + t->SetPidHypo(T.GetQp() >= 0 ? 211 : -211); // t->SetTime(T.Tpv[6]); // t->SetTimeError(T.Cpv[20]); //END add global track @@ -157,41 +154,25 @@ Int_t CbmL1GlobalTrackFinder::CopyL1Tracks(CbmEvent* event) // ----- Public method CbmL1TrackToCbmTrack ------------------------------------------ -void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTrack(CbmL1Track l1track, CbmTrack* track, int systemIdT) +void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTrack(CbmL1Track l1track, CbmTrack* track, int /*systemIdT*/) { - Int_t ndf = 0; + track->SetChiSq(l1track.GetChiSq()); + track->SetNDF(l1track.GetNdf()); + //track->SetPreviousTrackId(l1track.GetPreviousTrackId());//??? + //track->SetFlag(l1track.GetQuality());//??? - CbmL1Track* T = &l1track; - - CbmL1* L1 = CbmL1::Instance(); - - for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { - CbmL1HitId& h = L1->fvExternalHits[*ih]; - if (h.detId != systemIdT) continue; - } - ndf -= 5; - if (ndf <= 0) ndf = 1; - track->SetChiSq(T->chi2); - track->SetNDF(ndf); - //track->SetPreviousTrackId(T->GetPreviousTrackId());//??? - //track->SetFlag(T->GetQuality());//??? - - FairTrackParam fpar(*track->GetParamFirst()), lpar(*track->GetParamLast()); - cbm::L1Util::CopyTC2TrackParam(&fpar, T->T, T->C); - cbm::L1Util::CopyTC2TrackParam(&lpar, T->TLast, T->CLast); + track->SetParamFirst(cbm::L1Util::ConvertTrackParam(l1track)); + track->SetParamLast(cbm::L1Util::ConvertTrackParam(l1track.TLast)); } // ------------------------------------------------------------------------- // ----- Public method CbmL1TrackToCbmStsTrack ------------------------------------------ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmStsTrack(CbmL1Track l1track, CbmStsTrack* track) { - Int_t ndf = 0; - - CbmL1Track* T = &l1track; + CbmL1Track& T = l1track; + CbmL1* L1 = CbmL1::Instance(); - CbmL1* L1 = CbmL1::Instance(); - - for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { + for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) { CbmL1HitId& h = L1->fvExternalHits[*ih]; if (h.detId == 0) { track->AddMvdHit(h.hitId); } else if (h.detId == 1) { @@ -199,109 +180,87 @@ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmStsTrack(CbmL1Track l1track, CbmStsT } } - ndf -= 5; - if (ndf <= 0) ndf = 1; - - track->SetFlag(0); - track->SetChiSq(T->chi2); - track->SetNDF(T->NDF); - track->SetPidHypo(T->T[4] >= 0 ? 211 : -211); - track->SetStartTime(T->Tpv[6]); - track->SetStartTimeError(T->Cpv[20]); - track->SetFirstHitTime(T->T[6]); - track->SetFirstHitTimeError(T->C[20]); - track->SetLastHitTime(T->TLast[6]); - track->SetLastHitTimeError(T->CLast[20]); - - FairTrackParam fpar(*track->GetParamFirst()), lpar(*track->GetParamLast()); - cbm::L1Util::CopyTC2TrackParam(&fpar, T->T, T->C); - cbm::L1Util::CopyTC2TrackParam(&lpar, T->TLast, T->CLast); + track->SetChiSq(T.GetChiSq()); + track->SetNDF(T.GetNdf()); + track->SetPidHypo(T.GetQp() >= 0. ? 211 : -211); + track->SetStartTime(T.Tpv.GetTime()); + track->SetStartTimeError(T.Tpv.GetTimeError()); + track->SetFirstHitTime(T.GetTime()); + track->SetFirstHitTimeError(T.GetTimeError()); + track->SetLastHitTime(T.TLast.GetTime()); + track->SetLastHitTimeError(T.TLast.GetTimeError()); + + track->SetParamFirst(cbm::L1Util::ConvertTrackParam(T)); + track->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast)); } // ------------------------------------------------------------------------- // ----- Public method CbmL1TrackToCbmMuchTrack ------------------------------------------ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmMuchTrack(CbmL1Track l1track, CbmMuchTrack* track, int systemIdT) { - Int_t ndf = 0; - CbmL1Track* T = &l1track; + CbmL1Track& T = l1track; CbmL1* L1 = CbmL1::Instance(); - for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { + for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) { CbmL1HitId& h = L1->fvExternalHits[*ih]; if (h.detId != systemIdT) continue; track->AddHit(h.hitId, kMUCHPIXELHIT); } - ndf -= 5; - if (ndf <= 0) ndf = 1; - - track->SetChiSq(T->chi2); - track->SetNDF(ndf); + track->SetChiSq(T.GetChiSq()); + track->SetNDF(T.GetNdf()); //track->SetPreviousTrackId(T->GetPreviousTrackId());//??? //track->SetFlag(T->GetQuality());//??? - FairTrackParam fpar(*track->GetParamFirst()), lpar(*track->GetParamLast()); - cbm::L1Util::CopyTC2TrackParam(&fpar, T->T, T->C); - cbm::L1Util::CopyTC2TrackParam(&lpar, T->TLast, T->CLast); + track->SetParamFirst(cbm::L1Util::ConvertTrackParam(T)); + track->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast)); } // ------------------------------------------------------------------------- // ----- Public method CbmL1TrackToCbmTrdTrack ------------------------------------------ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTrdTrack(CbmL1Track l1track, CbmTrdTrack* track, int systemIdT) { - Int_t ndf = 0; - - CbmL1Track* T = &l1track; + CbmL1Track& T = l1track; CbmL1* L1 = CbmL1::Instance(); - for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { + for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) { CbmL1HitId& h = L1->fvExternalHits[*ih]; if (h.detId != systemIdT) continue; track->AddHit(h.hitId, kTRDHIT); } - ndf -= 5; - if (ndf <= 0) ndf = 1; - - track->SetChiSq(T->chi2); - track->SetNDF(ndf); + track->SetChiSq(T.GetChiSq()); + track->SetNDF(T.GetNdf()); //track->SetPreviousTrackId(T->GetPreviousTrackId());//??? //track->SetFlag(T->GetQuality());//??? - FairTrackParam fpar(*track->GetParamFirst()), lpar(*track->GetParamLast()); - cbm::L1Util::CopyTC2TrackParam(&fpar, T->Tpv, T->Cpv); - cbm::L1Util::CopyTC2TrackParam(&lpar, T->TLast, T->CLast); + track->SetParamFirst(cbm::L1Util::ConvertTrackParam(T.Tpv)); + track->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast)); } // ------------------------------------------------------------------------- // ----- Public method CbmL1TrackToCbmTofTrack ------------------------------------------ void CbmL1GlobalTrackFinder::CbmL1TrackToCbmTofTrack(CbmL1Track l1track, CbmTofTrack* track, int systemIdT) { - Int_t ndf = 0; - - CbmL1Track* T = &l1track; + CbmL1Track& T = l1track; CbmL1* L1 = CbmL1::Instance(); - for (vector<int>::iterator ih = T->Hits.begin(); ih != T->Hits.end(); ++ih) { + for (vector<int>::iterator ih = T.Hits.begin(); ih != T.Hits.end(); ++ih) { CbmL1HitId& h = L1->fvExternalHits[*ih]; if (h.detId != systemIdT) continue; track->AddHit(h.hitId, kTOFHIT); } - ndf -= 5; - if (ndf <= 0) ndf = 1; - - //track->SetChiSq(T->chi2); - //track->SetNDF(ndf); + track->SetChiSq(T.GetChiSq()); + track->SetNDF(T.GetNdf()); //track->SetPreviousTrackId(T->GetPreviousTrackId());//??? //track->SetFlag(T->GetQuality());//??? - //FairTrackParam fpar(*track->GetParamFirst()), lpar(*track->GetParamLast()); - //CbmL1Util::CopyTC2TrackParam(&fpar, T->T, T->C); - //CbmL1Util::CopyTC2TrackParam(&lpar, T->TLast, T->CLast); + track->SetParamFirst(cbm::L1Util::ConvertTrackParam(T)); + track->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast)); } // ------------------------------------------------------------------------- diff --git a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx index dcf6a6193560a54211205ab6aaa2d0e1d080a11b..80a21a974931b56e7ec27683bedfcacc5c540f80 100644 --- a/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx +++ b/reco/L1/OffLineInterface/CbmL1StsTrackFinder.cxx @@ -76,20 +76,17 @@ Int_t CbmL1StsTrackFinder::CopyL1Tracks(CbmEvent* event) if (event) event->AddData(ECbmDataType::kStsTrack, trackIndex); CbmStsTrack* t = L1_DYNAMIC_CAST<CbmStsTrack*>(fTracks->At(trackIndex++)); t->SetFlag(0); - FairTrackParam fpar(*t->GetParamFirst()), lpar(*t->GetParamLast()); - cbm::L1Util::CopyTC2TrackParam(&fpar, T.T, T.C); - cbm::L1Util::CopyTC2TrackParam(&lpar, T.TLast, T.CLast); - t->SetParamFirst(&fpar); - t->SetParamLast(&lpar); - t->SetChiSq(T.chi2); - t->SetNDF(T.NDF); - t->SetPidHypo(T.T[4] >= 0 ? 211 : -211); - t->SetStartTime(T.Tpv[6]); - t->SetStartTimeError(T.Cpv[20]); - t->SetFirstHitTime(T.T[6]); - t->SetFirstHitTimeError(T.C[20]); - t->SetLastHitTime(T.TLast[6]); - t->SetLastHitTimeError(T.CLast[20]); + t->SetParamFirst(cbm::L1Util::ConvertTrackParam(T)); + t->SetParamLast(cbm::L1Util::ConvertTrackParam(T.TLast)); + t->SetChiSq(T.GetChiSq()); + t->SetNDF(T.GetNdf()); + t->SetPidHypo(T.GetQp() >= 0 ? 211 : -211); + t->SetStartTime(T.Tpv.GetTime()); + t->SetStartTimeError(T.Tpv.GetTimeError()); + t->SetFirstHitTime(T.GetTime()); + t->SetFirstHitTimeError(T.GetTimeError()); + t->SetLastHitTime(T.TLast.GetTime()); + t->SetLastHitTimeError(T.TLast.GetTimeError()); for (vector<int>::iterator ih = it->Hits.begin(); ih != it->Hits.end(); ++ih) { CbmL1HitId& h = L1->fvExternalHits[*ih]; diff --git a/reco/L1/catools/CaToolsDef.h b/reco/L1/catools/CaToolsDef.h index d2607ec3b0da0ce268c35ef97e0d382885fde1ad..f51ab8745ffaac2cadcc8141ed7b0b4510773173 100644 --- a/reco/L1/catools/CaToolsDef.h +++ b/reco/L1/catools/CaToolsDef.h @@ -14,10 +14,10 @@ namespace cbm::ca::tools { - namespace undef = cbm::algo::ca::constants::undef; - namespace phys = cbm::algo::ca::constants::phys; - namespace clrs = cbm::algo::ca::constants::clrs; - namespace ca = cbm::algo::ca; + namespace constants = cbm::algo::ca::constants; + namespace phys = cbm::algo::ca::constants::phys; + namespace clrs = cbm::algo::ca::constants::clrs; + namespace ca = cbm::algo::ca; } // namespace cbm::ca::tools #endif // CaToolsDef_h diff --git a/reco/L1/catools/CaToolsLinkKey.h b/reco/L1/catools/CaToolsLinkKey.h index 3689c65bdb7c1fb84b06580e53bd38899591de01..1e101f301f4baac849ed24eb8c2c78af3b418c01 100644 --- a/reco/L1/catools/CaToolsLinkKey.h +++ b/reco/L1/catools/CaToolsLinkKey.h @@ -29,9 +29,9 @@ namespace cbm::ca::tools return lhs.fFile == rhs.fFile && lhs.fEvent == rhs.fEvent && lhs.fIndex == rhs.fIndex; } - int fIndex = undef::Int; ///< Index of MC point/track in external data structures - int fEvent = undef::Int; ///< Index of MC event - int fFile = undef::Int; ///< Index of MC file + int fIndex = cbm::algo::ca::constants::Undef<int>; ///< Index of MC point/track in external data structures + int fEvent = cbm::algo::ca::constants::Undef<int>; ///< Index of MC event + int fFile = cbm::algo::ca::constants::Undef<int>; ///< Index of MC file }; } // namespace ca::tools diff --git a/reco/L1/catools/CaToolsMCData.h b/reco/L1/catools/CaToolsMCData.h index d562e9954a1d71b9969de87187f6f0e744c74ce0..d871dc6757ce6bc8b78d18448fcef08075099a66 100644 --- a/reco/L1/catools/CaToolsMCData.h +++ b/reco/L1/catools/CaToolsMCData.h @@ -22,6 +22,10 @@ enum class L1DetectorID; +#include "CaSimd.h" + +using namespace cbm::algo::ca; //TODO: remove + namespace cbm::ca::tools { /// This class represents a package for tracking-related data diff --git a/reco/L1/catools/CaToolsMCPoint.h b/reco/L1/catools/CaToolsMCPoint.h index bda000cee018d1b200a582cb7b275021f7344a28..ecaf567af5bb0890ab389016fd1d85d226fa836f 100644 --- a/reco/L1/catools/CaToolsMCPoint.h +++ b/reco/L1/catools/CaToolsMCPoint.h @@ -16,10 +16,15 @@ #include "CaToolsLinkKey.h" #include "CaVector.h" +using namespace cbm::algo::ca; //TODO: remove + enum class L1DetectorID; namespace cbm::ca::tools { + namespace constants = cbm::algo::ca::constants; + namespace phys = cbm::algo::ca::constants::phys; + /// @brief Class describes a unified MC-point, used in CA tracking QA analysis /// class MCPoint { @@ -331,29 +336,30 @@ namespace cbm::ca::tools private: /// \brief Position at reference z of station [cm] - std::array<double, 3> fPos = {undef::Double, undef::Double, undef::Double}; + std::array<double, 3> fPos = {constants::Undef<double>, constants::Undef<double>, constants::Undef<double>}; /// \brief Position at entrance to station [cm] - std::array<double, 3> fPosIn = {undef::Double, undef::Double, undef::Double}; + std::array<double, 3> fPosIn = {constants::Undef<double>, constants::Undef<double>, constants::Undef<double>}; /// \brief Position at exit of station [cm] - std::array<double, 3> fPosOut = {undef::Double, undef::Double, undef::Double}; + std::array<double, 3> fPosOut = {constants::Undef<double>, constants::Undef<double>, constants::Undef<double>}; /// \brief Momentum at reference z of station [GeV/c] - std::array<double, 3> fMom = {undef::Double, undef::Double, undef::Double}; + std::array<double, 3> fMom = {constants::Undef<double>, constants::Undef<double>, constants::Undef<double>}; /// \brief Momentum at entrance to station [GeV/c] - std::array<double, 3> fMomIn = {undef::Double, undef::Double, undef::Double}; + std::array<double, 3> fMomIn = {constants::Undef<double>, constants::Undef<double>, constants::Undef<double>}; /// \brief Momentum at exit of station [cm] - std::array<double, 3> fMomOut = {undef::Double, undef::Double, undef::Double}; + std::array<double, 3> fMomOut = {constants::Undef<double>, constants::Undef<double>, constants::Undef<double>}; - double fMass = undef::Double; ///< Particle mass [GeV/c2] - double fCharge = undef::Double; ///< Particle charge [e] - double fTime = undef::Double; ///< Point time [ns] + double fMass = constants::Undef<double>; ///< Particle mass [GeV/c2] + double fCharge = constants::Undef<double>; ///< Particle charge [e] + double fTime = constants::Undef<double>; ///< Point time [ns] - LinkKey fLinkKey = {undef::Int, undef::Int, undef::Int}; ///< Link key of point + LinkKey fLinkKey = {constants::Undef<int>, constants::Undef<int>, constants::Undef<int>}; ///< Link key of point - int fPdgCode = undef::Int; ///< Particle PDG code - int fId = undef::Int; ///< Index of MC point in the external MC point container - int fTrackId = undef::Int; ///< Index of associated MC track in CA internal track container within TS/event - int fMotherId = undef::Int; ///< Index of mother track in CA internal data structures (within event/TS) - int fStationId = undef::Int; ///< Global index of active tracking station + int fPdgCode = constants::Undef<int>; ///< Particle PDG code + int fId = constants::Undef<int>; ///< Index of MC point in the external MC point container + int fTrackId = + constants::Undef<int>; ///< Index of associated MC track in CA internal track container within TS/event + int fMotherId = constants::Undef<int>; ///< Index of mother track in CA internal data structures (within event/TS) + int fStationId = constants::Undef<int>; ///< Global index of active tracking station L1DetectorID fDetectorId; ///< Detector ID of MC point diff --git a/reco/L1/catools/CaToolsMCTrack.h b/reco/L1/catools/CaToolsMCTrack.h index 2db0454b23c9babdcda7d808688016226a5eb3d4..3ec771e8649677a68103990ecfe3bb713346d738 100644 --- a/reco/L1/catools/CaToolsMCTrack.h +++ b/reco/L1/catools/CaToolsMCTrack.h @@ -25,6 +25,9 @@ class CbmL1HitDebugInfo; namespace cbm::ca::tools { class MCPoint; + + namespace constants = cbm::algo::ca::constants; + class MCTrack { public: /// Default constructor @@ -331,35 +334,37 @@ namespace cbm::ca::tools // ** Data variables ** // **************************** - double fMass = undef::Double; ///< Particle mass [GeV/c2] - double fCharge = undef::Double; ///< Particle charge [e] - double fTime = undef::Double; ///< Time of track [cm] + double fMass = constants::Undef<double>; ///< Particle mass [GeV/c2] + double fCharge = constants::Undef<double>; ///< Particle charge [e] + double fTime = constants::Undef<double>; ///< Time of track [cm] - std::array<double, 3> fPos = {undef::Double, undef::Double, undef::Double}; ///< Track vertex components [cm] - std::array<double, 3> fMom = {undef::Double, undef::Double, undef::Double}; ///< Momentum components [GeV/c] + std::array<double, 3> fPos = {constants::Undef<double>, constants::Undef<double>, + constants::Undef<double>}; ///< Track vertex components [cm] + std::array<double, 3> fMom = {constants::Undef<double>, constants::Undef<double>, + constants::Undef<double>}; ///< Momentum components [GeV/c] - int fPdgCode = undef::Int; ///< PDG encoding - unsigned fProcId = undef::Uint; ///< Process ID (from ROOT::TProcessID) + int fPdgCode = constants::Undef<int>; ///< PDG encoding + unsigned fProcId = constants::Undef<unsigned>; ///< Process ID (from ROOT::TProcessID) // Track address - int fId = undef::Int; ///< Index of MC track in internal container for TS/event - int fMotherId = undef::Int; ///< Index of mother MC track in the external tracks container + int fId = constants::Undef<int>; ///< Index of MC track in internal container for TS/event + int fMotherId = constants::Undef<int>; ///< Index of mother MC track in the external tracks container - LinkKey fLinkKey = {undef::Int, undef::Int, - undef::Int}; ///< A link key of this track in the external data structures + LinkKey fLinkKey = {constants::Undef<int>, constants::Undef<int>, + constants::Undef<int>}; ///< A link key of this track in the external data structures bool fIsSignal = false; ///< If the track comes from signal bool fIsReconstructable = false; ///< If track is reconstructable bool fIsAdditional = false; ///< If track is not reconstructable, but still interesting // Arrangement of hits and points within the stations - int fNofConsStationsWithHit = undef::Int; ///< Number of consecutive stations with hits - int fNofConsStationsWithPoint = undef::Int; ///< Number of consecutive stations with points - int fTotNofStationsWithHit = undef::Int; ///< Total number of stations with hits - int fTotNofStationsWithPoint = undef::Int; ///< Total number of stations with MC points - int fMaxNofPointsOnStation = undef::Int; ///< Max number of MC points on a station - int fMaxNofPointsOnSensor = undef::Int; ///< Max number of MC points with same Z (means on same sensor) - int fMaxNofHitsOnStation = undef::Int; ///< Max number of hits on a station + int fNofConsStationsWithHit = constants::Undef<int>; ///< Number of consecutive stations with hits + int fNofConsStationsWithPoint = constants::Undef<int>; ///< Number of consecutive stations with points + int fTotNofStationsWithHit = constants::Undef<int>; ///< Total number of stations with hits + int fTotNofStationsWithPoint = constants::Undef<int>; ///< Total number of stations with MC points + int fMaxNofPointsOnStation = constants::Undef<int>; ///< Max number of MC points on a station + int fMaxNofPointsOnSensor = constants::Undef<int>; ///< Max number of MC points with same Z (means on same sensor) + int fMaxNofHitsOnStation = constants::Undef<int>; ///< Max number of hits on a station ca::Vector<int> fvPointIndexes = {"ca::tools::fvPointIndexes"}; ///< Indexes of MC points in ext.container ca::Vector<int> fvHitIndexes = {"ca::tools::fvHitIndexes"}; ///< Indexes of hits in int.container diff --git a/reco/L1/catools/CaToolsMaterialHelper.cxx b/reco/L1/catools/CaToolsMaterialHelper.cxx index c14ac8f87686c5414b2016ad34bab9385904d41f..18a854e7d94e920880f2434a632b5ed0af65eba7 100644 --- a/reco/L1/catools/CaToolsMaterialHelper.cxx +++ b/reco/L1/catools/CaToolsMaterialHelper.cxx @@ -372,5 +372,5 @@ L1Material MaterialHelper::GenerateMaterialMap(double zRef, double zMin, double LOG(info) << "ca::tools::MaterialHelper: shooted " << nRays << " rays. Each ray crossed " << nCrosses * 1. / nRays << " material boundaries in average"; - return std::move(matBudget); + return matBudget; } diff --git a/reco/L1/qa/CbmCaHitQaData.h b/reco/L1/qa/CbmCaHitQaData.h index 08be69d94ee3d3cb6b7fd738aa6ad11ff38fab58..cd2fa8af1c6d110401f0ea846f69f86baa6e42c5 100644 --- a/reco/L1/qa/CbmCaHitQaData.h +++ b/reco/L1/qa/CbmCaHitQaData.h @@ -205,7 +205,7 @@ namespace cbm::ca int GetStationID() const { return fStationID; } /// @brief Resets data fields - void Reset() { this->operator=(std::move(HitQaData())); } + void Reset() { this->operator=(HitQaData()); } /// @brief Sets hit x-coordinate error /// @param hitDx Hit x-coordinate error [cm] diff --git a/reco/L1/qa/CbmCaInputQaSetup.h b/reco/L1/qa/CbmCaInputQaSetup.h index 31dc28335639519cb70751896c13aaf81cd8edb9..4a344f36cb4993a159006cc38d0c1884caeb067b 100644 --- a/reco/L1/qa/CbmCaInputQaSetup.h +++ b/reco/L1/qa/CbmCaInputQaSetup.h @@ -13,7 +13,6 @@ #include "CbmL1DetectorID.h" #include "CbmMCDataArray.h" #include "CbmMCDataObject.h" -#include "CbmMCEventList.h" #include "CbmMuchPixelHit.h" #include "CbmMuchPoint.h" #include "CbmMuchTrackingInterface.h" @@ -92,7 +91,6 @@ namespace cbm::ca DetIdArr_t<TClonesArray*> fvpBrHits = {{nullptr}}; ///< Input branch for hits DetIdArr_t<CbmMCDataArray*> fvpBrPoints = {{nullptr}}; ///< Input branch for MC points - CbmMCEventList* fpMCEventList = nullptr; ///< Pointer to MC event list CbmMCDataObject* fpMCEventHeader = nullptr; ///< Pointer to MC event header std::unique_ptr<L1Parameters> fpParameters = nullptr; ///< Pointer to CA parameters object std::string fsParametersFilename = ""; ///< Filename for the tracking parameters diff --git a/reco/L1/qa/CbmCaOutputQa.cxx b/reco/L1/qa/CbmCaOutputQa.cxx index 4d9d11ff4a65751146833e84a1eece427ba145e9..61d9694bb7ac91de16a0c991d95ac946a13b0e80 100644 --- a/reco/L1/qa/CbmCaOutputQa.cxx +++ b/reco/L1/qa/CbmCaOutputQa.cxx @@ -636,7 +636,7 @@ void OutputQa::DrawEvent() constexpr Marker_t kMarkerHitWPoint = 24; constexpr Marker_t kMarkerHitWOPoint = 28; constexpr double kFontSize = 0.035; - constexpr Width_t kLineWidth = 1.5; + constexpr Width_t kLineWidth = 1; constexpr Style_t kLineMCTrackReconstructed = 9; constexpr Style_t kLineMCTrackNotReconstructed = 10; constexpr Style_t kLineRecoTrackGhost = 2; diff --git a/reco/L1/qa/CbmCaTrackFitQa.cxx b/reco/L1/qa/CbmCaTrackFitQa.cxx index f80f0c138e1dab702bd84648217b6b307f8b3be2..2f4125cf3347e95e7ef61fddadb24798e399f3f2 100644 --- a/reco/L1/qa/CbmCaTrackFitQa.cxx +++ b/reco/L1/qa/CbmCaTrackFitQa.cxx @@ -129,7 +129,7 @@ void TrackFitQa::Init() // --------------------------------------------------------------------------------------------------------------------- // -void TrackFitQa::Fill(const L1TrackPar& trPar, const tools::MCPoint& mcPoint, bool bTimeMeasured, double weight) +void TrackFitQa::Fill(const TrackParamV& trPar, const tools::MCPoint& mcPoint, bool bTimeMeasured, double weight) { // Probably, a bottleneck L1Fit fitter; @@ -141,20 +141,20 @@ void TrackFitQa::Fill(const L1TrackPar& trPar, const tools::MCPoint& mcPoint, bo fieldRegion.SetUseOriginalField(); // Precised magnetic field is used fitter.Extrapolate(mcPoint.GetZOut(), fieldRegion); - const L1TrackPar& trParExtr = fitter.Tr(); // Track parameters extrapolated to given MC point + const TrackParamV& trParExtr = fitter.Tr(); // Track parameters extrapolated to given MC point // ** Time-independent measurements ** - FillResAndPull(ETrackParType::kX, trParExtr.GetX(), trParExtr.GetXErr(), mcPoint.GetXOut(), weight); - FillResAndPull(ETrackParType::kY, trParExtr.GetY(), trParExtr.GetYErr(), mcPoint.GetYOut(), weight); - FillResAndPull(ETrackParType::kTX, trParExtr.GetTx(), trParExtr.GetTxErr(), mcPoint.GetTxOut(), weight); - FillResAndPull(ETrackParType::kTY, trParExtr.GetTy(), trParExtr.GetTyErr(), mcPoint.GetTyOut(), weight); - FillResAndPull(ETrackParType::kQP, trParExtr.GetQp(), trParExtr.GetQpErr(), mcPoint.GetQpOut(), weight); + FillResAndPull(ETrackParType::kX, trParExtr.GetX()[0], trParExtr.GetXError()[0], mcPoint.GetXOut(), weight); + FillResAndPull(ETrackParType::kY, trParExtr.GetY()[0], trParExtr.GetYError()[0], mcPoint.GetYOut(), weight); + FillResAndPull(ETrackParType::kTX, trParExtr.GetTx()[0], trParExtr.GetTxError()[0], mcPoint.GetTxOut(), weight); + FillResAndPull(ETrackParType::kTY, trParExtr.GetTy()[0], trParExtr.GetTyError()[0], mcPoint.GetTyOut(), weight); + FillResAndPull(ETrackParType::kQP, trParExtr.GetQp()[0], trParExtr.GetQpError()[0], mcPoint.GetQpOut(), weight); // TODO: in which point do we calculate MC parameters (central, entrance, exit)?? - double recoP = std::fabs(mcPoint.GetCharge() / trParExtr.GetQp()); // reco mom. (with MC charge) - double resP = recoP - mcPoint.GetPOut(); // residual of total momentum - double resPhi = trParExtr.GetPhi() - mcPoint.GetPhiOut(); // residual of azimuthal angle - double resTheta = trParExtr.GetTheta() - mcPoint.GetThetaOut(); // residual of polar angle + double recoP = std::fabs(mcPoint.GetCharge() / trParExtr.GetQp()[0]); // reco mom. (with MC charge) + double resP = recoP - mcPoint.GetPOut(); // residual of total momentum + double resPhi = trParExtr.GetPhi()[0] - mcPoint.GetPhiOut(); // residual of azimuthal angle + double resTheta = trParExtr.GetTheta()[0] - mcPoint.GetThetaOut(); // residual of polar angle resPhi = std::atan2(std::sin(resPhi), std::cos(resPhi)); // overflow over (-pi, pi] protection @@ -164,8 +164,9 @@ void TrackFitQa::Fill(const L1TrackPar& trPar, const tools::MCPoint& mcPoint, bo // ** Time-dependent measurements ** if (bTimeMeasured) { - FillResAndPull(ETrackParType::kTIME, trParExtr.GetTime(), trParExtr.GetTimeErr(), mcPoint.GetTime(), weight); - FillResAndPull(ETrackParType::kVI, trParExtr.GetInvSpeed(), trParExtr.GetInvSpeedErr(), mcPoint.GetInvSpeedOut(), + FillResAndPull(ETrackParType::kTIME, trParExtr.GetTime()[0], trParExtr.GetTimeError()[0], mcPoint.GetTime(), + weight); + FillResAndPull(ETrackParType::kVI, trParExtr.GetVi()[0], trParExtr.GetViError()[0], mcPoint.GetInvSpeedOut(), weight); } } diff --git a/reco/L1/qa/CbmCaTrackFitQa.h b/reco/L1/qa/CbmCaTrackFitQa.h index b854bdb30dd49920fa7d1e2e20042dc068b2a0a8..6d626c981369c722e3baf6cf6bc02095861e41fa 100644 --- a/reco/L1/qa/CbmCaTrackFitQa.h +++ b/reco/L1/qa/CbmCaTrackFitQa.h @@ -98,7 +98,7 @@ namespace cbm::ca /// @note To be called in the loop over reconstructed tracks full sample /// @param iTrkReco Index of reconstructed track /// @param weight Weight - void Fill(const L1TrackPar& trPar, const tools::MCPoint& mcPoint, bool bTimeMeasured, double weight = 1); + void Fill(const TrackParamV& trPar, const tools::MCPoint& mcPoint, bool bTimeMeasured, double weight = 1); /// @brief Sets particle mass, used for fitting a track /// @param mass Particle mass [GeV/c2] diff --git a/reco/L1/qa/CbmCaTrackTypeQa.cxx b/reco/L1/qa/CbmCaTrackTypeQa.cxx index f25c0717d78e160ac9774a94b01b9c4bf90b69fd..de706d1e420e680edf9151c773c0515908170ec2 100644 --- a/reco/L1/qa/CbmCaTrackTypeQa.cxx +++ b/reco/L1/qa/CbmCaTrackTypeQa.cxx @@ -215,7 +215,7 @@ void TrackTypeQa::FillRecoTrack(int iTrkReco, double weight) int iPfst = (*fpvHits)[iHfst].GetBestMcPointId(); if (iPfst > -1) { const auto& mcPoint = fpMCData->GetPoint(iPfst); - L1TrackPar trPar(recoTrack.T, recoTrack.C); + TrackParamV trPar(recoTrack); fpFitQaFirstHit->Fill(trPar, mcPoint, isTimeFitted, weight); } @@ -224,7 +224,7 @@ void TrackTypeQa::FillRecoTrack(int iTrkReco, double weight) int iPlst = (*fpvHits)[iHlst].GetBestMcPointId(); if (iPlst > -1) { const auto& mcPoint = fpMCData->GetPoint(iPlst); - L1TrackPar trPar(recoTrack.TLast, recoTrack.CLast); + TrackParamV trPar(recoTrack.TLast); fpFitQaLastHit->Fill(trPar, mcPoint, isTimeFitted, weight); } } diff --git a/reco/L1/utils/CbmCaIdealHitProducerDet.h b/reco/L1/utils/CbmCaIdealHitProducerDet.h index 9b58a81df48da6a1a00bc5f8ade3a29b8e83472b..4eae7c1852888d8ebfa037e346f97ad23c05c8e5 100644 --- a/reco/L1/utils/CbmCaIdealHitProducerDet.h +++ b/reco/L1/utils/CbmCaIdealHitProducerDet.h @@ -60,6 +60,8 @@ namespace cbm::ca { + namespace constants = cbm::algo::ca::constants; + /// @brief Ideal hit producer class /// /// @@ -128,12 +130,12 @@ namespace cbm::ca /// @brief A structure to keep hit adjustment/creation settings for each station struct HitParameters { - double fPhiU {undef::Double}; ///< Angle of the first independent measured coordinate [rad] - double fPhiV {undef::Double}; ///< Angle of the second independent measured coordinate [rad] + double fPhiU {constants::Undef<double>}; ///< Angle of the first independent measured coordinate [rad] + double fPhiV {constants::Undef<double>}; ///< Angle of the second independent measured coordinate [rad] - double fDu = undef::Double; ///< Error of u-coordinate measurement [cm] - double fDv = undef::Double; ///< Error of v-coordinate measurement [cm] - double fDt = undef::Double; ///< Error of time measurement [ns] + double fDu {constants::Undef<double>}; ///< Error of u-coordinate measurement [cm] + double fDv {constants::Undef<double>}; ///< Error of v-coordinate measurement [cm] + double fDt {constants::Undef<double>}; ///< Error of time measurement [ns] /// PDFs selection for different quantities /// - 0: Bounded Gaussian distribution