ATLAS Offline Software
Loading...
Searching...
No Matches
CP::SelectionAccessorReadSys Class Referencefinal

the SelectionAccesor for reading systematically varied decorations More...

#include <SelectionAccessorReadSys.h>

Inheritance diagram for CP::SelectionAccessorReadSys:
Collaboration diagram for CP::SelectionAccessorReadSys:

Public Member Functions

 SelectionAccessorReadSys (const std::string &val_selectionName)
virtual SelectionType getBits (const SG::AuxElement &element, const CP::SystematicSet *sys) const override
 get the selection decoration
virtual bool getBool (const SG::AuxElement &element, const CP::SystematicSet *sys) const override
 get the selection decoration
virtual std::string label () const override
 get the label of the accessor
virtual bool isBool () const override
 whether this accessor returns a simple boolean
virtual CP::SystematicSet getInputAffecting (const ISystematicsSvc &svc, const std::string &objectName) const override
 get the systematics when reading from the decoration
virtual StatusCode fillSystematics (const ISystematicsSvc &svc, const std::vector< CP::SystematicSet > &sysList, ISysObjectHandleBase &objectHandle) override
 fill the systematic variations

Private Attributes

std::unordered_map< CP::SystematicSet, std::tuple< std::string, std::unique_ptr< ISelectionReadAccessor > > > m_dataCache
 the map of accessor we use
std::string m_selectionName
 the selectionName for this accessor

Detailed Description

the SelectionAccesor for reading systematically varied decorations

Definition at line 22 of file SelectionAccessorReadSys.h.

Constructor & Destructor Documentation

◆ SelectionAccessorReadSys()

CP::SelectionAccessorReadSys::SelectionAccessorReadSys ( const std::string & val_selectionName)

Definition at line 24 of file SelectionAccessorReadSys.cxx.

26 : m_selectionName (val_selectionName)
27 {}
std::string m_selectionName
the selectionName for this accessor

Member Function Documentation

◆ fillSystematics()

StatusCode CP::SelectionAccessorReadSys::fillSystematics ( const ISystematicsSvc & svc,
const std::vector< CP::SystematicSet > & sysList,
ISysObjectHandleBase & objectHandle )
overridevirtual

fill the systematic variations

Implements CP::ISelectionReadAccessor.

Definition at line 90 of file SelectionAccessorReadSys.cxx.

94 {
95 using namespace msgSelectionHelpers;
96
97 std::string baseName = m_selectionName;
98 std::string suffix;
99 if (auto split = baseName.find (',');
100 split != std::string::npos)
101 {
102 suffix = baseName.substr (split);
103 baseName.resize (split);
104 }
105
106 const CP::SystematicSet affecting
107 = svc.getDecorSystematics (objectHandle.getNamePattern(), baseName);
108 for (auto& sys : sysList)
109 {
110 CP::SystematicSet inputSys;
111 ANA_CHECK (SystematicSet::filterForAffectingSystematics (sys, affecting, inputSys));
112 std::string decorName;
113 ANA_CHECK (svc.makeSystematicsName (decorName, baseName, inputSys));
114 ANA_MSG_DEBUG ("SysReadDecorHandle: " << decorName << " (" << sys.name() << ")");
115 std::unique_ptr<ISelectionReadAccessor> accessor;
116 ANA_CHECK (makeSelectionReadAccessor (decorName + suffix, accessor));
117 m_dataCache.emplace (sys, std::make_tuple (decorName, std::move (accessor)));
118 }
119 ANA_CHECK (objectHandle.addDecorationDependency (svc, baseName, false));
120 return StatusCode::SUCCESS;
121 }
#define ANA_MSG_DEBUG(xmsg)
Macro printing debug messages.
#define ANA_CHECK(EXP)
check whether the given expression was successful
std::unordered_map< CP::SystematicSet, std::tuple< std::string, std::unique_ptr< ISelectionReadAccessor > > > m_dataCache
the map of accessor we use
static StatusCode filterForAffectingSystematics(const SystematicSet &systConfig, const SystematicSet &affectingSystematics, SystematicSet &filteredSystematics)
description: filter the systematics for the affected systematics returns: success guarantee: strong f...
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
StatusCode makeSelectionReadAccessor(const std::string &expr, std::unique_ptr< ISelectionReadAccessor > &accessor, bool defaultToChar)
make the ISelectionReadAccessor for the given name
AthROOTErrorHandlerSvc * svc
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.

◆ getBits()

SelectionType CP::SelectionAccessorReadSys::getBits ( const SG::AuxElement & element,
const CP::SystematicSet * sys ) const
overridevirtual

get the selection decoration

Implements CP::ISelectionReadAccessor.

Definition at line 31 of file SelectionAccessorReadSys.cxx.

34 {
35 if (sys == nullptr)
36 throw std::logic_error ("trying to read systematics accessor without systematic");
37 auto iter = m_dataCache.find (*sys);
38 if (iter == m_dataCache.end())
39 throw std::logic_error ("unknown systematic: " + sys->name());
40 return std::get<1>(iter->second)->getBits (element, sys);
41 }

◆ getBool()

bool CP::SelectionAccessorReadSys::getBool ( const SG::AuxElement & element,
const CP::SystematicSet * sys ) const
overridevirtual

get the selection decoration

Implements CP::ISelectionReadAccessor.

Definition at line 45 of file SelectionAccessorReadSys.cxx.

48 {
49 if (sys == nullptr)
50 throw std::logic_error ("trying to read systematics accessor without systematic");
51 auto iter = m_dataCache.find (*sys);
52 if (iter == m_dataCache.end())
53 throw std::logic_error ("unknown systematic: " + sys->name());
54 return std::get<1>(iter->second)->getBool (element, sys);
55 }

◆ getInputAffecting()

CP::SystematicSet CP::SelectionAccessorReadSys::getInputAffecting ( const ISystematicsSvc & svc,
const std::string & objectName ) const
overridevirtual

get the systematics when reading from the decoration

Implements CP::ISelectionReadAccessor.

Definition at line 77 of file SelectionAccessorReadSys.cxx.

80 {
81 std::string baseName = m_selectionName;
82 if (auto split = baseName.find (',');
83 split != std::string::npos)
84 baseName.resize (split);
85 return svc.getDecorSystematics (objectName, baseName);
86 }

◆ isBool()

bool CP::SelectionAccessorReadSys::isBool ( ) const
overridevirtual

whether this accessor returns a simple boolean

Implements CP::ISelectionReadAccessor.

Definition at line 66 of file SelectionAccessorReadSys.cxx.

68 {
69 for (auto& item : m_dataCache)
70 if (!std::get<1>(item.second)->isBool())
71 return false;
72 return true;
73 }

◆ label()

std::string CP::SelectionAccessorReadSys::label ( ) const
overridevirtual

get the label of the accessor

Implements CP::ISelectionReadAccessor.

Definition at line 58 of file SelectionAccessorReadSys.cxx.

60 {
61 return m_selectionName;
62 }

Member Data Documentation

◆ m_dataCache

std::unordered_map<CP::SystematicSet,std::tuple<std::string,std::unique_ptr<ISelectionReadAccessor> > > CP::SelectionAccessorReadSys::m_dataCache
private

the map of accessor we use

Definition at line 65 of file SelectionAccessorReadSys.h.

◆ m_selectionName

std::string CP::SelectionAccessorReadSys::m_selectionName
private

the selectionName for this accessor

Definition at line 69 of file SelectionAccessorReadSys.h.


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