ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. More...
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

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. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

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

◆ ~ConfigHelper()

jet::ConfigHelper::~ConfigHelper ( )
virtual

Definition at line 182 of file ConfigHelper.cxx.

183 {
186 }

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

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

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

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

◆ 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  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

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

◆ 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 != "")
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.

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

◆ m_gInfo

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

Definition at line 141 of file ConfigHelper.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_isInit

bool jet::ConfigHelper::m_isInit {}
private

Definition at line 132 of file ConfigHelper.h.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ 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:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
jet::GroupHelper::name
TString name
Definition: ConfigHelper.h:91
jet::ConfigHelper::setComponentJetDefSuffix
void setComponentJetDefSuffix(const std::string &suffix)
Definition: ConfigHelper.cxx:304
jet::ComponentHelper::groupNum
int groupNum
Definition: ConfigHelper.h:46
hotSpotInTAG.suffix
string suffix
Definition: hotSpotInTAG.py:186
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
jet::ConfigHelper::m_cInfo
ComponentHelper * m_cInfo
Definition: ConfigHelper.h:140
jet::ComponentHelper::uncNames
std::vector< TString > uncNames
Definition: ConfigHelper.h:72
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
JESUNC_SAFE_DELETE
#define JESUNC_SAFE_DELETE(T)
Definition: Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:25
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
jet::ConfigHelper::m_MCtype
const TString m_MCtype
Definition: ConfigHelper.h:136
jet::ComponentHelper::validName
TString validName
Definition: ConfigHelper.h:43
jet::ConfigHelper::enforceGroupNamePrefix
void enforceGroupNamePrefix(const std::string &prefix)
Definition: ConfigHelper.cxx:280
jet::GroupHelper::groupNum
int groupNum
Definition: ConfigHelper.h:96
jet::ComponentHelper::name
TString name
Definition: ConfigHelper.h:34
jet::ConfigHelper::m_confPrefix
const TString m_confPrefix
Definition: ConfigHelper.h:135
jet::ConfigHelper::addValidityHistogram
void addValidityHistogram(const std::string &histName)
Definition: ConfigHelper.cxx:324
jet::ConfigHelper::m_isInit
bool m_isInit
Definition: ConfigHelper.h:132
jet::ConfigHelper::m_energyScale
const float m_energyScale
Definition: ConfigHelper.h:137
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
JESUNC_NO_DEFAULT_CONSTRUCTOR
#define JESUNC_NO_DEFAULT_CONSTRUCTOR
Definition: Reconstruction/Jet/JetUncertainties/JetUncertainties/Helpers.h:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
jet::ConfigHelper::m_gInfo
GroupHelper * m_gInfo
Definition: ConfigHelper.h:141
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
jet::ComponentHelper::subComps
std::vector< TString > subComps
Definition: ConfigHelper.h:73