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, const std::string &objectName) 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 23 of file SelectionAccessorReadSys.cxx.

25 : m_selectionName (val_selectionName)
26 {}
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,
const std::string & objectName )
overridevirtual

fill the systematic variations

Implements CP::ISelectionReadAccessor.

Definition at line 89 of file SelectionAccessorReadSys.cxx.

93 {
94 using namespace msgSelectionHelpers;
95
96 std::string baseName = m_selectionName;
97 std::string suffix;
98 if (auto split = baseName.find (',');
99 split != std::string::npos)
100 {
101 suffix = baseName.substr (split);
102 baseName.resize (split);
103 }
104
105 const CP::SystematicSet affecting
106 = svc.getDecorSystematics (objectName, baseName);
107 for (auto& sys : sysList)
108 {
109 CP::SystematicSet inputSys;
110 ANA_CHECK (SystematicSet::filterForAffectingSystematics (sys, affecting, inputSys));
111 std::string decorName;
112 ANA_CHECK (svc.makeSystematicsName (decorName, baseName, inputSys));
113 ANA_MSG_DEBUG ("SysReadDecorHandle: " << decorName << " (" << sys.name() << ")");
114 std::unique_ptr<ISelectionReadAccessor> accessor;
115 ANA_CHECK (makeSelectionReadAccessor (decorName + suffix, accessor));
116 m_dataCache.emplace (sys, std::make_tuple (decorName, std::move (accessor)));
117 }
118 return StatusCode::SUCCESS;
119 }
#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 30 of file SelectionAccessorReadSys.cxx.

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

◆ 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 44 of file SelectionAccessorReadSys.cxx.

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

◆ 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 76 of file SelectionAccessorReadSys.cxx.

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

◆ isBool()

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

whether this accessor returns a simple boolean

Implements CP::ISelectionReadAccessor.

Definition at line 65 of file SelectionAccessorReadSys.cxx.

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

◆ label()

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

get the label of the accessor

Implements CP::ISelectionReadAccessor.

Definition at line 57 of file SelectionAccessorReadSys.cxx.

59 {
60 return m_selectionName;
61 }

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: