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

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

Inheritance diagram for CP::AsgxAODNTupleMakerAlg::ElementProcessor:
Collaboration diagram for CP::AsgxAODNTupleMakerAlg::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 103 of file AsgxAODNTupleMakerAlg.h.

Constructor & Destructor Documentation

◆ ElementProcessor()

CP::AsgxAODNTupleMakerAlg::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 614 of file AsgxAODNTupleMakerAlg.cxx.

615  : asg::AsgMessaging( "CP::AsgxAODNTupleMakerAlg::ElementProcessor" ) {
616 
617  }

Member Function Documentation

◆ addBranch()

StatusCode CP::AsgxAODNTupleMakerAlg::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 631 of file AsgxAODNTupleMakerAlg.cxx.

635  {
636 
638  class BranchFinder {
639  public:
641  typedef const BranchProcessor& argument_type;
643  BranchFinder( const std::string& branchName ) : m_name( branchName ) {}
645  bool operator()( argument_type bp ) const {
646  return ( bp.m_branchName == m_name );
647  }
648  private:
649  std::string m_name;
650  }; // class BranchFinder
651 
652  // Check if the corresponding aux item exists
653  bool validAuxItem = auxItemExists( auxName );
654  if( ! validAuxItem ) {
655  if( allowMissing ) {
656  // Return gracefully.
657  ATH_MSG_DEBUG( "Aux item \"" << auxName
658  << "\" not readable for branch \""
659  << branchName << "\"" );
660  return StatusCode::SUCCESS;
661  } else {
662  // Return gracefully.
663  ATH_MSG_ERROR( "Aux item \"" << auxName
664  << "\" not readable for branch \""
665  << branchName << "\"" );
666  return StatusCode::FAILURE;
667  }
668  }
669 
670  // Check whether this branch is already set up:
671  auto itr = std::find_if( m_branches.begin(), m_branches.end(),
672  BranchFinder( branchName ) );
673  if( itr != m_branches.end() ) {
674  ATH_MSG_WARNING( "Duplicate setup received for branch: " << branchName );
675  return StatusCode::SUCCESS;
676  }
677 
678  created = true;
679 
680  // Set up the new branch.
681  m_branches.emplace_back();
682  ATH_CHECK( m_branches.back().setup( tree, auxName, branchName, msg() ) );
683 
684  // Return gracefully.
685  return StatusCode::SUCCESS;
686  }

◆ 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::AsgxAODNTupleMakerAlg::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 619 of file AsgxAODNTupleMakerAlg.cxx.

620  {
621 
622  // Process all branches.
623  for( BranchProcessor& p : m_branches ) {
624  ATH_CHECK( p.process( element, msg() ) );
625  }
626 
627  // Return gracefully.
628  return StatusCode::SUCCESS;
629  }

◆ 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::AsgxAODNTupleMakerAlg::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 220 of file AsgxAODNTupleMakerAlg.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
CP::AsgxAODNTupleMakerAlg::ElementProcessor::m_branches
std::list< BranchProcessor > m_branches
List of branch processors set up for this xAOD object.
Definition: AsgxAODNTupleMakerAlg.h:220
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
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
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
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