ATLAS Offline Software
Loading...
Searching...
No Matches
MuonCalibIntHighpTSmearTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Framework include(s):
8
9// Local include(s):
10#include <cmath>
11#include "TRandom3.h"
12
17
18
19namespace CP
20{
21
25
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 {
42
43 }
44
45
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
62 {
63 // Do nothing, if it is data
64 if(mu.CB.isData) return 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 {
73 return CorrectionCode::Ok;
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:
95 return CorrectionCode::Ok;
96 }
97
99 {
101 return sys.find(systematic) != sys.end();
102 }
103
105 {
107 // No systematics for now
108 return result;
109 }
110
112
114 {
115 // No systematics current supported for this tool
116 return StatusCode::SUCCESS;
117 }
118
120 if (raw_mst_category < 0) {
122 } else if (raw_mst_category & IMuonSelectionTool::CategoryZero)
124 else if (raw_mst_category & IMuonSelectionTool::CategoryOne)
126 else if (raw_mst_category & IMuonSelectionTool::CategoryTwo)
128 else if (raw_mst_category & IMuonSelectionTool::CategoryThree)
130 else if (raw_mst_category & IMuonSelectionTool::CategoryFour)
132 else
134 }
135
136
137
138} // namespace CP
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
Handle class for reading from StoreGate.
Return value from object correction CP tools.
@ Ok
The correction was done successfully.
virtual CorrectionCode applyCorrection(MCP::MuonObj &mu) const =0
Declare the interface that the class provides.
MCP::MST_Categories ConvertToMacroCategory(const int raw_mst_category) const
MuonCalibIntHighpTSmearTool(const std::string &name)
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
Gaudi::Property< std::string > m_release
std::map< MCP::DataYear, HighpTConstMap > m_MS_AlignedAndCorrected_p1
std::map< MCP::DataYear, HighpTConstMap > m_MS_Misaligned_p2
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
virtual SystematicSet recommendedSystematics() const override
the list of all systematics this tool recommends to use
std::map< MCP::DataYear, HighpTConstMap > m_MS_Misaligned_p1
virtual SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
std::map< MCP::DataYear, HighpTConstMap > m_MS_AlignedAndCorrected_p2
virtual ASG_TOOL_CLASS3(MuonCalibIntHighpTSmearTool, CP::IMuonCalibIntTool, CP::ISystematicsTool, CP::IReentrantSystematicsTool) public bool isAffectedBySystematic(const SystematicVariation &systematic) const override
Declare the interface that this class provides.
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.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
@ Ok
The correction was done successfully.
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58
Select isolated Photons, Electrons and Muons.
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, 7 > dataYearList
Definition EnumDef.h:34
MST_Categories
Definition EnumDef.h:31