ATLAS Offline Software
Loading...
Searching...
No Matches
SystematicsTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7
8
9// $Id: SystematicsTool.cxx 768505 2016-08-17 18:13:04Z ssnyder $
10#include <iostream>
11
12// Infrastructure include(s):
14
15// Local include(s):
20
21// Other include(s):
22
23namespace CP {
24
30
32 isAffectedBySystematic( const SystematicVariation& systematic ) const {
33
34 RCU_READ_INVARIANT( this );
35 return ( m_affectingSystematics.find( systematic ) !=
37 }
38
45
52
53 const SystematicSet&
55
56 RCU_READ_INVARIANT( this );
57 if(m_appliedSystematics == 0){
58 std::cerr << "SystematicsTool::appliedSystematics WARNING: "
59 << "no systematic configuration has been applied yet. "
60 << "Returning NULL" << std::endl;
61 static const SystematicSet dummy;
62 return dummy;
63 }
65 }
66
68
69 RCU_READ_INVARIANT( this );
70 return m_appliedSystematics->name();
71 }
72
74 applySystematicVariation( const SystematicSet& systConfig ) {
75
77
78 // First, try to find this input set in the map
79 auto itr = m_systFilterMap.find(systConfig);
80
81 // This is a new input set, so we need to filter it
82 if(itr == m_systFilterMap.end()){
83
84 // Filter input systematics with the affecting systematics
85 SystematicSet myAppliedSystematics;
86 if( SystematicSet::
87 filterForAffectingSystematics( systConfig,
89 myAppliedSystematics ) !=
90 StatusCode::SUCCESS ) {
91 return StatusCode::FAILURE;
92 }
93
94 // Insert the new filtered set onto our filter map
95 itr = m_systFilterMap.insert
96 (std::make_pair(systConfig, myAppliedSystematics)).first;
97
98 }
99
100 // Apply the filtered systematics
101 if( sysApplySystematicVariation( itr->second ) !=
102 StatusCode::SUCCESS ) {
103 return StatusCode::FAILURE;
104 }
105
106 // Store the filtered systematics
107 m_appliedSystematics = &itr->second;
108 return StatusCode::SUCCESS;
109 }
110
112 addAffectingSystematic( const SystematicVariation& systematic, bool recommended ) {
113
114 RCU_READ_INVARIANT( this );
115
117 reg.registerSystematic( systematic );
118 m_affectingSystematics.insert( systematic );
119 if( recommended ) {
120 if( addRecommendedSystematic(systematic) != StatusCode::SUCCESS ) {
121 return StatusCode::FAILURE;
122 }
123 }
124 return StatusCode::SUCCESS;
125 }
126
129
130 RCU_READ_INVARIANT( this );
131
133 m_recommendedSystematics.insert( systematic );
134 if( reg.addSystematicToRecommended( systematic ) !=
135 StatusCode::SUCCESS ) {
136 return StatusCode::FAILURE;
137 }
138 return StatusCode::SUCCESS;
139 }
140
150
153
154 RCU_READ_INVARIANT( this );
155
158 if( reg.addSystematicsToRecommended( systematics ) !=
159 StatusCode::SUCCESS ) {
160 return StatusCode::FAILURE;
161 }
162 return StatusCode::SUCCESS;
163 }
164
166
167 //RCU_INVARIANT( this != 0 );
168 }
169
170} // namespace CP
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
static const std::vector< std::string > systematics
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Class to wrap a set of SystematicVariations.
SystematicsTool()
effects: standard constructor guarantee: strong failures: out of memory I
virtual bool isAffectedBySystematic(const SystematicVariation &systematic) const
returns: whether this tool is affected by the given systematic guarantee: no-fail
SystematicSet * m_appliedSystematics
description: pointer to currenty applied systematics
void addAffectingSystematics(const SystematicSet &systematics)
effects: add a SystematicSet to the registered systematics.
void testInvariant() const
effects: test the invariance of this object guarantee: no-fail
StatusCode addRecommendedSystematic(const SystematicVariation &systematic)
effects: add a systematic to the list of recommended systematics failures: unsupported systematic
virtual StatusCode sysApplySystematicVariation(const SystematicSet &systConfig)=0
effects: configure this tool for the given list of systematic variations.
virtual SystematicSet recommendedSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
SystematicSet m_recommendedSystematics
virtual SystematicSet affectingSystematics() const
returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of ...
std::unordered_map< SystematicSet, SystematicSet > m_systFilterMap
map of cached systematics filtering
StatusCode addRecommendedSystematics(const SystematicSet &systematics)
effects: add a SystematicSet to the recommended systematics.
virtual StatusCode applySystematicVariation(const SystematicSet &systConfig)
effects: configure this tool for the given list of systematic variations.
SystematicSet m_affectingSystematics
description: members directly corresponding to accessors
std::string appliedSystematicsString() const
returns: a string representation of appliedSystematics() guarantee: strong failures: out of memory II...
StatusCode addAffectingSystematic(const SystematicVariation &systematic, bool recommended)
effects: add a systematic to the list of registered systematics.
const SystematicSet & appliedSystematics() const
returns: the list of systematics that have been applied to this tool.
Select isolated Photons, Electrons and Muons.