ATLAS Offline Software
Loading...
Searching...
No Matches
CP::SysListHandle Class Reference

a class managing the property to configure the list of systematics to process More...

#include <SysListHandle.h>

Inheritance diagram for CP::SysListHandle:
Collaboration diagram for CP::SysListHandle:

Public Member Functions

template<typename T>
 SysListHandle (T *owner, const std::string &propertyName="systematicsService", const std::string &propertyDescription="systematics to evaluate")
 standard constructor
StatusCode addHandle (ISysHandleBase &handle)
 register an input handle we are using
::StatusCode initialize ()
 intialize this property
bool isInitialized () const noexcept
 whether initialize has been called successfully
const ISystematicsSvcservice () const
 the service we use
const std::vector< CP::SystematicSet > & systematicsVector () const
 the list of systematics to loop over
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
StatusCode addSystematics (const CP::SystematicSet &recommended, const CP::SystematicSet &affecting)
 register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystematicsTool)
StatusCode addSystematics (const IReentrantSystematicsTool &tool)

Private Member Functions

StatusCode fillSystematicsVector ()

Private Attributes

ServiceHandle< ISystematicsSvcm_systematicsService {"SystematicsSvc", ""}
 the handle for the systematics service
std::string m_affectingFilter
 an (optional) filter to remove affecting systematics
std::vector< ISysHandleBase * > m_sysHandles
 the list of systematics handles we have
CP::SystematicSet m_affecting
 this set of affecting systematics
std::vector< CP::SystematicSetm_systematicsVector
 the value of systematicsVector
bool m_isInitialized = false
 the value of isInitialized
std::function< MsgStream &()> m_msg
 the message stream we use

Detailed Description

a class managing the property to configure the list of systematics to process

Definition at line 32 of file SysListHandle.h.

Constructor & Destructor Documentation

◆ SysListHandle()

template<typename T>
CP::SysListHandle::SysListHandle ( T * owner,
const std::string & propertyName = "systematicsService",
const std::string & propertyDescription = "systematics to evaluate" )

standard constructor

Member Function Documentation

◆ addHandle()

StatusCode CP::SysListHandle::addHandle ( ISysHandleBase & handle)

register an input handle we are using

This is currently a no-op, but it could be useful for a variety of future directions we could take the systematics handling.

Precondition
!isInitialized()

Definition at line 28 of file SysListHandle.cxx.

30 {
31 if (isInitialized())
32 {
33 ANA_MSG_ERROR ("trying to add/initialize data handle after initializing SysListHandle");
34 return StatusCode::FAILURE;
35 }
36 if (handle.empty())
37 {
38 ANA_MSG_ERROR ("trying to add/initialize empty data handle");
39 return StatusCode::FAILURE;
40 }
41 m_sysHandles.push_back (&handle);
42 return StatusCode::SUCCESS;
43 }
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
std::vector< ISysHandleBase * > m_sysHandles
the list of systematics handles we have
bool isInitialized() const noexcept
whether initialize has been called successfully

◆ addSystematics() [1/2]

StatusCode CP::SysListHandle::addSystematics ( const CP::SystematicSet & recommended,
const CP::SystematicSet & affecting )

register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystematicsTool)

This is currently a no-op, but it could be useful for a variety of future directions we could take the systematics handling (or at least as a cross check of those).

Precondition
!isInitialized()

Definition at line 47 of file SysListHandle.cxx.

50 {
51 assert (!isInitialized());
52 ANA_CHECK (m_systematicsService->addSystematics (recommended, affecting));
53 m_affecting.insert (affecting);
54 return StatusCode::SUCCESS;
55 }
#define ANA_CHECK(EXP)
check whether the given expression was successful
CP::SystematicSet m_affecting
this set of affecting systematics
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service

◆ addSystematics() [2/2]

StatusCode CP::SysListHandle::addSystematics ( const IReentrantSystematicsTool & tool)

Definition at line 59 of file SysListHandle.cxx.

61 {
62 return addSystematics (tool.recommendedSystematics(),
63 tool.affectingSystematics());
64 }
StatusCode addSystematics(const CP::SystematicSet &recommended, const CP::SystematicSet &affecting)
register a set of affecting variables for the current algorithm (usually obtained from an CP::ISystem...

◆ fillSystematicsVector()

StatusCode CP::SysListHandle::fillSystematicsVector ( )
private

Definition at line 104 of file SysListHandle.cxx.

106 {
107 assert (m_systematicsVector.empty());
108
109 std::unordered_set<CP::SystematicSet> knownSys;
110
111 for (const auto& sys : m_systematicsService->makeSystematicsVector())
112 {
113 CP::SystematicSet filtered;
115 if (knownSys.find (filtered) == knownSys.end())
116 {
117 m_systematicsVector.push_back (filtered);
118 knownSys.insert (std::move(filtered));
119 }
120 }
121 return StatusCode::SUCCESS;
122 }
std::vector< CP::SystematicSet > m_systematicsVector
the value of systematicsVector
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...

◆ initialize()

StatusCode CP::SysListHandle::initialize ( )

intialize this property

This should be called exactly once during initialize of the owning algorithm.

Definition at line 68 of file SysListHandle.cxx.

70 {
71 for (ISysHandleBase *handle : m_sysHandles)
72 m_affecting.insert (handle->getInputAffecting (*m_systematicsService));
73 if (!m_affectingFilter.empty())
74 {
75 std::regex filter (m_affectingFilter);
76 auto affecting = std::move (m_affecting);
77 m_affecting.clear ();
78 for (auto& sys : affecting)
79 {
80 if (!std::regex_match (sys.basename(), filter))
81 {
82 m_affecting.insert (sys);
83 }
84 }
85 }
87 for (ISysHandleBase *handle : m_sysHandles)
89 m_isInitialized = true;
90 return StatusCode::SUCCESS;
91 }
StatusCode fillSystematicsVector()
bool m_isInitialized
the value of isInitialized
std::string m_affectingFilter
an (optional) filter to remove affecting systematics

◆ isInitialized()

bool CP::SysListHandle::isInitialized ( ) const
noexcept

whether initialize has been called successfully

◆ msg() [1/2]

MsgStream & asg::AsgMessagingForward::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 24 of file AsgMessagingForward.cxx.

25 {
26 return m_msg();
27 }
std::function< MsgStream &()> m_msg
the message stream we use

◆ msg() [2/2]

MsgStream & asg::AsgMessagingForward::msg ( const MSG::Level lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 29 of file AsgMessagingForward.cxx.

30 {
31 MsgStream& msg = m_msg ();
32 msg << lvl;
33 return msg;
34 }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool asg::AsgMessagingForward::msgLvl ( const MSG::Level lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 11 of file AsgMessagingForward.cxx.

12 {
13 MsgStream& msg = m_msg();
14 if (msg.level() <= lvl)
15 {
16 msg << lvl;
17 return true;
18 } else
19 {
20 return false;
21 }
22 }

◆ service()

const ISystematicsSvc & CP::SysListHandle::service ( ) const

the service we use

◆ systematicsVector()

const std::vector< CP::SystematicSet > & CP::SysListHandle::systematicsVector ( ) const

the list of systematics to loop over

The way used should use this is as: for (const auto& sys : m_systematicsList.systematicsVector()) { ... }

The important part is to use const auto& instead of const / CP::SystematicSet& here, as in the future this may be updated to be a vector of something other than a CP::SystematicSet (still convertible to const CP::SystematicSet& though).

Definition at line 95 of file SysListHandle.cxx.

97 {
98 assert (isInitialized());
100 }

Member Data Documentation

◆ m_affecting

CP::SystematicSet CP::SysListHandle::m_affecting
private

this set of affecting systematics

Definition at line 126 of file SysListHandle.h.

◆ m_affectingFilter

std::string CP::SysListHandle::m_affectingFilter
private

an (optional) filter to remove affecting systematics

Definition at line 118 of file SysListHandle.h.

◆ m_isInitialized

bool CP::SysListHandle::m_isInitialized = false
private

the value of isInitialized

Definition at line 134 of file SysListHandle.h.

◆ m_msg

std::function<MsgStream& ()> asg::AsgMessagingForward::m_msg
privateinherited

the message stream we use

This used to be a simple pointer to the MsgStream itself, but in AthenaMT the actual object used is local to the thread. So instead of pointing to it directly we are now using a function to look it up, which will get the thread-local object.

Definition at line 77 of file AsgMessagingForward.h.

◆ m_sysHandles

std::vector<ISysHandleBase*> CP::SysListHandle::m_sysHandles
private

the list of systematics handles we have

Definition at line 122 of file SysListHandle.h.

◆ m_systematicsService

ServiceHandle<ISystematicsSvc> CP::SysListHandle::m_systematicsService {"SystematicsSvc", ""}
private

the handle for the systematics service

Definition at line 114 of file SysListHandle.h.

114{"SystematicsSvc", ""};

◆ m_systematicsVector

std::vector<CP::SystematicSet> CP::SysListHandle::m_systematicsVector
private

the value of systematicsVector

Definition at line 130 of file SysListHandle.h.


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