ATLAS Offline Software
MuonCalibTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MCAST_MUONCALIBTOOL_H
6 #define MCAST_MUONCALIBTOOL_H
7 
8 // Framework include(s):
10 #include "AsgTools/AnaToolHandle.h"
11 #include "AsgTools/AsgTool.h"
17 
20 
21 
22 namespace CP {
23 
25  public asg::AsgTool {
26  // Create a proper constructor for Athena
29 
30  public:
31  enum CalibMode {
32  //this should be sync with PhysicsAnalysis/Algorithms/MuonAnalysisAlgorithms/python/MuonAnalysisConfig.py
33  noOption = -1, // <--- default
34  correctData_CB = 0,
35  correctData_IDMS = 1,
36  notCorrectData_IDMS = 2,
37  notCorrectData_CB = 3,
38  userDefined = 99,
39  };
40 
41  // Interface methods that must be defined
42  // Interface - Apply the correction on a modifyable object
43  virtual CorrectionCode applyCorrection(xAOD::Muon& mu) const override;
44  // Interface - Create a corrected copy from a constant muon
45  virtual CorrectionCode correctedCopy(const xAOD::Muon& input, xAOD::Muon*& output) const override;
46  // Interface - Is the tool affected by a specific systematic?
47  virtual bool isAffectedBySystematic(const SystematicVariation& systematic) const override;
48  // Interface - Which systematics have an effect on the tool's behaviour?
49  virtual SystematicSet affectingSystematics() const override;
50  // Interface - Systematics to be used for physics analysis
51  virtual SystematicSet recommendedSystematics() const override;
52  // Interface - Use specific systematic
53  virtual StatusCode applySystematicVariation(const SystematicSet& systConfig) override;
54  // Interface - get the expected resolution of the muon
55  virtual double expectedResolution(const std::string& DetType, const xAOD::Muon& mu, const bool addMCCorrectionSmearing) const override;
56  // Interface - get the expected resolution of the muon
57  virtual double expectedResolution(const int& DetType, const xAOD::Muon& mu, const bool addMCCorrectionSmearing) const override;
58  // Interface - Expert method to apply the MC correction on a modifyable trackParticle for ID- or MS-only corrections
59  virtual CorrectionCode applyCorrectionTrkOnly(xAOD::TrackParticle& inTrk, const int DetType) const override;
60 
61  public:
62  // Constructor
63  MuonCalibTool(const std::string& name);
64 
65  // Destructor
66  virtual ~MuonCalibTool() = default;
67 
68  virtual StatusCode initialize() override;
69 
70 
71  protected:
72  // Event info
73  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfo{this, "EventInfoContName", "EventInfo", "event info key"};
74 
75  Gaudi::Property<bool> m_isRun3{this, "IsRun3Geo", false, "Needed for MuonSelectionTool"};
76 
77  // Properties of the tool
78  Gaudi::Property<std::string> m_release{this, "release", "Recs2024_05_06_Run2Run3", "Release"};
79  // Systematics scheme
80  Gaudi::Property<std::string> m_sysScheme{this, "systematicScheme", "Corr_Scale", "Systematic scheme to be configured"};
81 
82  Gaudi::Property<bool> m_validationMode{this, "expert_validationMode", false, "Expert only option. Puts the tool in the validation mode setup"};
83  Gaudi::Property<bool> m_expertMode_isData{this, "expertMode_isData", false, "Expert only option. Overwrites the isData Flag"};
84  Gaudi::Property<int> m_expertMode_RunNumber{this, "expertMode_RunNumber", 0, "Expert only option. Overwrites RunNumber"};
85  Gaudi::Property<unsigned long long> m_expertMode_EvtNumber{this, "expertMode_EvtNumber", 0, "Expert only option. Overwrites EventNumber"};
86  Gaudi::Property<bool> m_useRndRun{this, "useRandomRunNumber", false, "To use the random run number for deciding which calibration to apply"};
87 
88  Gaudi::Property<int> m_calibMode{this, "calibMode", -1, "Calib mode"};
89 
90  //it should be used ONLY by releases>=24.2.24 and p-tag < p5834
91  //more infos here https://atlas-mcp.docs.cern.ch/guidelines/muonselectiontool/index.html
92  Gaudi::Property<bool> m_excludeNSWFromPrecisionLayers{this, "ExcludeNSWFromPrecisionLayers", false, "Cut on the number of precision layers ignores the NSW"};
93 
94  // Scale and Smear options
95  // Do direct CB calibration
96  Gaudi::Property<bool> m_doDirectCBCalib{this, "doDirectCBCalib", true, "Do direct calibration of CB tracks, otherwise, do ID+MS"};
97 
98 
99  // SagittaBias properties
100  Gaudi::Property<bool> m_doEtaSagittaSys{this, "doEtaSagittaSys", false, "Do Eta dependant systematic system"};
101  Gaudi::Property<bool> m_applyCorrectionOnData{this, "applyCorrectionOnData", true, "If to apply sagitta corrections on data, or take the full effect as systematic"};
102 
103 
104  // High pT correction options
105  // For more info: https://twiki.cern.ch/twiki/bin/view/Atlas/MuonSelectionToolR21#Usage_of_the_HighPt_selection
106  Gaudi::Property<bool> m_2stations_highpt_smearing{this, "do2StationsHighPt", false, "Extra smearing to be applied if high pT WP is used"};
107  // For more info: https://twiki.cern.ch/twiki/bin/view/Atlas/MuonSelectionToolR21#Usage_of_the_HighPt_selection
108  Gaudi::Property<bool> m_extra_highpt_smearing{this, "doExtraSmearing", false, "Flag provided to test if analysis are sensitive to high pT calibration. NOT TO BE USED FOR RESULTS. Please see twiki"};
109  Gaudi::Property<float> m_HighPtSystThreshold{this, "HighPtSystThr", 300.0, "Thershold for high pT smearing in GeV"};
110 
112 
115 
117 
118 
119  // internal tool function
120  // Converts xAOD object to an internal MuonObj for easier transfer of information
122  MCP::MuonObj convertToMuonObj(const xAOD::TrackParticle& inTrk, const int DetType) const;
125 
126 
127  MCP::DataYear getPeriod(bool isData) const;
128 
129  private:
130 
132 
133  }; // class MuonCalibTool
134 
135 } // namespace CP
136 
137 #endif
CP::MuonCalibTool::affectingSystematics
virtual SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
Definition: MuonCalibTool.cxx:289
CP::MuonCalibTool::applyCorrectionTrkOnly
virtual CorrectionCode applyCorrectionTrkOnly(xAOD::TrackParticle &inTrk, const int DetType) const override
Definition: MuonCalibTool.cxx:243
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
PropertyWrapper.h
MuonObj.h
asg::AnaToolHandle< CP::IMuonSelectionTool >
CP::MuonCalibTool::m_applyCorrectionOnData
Gaudi::Property< bool > m_applyCorrectionOnData
Definition: MuonCalibTool.h:101
CP::MuonCalibTool::m_MuonIntScaleSmearTool
asg::AnaToolHandle< CP::IMuonCalibIntScaleSmearTool > m_MuonIntScaleSmearTool
Definition: MuonCalibTool.h:114
CP::MuonCalibTool::m_2stations_highpt_smearing
Gaudi::Property< bool > m_2stations_highpt_smearing
Definition: MuonCalibTool.h:106
CP::MuonCalibTool::convertToMuonObj
MCP::MuonObj convertToMuonObj(const xAOD::Muon &mu) const
Definition: MuonCalibTool.cxx:404
CP::MuonCalibTool::applyCorrection
virtual ASG_TOOL_CLASS3(MuonCalibTool, CP::IMuonCalibrationAndSmearingTool, CP::ISystematicsTool, CP::IReentrantSystematicsTool) public CorrectionCode applyCorrection(xAOD::Muon &mu) const override
Declare the interface that the class provides.
Definition: MuonCalibTool.cxx:129
CP::MuonCalibTool::m_expertMode_EvtNumber
Gaudi::Property< unsigned long long > m_expertMode_EvtNumber
Definition: MuonCalibTool.h:85
CP::MuonCalibTool::m_excludeNSWFromPrecisionLayers
Gaudi::Property< bool > m_excludeNSWFromPrecisionLayers
Definition: MuonCalibTool.h:92
CP::MuonCalibTool::initializeRandNumbers
void initializeRandNumbers(MCP::MuonObj &obj) const
Decorate all information that's needed to ensure reproducibility of the smearing.
Definition: MuonCalibTool.cxx:514
CP::MuonCalibTool::m_extra_highpt_smearing
Gaudi::Property< bool > m_extra_highpt_smearing
Definition: MuonCalibTool.h:108
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::MuonCalibTool::initialize
virtual StatusCode initialize() override
Dummy implementation of the initialisation function.
Definition: MuonCalibTool.cxx:27
CP::SystematicVariation
Definition: SystematicVariation.h:47
SG::ReadHandleKey< xAOD::EventInfo >
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
CP::MuonCalibTool::m_isRun3
Gaudi::Property< bool > m_isRun3
Definition: MuonCalibTool.h:75
CP::IMuonCalibrationAndSmearingTool
Definition: IMuonCalibrationAndSmearingTool.h:24
CP::MuonCalibTool::m_expertMode_isData
Gaudi::Property< bool > m_expertMode_isData
Definition: MuonCalibTool.h:83
CP::MuonCalibTool::~MuonCalibTool
virtual ~MuonCalibTool()=default
CP::MuonCalibTool::m_sysScheme
Gaudi::Property< std::string > m_sysScheme
Definition: MuonCalibTool.h:80
IMuonSelectionTool.h
CP::MuonCalibTool::m_doDirectCBCalib
Gaudi::Property< bool > m_doDirectCBCalib
Definition: MuonCalibTool.h:96
CP::MuonCalibTool::m_MuonSelectionTool
asg::AnaToolHandle< CP::IMuonSelectionTool > m_MuonSelectionTool
Definition: MuonCalibTool.h:111
CP::MuonCalibTool::m_doEtaSagittaSys
Gaudi::Property< bool > m_doEtaSagittaSys
Definition: MuonCalibTool.h:100
CP::MuonCalibTool::MuonCalibTool
MuonCalibTool(const std::string &name)
Definition: MuonCalibTool.cxx:18
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
CP::MuonCalibTool::m_expertMode_RunNumber
Gaudi::Property< int > m_expertMode_RunNumber
Definition: MuonCalibTool.h:84
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
CP::MuonCalibTool::m_calibMode
Gaudi::Property< int > m_calibMode
Definition: MuonCalibTool.h:88
AnaToolHandle.h
merge.output
output
Definition: merge.py:17
CP::MuonCalibTool::m_release
Gaudi::Property< std::string > m_release
Definition: MuonCalibTool.h:78
CP::MuonCalibTool::correctedCopy
virtual CorrectionCode correctedCopy(const xAOD::Muon &input, xAOD::Muon *&output) const override
Create a corrected copy from a constant muon.
Definition: MuonCalibTool.cxx:261
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
CP::MuonCalibTool::m_validationMode
Gaudi::Property< bool > m_validationMode
Definition: MuonCalibTool.h:82
CP::MuonCalibTool
Definition: MuonCalibTool.h:25
IMuonCalibrationAndSmearingTool.h
EventInfo.h
CP::ISystematicsTool
Interface for all CP tools supporting systematic variations.
Definition: ISystematicsTool.h:32
CP::MuonCalibTool::m_MuonIntHighTSmearToolInitialized
bool m_MuonIntHighTSmearToolInitialized
Definition: MuonCalibTool.h:131
CP::MuonCalibTool::m_HighPtSystThreshold
Gaudi::Property< float > m_HighPtSystThreshold
Definition: MuonCalibTool.h:109
CP::MuonCalibTool::applySystematicVariation
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
Definition: MuonCalibTool.cxx:299
CP::MuonCalibTool::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: MuonCalibTool.h:73
CP::MuonCalibTool::isAffectedBySystematic
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const override
Declare the interface that this class provides.
Definition: MuonCalibTool.cxx:283
ASG_TOOL_CLASS3
#define ASG_TOOL_CLASS3(CLASSNAME, INT1, INT2, INT3)
Definition: AsgToolMacros.h:85
CP::MuonCalibTool::expectedResolution
virtual double expectedResolution(const std::string &DetType, const xAOD::Muon &mu, const bool addMCCorrectionSmearing) const override
Get the expected pT resolution.
Definition: MuonCalibTool.cxx:315
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CP::IReentrantSystematicsTool
interface for all CP tools supporting systematic variations within a reentrant algorithm
Definition: IReentrantSystematicsTool.h:58
IMuonCalibIntTool.h
CP::MuonCalibTool::m_MuonIntSagittaTool
asg::AnaToolHandle< CP::IMuonCalibIntTool > m_MuonIntSagittaTool
Definition: MuonCalibTool.h:113
MCP::DataYear
DataYear
Definition: EnumDef.h:28
MCP::MuonObj
Definition: MuonObj.h:126
CP::MuonCalibTool::m_useRndRun
Gaudi::Property< bool > m_useRndRun
Definition: MuonCalibTool.h:86
CP::MuonCalibTool::getPeriod
MCP::DataYear getPeriod(bool isData) const
Definition: MuonCalibTool.cxx:537
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:43
DetType
Definition: DetType.h:10
CP::MuonCalibTool::m_MuonIntHighTSmearTool
asg::AnaToolHandle< CP::IMuonCalibIntTool > m_MuonIntHighTSmearTool
Definition: MuonCalibTool.h:116
AsgTool.h
python.PyAthena.obj
obj
Definition: PyAthena.py:132
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
SystematicsCache.h
CP::MuonCalibTool::recommendedSystematics
virtual SystematicSet recommendedSystematics() const override
the list of all systematics this tool recommends to use
Definition: MuonCalibTool.cxx:297