Skip to content

Commit 4368703

Browse files
committed
Add the utility codes for the MFT-MUON matching
1 parent 79ea4b7 commit 4368703

File tree

7 files changed

+581
-0
lines changed

7 files changed

+581
-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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
12+
o2_add_library(MFTMuonMatching
13+
SOURCES src/MftMuonMatchingUtils.cxx
14+
src/MatchingTagAndProbe.cxx
15+
PUBLIC_LINK_LIBRARIES O2::CCDB
16+
O2::DataFormatsMFT
17+
O2::DetectorsCalibration
18+
O2::DetectorsDCS
19+
O2::GlobalTracking
20+
O2::ReconstructionDataFormats
21+
O2::DataFormatsGlobalTracking
22+
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: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
12+
/// @file MatchingTagAndProbe.h
13+
14+
#ifndef O2_MFT_MATCHING_TAG_AND_PROBE_H
15+
#define O2_MFT_MATCHING_TAG_AND_PROBE_H
16+
17+
/// @file MatchingTagAndProbe.h
18+
/// @brief Template-based utility for finding Tag and Probe pairs in ALICE O2.
19+
20+
#include <cmath>
21+
22+
#include "Math/SMatrix.h"
23+
#include "Math/SVector.h"
24+
25+
#include "TLorentzVector.h"
26+
27+
#include "Framework/Logger.h"
28+
#include "DetectorsBase/Propagator.h"
29+
#include "MCHTracking/TrackExtrap.h"
30+
#include "ReconstructionDataFormats/GlobalFwdTrack.h"
31+
#include "GlobalTracking/MatchGlobalFwd.h"
32+
33+
namespace o2
34+
{
35+
namespace mft
36+
{
37+
38+
using SMatrix55 = ROOT::Math::SMatrix<double, 5, 5, ROOT::Math::MatRepSym<double, 5>>;
39+
using SMatrix5 = ROOT::Math::SVector<Double_t, 5>;
40+
41+
template <typename MUON, typename Collision>
42+
class MatchingTagAndProbe
43+
{
44+
private:
45+
inline void fillCovarianceArray(MUON const& muontrack, float cov[15]) const
46+
{
47+
cov[0] = muontrack.cXX();
48+
cov[1] = muontrack.cXY();
49+
cov[2] = muontrack.cYY();
50+
cov[3] = muontrack.cPhiX();
51+
cov[4] = muontrack.cPhiY();
52+
cov[5] = muontrack.cPhiPhi();
53+
cov[6] = muontrack.cTglX();
54+
cov[7] = muontrack.cTglY();
55+
cov[8] = muontrack.cTglPhi();
56+
cov[9] = muontrack.cTglTgl();
57+
cov[10] = muontrack.c1PtX();
58+
cov[11] = muontrack.c1PtY();
59+
cov[12] = muontrack.c1PtPhi();
60+
cov[13] = muontrack.c1PtTgl();
61+
cov[14] = muontrack.c1Pt21Pt2();
62+
}
63+
64+
inline void setTagAndProbe()
65+
{
66+
if (muontrack1.pt() > muontrack2.pt()) {
67+
tagIdx = 0;
68+
probeIdx = 1;
69+
} else {
70+
tagIdx = 1;
71+
probeIdx = 0;
72+
}
73+
}
74+
75+
o2::dataformats::GlobalFwdTrack muontrack_at_pv[2];
76+
TLorentzVector mDimuon;
77+
MUON muontrack1;
78+
MUON muontrack2;
79+
Collision collision;
80+
int tagIdx, probeIdx;
81+
int16_t mQ;
82+
83+
const float mMu = 0.105658; // Muon mass (GeV/c^2)
84+
85+
inline o2::dataformats::GlobalFwdTrack propagateMUONtoPV(MUON const& muontrack) const
86+
{
87+
const double mz = muontrack.z();
88+
const double mchi2 = muontrack.chi2();
89+
const float mx = muontrack.x();
90+
const float my = muontrack.y();
91+
const float mphi = muontrack.phi();
92+
const float mtgl = muontrack.tgl();
93+
const float m1pt = muontrack.signed1Pt();
94+
95+
float cov[15];
96+
97+
fillCovarianceArray(muontrack, cov);
98+
99+
SMatrix5 tpars(mx, my, mphi, mtgl, m1pt);
100+
SMatrix55 tcovs(cov, cov + 15);
101+
102+
o2::track::TrackParCovFwd parcovmuontrack{mz, tpars, tcovs, mchi2};
103+
104+
o2::dataformats::GlobalFwdTrack gtrack;
105+
gtrack.setParameters(tpars);
106+
gtrack.setZ(parcovmuontrack.getZ());
107+
gtrack.setCovariances(tcovs);
108+
109+
o2::globaltracking::MatchGlobalFwd mMatching;
110+
auto mchtrack = mMatching.FwdtoMCH(gtrack);
111+
112+
o2::mch::TrackExtrap::extrapToVertex(mchtrack,
113+
collision.posX(),
114+
collision.posY(),
115+
collision.posZ(),
116+
collision.covXX(),
117+
collision.covYY());
118+
119+
auto fwdtrack = mMatching.MCHtoFwd(mchtrack);
120+
o2::dataformats::GlobalFwdTrack extrap_muontrack;
121+
extrap_muontrack.setParameters(fwdtrack.getParameters());
122+
extrap_muontrack.setZ(fwdtrack.getZ());
123+
extrap_muontrack.setCovariances(fwdtrack.getCovariances());
124+
125+
return extrap_muontrack;
126+
}
127+
128+
public:
129+
MatchingTagAndProbe(const MUON& muon1, const MUON& muon2, const Collision& coll) : muontrack1(muon1), muontrack2(muon2), collision(coll), tagIdx(-1), probeIdx(-1), mQ(0)
130+
{
131+
mQ = muontrack1.sign() + muontrack2.sign();
132+
setTagAndProbe();
133+
}
134+
135+
inline void calcMuonPairAtPV()
136+
{
137+
muontrack_at_pv[0] = propagateMUONtoPV(muontrack1);
138+
muontrack_at_pv[1] = propagateMUONtoPV(muontrack2);
139+
TLorentzVector vMuon1, vMuon2;
140+
vMuon1.SetPtEtaPhiM(muontrack_at_pv[0].getPt(),
141+
muontrack_at_pv[0].getEta(),
142+
muontrack_at_pv[0].getPhi(),
143+
mMu);
144+
vMuon2.SetPtEtaPhiM(muontrack_at_pv[1].getPt(),
145+
muontrack_at_pv[1].getEta(),
146+
muontrack_at_pv[1].getPhi(),
147+
mMu);
148+
mDimuon = vMuon1 + vMuon2;
149+
}
150+
151+
inline int getTagMuonIndex() const { return tagIdx; }
152+
inline int getProbeMuonIndex() const { return probeIdx; }
153+
inline float getMass() const { return mDimuon.M(); }
154+
inline float getPt() const { return mDimuon.Pt(); }
155+
inline float getRap() const { return mDimuon.Rapidity(); }
156+
inline int16_t getCharge() const { return mQ; }
157+
inline const o2::dataformats::GlobalFwdTrack& getMuonAtPV(int idx) const
158+
{
159+
return muontrack_at_pv[idx];
160+
}
161+
}; // end of class MatchingTagAndProbe
162+
163+
} // namespace mft
164+
} // namespace o2
165+
166+
#endif // O2_MFT_MATCHING_TAG_AND_PROBE_H

0 commit comments

Comments
 (0)