ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 More...
 
StatusCode addHandle (ISysHandleBase &handle)
 register an input handle we are using More...
 
::StatusCode initialize ()
 intialize this property More...
 
bool isInitialized () const noexcept
 whether initialize has been called successfully More...
 
const ISystematicsSvcservice () const
 the service we use More...
 
const std::vector< CP::SystematicSet > & systematicsVector () const
 the list of systematics to loop over More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
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) More...
 
StatusCode addSystematics (const IReentrantSystematicsTool &tool)
 

Private Member Functions

StatusCode fillSystematicsVector ()
 

Private Attributes

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

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  }

◆ 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  }

◆ 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  }

◆ 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 (filtered);
119  }
120  }
121  return StatusCode::SUCCESS;
122  }

◆ 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  {
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  {
83  }
84  }
85  }
87  for (ISysHandleBase *handle : m_sysHandles)
88  ANA_CHECK (handle->fillSystematics (*m_systematicsService, m_affecting, m_systematicsVector));
89  m_isInitialized = true;
90  return StatusCode::SUCCESS;
91  }

◆ 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  }

◆ 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  }

◆ 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());
99  return m_systematicsVector;
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.

◆ 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:
asg::AsgMessagingForward::m_msg
std::function< MsgStream &()> m_msg
the message stream we use
Definition: AsgMessagingForward.h:77
CP::SysListHandle::m_isInitialized
bool m_isInitialized
the value of isInitialized
Definition: SysListHandle.h:134
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
CP::SysListHandle::addSystematics
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...
Definition: SysListHandle.cxx:48
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
ANA_CHECK
#define ANA_CHECK(EXP)
check whether the given expression was successful
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:324
CP::SysListHandle::isInitialized
bool isInitialized() const noexcept
whether initialize has been called successfully
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
asg::AsgMessagingForward::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessagingForward.cxx:24
covarianceTool.filter
filter
Definition: covarianceTool.py:514
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
CP::SysListHandle::m_systematicsVector
std::vector< CP::SystematicSet > m_systematicsVector
the value of systematicsVector
Definition: SysListHandle.h:130
CP::SysListHandle::m_systematicsService
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
Definition: SysListHandle.h:114
CP::SysListHandle::m_affecting
CP::SystematicSet m_affecting
this set of affecting systematics
Definition: SysListHandle.h:126
CP::SysListHandle::m_affectingFilter
std::string m_affectingFilter
an (optional) filter to remove affecting systematics
Definition: SysListHandle.h:118
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
CP::SystematicSet::clear
void clear()
description: clear the set
Definition: SystematicSet.cxx:119
CP::SysListHandle::fillSystematicsVector
StatusCode fillSystematicsVector()
Definition: SysListHandle.cxx:105
CP::SysListHandle::m_sysHandles
std::vector< ISysHandleBase * > m_sysHandles
the list of systematics handles we have
Definition: SysListHandle.h:122
CP::SystematicSet::filterForAffectingSystematics
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Definition: SystematicSet.cxx:213