FairShip
Loading...
Searching...
No Matches
RecoVertex.cxx
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-3.0-or-later
2// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3// Collaboration
4
5#include "RecoVertex.h"
6
7#include <algorithm>
8#include <cmath>
9#include <stdexcept>
10
11namespace SHiP {
12
13RecoVertex::RecoVertex(const TVector3& position,
14 const std::array<Double_t, 6>& covariance, Double_t chi2,
15 Double_t nDoF)
16 : TObject(),
17 m_x(position.X()),
18 m_y(position.Y()),
19 m_z(position.Z()),
20 m_err_x(std::sqrt(std::max(0.0, covariance[0]))),
21 m_err_y(std::sqrt(std::max(0.0, covariance[3]))),
22 m_err_z(std::sqrt(std::max(0.0, covariance[5]))),
23 m_chi2(chi2),
24 m_nDoF(nDoF),
25 m_cov_elements(covariance.begin(), covariance.end()) {}
26
27void RecoVertex::AddTrack(Int_t trackId, const TVector3& momentum,
28 const std::array<Double_t, 6>& momentumCovariance) {
29 m_trackIds.push_back(trackId);
30 m_trackPx.push_back(momentum.X());
31 m_trackPy.push_back(momentum.Y());
32 m_trackPz.push_back(momentum.Z());
33 m_trackCovP.insert(m_trackCovP.end(), momentumCovariance.begin(),
34 momentumCovariance.end());
35}
36
37std::array<Double_t, 6> RecoVertex::GetTrackMomentumCovariance(size_t i) const {
38 if (i >= m_trackIds.size()) {
39 throw std::out_of_range("RecoVertex: track index out of range");
40 }
41 std::array<Double_t, 6> covariance{};
42 std::copy_n(m_trackCovP.begin() + 6 * i, 6, covariance.begin());
43 return covariance;
44}
45
46} // namespace SHiP
void AddTrack(Int_t trackId, const TVector3 &momentum, const std::array< Double_t, 6 > &momentumCovariance)
Double_t chi2() const
Definition RecoVertex.h:48
Double_t m_err_z
Definition RecoVertex.h:69
std::vector< Double_t > m_trackCovP
Momentum covariances of all tracks, 6 elements per track.
Definition RecoVertex.h:79
Double_t nDoF() const
Definition RecoVertex.h:49
Double_t m_nDoF
Definition RecoVertex.h:71
std::array< Double_t, 6 > GetTrackMomentumCovariance(size_t i) const
Momentum covariance of track i, as 6 upper-triangle elements.
Double_t m_err_x
Definition RecoVertex.h:67
RecoVertex()=default
std::vector< Double_t > m_trackPx
Definition RecoVertex.h:75
std::vector< Double_t > m_trackPz
Definition RecoVertex.h:77
std::vector< Int_t > m_trackIds
Definition RecoVertex.h:74
Double_t m_chi2
Definition RecoVertex.h:70
std::vector< Double_t > m_cov_elements
Definition RecoVertex.h:73
Double_t m_err_y
Definition RecoVertex.h:68
std::vector< Double_t > m_trackPy
Definition RecoVertex.h:76