ATLAS Offline Software
IsoVariableHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3  */
4 
8 namespace CP {
9 
10  //######################################################################################################
11  // IsoVariableHelper
12  //######################################################################################################
13  IsoVariableHelper::IsoVariableHelper(xAOD::Iso::IsolationType type, const std::string& backupPreFix, const std::string& isoDecSuffix) :
14  asg::AsgMessaging{"IsoVariableHelper_ "+ std::string(xAOD::Iso::toString(type))},
15  m_isoType(type),
16  m_BackupIso(!backupPreFix.empty()),
17  m_dec_IsoIsBackup("IsBackup_" + std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix),
18  m_acc_IsoIsBackup("IsBackup_" + std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix),
19  m_acc_iso_variable(xAOD::Iso::toString(type)),
20  m_dec_iso_variable(xAOD::Iso::toString(type) + (isoDecSuffix.empty() ? "" : "_") + isoDecSuffix),
21  m_acc_iso_backup(std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix),
22  m_dec_iso_backup(std::string(xAOD::Iso::toString(type)) + (backupPreFix.empty() ? "" : "_") + backupPreFix) {}
23 
25  if (!particle) {
26  ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": no particle given");
27  return CorrectionCode::Error;
28  }
29  if (!m_BackupIso) {
31  } else {
33  ATH_MSG_WARNING(__func__<<"() -- "<<__LINE__<<":"
34  <<" No isolation value was backuped thus far. "
35  <<"Did you call the BackupIsolation before for "
37  return CorrectionCode::Error;
38  } else {
40  }
41  }
42  return CorrectionCode::Ok;
43  }
45  const xAOD::IParticle* originalParticle = xAOD::getOriginalObject(*particle);
46  if (originalParticle && getIsolation(originalParticle, value) == CorrectionCode::Error)
47  return CorrectionCode::Error;
48  else if (!originalParticle) {
49  ATH_MSG_DEBUG(__func__<<"() -- "<<__LINE__<<": No orignal object was found");
50  return getIsolation(particle, value);
51  }
52  return CorrectionCode::Ok;
53  }
56  ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": Failed to retrieve isolation "<<
58  return CorrectionCode::Error;
59  }
61  return CorrectionCode::Ok;
62  }
64  if (!particle) {
65  ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": no particle given");
66  return CorrectionCode::Error;
67  }
69  float Isovalue = 0;
70  if (getIsolation(particle, Isovalue) == CorrectionCode::Error) {
71  return CorrectionCode::Error;
72  }
73  m_dec_IsoIsBackup(*particle) = true;
74  m_dec_iso_backup(*particle) = Isovalue;
75  }
76  return CorrectionCode::Ok;
77  }
79  if (!particle) {
80  ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": no particle given");
81  return CorrectionCode::Error;
82  }
83  if (std::isnan(value) || std::isinf(value)) {
84  ATH_MSG_ERROR(__func__<<"() -- "<<__LINE__<<": the value is not a number");
85  return CorrectionCode::Error;
86  }
88  return CorrectionCode::Ok;
89  }
91  std::string IsoVariableHelper::name() const { return std::string(xAOD::Iso::toCString(isotype())); }
92 
93 } // namespace CP
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
CP::IsoVariableHelper::m_BackupIso
bool m_BackupIso
Definition: IsoVariableHelper.h:35
xAOD::Iso::toString
std::string toString(const IsoType &iso)
Definition: IsolationHelpers.h:59
SG::ConstAccessor::auxid
SG::auxid_t auxid() const
Return the aux id for this variable.
asg
Definition: DataHandleTestTool.h:28
CP::IsoVariableHelper::IsoVariableHelper
IsoVariableHelper(IsoType type, const std::string &backupPreFix, const std::string &isoDecSuffix="")
Definition: IsoVariableHelper.cxx:13
athena.value
value
Definition: athena.py:124
CP::IsoVariableHelper::m_acc_iso_variable
FloatAccessor m_acc_iso_variable
Definition: IsoVariableHelper.h:39
CP::IsoVariableHelper::m_dec_iso_backup
FloatDecorator m_dec_iso_backup
Definition: IsoVariableHelper.h:43
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CP
Select isolated Photons, Electrons and Muons.
Definition: Control/xAODRootAccess/xAODRootAccess/TEvent.h:48
dumpTruth.getName
getName
Definition: dumpTruth.py:34
CP::IsoVariableHelper::getIsolation
CorrectionCode getIsolation(const xAOD::IParticle *particle, float &value) const
Definition: IsoVariableHelper.cxx:54
CP::IsoVariableHelper::getOriginalIsolation
CorrectionCode getOriginalIsolation(const xAOD::IParticle *particle, float &value) const
Definition: IsoVariableHelper.cxx:24
CP::IsoVariableHelper::isotype
IsoType isotype() const
Definition: IsoVariableHelper.cxx:90
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
IsoVariableHelper.h
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::Iso::IsolationType
IsolationType
Overall enumeration for isolation types in xAOD files.
Definition: IsolationType.h:26
CP::IsoVariableHelper::m_dec_IsoIsBackup
CharDecorator m_dec_IsoIsBackup
Definition: IsoVariableHelper.h:36
CP::IsoVariableHelper::m_acc_IsoIsBackup
CharAccessor m_acc_IsoIsBackup
Definition: IsoVariableHelper.h:37
CP::IsoVariableHelper::m_dec_iso_variable
FloatDecorator m_dec_iso_variable
Definition: IsoVariableHelper.h:40
CP::IsoVariableHelper::getIsolationFromOriginal
CorrectionCode getIsolationFromOriginal(const xAOD::IParticle *particle, float &value) const
Definition: IsoVariableHelper.cxx:44
CP::IsoVariableHelper::setIsolation
CorrectionCode setIsolation(const xAOD::IParticle *P, float value) const
Definition: IsoVariableHelper.cxx:78
CP::IsoVariableHelper::name
std::string name() const
Definition: IsoVariableHelper.cxx:91
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::IsoVariableHelper::m_acc_iso_backup
FloatAccessor m_acc_iso_backup
Definition: IsoVariableHelper.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
IsolationHelpers.h
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CP::IsoVariableHelper::backupIsolation
CorrectionCode backupIsolation(const xAOD::IParticle *particle) const
Definition: IsoVariableHelper.cxx:63
SG::ConstAccessor::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
IParticleHelpers.h
xAOD::getOriginalObject
const IParticle * getOriginalObject(const IParticle &copy)
This function can be used to conveniently get a pointer back to the original object from which a copy...
Definition: IParticleHelpers.cxx:140
CP::IsoVariableHelper::m_isoType
IsoType m_isoType
Definition: IsoVariableHelper.h:34