Skip to content

Commit d303c90

Browse files
committed
Add MFT Matching Utils v0
1 parent 9a4e708 commit d303c90

File tree

7 files changed

+560
-0
lines changed

7 files changed

+560
-0
lines changed

Detectors/ITSMFT/MFT/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ add_subdirectory(calibration)
1818
add_subdirectory(condition)
1919
add_subdirectory(assessment)
2020
add_subdirectory(alignment)
21+
add_subdirectory(matching)
2122

2223
o2_data_file(COPY data DESTINATION Detectors/Geometry/MFT/)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
o2_add_library(MFTMuonMatching
12+
SOURCES src/MftMuonMatchingUtils.cxx
13+
src/MatchingTagAndProbe.cxx
14+
PUBLIC_LINK_LIBRARIES O2::CCDB
15+
O2::DataFormatsMFT
16+
O2::DetectorsCalibration
17+
O2::DetectorsDCS
18+
O2::GlobalTracking
19+
O2::ReconstructionDataFormats
20+
O2::DataFormatsGlobalTracking
21+
Microsoft.GSL::GSL)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- doxy
2+
\page refMFTMuonMatching Matching
3+
/doxy -->
4+
# MFT Matching
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#ifndef O2_MFT_MATCHING_TAG_AND_PROBE_H
2+
#define O2_MFT_MATCHING_TAG_AND_PROBE_H
3+
4+
/// @file MatchingTagAndProbe.h
5+
/// @brief Template-based utility for finding Tag and Probe pairs in ALICE O2.
6+
7+
#include <cmath>
8+
9+
#include "Math/SMatrix.h"
10+
#include "Math/SVector.h"
11+
12+
#include "TLorentzVector.h"
13+
14+
#include "Framework/Logger.h"
15+
#include "DetectorsBase/Propagator.h"
16+
#include "MCHTracking/TrackExtrap.h"
17+
#include "ReconstructionDataFormats/GlobalFwdTrack.h"
18+
#include "GlobalTracking/MatchGlobalFwd.h"
19+
20+
namespace o2
21+
{
22+
namespace mft
23+
{
24+
25+
using SMatrix55 = ROOT::Math::SMatrix<double, 5, 5, ROOT::Math::MatRepSym<double, 5>>;
26+
using SMatrix5 = ROOT::Math::SVector<Double_t, 5>;
27+
28+
template <typename MUON, typename Collision>
29+
class MatchingTagAndProbe
30+
{
31+
private:
32+
inline void fillCovarianceArray(MUON const& muontrack, float cov[15]) const
33+
{
34+
cov[0] = muontrack.cXX();
35+
cov[1] = muontrack.cXY();
36+
cov[2] = muontrack.cYY();
37+
cov[3] = muontrack.cPhiX();
38+
cov[4] = muontrack.cPhiY();
39+
cov[5] = muontrack.cPhiPhi();
40+
cov[6] = muontrack.cTglX();
41+
cov[7] = muontrack.cTglY();
42+
cov[8] = muontrack.cTglPhi();
43+
cov[9] = muontrack.cTglTgl();
44+
cov[10] = muontrack.c1PtX();
45+
cov[11] = muontrack.c1PtY();
46+
cov[12] = muontrack.c1PtPhi();
47+
cov[13] = muontrack.c1PtTgl();
48+
cov[14] = muontrack.c1Pt21Pt2();
49+
}
50+
51+
inline void setTagAndProbe()
52+
{
53+
if (muontrack1.pt() > muontrack2.pt()) {
54+
tagIdx = 0;
55+
probeIdx = 1;
56+
} else {
57+
tagIdx = 1;
58+
probeIdx = 0;
59+
}
60+
}
61+
62+
o2::dataformats::GlobalFwdTrack muontrack_at_pv[2];
63+
TLorentzVector mDimuon;
64+
MUON muontrack1;
65+
MUON muontrack2;
66+
Collision collision;
67+
int tagIdx, probeIdx;
68+
int16_t mQ;
69+
70+
const float mMu = 0.105658; // Muon mass (GeV/c^2)
71+
72+
inline o2::dataformats::GlobalFwdTrack propagateMUONtoPV(MUON const& muontrack) const
73+
{
74+
const double mz = muontrack.z();
75+
const double mchi2 = muontrack.chi2();
76+
const float mx = muontrack.x();
77+
const float my = muontrack.y();
78+
const float mphi = muontrack.phi();
79+
const float mtgl = muontrack.tgl();
80+
const float m1pt = muontrack.signed1Pt();
81+
82+
float cov[15];
83+
84+
fillCovarianceArray(muontrack, cov);
85+
86+
SMatrix5 tpars(mx, my, mphi, mtgl, m1pt);
87+
SMatrix55 tcovs(cov, cov + 15);
88+
89+
o2::track::TrackParCovFwd parcovmuontrack{mz, tpars, tcovs, mchi2};
90+
91+
o2::dataformats::GlobalFwdTrack gtrack;
92+
gtrack.setParameters(tpars);
93+
gtrack.setZ(parcovmuontrack.getZ());
94+
gtrack.setCovariances(tcovs);
95+
96+
o2::globaltracking::MatchGlobalFwd mMatching;
97+
auto mchtrack = mMatching.FwdtoMCH(gtrack);
98+
99+
o2::mch::TrackExtrap::extrapToVertex(mchtrack,
100+
collision.posX(),
101+
collision.posY(),
102+
collision.posZ(),
103+
collision.covXX(),
104+
collision.covYY());
105+
106+
auto fwdtrack = mMatching.MCHtoFwd(mchtrack);
107+
o2::dataformats::GlobalFwdTrack extrap_muontrack;
108+
extrap_muontrack.setParameters(fwdtrack.getParameters());
109+
extrap_muontrack.setZ(fwdtrack.getZ());
110+
extrap_muontrack.setCovariances(fwdtrack.getCovariances());
111+
112+
return extrap_muontrack;
113+
}
114+
115+
public:
116+
MatchingTagAndProbe(const MUON& muon1, const MUON& muon2, const Collision& coll) : muontrack1(muon1), muontrack2(muon2), collision(coll), tagIdx(-1), probeIdx(-1), mQ(0)
117+
{
118+
mQ = muontrack1.sign() + muontrack2.sign();
119+
setTagAndProbe();
120+
}
121+
122+
inline void calcMuonPairAtPV()
123+
{
124+
muontrack_at_pv[0] = propagateMUONtoPV(muontrack1);
125+
muontrack_at_pv[1] = propagateMUONtoPV(muontrack2);
126+
TLorentzVector vMuon1, vMuon2;
127+
vMuon1.SetPtEtaPhiM(muontrack_at_pv[0].getPt(),
128+
muontrack_at_pv[0].getEta(),
129+
muontrack_at_pv[0].getPhi(),
130+
mMu);
131+
vMuon2.SetPtEtaPhiM(muontrack_at_pv[1].getPt(),
132+
muontrack_at_pv[1].getEta(),
133+
muontrack_at_pv[1].getPhi(),
134+
mMu);
135+
mDimuon = vMuon1 + vMuon2;
136+
}
137+
138+
inline int getTagMuonIndex() const { return tagIdx; }
139+
inline int getProbeMuonIndex() const { return probeIdx; }
140+
inline float getMass() const { return mDimuon.M(); }
141+
inline float getPt() const { return mDimuon.Pt(); }
142+
inline float getRap() const { return mDimuon.Rapidity(); }
143+
inline int16_t getCharge() const { return mQ; }
144+
inline const o2::dataformats::GlobalFwdTrack& getMuonAtPV(int idx) const
145+
{
146+
return muontrack_at_pv[idx];
147+
}
148+
}; // end of class MatchingTagAndProbe
149+
150+
} // namespace mft
151+
} // namespace o2
152+
153+
#endif // O2_MFT_MATCHING_TAG_AND_PROBE_H

0 commit comments

Comments
 (0)