ATLAS Offline Software
Loading...
Searching...
No Matches
CP::MuonCalibIntScaleSmearTool Class Referenceabstract

#include <MuonCalibIntScaleSmearTool.h>

Inheritance diagram for CP::MuonCalibIntScaleSmearTool:
Collaboration diagram for CP::MuonCalibIntScaleSmearTool:

Classes

struct  ParameterSetScaleSmear

Public Member Functions

 MuonCalibIntScaleSmearTool (const std::string &name)
virtual ~MuonCalibIntScaleSmearTool ()=default
virtual StatusCode initialize () override
 Dummy implementation of the initialisation function.
virtual void print () const
 Print the state of the tool.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
virtual CorrectionCode applyCorrection (MCP::MuonObj &mu) const =0
 Declare the interface that the class provides.
Additional helper functions, not directly mimicking Athena
template<class T>
const T * getProperty (const std::string &name) const
 Get one of the tool's properties.
const std::string & msg_level_name () const __attribute__((deprecated))
 A deprecated function for getting the message level's name.
const std::string & getName (const void *ptr) const
 Get the name of an object that is / should be in the event store.
SG::sgkey_t getKey (const void *ptr) const
 Get the (hashed) key of an object that is in the event store.

Protected Types

typedef std::map< MCP::ScaleResCorrection, std::shared_ptr< MCP::CalibContainer > > ScaleSmearCorrConstMap

Protected Member Functions

StatusCode calcSystematicVariation (const SystematicSet &systConfig, ParameterSetScaleSmear &param) const
std::map< MCP::ScaleSmearParam, doublegetConstants (const MCP::TrackCalibObj &trk, const std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > &constants, const std::map< MCP::ScaleSmearParam, double > &direction) const
double getCorrectedPt (const MCP::MuonObj &mu, const MCP::TrackCalibObj &trk, const std::map< MCP::ScaleSmearParam, double > &calibConstant) const
double getSmearCorr (const MCP::MuonObj &mu, const MCP::TrackCalibObj &trk, double r0, double r1, double r2) const
double getCorrectedCBPtWithIDMSComb (const MCP::MuonObj &mu, const std::map< MCP::ScaleSmearParam, double > &calibIDConstant, const std::map< MCP::ScaleSmearParam, double > &calibMEConstant) const
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

SG::ReadHandleKey< xAOD::EventInfom_eventInfo {this, "EventInfoContName", "EventInfo", "event info key"}
Gaudi::Property< std::string > m_release {this, "release", "Recs2025_12_11_Run2Run3", "Release"}
Gaudi::Property< std::string > m_sysScheme {this, "systematicScheme", "Corr_Scale", "Systematic scheme to be configured"}
Gaudi::Property< intm_calibMode {this, "calibMode", -1, "Calib mode"}
SystematicsCache< ParameterSetScaleSmearm_Parameters {this}
const ParameterSetScaleSmearm_currentParameters {nullptr}
std::map< MCP::DataYear, std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > > m_IDparams
std::map< MCP::DataYear, std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > > m_MEparams
std::map< MCP::DataYear, std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > > m_CBparams
std::map< MCP::DataYear, std::map< MCP::ExpectedResParam, std::shared_ptr< MCP::CalibContainer > > > m_IDExpectedResparams
std::map< MCP::DataYear, std::map< MCP::ExpectedResParam, std::shared_ptr< MCP::CalibContainer > > > m_MEExpectedResparams

Static Protected Attributes

static constexpr std::array< MCP::ScaleSmearParam, 5 > m_paramList {MCP::ScaleSmearParam::s0, MCP::ScaleSmearParam::s1, MCP::ScaleSmearParam::r0, MCP::ScaleSmearParam::r1, MCP::ScaleSmearParam::r2}

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

virtual ASG_TOOL_CLASS3(MuonCalibIntScaleSmearTool, CP::IMuonCalibIntScaleSmearTool, CP::ISystematicsTool, CP::IReentrantSystematicsTool) public double getExpectedResolution (const int &DetType, double pT, double eta, double phi, MCP::DataYear year, bool isData) const override
 Declare the interface that the class provides.
virtual bool isAffectedBySystematic (const SystematicVariation &systematic) const override
 Declare the interface that this class provides.
virtual SystematicSet affectingSystematics () const override
 the list of all systematics this tool can be affected by
virtual SystematicSet recommendedSystematics () const override
 the list of all systematics this tool recommends to use
virtual StatusCode applySystematicVariation (const SystematicSet &systConfig) override
 effects: configure this tool for the given list of systematic variations.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 28 of file MuonCalibIntScaleSmearTool.h.

Member Typedef Documentation

◆ ScaleSmearCorrConstMap

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MuonCalibIntScaleSmearTool()

CP::MuonCalibIntScaleSmearTool::MuonCalibIntScaleSmearTool ( const std::string & name)

Definition at line 21 of file MuonCalibIntScaleSmearTool.cxx.

21 : asg::AsgTool(name)
22 {}

◆ ~MuonCalibIntScaleSmearTool()

virtual CP::MuonCalibIntScaleSmearTool::~MuonCalibIntScaleSmearTool ( )
virtualdefault

Member Function Documentation

◆ affectingSystematics()

SystematicSet CP::MuonCalibIntScaleSmearTool::affectingSystematics ( ) const
overrideprivatevirtual

the list of all systematics this tool can be affected by

Scale Systematics

Implements CP::IReentrantSystematicsTool.

Definition at line 290 of file MuonCalibIntScaleSmearTool.cxx.

291 {
292 SystematicSet result;
294 // Resolution systematics
296 if (m_calibMode == MuonCalibTool::correctData_CB || m_calibMode == MuonCalibTool::notCorrectData_CB || m_sysScheme == "AllSys") {
297 // CB systematics
298 result.insert(SystematicVariation("MUON_CB", 1));
299 result.insert(SystematicVariation("MUON_CB", -1));
300 }
301 if (m_calibMode == MuonCalibTool::correctData_IDMS || m_calibMode == MuonCalibTool::notCorrectData_IDMS || m_calibMode == MuonCalibTool::correctData_IDonly || m_sysScheme == "AllSys") {
302 // ID systematics
303 result.insert(SystematicVariation("MUON_ID", 1));
304 result.insert(SystematicVariation("MUON_ID", -1));
305 }
306 if (m_calibMode == MuonCalibTool::correctData_IDMS || m_calibMode == MuonCalibTool::notCorrectData_IDMS || m_calibMode == MuonCalibTool::correctData_MSonly || m_sysScheme == "AllSys") {
307 // MS systematics
308 result.insert(SystematicVariation("MUON_MS", 1));
309 result.insert(SystematicVariation("MUON_MS", -1));
310 }
311
315 if (m_sysScheme == "Corr_Scale") {
316 result.insert(SystematicVariation("MUON_SCALE", 1));
317 result.insert(SystematicVariation("MUON_SCALE", -1));
318 }
319 else if (m_sysScheme == "Decorr_Scale" || m_sysScheme == "AllSys") {
320 // Either doing direct calib of CB or asking for all the sys
321 if (m_calibMode == MuonCalibTool::correctData_CB || m_calibMode == MuonCalibTool::notCorrectData_CB || m_sysScheme == "AllSys") {
322 result.insert(SystematicVariation("MUON_SCALE_CB", 1));
323 result.insert(SystematicVariation("MUON_SCALE_CB", -1));
324
325 result.insert(SystematicVariation("MUON_SCALE_CB_ELOSS", 1));
326 result.insert(SystematicVariation("MUON_SCALE_CB_ELOSS", -1));
327 }
328
329 // Either not doing direct calib of CB or asking for IDonly calib or asking for all the sys
330 if (m_calibMode == MuonCalibTool::correctData_IDMS || m_calibMode == MuonCalibTool::notCorrectData_IDMS || m_calibMode == MuonCalibTool::correctData_IDonly || m_sysScheme == "AllSys") {
331 result.insert(SystematicVariation("MUON_SCALE_ID", 1));
332 result.insert(SystematicVariation("MUON_SCALE_ID", -1));
333 }
334
335 // Either not doing direct calib of CB or asking for MEonly calib or asking for all the sys
336 if (m_calibMode == MuonCalibTool::correctData_IDMS || m_calibMode == MuonCalibTool::notCorrectData_IDMS || m_calibMode == MuonCalibTool::correctData_MSonly || m_sysScheme == "AllSys") {
337 result.insert(SystematicVariation("MUON_SCALE_MS", 1));
338 result.insert(SystematicVariation("MUON_SCALE_MS", -1));
339
340 result.insert(SystematicVariation("MUON_SCALE_MS_ELOSS", 1));
341 result.insert(SystematicVariation("MUON_SCALE_MS_ELOSS", -1));
342 }
343 }
344
345
346
347
348 return result;
349 }
Gaudi::Property< std::string > m_sysScheme

◆ applyCorrection()

virtual CorrectionCode CP::IMuonCalibIntTool::applyCorrection ( MCP::MuonObj & mu) const
pure virtualinherited

Declare the interface that the class provides.

Apply the correction on a modifyable object

◆ applySystematicVariation()

StatusCode CP::MuonCalibIntScaleSmearTool::applySystematicVariation ( const SystematicSet & systConfig)
overrideprivatevirtual

effects: configure this tool for the given list of systematic variations.

any requested systematics that are not affecting this tool will be silently ignored (unless they cause other errors). failures: systematic unknown failures: requesting multiple variations on the same systematic (e.g. up & down) failures: requesting an unsupported variation on an otherwise supported systematic (e.g. a 2 sigma variation and the tool only supports 1 sigma variations) failures: unsupported combination of supported systematic failures: other tool specific errors

Implements CP::ISystematicsTool.

Definition at line 483 of file MuonCalibIntScaleSmearTool.cxx.

484 {
485 return m_Parameters.get(systConfig, m_currentParameters);
486 }
SystematicsCache< ParameterSetScaleSmear > m_Parameters
const ParameterSetScaleSmear * m_currentParameters

◆ calcSystematicVariation()

StatusCode CP::MuonCalibIntScaleSmearTool::calcSystematicVariation ( const SystematicSet & systConfig,
ParameterSetScaleSmear & param ) const
protected

Definition at line 353 of file MuonCalibIntScaleSmearTool.cxx.

354 {
360
366
372
373
374 // ID systematics
375 SystematicVariation syst = systConfig.getSystematicByBaseName("MUON_ID");
376
377 if (syst == SystematicVariation("MUON_ID", 1)) {
381 } else if (syst == SystematicVariation("MUON_ID", -1)) {
385 } else if (!syst.empty()) return StatusCode::FAILURE;
386
387 // MS systematics
388 syst = systConfig.getSystematicByBaseName("MUON_MS");
389
390 if (syst == SystematicVariation("MUON_MS", 1)) {
394 } else if (syst == SystematicVariation("MUON_MS", -1)) {
398 } else if (!syst.empty()) return StatusCode::FAILURE;
399
400 // CB systematics
401 syst = systConfig.getSystematicByBaseName("MUON_CB");
402
403 if (syst == SystematicVariation("MUON_CB", 1)) {
407 } else if (syst == SystematicVariation("MUON_CB", -1)) {
411 } else if (!syst.empty()) return StatusCode::FAILURE;
412
413 // Scale systematics
414 syst = systConfig.getSystematicByBaseName("MUON_SCALE");
415
416 if (syst == SystematicVariation("MUON_SCALE", 1)) {
419
422
425
426 } else if (syst == SystematicVariation("MUON_SCALE", -1)) {
429
432
435 } else if (!syst.empty()) return StatusCode::FAILURE;
436
437 // Split scale ID/MS/EGloss
438 syst = systConfig.getSystematicByBaseName("MUON_SCALE_ID");
439
440 if (syst == SystematicVariation("MUON_SCALE_ID", 1)) {
443 } else if (syst == SystematicVariation("MUON_SCALE_ID", -1)) {
446 } else if (!syst.empty()) return StatusCode::FAILURE;
447
448 syst = systConfig.getSystematicByBaseName("MUON_SCALE_MS");
449
450 if (syst == SystematicVariation("MUON_SCALE_MS", 1)) {
452 } else if (syst == SystematicVariation("MUON_SCALE_MS", -1)) {
454 } else if (!syst.empty()) return StatusCode::FAILURE;
455
456 syst = systConfig.getSystematicByBaseName("MUON_SCALE_MS_ELOSS");
457
458 if (syst == SystematicVariation("MUON_SCALE_MS_ELOSS", 1)) {
460 } else if (syst == SystematicVariation("MUON_SCALE_MS_ELOSS", -1)) {
462 } else if (!syst.empty()) return StatusCode::FAILURE;
463
464 syst = systConfig.getSystematicByBaseName("MUON_SCALE_CB");
465
466 if (syst == SystematicVariation("MUON_SCALE_CB", 1)) {
468 } else if (syst == SystematicVariation("MUON_SCALE_CB", -1)) {
470 } else if (!syst.empty()) return StatusCode::FAILURE;
471
472 syst = systConfig.getSystematicByBaseName("MUON_SCALE_CB_ELOSS");
473
474 if (syst == SystematicVariation("MUON_SCALE_CB_ELOSS", 1)) {
476 } else if (syst == SystematicVariation("MUON_SCALE_CB_ELOSS", -1)) {
478 } else if (!syst.empty()) return StatusCode::FAILURE;
479
480 return StatusCode::SUCCESS;
481 }
SystematicVariation getSystematicByBaseName(const std::string &basename) const
description: get the first systematic matching basename
bool empty() const
returns: whether this is an empty systematic, i.e.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getConstants()

std::map< MCP::ScaleSmearParam, double > CP::MuonCalibIntScaleSmearTool::getConstants ( const MCP::TrackCalibObj & trk,
const std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > & constants,
const std::map< MCP::ScaleSmearParam, double > & direction ) const
protected

Definition at line 117 of file MuonCalibIntScaleSmearTool.cxx.

118 {
119
120 std::map<MCP::ScaleSmearParam, double> calibConstants;
121
122 // Extra the constants from container into a simple map
123 for(const auto& param: m_paramList)
124 {
125 const auto & contantList = constants.at(param);
126
127 double val = contantList.at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
128 if(direction.at(param) == MCP::SystVariation::Up)
129 {
130 val += contantList.at(MCP::ScaleResCorrection::SystErr__1up)->getCalibConstant(trk);
131 }
132 else if (direction.at(param) == MCP::SystVariation::Down)
133 {
134 val -= contantList.at(MCP::ScaleResCorrection::SystErr__1down)->getCalibConstant(trk);
135 }
136
137 // Remove unphysical smearing
139 {
140 val = std::max(0.0, val);
141 }
142
143 calibConstants[param] = val;
144 }
145
146 return calibConstants;
147 }
static constexpr std::array< MCP::ScaleSmearParam, 5 > m_paramList
const Amg::Vector3D & direction() const
Method to retrieve the direction at the Intersection.

◆ getCorrectedCBPtWithIDMSComb()

double CP::MuonCalibIntScaleSmearTool::getCorrectedCBPtWithIDMSComb ( const MCP::MuonObj & mu,
const std::map< MCP::ScaleSmearParam, double > & calibIDConstant,
const std::map< MCP::ScaleSmearParam, double > & calibMEConstant ) const
protected

Definition at line 187 of file MuonCalibIntScaleSmearTool.cxx.

188 {
189 // calculate the relative of ID and ME for the corrections
190 double weightID = 0.5;
191 double weightME = 0.5;
192
193 double deltaCBME = mu.CB.calib_pt - mu.ME.calib_pt;
194 double deltaCBID = mu.CB.calib_pt - mu.ID.calib_pt;
195
196 if (mu.ME.calib_pt == 0)
197 {
198 weightID = 1.0;
199 weightME = 0.0;
200 }
201 else if (mu.ID.calib_pt == 0)
202 {
203 weightID = 0.0;
204 weightME = 1.0;
205 }
206 else if (mu.CB.calib_pt != 0)
207 {
208 if (std::abs(deltaCBME) > 0 || std::abs(deltaCBID) > 0)
209 {
210 double R = 1, Rplus = 1;
211 if (std::abs(deltaCBME) == std::abs(deltaCBID))
212 {
213 // do nothing
214 }
215 else if (std::abs(deltaCBME) != 0 &&
216 std::abs(deltaCBME) > std::abs(deltaCBID)) {
217 R = (-deltaCBID) / deltaCBME; /* R~wMS/wID */
218 Rplus = 1 + R;
219 if (Rplus != 0 && R > 0) {
220 weightID = 1 / Rplus;
221 weightME = R / Rplus;
222 }
223 }
224 else if (std::abs(deltaCBID) != 0 &&
225 std::abs(deltaCBME) < std::abs(deltaCBID)) {
226 R = (-deltaCBME) / (deltaCBID); /* R~wID/wMS */
227 Rplus = 1 + R;
228 if (Rplus != 0 && R > 0) {
229 weightID = R / Rplus;
230 weightME = 1 / Rplus;
231 }
232 }
233 }
234 }
235 // If no correction was found
236 if(weightID == 0.5 && weightME == 0.5)
237 {
238 if(mu.expectedPercentResME<std::numeric_limits<double>::epsilon() ||
239 mu.CB.calib_pt<std::numeric_limits<double>::epsilon() || mu.expectedPercentResID<std::numeric_limits<double>::epsilon() ){
240 ATH_MSG_VERBOSE("Potential FPE caught! Continue with averaging ID+MS");
241 ATH_MSG_VERBOSE("mu.expectedPercentResME = "<<mu.expectedPercentResME);
242 ATH_MSG_VERBOSE("mu.expectedPercentResID = "<<mu.expectedPercentResID);
243 ATH_MSG_VERBOSE("mu.CB.calib_pt = "<<mu.CB.calib_pt);
244 } else {
245 double wME = mu.ME.calib_pt / mu.CB.calib_pt / std::pow(mu.expectedPercentResME, 2);
246 double wID = mu.ID.calib_pt / mu.CB.calib_pt / std::pow(mu.expectedPercentResID, 2);
247 weightID = wID / (wME + wID);
248 weightME = wME / (wME + wID);
249 }
250 }
251
252
253 // Calculate the denominator for the scale correction
254 double smearIDCorr = getSmearCorr(mu, mu.ID, calibIDConstant.at(MCP::ScaleSmearParam::r0), calibIDConstant.at(MCP::ScaleSmearParam::r1), calibIDConstant.at(MCP::ScaleSmearParam::r2));
255 double smearMECorr = getSmearCorr(mu, mu.ME, calibMEConstant.at(MCP::ScaleSmearParam::r0), calibMEConstant.at(MCP::ScaleSmearParam::r1), calibMEConstant.at(MCP::ScaleSmearParam::r2));
256 double smearCorr = weightID * smearIDCorr + weightME * smearMECorr;
257 double scaleCB = 0;
258
259 // apply the full correction
260 if(weightID == 0) scaleCB = (calibMEConstant.at(MCP::ScaleSmearParam::s1) + calibMEConstant.at(MCP::ScaleSmearParam::s0) / mu.ME.calib_pt) * weightME;
261 else if(weightME == 0) scaleCB = calibIDConstant.at(MCP::ScaleSmearParam::s1) * weightID ;
262 else scaleCB = (calibIDConstant.at(MCP::ScaleSmearParam::s1) * weightID + (calibMEConstant.at(MCP::ScaleSmearParam::s1) + calibMEConstant.at(MCP::ScaleSmearParam::s0) / mu.ME.calib_pt) * weightME);
263
264 ATH_MSG_VERBOSE("mu.ID.calib_pt: "<<mu.ID.calib_pt);
265 ATH_MSG_VERBOSE("mu.ME.calib_pt: "<<mu.ME.calib_pt);
266 ATH_MSG_VERBOSE("mu.CB.calib_pt: "<<mu.CB.calib_pt);
267 ATH_MSG_VERBOSE("mu.expectedPercentResME: "<<mu.expectedPercentResME);
268 ATH_MSG_VERBOSE("mu.expectedPercentResID: "<<mu.expectedPercentResID);
269
270 ATH_MSG_VERBOSE("weightID: "<<weightID);
271 ATH_MSG_VERBOSE("weightME: "<<weightME);
272 ATH_MSG_VERBOSE("smearIDCorr: "<<smearIDCorr);
273 ATH_MSG_VERBOSE("smearMECorr: "<<smearMECorr);
274 ATH_MSG_VERBOSE("smearCorr: "<<smearCorr);
275 ATH_MSG_VERBOSE("scaleCB: "<<scaleCB);
276
277 double pT = mu.CB.calib_pt;
278 double corrpT = (pT + pT * scaleCB)/(1 + smearCorr);
279
280 return corrpT;
281 }
#define ATH_MSG_VERBOSE(x)
double getSmearCorr(const MCP::MuonObj &mu, const MCP::TrackCalibObj &trk, double r0, double r1, double r2) const
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)

◆ getCorrectedPt()

double CP::MuonCalibIntScaleSmearTool::getCorrectedPt ( const MCP::MuonObj & mu,
const MCP::TrackCalibObj & trk,
const std::map< MCP::ScaleSmearParam, double > & calibConstant ) const
protected

Definition at line 150 of file MuonCalibIntScaleSmearTool.cxx.

151 {
152 if(trk.calib_pt == 0) return 0;
153
154 // For debugging:: Todo add checking if in verbose mode
155 ATH_MSG_VERBOSE("MuonType: "<<MCP::toString(trk.type));
156 for(const auto& var: calibConstant) ATH_MSG_VERBOSE("var: "<<MCP::toString(var.first)<<" = "<<var.second);
157
158 double pT = trk.calib_pt;
159
160 // Calculate the denominator for the scale correction
161 double smearCorr = getSmearCorr(mu, trk, calibConstant.at(MCP::ScaleSmearParam::r0), calibConstant.at(MCP::ScaleSmearParam::r1), calibConstant.at(MCP::ScaleSmearParam::r2));
162 ATH_MSG_VERBOSE("smearCorr: "<<smearCorr);
163
164 // apply the full correction
165 double corrpT = (pT + pT * calibConstant.at(MCP::ScaleSmearParam::s1) + calibConstant.at(MCP::ScaleSmearParam::s0))/(1 + smearCorr);
166
167 return corrpT;
168 }
std::string toString(TrackType trkType)
Definition EnumDef.h:39
double calib_pt
Smeared track pt.
Definition MuonObj.h:155
const TrackType type
Flag telling the code whether this is CB/ME/ID.
Definition MuonObj.h:149

◆ getExpectedResolution()

double CP::MuonCalibIntScaleSmearTool::getExpectedResolution ( const int & DetType,
double pT,
double eta,
double phi,
MCP::DataYear year,
bool addMCCorrectionSmearing ) const
overrideprivatevirtual

Declare the interface that the class provides.

Apply the correction on a modifyable object

Implements CP::IMuonCalibIntScaleSmearTool.

Definition at line 489 of file MuonCalibIntScaleSmearTool.cxx.

490 {
491
492 const auto & IDcorrConstants = m_IDparams.at(year);
493 const auto & MEcorrConstants = m_MEparams.at(year);
494 const auto & IDExpectedResConstants = m_IDExpectedResparams.at(year);
495 const auto & MEExpectedResConstants = m_MEExpectedResparams.at(year);
496
499
500 auto trk = MCP::TrackCalibObj(type, pT * GeVtoMeV, eta, phi, year, false);
501
502
503 double expRes = 0.;
504 if (DetType == MCP::DetectorType::MS)
505 {
506 if (pT == 0) return 1e12;
507
508 double p0 = 0;
509 double p1 = 0;
510 double p2 = 0;
511
512 if(!addMCCorrectionSmearing)
513 {
514 p0 = MEExpectedResConstants.at(MCP::ExpectedResParam::r0)->getCalibConstant(trk);
515 p1 = MEExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
516 p2 = MEExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
517 }
518 else
519 {
520 double expectedP0 = MEExpectedResConstants.at(MCP::ExpectedResParam::r0)->getCalibConstant(trk);
521 double expectedP1 = MEExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
522 double expectedP2 = MEExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
523
524 double r0 = MEcorrConstants.at(MCP::ScaleSmearParam::r0).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
525 double r1 = MEcorrConstants.at(MCP::ScaleSmearParam::r1).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
526 double r2 = MEcorrConstants.at(MCP::ScaleSmearParam::r2).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
527
528 p0 = std::sqrt(std::pow(expectedP0, 2) + std::pow(r0, 2));
529 p1 = std::sqrt(std::pow(expectedP1, 2) + std::pow(r1, 2));
530 p2 = std::sqrt(std::pow(expectedP2, 2) + std::pow(r2, 2));
531 }
532
533 expRes = std::sqrt(std::pow(p0 / pT, 2) + std::pow(p1, 2) + std::pow(p2 * pT, 2));
534
535 }
536 else if (DetType == MCP::DetectorType::ID)
537 {
538 if (pT == 0) return 1e12;
539
540 double p1 = 0;
541 double p2 = 0;
542
543 if(!addMCCorrectionSmearing)
544 {
545 p1 = IDExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
546 p2 = IDExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
547 double p2Tan = IDExpectedResConstants.at(MCP::ExpectedResParam::r2tan2)->getCalibConstant(trk);
548 if(p2Tan) p2 = p2Tan;
549 }
550 else
551 {
552 double expectedP1 = IDExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
553 double expectedP2 = IDExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
554 double p2Tan = IDExpectedResConstants.at(MCP::ExpectedResParam::r2tan2)->getCalibConstant(trk);
555 if(p2Tan) expectedP2 = p2Tan;
556
557 double r1 = IDcorrConstants.at(MCP::ScaleSmearParam::r1).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
558 double r2 = IDcorrConstants.at(MCP::ScaleSmearParam::r2).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
559
560 p1 = std::sqrt(std::pow(expectedP1, 2) + std::pow(r1, 2));
561 p2 = std::sqrt(std::pow(expectedP2, 2) + std::pow(r2, 2));
562
563 if(p2Tan) p2 = p2 * std::sinh(eta) * std::sinh(eta);
564 }
565
566 expRes = std::sqrt(std::pow(p1, 2) + std::pow(p2 * pT, 2));
567 return expRes;
568 }
569 else
570 {
571 ATH_MSG_ERROR("wrong DetType in input " << DetType);
572 return 0.;
573 }
574
575 return expRes;
576 }
Scalar eta() const
pseudorapidity method
#define ATH_MSG_ERROR(x)
std::map< MCP::DataYear, std::map< MCP::ExpectedResParam, std::shared_ptr< MCP::CalibContainer > > > m_MEExpectedResparams
std::map< MCP::DataYear, std::map< MCP::ExpectedResParam, std::shared_ptr< MCP::CalibContainer > > > m_IDExpectedResparams
std::map< MCP::DataYear, std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > > m_MEparams
std::map< MCP::DataYear, std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > > m_IDparams
TrackType
Definition EnumDef.h:13
const double r0
electron radius{cm}

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void * ptr) const
inherited

Get the (hashed) key of an object that is in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the SG::sgkey_t key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getName
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The hashed key of the object in the store. If not found, an invalid (zero) key.

Definition at line 119 of file AsgTool.cxx.

119 {
120
121#ifdef XAOD_STANDALONE
122 // In case we use @c xAOD::Event, we have a direct function call
123 // for this.
124 return evtStore()->event()->getKey( ptr );
125#else
126 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127 return ( proxy == nullptr ? 0 : proxy->sgkey() );
128#endif // XAOD_STANDALONE
129 }
ServiceHandle< StoreGateSvc > & evtStore()

◆ getName()

const std::string & asg::AsgTool::getName ( const void * ptr) const
inherited

Get the name of an object that is / should be in the event store.

This is a bit of a special one. StoreGateSvc and xAOD::Event both provide ways for getting the std::string name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.

In order to allow tools to efficiently perform this operation, they can use this helper function.

See also
asg::AsgTool::getKey
Parameters
ptrThe bare pointer to the object that the event store should know about
Returns
The string name of the object in the store. If not found, an empty string.

Definition at line 106 of file AsgTool.cxx.

106 {
107
108#ifdef XAOD_STANDALONE
109 // In case we use @c xAOD::Event, we have a direct function call
110 // for this.
111 return evtStore()->event()->getName( ptr );
112#else
113 const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114 static const std::string dummy = "";
115 return ( proxy == nullptr ? dummy : proxy->name() );
116#endif // XAOD_STANDALONE
117 }

◆ getProperty()

template<class T>
const T * asg::AsgTool::getProperty ( const std::string & name) const
inherited

Get one of the tool's properties.

◆ getSmearCorr()

double CP::MuonCalibIntScaleSmearTool::getSmearCorr ( const MCP::MuonObj & mu,
const MCP::TrackCalibObj & trk,
double r0,
double r1,
double r2 ) const
protected

Definition at line 170 of file MuonCalibIntScaleSmearTool.cxx.

171 {
172 if(trk.calib_pt == 0) return 1;
173
174 double pT = trk.calib_pt;
175 if(trk.type == MCP::TrackType::ID)
176 {
177 // ID applies a tan(theta) correction for r2 for high eta muons
178 double additional_weight = 1.;
179 if (std::abs(trk.eta) > 2) additional_weight = sinh(trk.eta);
180
181 return r1 * mu.rnd_g3 + r2 * mu.rnd_g4 * pT * additional_weight;
182 }
183 return r0 * mu.rnd_g0 / pT + r1 * mu.rnd_g1 + r2 * mu.rnd_g2 * pT;
184 }
const double eta
Value of the track-eta.
Definition MuonObj.h:157

◆ initialize()

StatusCode CP::MuonCalibIntScaleSmearTool::initialize ( void )
overridevirtual

Dummy implementation of the initialisation function.

It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...

Reimplemented from asg::AsgTool.

Definition at line 24 of file MuonCalibIntScaleSmearTool.cxx.

25 {
26 // Greet the user:
27 ATH_MSG_INFO("Initializing MuonCalibIntScaleSmearTool");
28
29 // Get the m_eventinfo container
30 ATH_CHECK(m_eventInfo.initialize());
31
32
33 // Load the constants
34 for(const auto & year: MCP::dataYearList)
35 {
36 for(const auto & param: m_paramList)
37 {
41 }
42
45 }
46
47
48 m_currentParameters = nullptr;
49 // Init the systematics
50 m_Parameters.initialize(affectingSystematics(), [this](const SystematicSet &systConfig, ParameterSetScaleSmear &param)
51 { return calcSystematicVariation(systConfig, param); });
52 if (!applySystematicVariation(SystematicSet()))
53 {
54 ATH_MSG_ERROR("Unable to run with no systematic");
55 return StatusCode::FAILURE;
56 }
57 SystematicRegistry &registry = SystematicRegistry::getInstance();
58 if (registry.registerSystematics(*this) != StatusCode::SUCCESS)
59 {
60 ATH_MSG_ERROR("Unkown systematic list");
61 return StatusCode::FAILURE;
62 }
63 // Return gracefully:
64 return StatusCode::SUCCESS;
65 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
Gaudi::Property< std::string > m_release
virtual SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
std::map< MCP::DataYear, std::map< MCP::ScaleSmearParam, ScaleSmearCorrConstMap > > m_CBparams
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig) override
effects: configure this tool for the given list of systematic variations.
StatusCode calcSystematicVariation(const SystematicSet &systConfig, ParameterSetScaleSmear &param) const
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
std::map< ExpectedResParam, std::shared_ptr< CalibContainer > > createExpectedResMap(DataYear dataYear, TrackType type, const std::string &recommendationPath)
std::map< ScaleResCorrection, std::shared_ptr< CalibContainer > > createScaleResCorrMap(DataYear dataYear, TrackType type, const std::string &recommendationPath, ScaleSmearParam param)
static constexpr std::array< MCP::DataYear, 7 > dataYearList
Definition EnumDef.h:34

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isAffectedBySystematic()

bool CP::MuonCalibIntScaleSmearTool::isAffectedBySystematic ( const SystematicVariation & systematic) const
overrideprivatevirtual

Declare the interface that this class provides.

returns: whether this tool is affected by the given systematics

Implements CP::ISystematicsTool.

Definition at line 284 of file MuonCalibIntScaleSmearTool.cxx.

285 {
286 SystematicSet sys = affectingSystematics();
287 return sys.find(systematic) != sys.end();
288 }

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msg_level_name()

const std::string & asg::AsgTool::msg_level_name ( ) const
inherited

A deprecated function for getting the message level's name.

Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:

MSG::name( msg().level() )

This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.

Returns
The string name of the current minimum message level that's printed

Definition at line 101 of file AsgTool.cxx.

101 {
102
103 return MSG::name( msg().level() );
104 }
MsgStream & msg() const
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition MsgLevel.cxx:19

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ print()

◆ recommendedSystematics()

SystematicSet CP::MuonCalibIntScaleSmearTool::recommendedSystematics ( ) const
overrideprivatevirtual

the list of all systematics this tool recommends to use

Implements CP::IReentrantSystematicsTool.

Definition at line 351 of file MuonCalibIntScaleSmearTool.cxx.

351{ return affectingSystematics(); }

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_calibMode

Gaudi::Property<int> CP::MuonCalibIntScaleSmearTool::m_calibMode {this, "calibMode", -1, "Calib mode"}
protected

Definition at line 70 of file MuonCalibIntScaleSmearTool.h.

70{this, "calibMode", -1, "Calib mode"};

◆ m_CBparams

std::map<MCP::DataYear, std::map<MCP::ScaleSmearParam, ScaleSmearCorrConstMap> > CP::MuonCalibIntScaleSmearTool::m_CBparams
protected

Definition at line 91 of file MuonCalibIntScaleSmearTool.h.

◆ m_currentParameters

const ParameterSetScaleSmear* CP::MuonCalibIntScaleSmearTool::m_currentParameters {nullptr}
protected

Definition at line 86 of file MuonCalibIntScaleSmearTool.h.

86{nullptr};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_eventInfo

SG::ReadHandleKey<xAOD::EventInfo> CP::MuonCalibIntScaleSmearTool::m_eventInfo {this, "EventInfoContName", "EventInfo", "event info key"}
protected

Definition at line 61 of file MuonCalibIntScaleSmearTool.h.

61{this, "EventInfoContName", "EventInfo", "event info key"};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_IDExpectedResparams

std::map<MCP::DataYear, std::map<MCP::ExpectedResParam, std::shared_ptr<MCP::CalibContainer> > > CP::MuonCalibIntScaleSmearTool::m_IDExpectedResparams
protected

Definition at line 94 of file MuonCalibIntScaleSmearTool.h.

◆ m_IDparams

std::map<MCP::DataYear, std::map<MCP::ScaleSmearParam, ScaleSmearCorrConstMap> > CP::MuonCalibIntScaleSmearTool::m_IDparams
protected

Definition at line 89 of file MuonCalibIntScaleSmearTool.h.

◆ m_MEExpectedResparams

std::map<MCP::DataYear, std::map<MCP::ExpectedResParam, std::shared_ptr<MCP::CalibContainer> > > CP::MuonCalibIntScaleSmearTool::m_MEExpectedResparams
protected

Definition at line 95 of file MuonCalibIntScaleSmearTool.h.

◆ m_MEparams

std::map<MCP::DataYear, std::map<MCP::ScaleSmearParam, ScaleSmearCorrConstMap> > CP::MuonCalibIntScaleSmearTool::m_MEparams
protected

Definition at line 90 of file MuonCalibIntScaleSmearTool.h.

◆ m_Parameters

SystematicsCache<ParameterSetScaleSmear> CP::MuonCalibIntScaleSmearTool::m_Parameters {this}
protected

Definition at line 85 of file MuonCalibIntScaleSmearTool.h.

85{this};

◆ m_paramList

◆ m_release

Gaudi::Property<std::string> CP::MuonCalibIntScaleSmearTool::m_release {this, "release", "Recs2025_12_11_Run2Run3", "Release"}
protected

Definition at line 64 of file MuonCalibIntScaleSmearTool.h.

64{this, "release", "Recs2025_12_11_Run2Run3", "Release"};

◆ m_sysScheme

Gaudi::Property<std::string> CP::MuonCalibIntScaleSmearTool::m_sysScheme {this, "systematicScheme", "Corr_Scale", "Systematic scheme to be configured"}
protected

Definition at line 67 of file MuonCalibIntScaleSmearTool.h.

67{this, "systematicScheme", "Corr_Scale", "Systematic scheme to be configured"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: