ATLAS Offline Software
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 
19 namespace CP
20 {
21 
23  {
24  }
25 
27  {
28  // Greet the user:
29  ATH_MSG_INFO("Initializing MuonCalibIntHighpTSmearTool");
30 
31  // Get the m_eventinfo container
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);
67 
68  ATH_MSG_VERBOSE("Doing high pT smearing: "<<int(cat)<<" for year: "<<int(mu.CB.year)<<" raw: "<<mu.raw_mst_category);
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
python.Dso.registry
registry
Definition: Control/AthenaServices/python/Dso.py:159
MCP::MST_Categories::Three
@ Three
MCP::MST_Categories::Undefined
@ Undefined
CP::IMuonSelectionTool::CategoryOne
@ CategoryOne
Definition: IMuonSelectionTool.h:44
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
MCP::MST_Categories::Two
@ Two
CP::MuonCalibIntHighpTSmearTool::ConvertToMacroCategory
MCP::MST_Categories ConvertToMacroCategory(const int raw_mst_category) const
Definition: MuonCalibIntHighpTSmearTool.cxx:119
CP::MuonCalibIntHighpTSmearTool::recommendedSystematics
virtual SystematicSet recommendedSystematics() const override
the list of all systematics this tool recommends to use
Definition: MuonCalibIntHighpTSmearTool.cxx:111
CP::MuonCalibIntHighpTSmearTool::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: MuonCalibIntHighpTSmearTool.h:59
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
asg
Definition: DataHandleTestTool.h:28
CP::IMuonSelectionTool::CategoryZero
@ CategoryZero
Definition: IMuonSelectionTool.h:43
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::IMuonSelectionTool::CategoryThree
@ CategoryThree
Definition: IMuonSelectionTool.h:46
CP::IMuonSelectionTool::CategoryTwo
@ CategoryTwo
Definition: IMuonSelectionTool.h:45
CP::IMuonCalibIntTool::applyCorrection
virtual CorrectionCode applyCorrection(MCP::MuonObj &mu) const =0
Declare the interface that the class provides.
CalibInitializer.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CP::SystematicVariation
Definition: SystematicVariation.h:47
python.AtlRunQueryAMI.year
year
Definition: AtlRunQueryAMI.py:226
MCP::CalibInitializer::createHighpTCorrMap
std::map< MST_Categories, std::shared_ptr< CalibContainer > > createHighpTCorrMap(DataYear dataYear, const std::string &type, const std::string &recommendationPath, const std::string &param)
Definition: CalibInitializer.cxx:59
CP::MuonCalibIntHighpTSmearTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: MuonCalibIntHighpTSmearTool.cxx:26
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
IMuonSelectionTool.h
CP::MuonCalibIntHighpTSmearTool::m_MS_AlignedAndCorrected_p1
std::map< MCP::DataYear, HighpTConstMap > m_MS_AlignedAndCorrected_p1
Definition: MuonCalibIntHighpTSmearTool.h:69
CP::MuonCalibIntHighpTSmearTool::m_MS_AlignedAndCorrected_p2
std::map< MCP::DataYear, HighpTConstMap > m_MS_AlignedAndCorrected_p2
Definition: MuonCalibIntHighpTSmearTool.h:70
MCP::MST_Categories::Four
@ Four
MuonCalibIntHighpTSmearTool.h
MCP::MST_Categories
MST_Categories
Definition: EnumDef.h:31
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
CP::MuonCalibIntHighpTSmearTool::m_MS_Misaligned_p1
std::map< MCP::DataYear, HighpTConstMap > m_MS_Misaligned_p1
Definition: MuonCalibIntHighpTSmearTool.h:67
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MCP::MST_Categories::One
@ One
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
CP::MuonCalibIntHighpTSmearTool::m_release
Gaudi::Property< std::string > m_release
Definition: MuonCalibIntHighpTSmearTool.h:62
MCP::MST_Categories::Zero
@ Zero
PathResolver.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ReadHandle.h
Handle class for reading from StoreGate.
EnumDef.h
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::MuonCalibIntHighpTSmearTool::isAffectedBySystematic
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.
Definition: MuonCalibIntHighpTSmearTool.cxx:98
CP::SystematicRegistry
This module implements the central registry for handling systematic uncertainties with CP tools.
Definition: SystematicRegistry.h:25
CP::MuonCalibIntHighpTSmearTool::affectingSystematics
virtual SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
Definition: MuonCalibIntHighpTSmearTool.cxx:104
CP::MuonCalibIntHighpTSmearTool::m_MS_Misaligned_p2
std::map< MCP::DataYear, HighpTConstMap > m_MS_Misaligned_p2
Definition: MuonCalibIntHighpTSmearTool.h:68
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CP::IMuonSelectionTool::CategoryFour
@ CategoryFour
Definition: IMuonSelectionTool.h:47
MCP::MuonObj
Definition: MuonObj.h:126
CP::MuonCalibIntHighpTSmearTool::MuonCalibIntHighpTSmearTool
MuonCalibIntHighpTSmearTool(const std::string &name)
Definition: MuonCalibIntHighpTSmearTool.cxx:22
CP::MuonCalibIntHighpTSmearTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
Definition: MuonCalibIntHighpTSmearTool.cxx:113
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25