ATLAS Offline Software
OutOfValidityHelper.cxx
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 //
9 // includes
10 //
11 
13 
17 
18 //
19 // method implementations
20 //
21 
22 namespace CP
23 {
25  initialize ()
26  {
27  if (!m_decorationName.empty())
28  {
31  }
32 
33  m_isInitialized = true;
34  return StatusCode::SUCCESS;
35  }
36 
37 
40  const CP::CorrectionCode& code,
41  const char *context) const
42  {
43  assert (m_isInitialized);
44 
45  switch (code)
46  {
48  if (m_write_accessor) m_write_accessor->setBool (particle, true);
49  return StatusCode::SUCCESS;
51  return StatusCode::FAILURE;
53  if (m_write_accessor) m_write_accessor->setBool (particle, false);
54  switch (OutOfValidityAction (m_action))
55  {
57  ANA_MSG_ERROR ("encountered OutOfValidity: " << context);
58  return StatusCode::FAILURE;
60  ANA_MSG_WARNING ("encountered OutOfValidity: " << context);
61  return StatusCode::SUCCESS;
63  return StatusCode::SUCCESS;
64  }
65  }
66  ANA_MSG_ERROR (__FILE__ << ":" << __LINE__ << ": invalid enum value encountered " << code << " " << int (m_action));
67  return StatusCode::FAILURE;
68  }
69 
71  get (const xAOD::IParticle& particle) const {
72  return m_read_accessor->getBool(particle);
73  }
74 
75 
76 }
OutOfValidityHelper.h
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::OutOfValidityAction::SILENT
@ SILENT
don't print anything and return success
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
CP::makeSelectionWriteAccessor
StatusCode makeSelectionWriteAccessor(const std::string &name, std::unique_ptr< ISelectionWriteAccessor > &accessor, bool defaultToChar)
Produces a simple ISelectionWriteAccessor accessing the given decoration.
Definition: ISelectionAccessor.cxx:170
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
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
CP::OutOfValidityAction::ABORT
@ ABORT
print an error message and return a failure status code (triggering an abort)
CP::CorrectionCode::OutOfValidityRange
@ OutOfValidityRange
Input object is out of validity range.
Definition: CorrectionCode.h:37
CP::CorrectionCode::Error
@ Error
Some error happened during the object correction.
Definition: CorrectionCode.h:36
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
MessageCheck.h
macros for messaging and checking status codes
ANA_MSG_WARNING
#define ANA_MSG_WARNING(xmsg)
Macro printing warning messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:292
CP::OutOfValidityHelper::get
bool get(const xAOD::IParticle &particle) const
retrieve the OutOfValidity decision, where true = particle passes validity check
Definition: OutOfValidityHelper.cxx:71
StatusCode.h
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::makeSelectionReadAccessor
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
Definition: ISelectionAccessor.cxx:54
CP::OutOfValidityHelper::initialize
::StatusCode initialize()
standard initialize
Definition: OutOfValidityHelper.cxx:25
CP::CorrectionCode::Ok
@ Ok
The correction was done successfully.
Definition: CorrectionCode.h:38
CP::CorrectionCode
Return value from object correction CP tools.
Definition: CorrectionCode.h:31
CP::OutOfValidityHelper::m_isInitialized
bool m_isInitialized
whether we have been initialized
Definition: OutOfValidityHelper.h:114
CorrectionCode.h