ATLAS Offline Software
Loading...
Searching...
No Matches
jet::UncertaintySet Class Reference

#include <UncertaintySet.h>

Inheritance diagram for jet::UncertaintySet:
Collaboration diagram for jet::UncertaintySet:

Public Member Functions

 UncertaintySet (const std::string &name="")
virtual ~UncertaintySet ()
virtual StatusCode initialize (const CP::SystematicSet &systConfig, const std::vector< UncertaintyGroup * > &groups)
virtual std::string getName () const
virtual bool getValidity (const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const
virtual double getUncertainty (const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const
virtual bool getValidUncertainty (double &unc, const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const
virtual std::vector< CompScaleVar::TypeEnumgetScaleVars () const
virtual std::vector< std::pair< CompScaleVar::TypeEnum, bool > > getValiditySet (const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
virtual std::vector< std::pair< CompScaleVar::TypeEnum, double > > getUncertaintySet (const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
virtual std::vector< std::pair< CompScaleVar::TypeEnum, bool > > getValidUncertaintySet (std::vector< std::pair< CompScaleVar::TypeEnum, double > > &unc, const xAOD::Jet &jet, const xAOD::EventInfo &eInfo) const
JetTopology::TypeEnum getTopology (const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const
void setLevel (MSG::Level lvl)
 Change the current logging level.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Private Member Functions

CompScaleVar::TypeEnum getSingleVar () const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

const std::string m_name
bool m_isInit
std::vector< UncertaintyGroup * > m_groups
std::vector< float > m_shiftWeights
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 28 of file UncertaintySet.h.

Constructor & Destructor Documentation

◆ UncertaintySet()

jet::UncertaintySet::UncertaintySet ( const std::string & name = "")

Definition at line 23 of file UncertaintySet.cxx.

24 : asg::AsgMessaging(name)
25 , m_name(name)
26 , m_isInit(false)
27 , m_groups()
29{ }
std::vector< float > m_shiftWeights
const std::string m_name
std::vector< UncertaintyGroup * > m_groups

◆ ~UncertaintySet()

jet::UncertaintySet::~UncertaintySet ( )
virtualdefault

Member Function Documentation

◆ getName()

std::string jet::UncertaintySet::getName ( ) const
virtual

Definition at line 75 of file UncertaintySet.cxx.

76{
77 return m_name;
78}

◆ getScaleVars()

std::vector< CompScaleVar::TypeEnum > jet::UncertaintySet::getScaleVars ( ) const
virtual

Definition at line 193 of file UncertaintySet.cxx.

194{
195 // Make a super-set and fill it from each group
196 std::set<CompScaleVar::TypeEnum> scaleVarSet;
197 for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup)
198 {
199 std::set<CompScaleVar::TypeEnum> localSet = m_groups.at(iGroup)->getScaleVars();
200 scaleVarSet.insert(localSet.begin(),localSet.end());
201 }
202
203 // Convert to a vector
204 std::vector<CompScaleVar::TypeEnum> scaleVars;
205 std::set<CompScaleVar::TypeEnum>::const_iterator iter;
206 for (iter = scaleVarSet.begin(); iter != scaleVarSet.end(); ++iter)
207 scaleVars.push_back(*(iter));
208 return scaleVars;
209}

◆ getSingleVar()

CompScaleVar::TypeEnum jet::UncertaintySet::getSingleVar ( ) const
private

Definition at line 86 of file UncertaintySet.cxx.

87{
88 std::set<CompScaleVar::TypeEnum> vars = m_groups.at(0)->getScaleVars();
89 if (vars.size() != 1)
91 const CompScaleVar::TypeEnum singleVar = *(vars.begin());
92
93 for (size_t iGroup = 1; iGroup < m_groups.size(); ++iGroup)
94 {
95 std::set<CompScaleVar::TypeEnum> vars2 = m_groups.at(iGroup)->getScaleVars();
96 if (vars2.size() != 1 || singleVar != *(vars2.begin()))
97 {
99 }
100 }
101
102 return singleVar;
103}

◆ getTopology()

JetTopology::TypeEnum jet::UncertaintySet::getTopology ( const CompScaleVar::TypeEnum scaleVar = CompScaleVar::UNKNOWN) const

Definition at line 284 of file UncertaintySet.cxx.

285{
286 // The topology is not normally needed
287 // Most variables are topology-independent, and thus are listed as "UNKNOWN"
288 // Mixing topology-agnostic and topology-specific variables is expected
289 // Mixing topology-specific variables of different topologies is not expected
290
291 // Furthermore, the user can specify either a specific scale variable or not
292 // If the user doesn't specify (or specifies UNKNOWN, the default), then it checks all
293
295
296 for (const UncertaintyGroup* group : m_groups)
297 {
298 if (group->getTopology() != JetTopology::UNKNOWN)
299 {
300 if (result == JetTopology::UNKNOWN)
301 result = group->getTopology();
302 else if (result != group->getTopology(scaleVar))
304 }
305 if (result == JetTopology::MIXED)
306 return result; // If it's mixed, it won't change any further
307 }
308
309 return result; // If we got here, it's not a mixed topology, so return what it is
310}

◆ getUncertainty()

double jet::UncertaintySet::getUncertainty ( const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo,
const CompScaleVar::TypeEnum scaleVar = CompScaleVar::UNKNOWN ) const
virtual

Definition at line 126 of file UncertaintySet.cxx.

127{
128 // This is the sum of shifts multiple uncorrelated groups
129 // This could be a positive or negative number
130 // Each individual group uncertainty will always be positive (quad sum of subgroups)
131 // But the weight may be positive or negative (+N sigma or -N sigma variations)
132
133 if (m_groups.empty())
134 return 0;
135
136 // If the scale var wasn't specified, need to ensure all groups match
137 const bool checkScaleVar = scaleVar == CompScaleVar::UNKNOWN;
138 const CompScaleVar::TypeEnum scaleVariable = checkScaleVar ? getSingleVar() : scaleVar;
139 if (scaleVariable == CompScaleVar::UNKNOWN)
140 {
141 ATH_MSG_ERROR("Asked for uncertainty of a multi-scale-variable set without specifying any scale variable: " << m_name);
142 return JESUNC_ERROR_CODE;
143 }
144
145 // Checked conditions, now get the uncertainty
146 double unc = 0;
147 for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup)
148 {
149 unc += m_groups.at(iGroup)->getUncertainty(jet,eInfo,scaleVariable)*m_shiftWeights.at(iGroup);
150 }
151
152 return unc;
153}
#define ATH_MSG_ERROR(x)
CompScaleVar::TypeEnum getSingleVar() const

◆ getUncertaintySet()

std::vector< std::pair< CompScaleVar::TypeEnum, double > > jet::UncertaintySet::getUncertaintySet ( const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo ) const
virtual

Definition at line 230 of file UncertaintySet.cxx.

231{
232 std::vector< std::pair<CompScaleVar::TypeEnum,double> > unc;
233
234 // Simple case
235 if (m_groups.empty())
236 return unc;
237
238 // Get the sets
239 const std::vector<CompScaleVar::TypeEnum> scaleVars = getScaleVars();
240
241 // Process the sets one by one
242 for (size_t iVar = 0; iVar < scaleVars.size(); ++iVar)
243 unc.emplace_back(scaleVars.at(iVar),getUncertainty(jet,eInfo,scaleVars.at(iVar)));
244
245 // Done, return
246 return unc;
247}
virtual double getUncertainty(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const
virtual std::vector< CompScaleVar::TypeEnum > getScaleVars() const

◆ getValidity()

bool jet::UncertaintySet::getValidity ( const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo,
const CompScaleVar::TypeEnum scaleVar = CompScaleVar::UNKNOWN ) const
virtual

Definition at line 105 of file UncertaintySet.cxx.

106{
107 if (m_groups.empty())
108 return true;
109
110 // If the scale var wasn't specified, need to ensure all groups match
111 const bool checkScaleVar = scaleVar == CompScaleVar::UNKNOWN;
112 const CompScaleVar::TypeEnum scaleVariable = checkScaleVar ? getSingleVar() : scaleVar;
113 if (scaleVariable == CompScaleVar::UNKNOWN)
114 {
115 ATH_MSG_ERROR("Asked for validity of a multi-scale variable set without specifying any scale variable: " << m_name);
116 return false;
117 }
118
119 // Checked conditions, now get the validity
120 for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup)
121 if (!m_groups.at(iGroup)->getValidity(jet,eInfo,scaleVariable))
122 return false;
123 return true;
124}

◆ getValiditySet()

std::vector< std::pair< CompScaleVar::TypeEnum, bool > > jet::UncertaintySet::getValiditySet ( const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo ) const
virtual

Definition at line 211 of file UncertaintySet.cxx.

212{
213 std::vector< std::pair<CompScaleVar::TypeEnum,bool> > validity;
214
215 // Simple case
216 if (m_groups.empty())
217 return validity;
218
219 // Get the sets
220 const std::vector<CompScaleVar::TypeEnum> scaleVars = getScaleVars();
221
222 // Process the sets one by one
223 for (size_t iVar = 0; iVar < scaleVars.size(); ++iVar)
224 validity.emplace_back(scaleVars.at(iVar),getValidity(jet,eInfo,scaleVars.at(iVar)));
225
226 // Done, return
227 return validity;
228}
virtual bool getValidity(const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const

◆ getValidUncertainty()

bool jet::UncertaintySet::getValidUncertainty ( double & unc,
const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo,
const CompScaleVar::TypeEnum scaleVar = CompScaleVar::UNKNOWN ) const
virtual

Definition at line 155 of file UncertaintySet.cxx.

156{
157 // See getUncertainty for discussion
158 // This is not just calling the other two methods for speed, O(n) instead of O(2n)
159
160 if (m_groups.empty())
161 {
162 unc = 0;
163 return true;
164 }
165
166 // If the scale var wasn't specified, need to ensure all groups match
167 const bool checkScaleVar = scaleVar == CompScaleVar::UNKNOWN;
168 const CompScaleVar::TypeEnum scaleVariable = checkScaleVar ? getSingleVar() : scaleVar;
169 if (scaleVariable == CompScaleVar::UNKNOWN)
170 {
171 ATH_MSG_ERROR("Asked for valid uncertainty of a multi-scale-variable set without specifying any scale variable: " << m_name);
172 return false;
173 }
174
175 // Checked conditions, now get the uncertainty and validity
176 double localUnc = 0;
177 for (size_t iGroup = 0; iGroup < m_groups.size(); ++iGroup)
178 {
179 if (!m_groups.at(iGroup)->getValidity(jet,eInfo,scaleVariable))
180 return false;
181 localUnc += m_groups.at(iGroup)->getUncertainty(jet,eInfo,scaleVariable)*m_shiftWeights.at(iGroup);
182 }
183 unc = localUnc;
184 return true;
185}

◆ getValidUncertaintySet()

std::vector< std::pair< CompScaleVar::TypeEnum, bool > > jet::UncertaintySet::getValidUncertaintySet ( std::vector< std::pair< CompScaleVar::TypeEnum, double > > & unc,
const xAOD::Jet & jet,
const xAOD::EventInfo & eInfo ) const
virtual

Definition at line 249 of file UncertaintySet.cxx.

250{
251 std::vector< std::pair<CompScaleVar::TypeEnum,bool> > validity;
252 std::vector< std::pair<CompScaleVar::TypeEnum,double> > localUnc;
253
254 // Simple case
255 if (m_groups.empty())
256 {
257 unc = std::move(localUnc);
258 return validity;
259 }
260
261 // Get the sets
262 const std::vector<CompScaleVar::TypeEnum> scaleVars = getScaleVars();
263
264 // Process the sets one by one
265 for (size_t iVar = 0; iVar < scaleVars.size(); ++iVar)
266 {
267 double localUncValue = JESUNC_ERROR_CODE;
268 validity.emplace_back(scaleVars.at(iVar),getValidUncertainty(localUncValue,jet,eInfo,scaleVars.at(iVar)));
269 localUnc.emplace_back(scaleVars.at(iVar),localUncValue);
270 }
271
272 // Done, return
273 unc = std::move(localUnc);
274 return validity;
275}
virtual bool getValidUncertainty(double &unc, const xAOD::Jet &jet, const xAOD::EventInfo &eInfo, const CompScaleVar::TypeEnum scaleVar=CompScaleVar::UNKNOWN) const

◆ initialize()

StatusCode jet::UncertaintySet::initialize ( const CP::SystematicSet & systConfig,
const std::vector< UncertaintyGroup * > & groups )
virtual

Definition at line 34 of file UncertaintySet.cxx.

35{
36 // Ensure it wasn't already initialized
37 if (m_isInit)
38 {
39 ATH_MSG_ERROR("Blocking double-initialization for: " << m_name.c_str());
40 return StatusCode::FAILURE;
41 }
42
43 // Parse all of the names to get the groups
44 std::set<UncertaintyGroup*> compSet;
45 for (CP::SystematicSet::const_iterator iter = systConfig.begin(); iter != systConfig.end(); ++iter)
46 for (size_t iGroup = 0; iGroup < groups.size(); ++iGroup)
47 if (groups.at(iGroup)->getName().CompareTo(iter->basename().c_str()) == 0)
48 {
49 // Watch for double-specified elements
50 if (compSet.count(groups.at(iGroup)))
51 {
52 ATH_MSG_ERROR("Multiple independent shifts requested for a single group: " << groups.at(iGroup)->getName().Data());
53 return StatusCode::FAILURE;
54 }
55 compSet.insert(groups.at(iGroup));
56
57 m_groups.push_back(groups.at(iGroup));
58 m_shiftWeights.push_back(iter->parameter());
59 break;
60 }
61
62
63 // Ensure all of the elements were found
64 if (systConfig.size() != m_groups.size())
65 {
66 ATH_MSG_ERROR(Form("Input SystematicSet is %zu elements, but only found %zu UncertaintyGroups",systConfig.size(),m_groups.size()));
67 return StatusCode::FAILURE;
68 }
69
70 // All good
71 m_isInit = true;
72 return StatusCode::SUCCESS;
73}
const_iterator end() const
description: const iterator to the end of the set
std::set< SystematicVariation >::const_iterator const_iterator
const_iterator begin() const
description: const iterator to the beginning of the set
size_t size() const
returns: size of the set

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ msg() [1/2]

MsgStream & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49 {
50#ifndef XAOD_STANDALONE
51 return ::AthMessaging::msg();
52#else // not XAOD_STANDALONE
53 return m_msg;
54#endif // not XAOD_STANDALONE
55 }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57 {
58#ifndef XAOD_STANDALONE
59 return ::AthMessaging::msg( lvl );
60#else // not XAOD_STANDALONE
61 m_msg << lvl;
62 return m_msg;
63#endif // not XAOD_STANDALONE
64 }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41 {
42#ifndef XAOD_STANDALONE
43 return ::AthMessaging::msgLvl( lvl );
44#else // not XAOD_STANDALONE
45 return m_msg.msgLevel( lvl );
46#endif // not XAOD_STANDALONE
47 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_groups

std::vector<UncertaintyGroup*> jet::UncertaintySet::m_groups
private

Definition at line 59 of file UncertaintySet.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_isInit

bool jet::UncertaintySet::m_isInit
private

Definition at line 58 of file UncertaintySet.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_name

const std::string jet::UncertaintySet::m_name
private

Definition at line 57 of file UncertaintySet.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_shiftWeights

std::vector<float> jet::UncertaintySet::m_shiftWeights
private

Definition at line 60 of file UncertaintySet.h.


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