Project
Loading...
Searching...
No Matches
TrackMCH.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
18
19#include <cmath>
20#include <limits>
21#include <fmt/format.h>
22#include <string>
23#include <iostream>
24
25namespace o2
26{
27namespace mch
28{
29
30//__________________________________________________________________________
31TrackMCH::TrackMCH(double z, const TMatrixD& param, const TMatrixD& cov, double chi2, int firstClIdx, int nClusters,
32 double zAtMID, const TMatrixD& paramAtMID, const TMatrixD& covAtMID, const Time& time)
33 : mZ(z), mChi2(chi2), mClusRef(firstClIdx, nClusters), mZAtMID(zAtMID), mTimeMUS(time)
34{
37 setCovariances(cov);
38 setParametersAtMID(paramAtMID);
39 setCovariancesAtMID(covAtMID);
40}
41
42//__________________________________________________________________________
43double TrackMCH::getPx() const
44{
46 return getPz() * mParam[1];
47}
48
49//__________________________________________________________________________
50double TrackMCH::getPy() const
51{
53 return getPz() * mParam[3];
54}
55
56//__________________________________________________________________________
57double TrackMCH::getPz() const
58{
60 if (mParam[4] != 0.) {
61 return -std::abs(1. / mParam[4]) / std::sqrt(1. + mParam[3] * mParam[3]); // spectro. (z<0)
62 } else {
63 return -std::numeric_limits<float>::max() / std::sqrt(1. + mParam[3] * mParam[3] + mParam[1] * mParam[1]);
64 }
65}
66
67//__________________________________________________________________________
68double TrackMCH::getP() const
69{
71 if (mParam[4] != 0.) {
72 return std::abs(1. / mParam[4]) / std::sqrt(1. + mParam[3] * mParam[3]) *
73 std::sqrt(1. + mParam[3] * mParam[3] + mParam[1] * mParam[1]);
74 } else {
75 return std::numeric_limits<float>::max();
76 }
77}
78
79//__________________________________________________________________________
80void TrackMCH::setCovariances(const TMatrixD& src, double (&dest)[SCovSize])
81{
83 for (int i = 0; i < SNParams; i++) {
84 for (int j = 0; j <= i; j++) {
85 dest[SCovIdx[i][j]] = src(i, j);
86 }
87 }
88}
89
90//__________________________________________________________________________
91InteractionRecord TrackMCH::getMeanIR(uint32_t refOrbit) const
92{
93 InteractionRecord startIR(0, refOrbit);
94 auto trackBCinTF = std::llround(mTimeMUS.getTimeStamp() / constants::lhc::LHCBunchSpacingMUS);
95 return startIR + trackBCinTF;
96}
97
98std::ostream& operator<<(std::ostream& os, const o2::mch::TrackMCH& t)
99{
100 os << asString(t);
101 return os;
102}
103
104std::string asString(const o2::mch::TrackMCH& t)
105{
106 auto pt = std::sqrt(t.getPx() * t.getPx() + t.getPy() * t.getPy());
107 return fmt::format("({:s}) p {:7.2f} pt {:7.2f} nclusters: {} z: {:7.2f}", t.getSign() == -1 ? "-" : "+", t.getP(), pt, t.getNClusters(), t.getZ());
108}
109
110} // namespace mch
111} // namespace o2
int16_t time
Definition RawEventData.h:4
int32_t i
uint32_t j
Definition RawData.h:0
Definition of the MCH track.
int nClusters
MCH track external format.
Definition TrackMCH.h:34
TrackMCH()=default
void setParametersAtMID(const TMatrixD &param)
set the track parameters on the MID side
Definition TrackMCH.h:87
InteractionRecord getMeanIR(uint32_t refOrbit) const
interaction record corresponding to the mean track time
Definition TrackMCH.cxx:91
double getZ() const
get the track z position where the parameters are evaluated
Definition TrackMCH.h:55
void setCovariances(const TMatrixD &cov)
set the track parameter covariances
Definition TrackMCH.h:77
double getPz() const
Definition TrackMCH.cxx:57
double getP() const
Definition TrackMCH.cxx:68
double getPx() const
Definition TrackMCH.cxx:43
void setParameters(const TMatrixD &param)
set the track parameters
Definition TrackMCH.h:70
int getNClusters() const
get the number of clusters attached to the track
Definition TrackMCH.h:106
void setCovariancesAtMID(const TMatrixD &cov)
set the track parameter covariances on the MID side
Definition TrackMCH.h:94
double getPy() const
Definition TrackMCH.cxx:50
short getSign() const
get the muon sign
Definition TrackMCH.h:65
GLenum src
Definition glcorearb.h:1767
GLenum GLfloat param
Definition glcorearb.h:271
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
constexpr double LHCBunchSpacingMUS
std::ostream & operator<<(std::ostream &os, const o2::dataformats::MeanVertexObject &o)
std::string asString(const o2::mch::TrackMCH &t)
Definition TrackMCH.cxx:104
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...