ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalibIntHighpTSmearTool.cxx File Reference
Include dependency graph for MuonCalibIntHighpTSmearTool.cxx:

Go to the source code of this file.

Functions

namespace ADD_CMODE (CP)

Function Documentation

◆ ADD_CMODE()

namespace ADD_CMODE ( CP )

Definition at line 1 of file MuonCalibIntHighpTSmearTool.cxx.

20{
21
22 MuonCalibIntHighpTSmearTool::MuonCalibIntHighpTSmearTool(const std::string &name) : asg::AsgTool(name)
23 {
24 }
25
26 StatusCode MuonCalibIntHighpTSmearTool::initialize()
27 {
28 // Greet the user:
29 ATH_MSG_INFO("Initializing MuonCalibIntHighpTSmearTool");
30
31 // Get the m_eventinfo container
32 ATH_CHECK(m_eventInfo.initialize());
33
34
35 // Load the constants
36 for(const auto& year: MCP::dataYearList)
37 {
38 m_MS_Misaligned_p1[year] = MCP::CalibInitializer::createHighpTCorrMap(year, "Misaligned", m_release, "p1");
39 m_MS_Misaligned_p2[year] = MCP::CalibInitializer::createHighpTCorrMap(year, "Misaligned", m_release, "p2");
40 m_MS_AlignedAndCorrected_p1[year] = MCP::CalibInitializer::createHighpTCorrMap(year, "AlignedAndCorrected", m_release, "p1");
41 m_MS_AlignedAndCorrected_p2[year] = MCP::CalibInitializer::createHighpTCorrMap(year, "AlignedAndCorrected", m_release, "p2");
42
43 }
44
45
46 if (!applySystematicVariation(CP::SystematicSet()))
47 {
48 ATH_MSG_ERROR("Unable to run with no systematic");
49 return StatusCode::FAILURE;
50 }
52 if (registry.registerSystematics(*this) != StatusCode::SUCCESS)
53 {
54 ATH_MSG_ERROR("Unkown systematic list");
55 return StatusCode::FAILURE;
56 }
57 // Return gracefully:
58 return StatusCode::SUCCESS;
59 }
60
61 CP::CorrectionCode MuonCalibIntHighpTSmearTool::applyCorrection(MCP::MuonObj& mu) const
62 {
63 // Do nothing, if it is data
64 if(mu.CB.isData) return CP::CorrectionCode::Ok;
65
66 auto cat = ConvertToMacroCategory(mu.raw_mst_category.value());
67
68 ATH_MSG_VERBOSE("Doing high pT smearing: "<<int(cat)<<" for year: "<<int(mu.CB.year)<<" raw: "<<mu.raw_mst_category.value());
69
70 // If undefined, don't perform any smearing
72 {
74 }
75
76
77 double MS_Misaligned_p1 = m_MS_Misaligned_p1.at(mu.CB.year).at(cat)->getCalibConstant(mu.CB);
78 double MS_Misaligned_p2 = m_MS_Misaligned_p2.at(mu.CB.year).at(cat)->getCalibConstant(mu.CB);
79 double reso_Misaligned = std::hypot(MS_Misaligned_p1, MS_Misaligned_p2 * mu.CB.calib_pt);
80
81 double MS_AlignedAndCorrected_p1 = m_MS_AlignedAndCorrected_p1.at(mu.CB.year).at(cat)->getCalibConstant(mu.CB);
82 double MS_AlignedAndCorrected_p2 = m_MS_AlignedAndCorrected_p2.at(mu.CB.year).at(cat)->getCalibConstant(mu.CB);
83
84 double reso_AlignedAndCorrected = std::sqrt(std::pow(MS_AlignedAndCorrected_p1, 2) + std::pow(MS_AlignedAndCorrected_p2 * mu.CB.calib_pt, 2));
85
86 double smearDeltaCBOnly = 0;
87 if (reso_Misaligned > reso_AlignedAndCorrected) smearDeltaCBOnly = std::sqrt(std::pow(reso_Misaligned, 2) - std::pow(reso_AlignedAndCorrected, 2));
88
89
90 double smeared_combined_pt = mu.CB.calib_pt * (1. + mu.rnd_g_highPt * smearDeltaCBOnly);
91
92 mu.CB.calib_pt = smeared_combined_pt;
93
94 // Return gracefully:
96 }
97
98 bool MuonCalibIntHighpTSmearTool::isAffectedBySystematic(const CP::SystematicVariation &systematic) const
99 {
100 CP::SystematicSet sys = affectingSystematics();
101 return sys.find(systematic) != sys.end();
102 }
103
104 CP::SystematicSet MuonCalibIntHighpTSmearTool::affectingSystematics() const
105 {
107 // No systematics for now
108 return result;
109 }
110
111 CP::SystematicSet MuonCalibIntHighpTSmearTool::recommendedSystematics() const { return affectingSystematics(); }
112
113 StatusCode MuonCalibIntHighpTSmearTool::applySystematicVariation(const CP::SystematicSet&)
114 {
115 // No systematics current supported for this tool
116 return StatusCode::SUCCESS;
117 }
118
119 MCP::MST_Categories MuonCalibIntHighpTSmearTool::ConvertToMacroCategory(const int raw_mst_category) const {
120 if (raw_mst_category < 0) {
122 } else if (raw_mst_category & CP::IMuonSelectionTool::CategoryZero)
124 else if (raw_mst_category & CP::IMuonSelectionTool::CategoryOne)
126 else if (raw_mst_category & CP::IMuonSelectionTool::CategoryTwo)
128 else if (raw_mst_category & CP::IMuonSelectionTool::CategoryThree)
130 else if (raw_mst_category & CP::IMuonSelectionTool::CategoryFour)
132 else
134 }
135
136
137
138} // namespace ADD_CMODE(CP)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
Return value from object correction CP tools.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
::StatusCode StatusCode
StatusCode definition for legacy code.
std::map< MST_Categories, std::shared_ptr< CalibContainer > > createHighpTCorrMap(DataYear dataYear, const std::string &type, const std::string &recommendationPath, const std::string &param)
static constexpr std::array< MCP::DataYear, 8 > dataYearList
Definition EnumDef.h:34
MST_Categories
Definition EnumDef.h:31