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_03_26_Run2Run3", "Release"}
Gaudi::Property< std::string > m_sysScheme {this, "systematicScheme", "Corr_Scale", "Systematic scheme to be configured"}
Gaudi::Property< boolm_doDirectCBCalib {this, "doDirectCBCalib", true, "Do direct calibration of CB tracks, otherwise, do ID+MS"}
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 20 of file MuonCalibIntScaleSmearTool.cxx.

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

◆ ~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 281 of file MuonCalibIntScaleSmearTool.cxx.

282 {
283 SystematicSet result;
285 // Resolution systematics
287 if (m_doDirectCBCalib || m_sysScheme == "AllSys") {
288 // CB systematics
289 result.insert(SystematicVariation("MUON_CB", 1));
290 result.insert(SystematicVariation("MUON_CB", -1));
291 }
292 if (!m_doDirectCBCalib || m_sysScheme == "AllSys") {
293 // ID systematics
294 result.insert(SystematicVariation("MUON_ID", 1));
295 result.insert(SystematicVariation("MUON_ID", -1));
296
297 // MS systematics
298 result.insert(SystematicVariation("MUON_MS", 1));
299 result.insert(SystematicVariation("MUON_MS", -1));
300 }
301
305 if (m_sysScheme == "Corr_Scale") {
306 result.insert(SystematicVariation("MUON_SCALE", 1));
307 result.insert(SystematicVariation("MUON_SCALE", -1));
308 }
309 else if (m_sysScheme == "Decorr_Scale" || m_sysScheme == "AllSys") {
310 // Either doing direct calib of CB or asking for all the sys
311 if (m_doDirectCBCalib || m_sysScheme == "AllSys") {
312 result.insert(SystematicVariation("MUON_SCALE_CB", 1));
313 result.insert(SystematicVariation("MUON_SCALE_CB", -1));
314
315 result.insert(SystematicVariation("MUON_SCALE_CB_ELOSS", 1));
316 result.insert(SystematicVariation("MUON_SCALE_CB_ELOSS", -1));
317 }
318
319 // Either not doing direct calib of CB or asking for all the sys
320 if (!m_doDirectCBCalib || m_sysScheme == "AllSys") {
321 result.insert(SystematicVariation("MUON_SCALE_ID", 1));
322 result.insert(SystematicVariation("MUON_SCALE_ID", -1));
323
324 result.insert(SystematicVariation("MUON_SCALE_MS", 1));
325 result.insert(SystematicVariation("MUON_SCALE_MS", -1));
326
327 result.insert(SystematicVariation("MUON_SCALE_MS_ELOSS", 1));
328 result.insert(SystematicVariation("MUON_SCALE_MS_ELOSS", -1));
329 }
330 }
331
332
333
334
335 return result;
336 }
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 470 of file MuonCalibIntScaleSmearTool.cxx.

471 {
472 return m_Parameters.get(systConfig, m_currentParameters);
473 }
SystematicsCache< ParameterSetScaleSmear > m_Parameters
const ParameterSetScaleSmear * m_currentParameters

◆ calcSystematicVariation()

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

Definition at line 340 of file MuonCalibIntScaleSmearTool.cxx.

341 {
347
353
359
360
361 // ID systematics
362 SystematicVariation syst = systConfig.getSystematicByBaseName("MUON_ID");
363
364 if (syst == SystematicVariation("MUON_ID", 1)) {
368 } else if (syst == SystematicVariation("MUON_ID", -1)) {
372 } else if (!syst.empty()) return StatusCode::FAILURE;
373
374 // MS systematics
375 syst = systConfig.getSystematicByBaseName("MUON_MS");
376
377 if (syst == SystematicVariation("MUON_MS", 1)) {
381 } else if (syst == SystematicVariation("MUON_MS", -1)) {
385 } else if (!syst.empty()) return StatusCode::FAILURE;
386
387 // CB systematics
388 syst = systConfig.getSystematicByBaseName("MUON_CB");
389
390 if (syst == SystematicVariation("MUON_CB", 1)) {
394 } else if (syst == SystematicVariation("MUON_CB", -1)) {
398 } else if (!syst.empty()) return StatusCode::FAILURE;
399
400 // Scale systematics
401 syst = systConfig.getSystematicByBaseName("MUON_SCALE");
402
403 if (syst == SystematicVariation("MUON_SCALE", 1)) {
406
409
412
413 } else if (syst == SystematicVariation("MUON_SCALE", -1)) {
416
419
422 } else if (!syst.empty()) return StatusCode::FAILURE;
423
424 // Split scale ID/MS/EGloss
425 syst = systConfig.getSystematicByBaseName("MUON_SCALE_ID");
426
427 if (syst == SystematicVariation("MUON_SCALE_ID", 1)) {
430 } else if (syst == SystematicVariation("MUON_SCALE_ID", -1)) {
433 } else if (!syst.empty()) return StatusCode::FAILURE;
434
435 syst = systConfig.getSystematicByBaseName("MUON_SCALE_MS");
436
437 if (syst == SystematicVariation("MUON_SCALE_MS", 1)) {
439 } else if (syst == SystematicVariation("MUON_SCALE_MS", -1)) {
441 } else if (!syst.empty()) return StatusCode::FAILURE;
442
443 syst = systConfig.getSystematicByBaseName("MUON_SCALE_MS_ELOSS");
444
445 if (syst == SystematicVariation("MUON_SCALE_MS_ELOSS", 1)) {
447 } else if (syst == SystematicVariation("MUON_SCALE_MS_ELOSS", -1)) {
449 } else if (!syst.empty()) return StatusCode::FAILURE;
450
451 syst = systConfig.getSystematicByBaseName("MUON_SCALE_CB");
452
453 if (syst == SystematicVariation("MUON_SCALE_CB", 1)) {
455 } else if (syst == SystematicVariation("MUON_SCALE_CB", -1)) {
457 } else if (!syst.empty()) return StatusCode::FAILURE;
458
459 syst = systConfig.getSystematicByBaseName("MUON_SCALE_CB_ELOSS");
460
461 if (syst == SystematicVariation("MUON_SCALE_CB_ELOSS", 1)) {
463 } else if (syst == SystematicVariation("MUON_SCALE_CB_ELOSS", -1)) {
465 } else if (!syst.empty()) return StatusCode::FAILURE;
466
467 return StatusCode::SUCCESS;
468 }
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 108 of file MuonCalibIntScaleSmearTool.cxx.

109 {
110
111 std::map<MCP::ScaleSmearParam, double> calibConstants;
112
113 // Extra the constants from container into a simple map
114 for(const auto& param: m_paramList)
115 {
116 const auto & contantList = constants.at(param);
117
118 double val = contantList.at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
119 if(direction.at(param) == MCP::SystVariation::Up)
120 {
121 val += contantList.at(MCP::ScaleResCorrection::SystErr__1up)->getCalibConstant(trk);
122 }
123 else if (direction.at(param) == MCP::SystVariation::Down)
124 {
125 val -= contantList.at(MCP::ScaleResCorrection::SystErr__1down)->getCalibConstant(trk);
126 }
127
128 // Remove unphysical smearing
130 {
131 val = std::max(0.0, val);
132 }
133
134 calibConstants[param] = val;
135 }
136
137 return calibConstants;
138 }
static constexpr std::array< MCP::ScaleSmearParam, 5 > m_paramList

◆ 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 178 of file MuonCalibIntScaleSmearTool.cxx.

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

142 {
143 if(trk.calib_pt == 0) return 0;
144
145 // For debugging:: Todo add checking if in verbose mode
146 ATH_MSG_VERBOSE("MuonType: "<<MCP::toString(trk.type));
147 for(const auto& var: calibConstant) ATH_MSG_VERBOSE("var: "<<MCP::toString(var.first)<<" = "<<var.second);
148
149 double pT = trk.calib_pt;
150
151 // Calculate the denominator for the scale correction
152 double smearCorr = getSmearCorr(mu, trk, calibConstant.at(MCP::ScaleSmearParam::r0), calibConstant.at(MCP::ScaleSmearParam::r1), calibConstant.at(MCP::ScaleSmearParam::r2));
153 ATH_MSG_VERBOSE("smearCorr: "<<smearCorr);
154
155 // apply the full correction
156 double corrpT = (pT + pT * calibConstant.at(MCP::ScaleSmearParam::s1) + calibConstant.at(MCP::ScaleSmearParam::s0))/(1 + smearCorr);
157
158 return corrpT;
159 }
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 476 of file MuonCalibIntScaleSmearTool.cxx.

477 {
478
479 const auto & IDcorrConstants = m_IDparams.at(year);
480 const auto & MEcorrConstants = m_MEparams.at(year);
481 const auto & IDExpectedResConstants = m_IDExpectedResparams.at(year);
482 const auto & MEExpectedResConstants = m_MEExpectedResparams.at(year);
483
486
487 auto trk = MCP::TrackCalibObj(type, pT * GeVtoMeV, eta, phi, year, false);
488
489
490 double expRes = 0.;
491 if (DetType == MCP::DetectorType::MS)
492 {
493 if (pT == 0) return 1e12;
494
495 double p0 = 0;
496 double p1 = 0;
497 double p2 = 0;
498
499 if(!addMCCorrectionSmearing)
500 {
501 p0 = MEExpectedResConstants.at(MCP::ExpectedResParam::r0)->getCalibConstant(trk);
502 p1 = MEExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
503 p2 = MEExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
504 }
505 else
506 {
507 double expectedP0 = MEExpectedResConstants.at(MCP::ExpectedResParam::r0)->getCalibConstant(trk);
508 double expectedP1 = MEExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
509 double expectedP2 = MEExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
510
511 double r0 = MEcorrConstants.at(MCP::ScaleSmearParam::r0).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
512 double r1 = MEcorrConstants.at(MCP::ScaleSmearParam::r1).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
513 double r2 = MEcorrConstants.at(MCP::ScaleSmearParam::r2).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
514
515 p0 = std::sqrt(std::pow(expectedP0, 2) + std::pow(r0, 2));
516 p1 = std::sqrt(std::pow(expectedP1, 2) + std::pow(r1, 2));
517 p2 = std::sqrt(std::pow(expectedP2, 2) + std::pow(r2, 2));
518 }
519
520 expRes = std::sqrt(std::pow(p0 / pT, 2) + std::pow(p1, 2) + std::pow(p2 * pT, 2));
521
522 }
523 else if (DetType == MCP::DetectorType::ID)
524 {
525 if (pT == 0) return 1e12;
526
527 double p1 = 0;
528 double p2 = 0;
529
530 if(!addMCCorrectionSmearing)
531 {
532 p1 = IDExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
533 p2 = IDExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
534 double p2Tan = IDExpectedResConstants.at(MCP::ExpectedResParam::r2tan2)->getCalibConstant(trk);
535 if(p2Tan) p2 = p2Tan;
536 }
537 else
538 {
539 double expectedP1 = IDExpectedResConstants.at(MCP::ExpectedResParam::r1)->getCalibConstant(trk);
540 double expectedP2 = IDExpectedResConstants.at(MCP::ExpectedResParam::r2)->getCalibConstant(trk);
541 double p2Tan = IDExpectedResConstants.at(MCP::ExpectedResParam::r2tan2)->getCalibConstant(trk);
542 if(p2Tan) expectedP2 = p2Tan;
543
544 double r1 = IDcorrConstants.at(MCP::ScaleSmearParam::r1).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
545 double r2 = IDcorrConstants.at(MCP::ScaleSmearParam::r2).at(MCP::ScaleResCorrection::Nominal)->getCalibConstant(trk);
546
547 p1 = std::sqrt(std::pow(expectedP1, 2) + std::pow(r1, 2));
548 p2 = std::sqrt(std::pow(expectedP2, 2) + std::pow(r2, 2));
549
550 if(p2Tan) p2 = p2 * std::sinh(eta) * std::sinh(eta);
551 }
552
553 expRes = std::sqrt(std::pow(p1, 2) + std::pow(p2 * pT, 2));
554 return expRes;
555 }
556 else
557 {
558 ATH_MSG_ERROR("wrong DetType in input " << DetType);
559 return 0.;
560 }
561
562 return expRes;
563 }
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::TEvent 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::TEvent, 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::TEvent 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::TEvent, 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 161 of file MuonCalibIntScaleSmearTool.cxx.

162 {
163 if(trk.calib_pt == 0) return 1;
164
165 double pT = trk.calib_pt;
166 if(trk.type == MCP::TrackType::ID)
167 {
168 // ID applies a tan(theta) correction for r2 for high eta muons
169 double additional_weight = 1.;
170 if (std::abs(trk.eta) > 2) additional_weight = sinh(trk.eta);
171
172 return r1 * mu.rnd_g3 + r2 * mu.rnd_g4 * pT * additional_weight;
173 }
174 return r0 * mu.rnd_g0 / pT + r1 * mu.rnd_g1 + r2 * mu.rnd_g2 * pT;
175 }
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 23 of file MuonCalibIntScaleSmearTool.cxx.

24 {
25 // Greet the user:
26 ATH_MSG_INFO("Initializing MuonCalibIntScaleSmearTool");
27
28 // Get the m_eventinfo container
29 ATH_CHECK(m_eventInfo.initialize());
30
31
32 // Load the constants
33 for(const auto & year: MCP::dataYearList)
34 {
35 for(const auto & param: m_paramList)
36 {
40 }
41
44 }
45
46
47 m_currentParameters = nullptr;
48 // Init the systematics
49 m_Parameters.initialize(affectingSystematics(), [this](const SystematicSet &systConfig, ParameterSetScaleSmear &param)
50 { return calcSystematicVariation(systConfig, param); });
51 if (!applySystematicVariation(SystematicSet()))
52 {
53 ATH_MSG_ERROR("Unable to run with no systematic");
54 return StatusCode::FAILURE;
55 }
56 SystematicRegistry &registry = SystematicRegistry::getInstance();
57 if (registry.registerSystematics(*this) != StatusCode::SUCCESS)
58 {
59 ATH_MSG_ERROR("Unkown systematic list");
60 return StatusCode::FAILURE;
61 }
62 // Return gracefully:
63 return StatusCode::SUCCESS;
64 }
#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 275 of file MuonCalibIntScaleSmearTool.cxx.

276 {
277 SystematicSet sys = affectingSystematics();
278 return sys.find(systematic) != sys.end();
279 }

◆ 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 338 of file MuonCalibIntScaleSmearTool.cxx.

338{ 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_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_doDirectCBCalib

Gaudi::Property<bool> CP::MuonCalibIntScaleSmearTool::m_doDirectCBCalib {this, "doDirectCBCalib", true, "Do direct calibration of CB tracks, otherwise, do ID+MS"}
protected

Definition at line 70 of file MuonCalibIntScaleSmearTool.h.

70{this, "doDirectCBCalib", true, "Do direct calibration of CB tracks, otherwise, do ID+MS"};

◆ 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 95 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 96 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_03_26_Run2Run3", "Release"}
protected

Definition at line 64 of file MuonCalibIntScaleSmearTool.h.

64{this, "release", "Recs2025_03_26_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: