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

#include <ConfigHelper.h>

Inheritance diagram for jet::ConfigHelper:
Collaboration diagram for jet::ConfigHelper:

Public Member Functions

 ConfigHelper (const TString &confPrefix, const TString &MCtype, const float energyScaleVal)
virtual StatusCode initialize (TEnv &settings)
virtual ~ConfigHelper ()
bool isCompGroup () const
bool isComponent () const
bool isGroup () const
const ComponentHelpergetComponentInfo () const
const GroupHelpergetGroupInfo () const
void enforceGroupNamePrefix (const std::string &prefix)
void enforceGroupNamePrefix (const TString &prefix)
void setComponentJetDefSuffix (const std::string &suffix)
void setComponentJetDefSuffix (const TString &suffix)
void addValidityHistogram (const std::string &histName)
void addValidityHistogram (const TString &histName)

Private Member Functions

 ConfigHelper ()
void setLevel (MSG::Level lvl)
 Change the current logging level.
void initMessaging () const
 Initialize our message level and MessageSvc.
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 Attributes

bool m_isInit {}
const TString m_confPrefix
const TString m_MCtype
const float m_energyScale {}
ComponentHelperm_cInfo {}
GroupHelperm_gInfo {}
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 105 of file ConfigHelper.h.

Constructor & Destructor Documentation

◆ ConfigHelper() [1/2]

jet::ConfigHelper::ConfigHelper ( const TString & confPrefix,
const TString & MCtype,
const float energyScaleVal )

Definition at line 172 of file ConfigHelper.cxx.

173 : asg::AsgMessaging(confPrefix.Data())
174 , m_isInit(false)
175 , m_confPrefix(confPrefix)
176 , m_MCtype(MCtype)
177 , m_energyScale(energyScaleVal)
178 , m_cInfo(nullptr)
179 , m_gInfo(nullptr)
180{ }
ComponentHelper * m_cInfo
const TString m_confPrefix
GroupHelper * m_gInfo
const TString m_MCtype
const float m_energyScale

◆ ~ConfigHelper()

jet::ConfigHelper::~ConfigHelper ( )
virtual

◆ ConfigHelper() [2/2]

jet::ConfigHelper::ConfigHelper ( )
private

Definition at line 160 of file ConfigHelper.cxx.

161 : asg::AsgMessaging("")
162 , m_isInit(false)
163 , m_confPrefix("")
164 , m_MCtype("")
165 , m_energyScale(0)
166 , m_cInfo(nullptr)
167 , m_gInfo(nullptr)
168{
170}

Member Function Documentation

◆ addValidityHistogram() [1/2]

void jet::ConfigHelper::addValidityHistogram ( const std::string & histName)

Definition at line 324 of file ConfigHelper.cxx.

325{
326 addValidityHistogram(TString(histName.c_str()));
327}
void addValidityHistogram(const std::string &histName)

◆ addValidityHistogram() [2/2]

void jet::ConfigHelper::addValidityHistogram ( const TString & histName)

Definition at line 329 of file ConfigHelper.cxx.

330{
331 if (histName != "")
332 {
333 if (m_cInfo->validName != "")
334 {
335 ATH_MSG_WARNING(Form("Ignoring request to add validity histogram to: %s",m_cInfo->name.Data()));
336 ATH_MSG_WARNING(Form("The following validity histogram was already specified: %s",m_cInfo->validName.Data()));
337 ATH_MSG_WARNING(Form("Blocking overwrite with a new validity histogram: %s",histName.Data()));
338 }
339 else
340 m_cInfo->validName = histName;
341 }
342}
#define ATH_MSG_WARNING(x)

◆ enforceGroupNamePrefix() [1/2]

void jet::ConfigHelper::enforceGroupNamePrefix ( const std::string & prefix)

Definition at line 280 of file ConfigHelper.cxx.

281{
282 enforceGroupNamePrefix(TString(prefix.c_str()));
283}
void enforceGroupNamePrefix(const std::string &prefix)

◆ enforceGroupNamePrefix() [2/2]

void jet::ConfigHelper::enforceGroupNamePrefix ( const TString & prefix)

Definition at line 285 of file ConfigHelper.cxx.

286{
287 // Special config file string must exactly match this to activate the condition
288 const TString NOPREFIX = "NOPREFIX_";
289
290 // Check for a special NOPREFIX string
291 // This is to support parameters from other groups we have propagated into our uncertainties
292 // NPs can now have the same name, so tools will coherently scale different properties for the same uncertainty name
293 if (m_gInfo->name.BeginsWith(NOPREFIX))
294 m_gInfo->name = m_gInfo->name.ReplaceAll(NOPREFIX,"");
295
296 // Doesn't have the prefix
297 else if (!m_gInfo->name.BeginsWith(prefix,TString::kIgnoreCase))
298 m_gInfo->name = Form("%s%s",prefix.Data(),m_gInfo->name.Data());
299 // Has the right prefix, but not the right case (enforce identical prefix)
300 else if (!m_gInfo->name.BeginsWith(prefix))
301 m_gInfo->name.Replace(0,prefix.Length(),prefix);
302}

◆ getComponentInfo()

const ComponentHelper * jet::ConfigHelper::getComponentInfo ( ) const

Definition at line 260 of file ConfigHelper.cxx.

261{
262 if (!m_isInit)
263 {
264 ATH_MSG_ERROR("ConfigHelper has not yet been initialized: " << m_confPrefix.Data());
265 return nullptr;
266 }
267 return m_cInfo;
268}
#define ATH_MSG_ERROR(x)

◆ getGroupInfo()

const GroupHelper * jet::ConfigHelper::getGroupInfo ( ) const

Definition at line 270 of file ConfigHelper.cxx.

271{
272 if (!m_isInit)
273 {
274 ATH_MSG_ERROR("ConfigHelper has not yet been initialized: " << m_confPrefix.Data());
275 return nullptr;
276 }
277 return m_gInfo;
278}

◆ initialize()

StatusCode jet::ConfigHelper::initialize ( TEnv & settings)
virtual

Definition at line 188 of file ConfigHelper.cxx.

189{
190 if (m_isInit)
191 {
192 ATH_MSG_ERROR("Blocking double-initialization: " << m_confPrefix.Data());
193 return StatusCode::FAILURE;
194 }
195
196 m_cInfo = new ComponentHelper(settings, m_confPrefix, m_MCtype, m_energyScale);
197 if (!m_cInfo)
198 {
199 ATH_MSG_ERROR("Failed to create ComponentHelper: " << m_confPrefix.Data());
200 return StatusCode::FAILURE;
201 }
202
203 m_gInfo = new GroupHelper(settings, m_confPrefix, m_MCtype);
204 if (!m_gInfo)
205 {
206 ATH_MSG_ERROR("Failed to create GroupHelper: " << m_confPrefix.Data());
207 return StatusCode::FAILURE;
208 }
209
210 m_isInit = true;
211 return StatusCode::SUCCESS;
212}

◆ 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)

◆ isCompGroup()

bool jet::ConfigHelper::isCompGroup ( ) const

Definition at line 214 of file ConfigHelper.cxx.

215{
216 if (!m_isInit)
217 {
218 ATH_MSG_ERROR("ConfigHelper has not yet been initialized: " << m_confPrefix.Data());
219 return false;
220 }
221
222 // Simple group possibilities:
223 // Single-component with all group info specified on the component, "Group" == 0 (or unspec)
224 // Multi-component "SubComp" with all group info specified on the component, "Group" == 0
225 // So the defining factor of simple groups is "Group" == 0 (== unspecified)
226 // It also has to have a name to ensure it's not just empty (it will be if this is a group)
227 if (m_cInfo->groupNum == 0 && m_cInfo->name != "")
228 return true;
229 return false;
230}

◆ isComponent()

bool jet::ConfigHelper::isComponent ( ) const

Definition at line 232 of file ConfigHelper.cxx.

233{
234 if (!m_isInit)
235 {
236 ATH_MSG_ERROR("ConfigHelper has not yet been initialized: " << m_confPrefix.Data());
237 return false;
238 }
239
240 // Component means that it has a component name and that the group is specified
241 if (m_cInfo->groupNum != 0 && m_cInfo->name != "")
242 return true;
243 return false;
244}

◆ isGroup()

bool jet::ConfigHelper::isGroup ( ) const

Definition at line 246 of file ConfigHelper.cxx.

247{
248 if (!m_isInit)
249 {
250 ATH_MSG_ERROR("ConfigHelper has not yet been initialized: " << m_confPrefix.Data());
251 return false;
252 }
253
254 // Group means that it has a group name and the group is specified
255 if (m_gInfo->groupNum != 0 && m_gInfo->name != "")
256 return true;
257 return false;
258}

◆ 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 }

◆ setComponentJetDefSuffix() [1/2]

void jet::ConfigHelper::setComponentJetDefSuffix ( const std::string & suffix)

Definition at line 304 of file ConfigHelper.cxx.

305{
306 setComponentJetDefSuffix(TString(suffix.c_str()));
307}
void setComponentJetDefSuffix(const std::string &suffix)

◆ setComponentJetDefSuffix() [2/2]

void jet::ConfigHelper::setComponentJetDefSuffix ( const TString & suffix)

Definition at line 309 of file ConfigHelper.cxx.

310{
311 if (m_cInfo->uncNames.empty() && m_cInfo->subComps.empty())
312 m_cInfo->uncNames.push_back(m_cInfo->name+"_"+suffix);
313 else if (!m_cInfo->uncNames.empty())
314 for (size_t iName = 0; iName < m_cInfo->uncNames.size(); ++iName)
315 m_cInfo->uncNames[iName] = m_cInfo->uncNames[iName] + "_" + suffix;
316 else if (!m_cInfo->subComps.empty())
317 for (size_t iSubComp = 0; iSubComp < m_cInfo->subComps.size(); ++iSubComp)
318 m_cInfo->subComps[iSubComp] = m_cInfo->subComps[iSubComp] + "_" + suffix;
319
320 if (m_cInfo->validName != "")
321 m_cInfo->validName = m_cInfo->validName+"_"+suffix;
322}

◆ 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_cInfo

ComponentHelper* jet::ConfigHelper::m_cInfo {}
private

Definition at line 140 of file ConfigHelper.h.

140{};

◆ m_confPrefix

const TString jet::ConfigHelper::m_confPrefix
private

Definition at line 135 of file ConfigHelper.h.

◆ m_energyScale

const float jet::ConfigHelper::m_energyScale {}
private

Definition at line 137 of file ConfigHelper.h.

137{};

◆ m_gInfo

GroupHelper* jet::ConfigHelper::m_gInfo {}
private

Definition at line 141 of file ConfigHelper.h.

141{};

◆ 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::ConfigHelper::m_isInit {}
private

Definition at line 132 of file ConfigHelper.h.

132{};

◆ 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_MCtype

const TString jet::ConfigHelper::m_MCtype
private

Definition at line 136 of file ConfigHelper.h.

◆ 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_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.


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