ATLAS Offline Software
Loading...
Searching...
No Matches
SysListHandle.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8//
9// includes
10//
11
13
19#include <regex>
20#include <unordered_set>
21
22//
23// method implementations
24//
25
26namespace CP
27{
28 StatusCode SysListHandle ::
29 addHandle (ISysHandleBase& handle)
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 }
44
45
46
47 StatusCode SysListHandle ::
48 addSystematics (const CP::SystematicSet& recommended,
49 const CP::SystematicSet& affecting)
50 {
51 assert (!isInitialized());
52 ANA_CHECK (m_systematicsService->addSystematics (recommended, affecting));
53 m_affecting.insert (affecting);
54 return StatusCode::SUCCESS;
55 }
56
57
58
59 StatusCode SysListHandle ::
60 addSystematics (const IReentrantSystematicsTool& tool)
61 {
62 return addSystematics (tool.recommendedSystematics(),
63 tool.affectingSystematics());
64 }
65
66
67
68 ::StatusCode SysListHandle ::
69 initialize ()
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 }
92
93
94
95 const std::vector<CP::SystematicSet>& SysListHandle ::
96 systematicsVector () const
97 {
98 assert (isInitialized());
100 }
101
102
103
104 StatusCode SysListHandle ::
105 fillSystematicsVector ()
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 }
123
124
125}
macros for messaging and checking status codes
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
interface for all CP tools supporting systematic variations within a reentrant algorithm
a basic interface for all systematics handles
virtual bool empty() const noexcept=0
whether this is an empty handle
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...
StatusCode fillSystematicsVector()
CP::SystematicSet m_affecting
this set of affecting systematics
std::vector< ISysHandleBase * > m_sysHandles
the list of systematics handles we have
std::vector< CP::SystematicSet > m_systematicsVector
the value of systematicsVector
bool isInitialized() const noexcept
whether initialize has been called successfully
bool m_isInitialized
the value of isInitialized
ServiceHandle< ISystematicsSvc > m_systematicsService
the handle for the systematics service
std::string m_affectingFilter
an (optional) filter to remove affecting systematics
Class to wrap a set of SystematicVariations.
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
Select isolated Photons, Electrons and Muons.