ATLAS Offline Software
OutOfValidityHelper.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 #ifndef SELECTION_HELPERS__OUT_OF_VALIDITY_HELPER_H
9 #define SELECTION_HELPERS__OUT_OF_VALIDITY_HELPER_H
10 
16 #include <xAODBase/IParticle.h>
17 #include <memory>
18 
19 class StatusCode;
20 
21 namespace CP
22 {
23  class CorrectionCode;
24 
25 
34 
36  {
45  ABORT,
46 
52  WARNING,
53 
59  SILENT
60  };
61 
62 
63 
71 
73  {
75  public:
76  template<typename T>
77  OutOfValidityHelper (T *owner, const std::string& propertyName = "outOfValidity",
78  const std::string& propertyDescription = "how to handle out of validity results");
79 
80 
82  public:
84 
86  public:
88  const CP::CorrectionCode& code,
89  const char *context) const;
90 
92  public:
93  bool get (const xAOD::IParticle& particle) const;
94 
96  private:
98 
100  private:
101  std::unique_ptr<ISelectionWriteAccessor> m_write_accessor;
102  std::unique_ptr<ISelectionReadAccessor> m_read_accessor;
103 
105  private:
106  std::string m_decorationName;
107 
113  private:
114  bool m_isInitialized = false;
115  };
116 
117 
118 
119  template<typename T> OutOfValidityHelper ::
120  OutOfValidityHelper (T *owner, const std::string& propertyName,
121  const std::string& propertyDescription)
122  : asg::AsgMessagingForward (owner)
123  {
124  owner->declareProperty (propertyName, m_action,
125  propertyDescription);
126  owner->declareProperty (propertyName + "Deco", m_decorationName,
127  "decoration to set alongside action described by " + propertyName);
128  }
129 }
130 
132 #define ANA_CHECK_CORRECTION(helper,object,expr) \
133  { if (ATH_UNLIKELY((helper).check ((object), (expr), #expr).isFailure())) \
134  return StatusCode::FAILURE; }
135 
136 #endif
CP::OutOfValidityHelper::m_write_accessor
std::unique_ptr< ISelectionWriteAccessor > m_write_accessor
the accessor if we apply one
Definition: OutOfValidityHelper.h:101
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
CP::OutOfValidityHelper::OutOfValidityHelper
OutOfValidityHelper(T *owner, const std::string &propertyName="outOfValidity", const std::string &propertyDescription="how to handle out of validity results")
standard constructor
Definition: OutOfValidityHelper.h:120
IParticle.h
asg::AsgMessagingForward
base class to forward messages to another class
Definition: AsgMessagingForward.h:29
CP::OutOfValidityHelper
a helper to translate a CP::CorrectionCode into a ::StatusCode
Definition: OutOfValidityHelper.h:73
CP::OutOfValidityAction::SILENT
@ SILENT
don't print anything and return success
asg
Definition: DataHandleTestTool.h:28
AsgMessagingForward.h
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
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
CP::OutOfValidityAction::ABORT
@ ABORT
print an error message and return a failure status code (triggering an abort)
AthUnlikelyMacros.h
histSizes.code
code
Definition: histSizes.py:129
CP::OutOfValidityHelper::m_action
unsigned m_action
the action to take
Definition: OutOfValidityHelper.h:97
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CP::OutOfValidityAction
OutOfValidityAction
the action to perform on encountering an OutOfValidityRange in OutOfValidityHelper
Definition: OutOfValidityHelper.h:36
CP::OutOfValidityHelper::get
bool get(const xAOD::IParticle &particle) const
retrieve the OutOfValidity decision, where true = particle passes validity check
Definition: OutOfValidityHelper.cxx:71
CP::OutOfValidityHelper::m_read_accessor
std::unique_ptr< ISelectionReadAccessor > m_read_accessor
Definition: OutOfValidityHelper.h:102
CP::OutOfValidityHelper::check
::StatusCode check(const xAOD::IParticle &particle, const CP::CorrectionCode &code, const char *context) const
check the correction code and do the proper thing
Definition: OutOfValidityHelper.cxx:39
CP::OutOfValidityHelper::m_decorationName
std::string m_decorationName
the decoration name we use (if we have one)
Definition: OutOfValidityHelper.h:106
CP::OutOfValidityAction::WARNING
@ WARNING
print a warning message and return a success status code.
CP::OutOfValidityHelper::initialize
::StatusCode initialize()
standard initialize
Definition: OutOfValidityHelper.cxx:25
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
ISelectionReadAccessor.h
CP::OutOfValidityHelper::m_isInitialized
bool m_isInitialized
whether we have been initialized
Definition: OutOfValidityHelper.h:114
ISelectionWriteAccessor.h
AuxElement.h
Base class for elements of a container that can have aux data.