ATLAS Offline Software
Loading...
Searching...
No Matches
TruthRelatedMuonPlotOrganizer.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
12
14
15namespace Muon {
16
18 PlotBase* pParent, const std::string& sDir, bool doBinnedResolutionPlots,
19 std::vector<int> selPlots)
20 : PlotBase(pParent, sDir)
21// Truth related plots
22{
23
24 if (selPlots.empty()) {
25 for (unsigned int i = 0; i < MAX_TRUTHRELATEDPLOTCLASS; i++) {
26 m_selPlots.push_back(i);
27 }
28 } else {
29 m_selPlots = std::move(selPlots);
30 }
31
32 for (auto p : m_selPlots) {
33 switch (p) {
34 case TRK_MATCHEDTRUE:
35 m_oMatchedPlots = std::make_unique<Trk::ParamPlots>(
36 this, "/kinematics/", "Matched Muons");
37 break;
38 case TRK_MATCHEDRECO:
39 m_oMatchedRecoPlots = std::make_unique<Trk::ParamPlots>(
40 this, "/kinematicsReco/", "Matched Muons");
41 break;
42 case TRK_MSHITDIFF:
43 m_oMSHitDiffPlots =
44 std::make_unique<Trk::MSHitDiffPlots>(this, "/hits/");
45 break;
46 case MUON_HITDIFF:
47 m_oMuonHitDiffSummaryPlots =
48 std::make_unique<Muon::MuonHitDiffSummaryPlots>(this,
49 "/hits/");
50 break;
51 case MUON_TRUTHHIT:
52 m_oMuonTruthHitPlots =
53 std::make_unique<Muon::MuonTruthHitPlots>(this,
54 "/truthHits/");
55 break;
56 case MUON_RESOL:
57 m_oMuonResolutionPlots =
58 std::make_unique<Muon::MuonResolutionPlots>(
59 this, "/resolution/", "", doBinnedResolutionPlots);
60 break;
62 m_oDefParamPullPlots = std::make_unique<Trk::DefParamPullPlots>(
63 this, "/pulls/", "");
64 break;
65 case MUON_PULLSTAIL:
66 m_oMomentumTruthPullPlots_Tail =
67 std::make_unique<Muon::MomentumTruthPullPlots>(
68 this, "/momentumPulls/", "Tail");
69 break;
71 m_oMomentumTruthPullPlots_NoTail =
72 std::make_unique<Muon::MomentumTruthPullPlots>(
73 this, "/momentumPulls/", "NoTail");
74 break;
75 case MUON_PARAMELOSS:
76 m_oMatchedRecoElossPlots =
77 std::make_unique<Muon::MuonParamElossPlots>(this,
78 "/Eloss/");
79 break;
80 }
81 }
82}
83TruthRelatedMuonPlotOrganizer::~TruthRelatedMuonPlotOrganizer() = default;
84
86 const xAOD::TruthParticle& truthMu, const xAOD::Muon& mu, float weight) {
87 if (m_oMatchedPlots) {
88 m_oMatchedPlots->fill(truthMu, weight);
89 }
91 m_oMuonHitDiffSummaryPlots->fill(mu, truthMu, weight);
92 }
94 m_oMuonTruthHitPlots->fill(mu, weight);
95 }
96
97 // for eloss
99 m_oMatchedRecoElossPlots->fill(truthMu, mu, weight);
100 }
101
102 // Tracking related plots
103 const xAOD::TrackParticle* primaryTrk =
104 mu.trackParticle(xAOD::Muon::Primary);
105 // const xAOD::TrackParticle* meTrk =
106 // mu.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle);
107
108 if (!primaryTrk) {
109 return;
110 }
112 m_oMatchedRecoPlots->fill(*primaryTrk, weight);
113 }
114 if (m_oMSHitDiffPlots) {
115 m_oMSHitDiffPlots->fill(*primaryTrk, truthMu, weight);
116 }
118 m_oMuonResolutionPlots->fill(*primaryTrk, truthMu, weight);
119 }
121 m_oDefParamPullPlots->fill(*primaryTrk, truthMu, weight);
122 }
123
125 // muon spectrometer track at MS entry (not extrapolated)
126 const xAOD::TrackParticle* msTrk = mu.trackParticle(xAOD::Muon::TrackParticleType::MuonSpectrometerTrackParticle);
127 #ifndef XAOD_ANALYSIS
128 float eloss = 0;
129 if (mu.parameter(eloss, xAOD::Muon::ParamDef::EnergyLoss)) {
130 if (mu.energyLossType() != xAOD::Muon::EnergyLossType::Tail) { // to test MEASURED energy loss
132 m_oMomentumTruthPullPlots_NoTail->fill(mu, msTrk, truthMu,
133 weight);
134 }
135 } else {
138 mu, msTrk, truthMu,
139 weight); // to test PARAMETRIZED energy loss
140 }
141 }
142 }
143#endif // not XAOD_ANALYSIS
144 }
145}
146
148 const xAOD::TrackParticle& muTP,
149 float weight) {
150 // Tracking related plots
151 if (m_oMatchedPlots) {
152 m_oMatchedPlots->fill(truthMu, weight);
153 }
154 if (m_oMatchedRecoPlots) {
155 m_oMatchedRecoPlots->fill(muTP, weight);
156 }
157 if (m_oDefParamPullPlots) {
158 m_oDefParamPullPlots->fill(muTP, truthMu, weight);
159 }
160 if (m_oMuonResolutionPlots) {
161 m_oMuonResolutionPlots->fill(muTP, truthMu, weight);
162 }
163 if (m_oMSHitDiffPlots) {
164 m_oMSHitDiffPlots->fill(muTP, truthMu, weight);
165 }
166}
167
168} // namespace Muon
Helper class to provide constant type-safe access to aux data.
ElementLink< xAOD::TruthParticleContainer > TruthLink
std::unique_ptr< Muon::MuonHitDiffSummaryPlots > m_oMuonHitDiffSummaryPlots
std::unique_ptr< Trk::DefParamPullPlots > m_oDefParamPullPlots
std::unique_ptr< Trk::ParamPlots > m_oMatchedRecoPlots
std::unique_ptr< Trk::ParamPlots > m_oMatchedPlots
std::unique_ptr< Muon::MuonResolutionPlots > m_oMuonResolutionPlots
std::unique_ptr< Muon::MuonParamElossPlots > m_oMatchedRecoElossPlots
void fill(const xAOD::TruthParticle &truthMu, const xAOD::Muon &mu, float weight=1.0)
TruthRelatedMuonPlotOrganizer(PlotBase *pParent, const std::string &sDir, bool doBinnedResolutionPlots, std::vector< int > selPlots={})
std::unique_ptr< Muon::MomentumTruthPullPlots > m_oMomentumTruthPullPlots_NoTail
std::unique_ptr< Trk::MSHitDiffPlots > m_oMSHitDiffPlots
std::unique_ptr< Muon::MuonTruthHitPlots > m_oMuonTruthHitPlots
std::unique_ptr< Muon::MomentumTruthPullPlots > m_oMomentumTruthPullPlots_Tail
PlotBase(PlotBase *parent, std::string_view sDir)
Definition PlotBase.cxx:29
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.
Muon_v1 Muon
Reference the current persistent version: