ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
CP::AsgxAODMetNTupleMakerAlg::ElementProcessor Class Reference

Class writing all variables from one standalone object. More...

Inheritance diagram for CP::AsgxAODMetNTupleMakerAlg::ElementProcessor:
Collaboration diagram for CP::AsgxAODMetNTupleMakerAlg::ElementProcessor:

Classes

class  BranchProcessor
 Class writing one variable from an xAOD object into a branch. More...
 

Public Member Functions

 ElementProcessor ()
 Default constructor. More...
 
StatusCode process (const SG::AuxElement &element)
 Process the object. More...
 
StatusCode addBranch (TTree &tree, const std::string &auxName, const std::string &branchName, bool allowMissing, bool &created)
 Add one branch to the output tree. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

std::list< BranchProcessorm_branches
 List of branch processors set up for this xAOD object. More...
 
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

Class writing all variables from one standalone object.

It is designed to work with any type inheriting from SG::AuxElement. Like xAOD::EventInfo. Which is its main user at the moment...

Definition at line 79 of file AsgxAODMetNTupleMakerAlg.h.

Constructor & Destructor Documentation

◆ ElementProcessor()

CP::AsgxAODMetNTupleMakerAlg::ElementProcessor::ElementProcessor ( )

Default constructor.

We have to have a default constructor to initialise the asg::AsgMessaging base class correctly. Members of this class would not need an explicit constructor themselves.

Definition at line 360 of file AsgxAODMetNTupleMakerAlg.cxx.

361  : asg::AsgMessaging( "CP::AsgxAODMetNTupleMakerAlg::ElementProcessor" ) {
362 
363  }

Member Function Documentation

◆ addBranch()

StatusCode CP::AsgxAODMetNTupleMakerAlg::ElementProcessor::addBranch ( TTree &  tree,
const std::string &  auxName,
const std::string &  branchName,
bool  allowMissing,
bool &  created 
)

Add one branch to the output tree.

This function is used during the setup of the output tree to create one branch in it, from one specific auxiliary variable. The type of the variable is figured out at runtime using the auxiliary store infrastructure.

Parameters
treeThe tree to create the branch in
auxNameName of the auxiliary variable to create the branch from
branchNameThe name of the branch to create in the tree
allowMissingSet to true to print an error message in case of a failure
createdUsed to store if the branch was actually created
Returns
The usual StatusCode values

Helper class for finding an already existing branch processor.

Type of the predicate's argument

Constructor with key/name

Operator evaluating whether this is the branch we're looking for

< Name of the branch

Definition at line 377 of file AsgxAODMetNTupleMakerAlg.cxx.

381  {
382 
384  class BranchFinder {
385  public:
387  typedef const BranchProcessor& argument_type;
389  BranchFinder( const std::string& branchName ) : m_name( branchName ) {}
391  bool operator()( argument_type bp ) const {
392  return ( bp.m_branchName == m_name );
393  }
394  private:
395  std::string m_name;
396  }; // class BranchFinder
397 
398  // Check if the corresponding aux item exists
399  bool validAuxItem = auxItemExists( auxName );
400  if( ! validAuxItem ) {
401  if( allowMissing ) {
402  // Return gracefully.
403  ATH_MSG_DEBUG( "Aux item \"" << auxName
404  << "\" not readable for branch \""
405  << branchName << "\"" );
406  return StatusCode::SUCCESS;
407  } else {
408  // Return gracefully.
409  ATH_MSG_ERROR( "Aux item \"" << auxName
410  << "\" not readable for branch \""
411  << branchName << "\"" );
412  return StatusCode::FAILURE;
413  }
414  }
415 
416  // Check whether this branch is already set up:
417  auto itr = std::find_if( m_branches.begin(), m_branches.end(),
418  BranchFinder( branchName ) );
419  if( itr != m_branches.end() ) {
420  ATH_MSG_WARNING( "Duplicate setup received for branch: " << branchName );
421  return StatusCode::SUCCESS;
422  }
423 
424  created = true;
425 
426  // Set up the new branch.
427  m_branches.emplace_back();
428  ATH_CHECK( m_branches.back().setup( tree, auxName, branchName, msg() ) );
429 
430  // Return gracefully.
431  return StatusCode::SUCCESS;
432  }

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

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

◆ process()

StatusCode CP::AsgxAODMetNTupleMakerAlg::ElementProcessor::process ( const SG::AuxElement element)

Process the object.

This function is called during the event processing to extract all configured variables from a standalone xAOD object into the output variables set up using ElementProcessor::addBranch.

Parameters
elementThe xAOD (interface) object to process
Returns
The usual StatusCode values

Definition at line 365 of file AsgxAODMetNTupleMakerAlg.cxx.

366  {
367 
368  // Process all branches.
369  for( BranchProcessor& p : m_branches ) {
370  ATH_CHECK( p.process( element, msg() ) );
371  }
372 
373  // Return gracefully.
374  return StatusCode::SUCCESS;
375  }

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

std::list< BranchProcessor > CP::AsgxAODMetNTupleMakerAlg::ElementProcessor::m_branches
private

List of branch processors set up for this xAOD object.

Note that when we set up a branch, we tell TTree to remember a physical address in memory. To make sure that the address of the object held by the branch processors are not moved in memory after their construction, we have to use an std::list container here. std::vector would not work. (As it can relocate objects when increasing the size of the container.)

Definition at line 196 of file AsgxAODMetNTupleMakerAlg.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.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_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
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
asg::AsgMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessaging.cxx:49
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
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
AthHistogramming::m_name
std::string m_name
Instance name.
Definition: AthHistogramming.h:245
CP::AsgxAODMetNTupleMakerAlg::ElementProcessor::m_branches
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
Definition: AsgxAODMetNTupleMakerAlg.h:196
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
AthHistogramming::tree
TTree * tree(const std::string &treeName, const std::string &tDir="", const std::string &stream="")
Simplify the retrieval of registered TTrees.
Definition: AthHistogramming.cxx:378