ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
CP::SystematicsTool Class Referenceabstract

Base class for CP tools providing systematic variations. More...

#include <SystematicsTool.h>

Inheritance diagram for CP::SystematicsTool:
Collaboration diagram for CP::SystematicsTool:

Public Member Functions

 SystematicsTool ()
 effects: standard constructor guarantee: strong failures: out of memory I More...
 
virtual bool isAffectedBySystematic (const SystematicVariation &systematic) const
 returns: whether this tool is affected by the given systematic guarantee: no-fail More...
 
virtual SystematicSet affectingSystematics () const
 returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of memory II More...
 
virtual SystematicSet recommendedSystematics () const
 returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of memory II More...
 
const SystematicSetappliedSystematics () const
 returns: the list of systematics that have been applied to this tool. More...
 
std::string appliedSystematicsString () const
 returns: a string representation of appliedSystematics() guarantee: strong failures: out of memory II rationale: this is meant to be used when printing out the applied systematics for debugging purposes (or when embedding them in a string). More...
 
virtual StatusCode applySystematicVariation (const SystematicSet &systConfig)
 effects: configure this tool for the given list of systematic variations. More...
 
void testInvariant () const
 effects: test the invariance of this object guarantee: no-fail More...
 
virtual void print () const =0
 Print the state of the tool. More...
 

Protected Member Functions

StatusCode addAffectingSystematic (const SystematicVariation &systematic, bool recommended)
 effects: add a systematic to the list of registered systematics. More...
 
StatusCode addRecommendedSystematic (const SystematicVariation &systematic)
 effects: add a systematic to the list of recommended systematics failures: unsupported systematic More...
 
void addAffectingSystematics (const SystematicSet &systematics)
 effects: add a SystematicSet to the registered systematics. More...
 
StatusCode addRecommendedSystematics (const SystematicSet &systematics)
 effects: add a SystematicSet to the recommended systematics. More...
 
virtual StatusCode sysApplySystematicVariation (const SystematicSet &systConfig)=0
 effects: configure this tool for the given list of systematic variations. More...
 

Protected Attributes

SystematicSet m_affectingSystematics
 description: members directly corresponding to accessors More...
 
SystematicSet m_recommendedSystematics
 

Private Attributes

SystematicSetm_appliedSystematics
 description: pointer to currenty applied systematics More...
 
std::unordered_map< SystematicSet, SystematicSetm_systFilterMap
 map of cached systematics filtering More...
 

Detailed Description

Base class for CP tools providing systematic variations.

This module provides a base class for systematics aware CP tools. The interface provided in this module is intended for the general user. The module is considered to be in the pre-alpha stage.

CP tools are not required to use this base class to implement the systematics interface. They can just implement their own version of the interface. Though they should probably take a quick glance of what this class does, particularly they shouldn't forget to register all their systematics with the global list.

The main difference between implementing the interface yourself and using this base class is that with this class you register all the systematics with the base class. The tool then only needs to override sysApplySystematicVariation (instead of applySystematicVariation), which gets passed only the systematics filtered for the affecting systematics (which get also stored in the base class).

Author
Nils Krumnack nils..nosp@m.erik.nosp@m..krum.nosp@m.nack.nosp@m.@cern.nosp@m..ch
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
638687
Date
2015-01-10 21:31:47 +0100 (Sat, 10 Jan 2015)

Definition at line 48 of file SystematicsTool.h.

Constructor & Destructor Documentation

◆ SystematicsTool()

CP::SystematicsTool::SystematicsTool ( )

effects: standard constructor guarantee: strong failures: out of memory I

Definition at line 25 of file SystematicsTool.cxx.

27 
28  RCU_NEW_INVARIANT( this );
29  }

Member Function Documentation

◆ addAffectingSystematic()

StatusCode CP::SystematicsTool::addAffectingSystematic ( const SystematicVariation systematic,
bool  recommended 
)
protected

effects: add a systematic to the list of registered systematics.

It will optionally also add this sytematic to the recommended set. side effects: this will add the systematic to the global list of systematics, if not already there guarantee: strong failures: out of memory II

Definition at line 111 of file SystematicsTool.cxx.

112  {
113 
114  RCU_READ_INVARIANT( this );
115 
116  SystematicRegistry& reg = SystematicRegistry::getInstance();
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  }

◆ addAffectingSystematics()

void CP::SystematicsTool::addAffectingSystematics ( const SystematicSet systematics)
protected

effects: add a SystematicSet to the registered systematics.

Definition at line 141 of file SystematicsTool.cxx.

142  {
143 
144  RCU_READ_INVARIANT( this );
145 
146  SystematicRegistry& reg = SystematicRegistry::getInstance();
148  reg.registerSystematics( systematics );
149  }

◆ addRecommendedSystematic()

StatusCode CP::SystematicsTool::addRecommendedSystematic ( const SystematicVariation systematic)
protected

effects: add a systematic to the list of recommended systematics failures: unsupported systematic

Definition at line 127 of file SystematicsTool.cxx.

128  {
129 
130  RCU_READ_INVARIANT( this );
131 
132  SystematicRegistry& reg = SystematicRegistry::getInstance();
133  m_recommendedSystematics.insert( systematic );
134  if( reg.addSystematicToRecommended( systematic ) !=
135  StatusCode::SUCCESS ) {
136  return StatusCode::FAILURE;
137  }
138  return StatusCode::SUCCESS;
139  }

◆ addRecommendedSystematics()

StatusCode CP::SystematicsTool::addRecommendedSystematics ( const SystematicSet systematics)
protected

effects: add a SystematicSet to the recommended systematics.

Definition at line 151 of file SystematicsTool.cxx.

152  {
153 
154  RCU_READ_INVARIANT( this );
155 
156  SystematicRegistry& reg = SystematicRegistry::getInstance();
158  if( reg.addSystematicsToRecommended( systematics ) !=
159  StatusCode::SUCCESS ) {
160  return StatusCode::FAILURE;
161  }
162  return StatusCode::SUCCESS;
163  }

◆ affectingSystematics()

SystematicSet CP::SystematicsTool::affectingSystematics ( ) const
virtual

returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of memory II

Implements CP::IReentrantSystematicsTool.

Reimplemented in CP::JetJvtEfficiency, CP::JetQGTagger, and met::METSystematicsTool.

Definition at line 40 of file SystematicsTool.cxx.

40  {
41 
42  RCU_READ_INVARIANT( this );
44  }

◆ appliedSystematics()

const SystematicSet & CP::SystematicsTool::appliedSystematics ( ) const

returns: the list of systematics that have been applied to this tool.

this is not including systematics that were applied, but do not affect this tool guarantee: no-fail

Definition at line 54 of file SystematicsTool.cxx.

54  {
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  }
64  return *m_appliedSystematics;
65  }

◆ appliedSystematicsString()

std::string CP::SystematicsTool::appliedSystematicsString ( ) const

returns: a string representation of appliedSystematics() guarantee: strong failures: out of memory II rationale: this is meant to be used when printing out the applied systematics for debugging purposes (or when embedding them in a string).

Definition at line 67 of file SystematicsTool.cxx.

67  {
68 
69  RCU_READ_INVARIANT( this );
70  return m_appliedSystematics->name();
71  }

◆ applySystematicVariation()

StatusCode CP::SystematicsTool::applySystematicVariation ( const SystematicSet systConfig)
virtual

effects: configure this tool for the given list of systematic variations.

any requested systematics that are not affecting this tool will be silently ignored (unless they cause other errors). guarantee: basic failures: out of memory II failures: systematic unknown failures: requesting multiple variations on the same systematic (e.g. up & down) failures: requesting an unsupported variation on an otherwise supported systematic (e.g. a 2 sigma variation and the tool only supports 1 sigma variations) failures: unsupported combination of supported systematic failures: other tool specific errors

Implements CP::ISystematicsTool.

Reimplemented in CP::JetQGTagger, CP::JetJvtEfficiency, and met::METSystematicsTool.

Definition at line 73 of file SystematicsTool.cxx.

74  {
75 
76  RCU_CHANGE_INVARIANT( this );
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  }

◆ isAffectedBySystematic()

bool CP::SystematicsTool::isAffectedBySystematic ( const SystematicVariation systematic) const
virtual

returns: whether this tool is affected by the given systematic guarantee: no-fail

Implements CP::ISystematicsTool.

Reimplemented in CP::JetQGTagger, CP::JetJvtEfficiency, and met::METSystematicsTool.

Definition at line 31 of file SystematicsTool.cxx.

32  {
33 
34  RCU_READ_INVARIANT( this );
35  return ( m_affectingSystematics.find( systematic ) !=
37  }

◆ print()

virtual void asg::IAsgTool::print ( ) const
pure virtualinherited

◆ recommendedSystematics()

SystematicSet CP::SystematicsTool::recommendedSystematics ( ) const
virtual

returns: the list of all systematics this tool can be affected by guarantee: strong failures: out of memory II

Implements CP::IReentrantSystematicsTool.

Reimplemented in CP::JetJvtEfficiency, CP::JetQGTagger, and met::METSystematicsTool.

Definition at line 47 of file SystematicsTool.cxx.

47  {
48 
49  RCU_READ_INVARIANT( this );
51  }

◆ sysApplySystematicVariation()

virtual StatusCode CP::SystematicsTool::sysApplySystematicVariation ( const SystematicSet systConfig)
protectedpure virtual

effects: configure this tool for the given list of systematic variations.

systConfig is guaranteed to contain only supported systematics. guarantee: basic failures: out of memory II failures: unsupported combination of supported systematics failures: other tool specific errors

Implemented in CP::JetQGTagger, CP::FJvtEfficiencyTool, CP::JvtEfficiencyTool, CP::NNJvtEfficiencyTool, CP::JetJvtEfficiency, and met::METSystematicsTool.

◆ testInvariant()

void CP::SystematicsTool::testInvariant ( ) const

effects: test the invariance of this object guarantee: no-fail

Definition at line 165 of file SystematicsTool.cxx.

165  {
166 
167  //RCU_INVARIANT( this != 0 );
168  }

Member Data Documentation

◆ m_affectingSystematics

SystematicSet CP::SystematicsTool::m_affectingSystematics
protected

description: members directly corresponding to accessors

Definition at line 146 of file SystematicsTool.h.

◆ m_appliedSystematics

SystematicSet* CP::SystematicsTool::m_appliedSystematics
private

description: pointer to currenty applied systematics

Definition at line 151 of file SystematicsTool.h.

◆ m_recommendedSystematics

SystematicSet CP::SystematicsTool::m_recommendedSystematics
protected

Definition at line 147 of file SystematicsTool.h.

◆ m_systFilterMap

std::unordered_map<SystematicSet, SystematicSet> CP::SystematicsTool::m_systFilterMap
private

map of cached systematics filtering

Definition at line 154 of file SystematicsTool.h.


The documentation for this class was generated from the following files:
CP::SystematicsTool::m_appliedSystematics
SystematicSet * m_appliedSystematics
description: pointer to currenty applied systematics
Definition: SystematicsTool.h:151
CP::SystematicSet::name
std::string name() const
returns: the systematics joined into a single string.
Definition: SystematicSet.cxx:278
CP::SystematicsTool::m_affectingSystematics
SystematicSet m_affectingSystematics
description: members directly corresponding to accessors
Definition: SystematicsTool.h:146
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
CP::SystematicsTool::addRecommendedSystematic
StatusCode addRecommendedSystematic(const SystematicVariation &systematic)
effects: add a systematic to the list of recommended systematics failures: unsupported systematic
Definition: SystematicsTool.cxx:128
CP::SystematicsTool::m_systFilterMap
std::unordered_map< SystematicSet, SystematicSet > m_systFilterMap
map of cached systematics filtering
Definition: SystematicsTool.h:154
CP::SystematicsTool::sysApplySystematicVariation
virtual StatusCode sysApplySystematicVariation(const SystematicSet &systConfig)=0
effects: configure this tool for the given list of systematic variations.
CP::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition: SystematicSet.h:59
python.xAODType.dummy
dummy
Definition: xAODType.py:4
CheckAppliedSFs.systematics
def systematics
Definition: CheckAppliedSFs.py:231
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
CP::SystematicSet::find
iterator find(const SystematicVariation &sys) const
description: find an element in the set
Definition: SystematicSet.h:63
CP::SystematicsTool::m_recommendedSystematics
SystematicSet m_recommendedSystematics
Definition: SystematicsTool.h:147
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition: Assert.h:231
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition: Assert.h:229
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition: Assert.h:233