ATLAS Offline Software
Loading...
Searching...
No Matches
CP::RNtupleFieldHelpers::ContainerProcessor Class Reference

#include <RNtupleFieldHelpers.h>

Inheritance diagram for CP::RNtupleFieldHelpers::ContainerProcessor:
Collaboration diagram for CP::RNtupleFieldHelpers::ContainerProcessor:

Public Member Functions

 ContainerProcessor (const std::string &sgName)
virtual ~ContainerProcessor ()=default
 ContainerProcessor (const ContainerProcessor &)=delete
ContainerProcessoroperator= (const ContainerProcessor &)=delete
virtual StatusCode retrieveProcess (StoreType &evtStore) override
 retrieve and process the object
virtual StatusCode addBranch (ROOT::RNTupleModel &model, const BranchConfig &branchConfig, OutputBranchData &outputData) override
virtual StatusCode addBranch (TTree &tree, const BranchConfig &branchConfig, OutputBranchData &outputData) override
 Add one branch to the output tree.
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

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

Private Attributes

std::string m_sgName
std::vector< std::unique_ptr< ContainerFieldProcessor > > m_fields
TVirtualCollectionProxy * m_collProxy = nullptr
int m_auxElementOffset = -1
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 147 of file RNtupleFieldHelpers.h.

Constructor & Destructor Documentation

◆ ContainerProcessor() [1/2]

CP::RNtupleFieldHelpers::ContainerProcessor::ContainerProcessor ( const std::string & sgName)

Definition at line 409 of file RNtupleFieldHelpers.cxx.

410 : asg::AsgMessaging( "CP::RNtupleFieldHelpers::ContainerProcessor/" + sgName ), m_sgName(sgName) {}

◆ ~ContainerProcessor()

virtual CP::RNtupleFieldHelpers::ContainerProcessor::~ContainerProcessor ( )
virtualdefault

◆ ContainerProcessor() [2/2]

CP::RNtupleFieldHelpers::ContainerProcessor::ContainerProcessor ( const ContainerProcessor & )
delete

Member Function Documentation

◆ addBranch() [1/2]

StatusCode CP::RNtupleFieldHelpers::ContainerProcessor::addBranch ( ROOT::RNTupleModel & model,
const BranchConfig & branchConfig,
OutputBranchData & outputData )
overridevirtual

Implements CP::TreeBranchHelpers::IObjectProcessor.

Definition at line 412 of file RNtupleFieldHelpers.cxx.

414 {
415 if( !auxItemExists(outputData.auxName) ) {
416 ATH_MSG_ERROR("Aux item " << outputData.auxName << " missing");
417 return StatusCode::FAILURE;
418 }
419 m_fields.emplace_back( std::make_unique<ContainerFieldProcessor>() );
420 ATH_CHECK( m_fields.back()->setup( model, branchConfig, outputData, msg() ) );
421 return StatusCode::SUCCESS;
422 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
MsgStream & msg() const
The standard message stream.
std::vector< std::unique_ptr< ContainerFieldProcessor > > m_fields

◆ addBranch() [2/2]

StatusCode CP::RNtupleFieldHelpers::ContainerProcessor::addBranch ( TTree & ,
const BranchConfig & ,
OutputBranchData &  )
overridevirtual

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
Returns
The usual StatusCode values

Implements CP::TreeBranchHelpers::IObjectProcessor.

Definition at line 424 of file RNtupleFieldHelpers.cxx.

426 {
427 ATH_MSG_ERROR("ContainerProcessor::addBranch for TTree should not be called");
428 return StatusCode::FAILURE;
429 }

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

◆ operator=()

ContainerProcessor & CP::RNtupleFieldHelpers::ContainerProcessor::operator= ( const ContainerProcessor & )
delete

◆ retrieveProcess()

StatusCode CP::RNtupleFieldHelpers::ContainerProcessor::retrieveProcess ( StoreType & evtStore)
overridevirtual

retrieve and process the object

This function is called during the event processing to first retrieve the object from the event store, and then to extract all configured variables from the xAOD object into the output variables set up via addBranch.

Implements CP::TreeBranchHelpers::IObjectProcessor.

Definition at line 431 of file RNtupleFieldHelpers.cxx.

431 {
432 // Retrieve the container:
433 static const bool ALLOW_MISSING = false;
434 const TClass* cl = nullptr;
435 const SG::AuxVectorBase* vec = getVector( m_sgName,
436 evtStore,
437 ALLOW_MISSING, cl, msg() );
438
439 if( ! vec ) {
440 ATH_MSG_ERROR( "Failed to retrieve container \""
441 << m_sgName << "\"" );
442 return StatusCode::FAILURE;
443 }
444 const SG::AuxVectorBase& container = *vec;
445 if( ! m_collProxy ) {
446
447 // Get the collection proxy from the dictionary.
448 m_collProxy = cl->GetCollectionProxy();
449 if( ! m_collProxy ) {
450 ATH_MSG_ERROR( "No collection proxy provided by type: "
451 << cl->GetName() );
452 return StatusCode::FAILURE;
453 }
454
455 // Get the offset that one needs to use to get from the element
456 // pointers to SG::AuxElement pointers.
457 static const TClass* const auxElementClass =
458 TClass::GetClass( typeid( SG::AuxElement ) );
460 m_collProxy->GetValueClass()->GetBaseClassOffset( auxElementClass );
461 if( m_auxElementOffset < 0 ) {
462 ATH_MSG_ERROR( "Vector element type \""
463 << m_collProxy->GetValueClass()->GetName()
464 << "\" doesn't seem to inherit from \""
465 << auxElementClass->GetName() << "\"" );
466 return StatusCode::FAILURE;
467 }
468 }
469
470 void* cPtr =
471 const_cast< void* >( static_cast< const void* >( &container ) );
472 TVirtualCollectionProxy::TPushPop helper( m_collProxy, cPtr );
473 const UInt_t cSize = m_collProxy->Size();
474
475 for( auto& p : m_fields ) {
476 ATH_CHECK( p->resize( cSize, msg() ) );
477 }
478
479 for (UInt_t i = 0; i < cSize; ++i) {
480 char* elPtr = static_cast< char* >( m_collProxy->At( i ) );
481 if( ! elPtr ) {
482 ATH_MSG_ERROR( "Failed to get element " << i << " from container" );
483 return StatusCode::FAILURE;
484 }
485 const SG::AuxElement* element =
486 reinterpret_cast< const SG::AuxElement* >( elPtr +
488
489 for ( auto& p : m_fields ) {
490 ATH_CHECK( p->process( *element, i, msg() ) );
491 }
492 }
493 return StatusCode::SUCCESS;
494 }
std::vector< size_t > vec
MsgStream & msg() const
The standard message stream.
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
const SG::AuxVectorData * container() const
Return the container holding this element.
virtual const IAuxTypeVector * getVector(SG::auxid_t auxid) const override
Return vector interface for one aux data item.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]

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

int CP::RNtupleFieldHelpers::ContainerProcessor::m_auxElementOffset = -1
private

Definition at line 168 of file RNtupleFieldHelpers.h.

◆ m_collProxy

TVirtualCollectionProxy* CP::RNtupleFieldHelpers::ContainerProcessor::m_collProxy = nullptr
private

Definition at line 167 of file RNtupleFieldHelpers.h.

◆ m_fields

std::vector< std::unique_ptr<ContainerFieldProcessor> > CP::RNtupleFieldHelpers::ContainerProcessor::m_fields
private

Definition at line 166 of file RNtupleFieldHelpers.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

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

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_sgName

std::string CP::RNtupleFieldHelpers::ContainerProcessor::m_sgName
private

Definition at line 165 of file RNtupleFieldHelpers.h.


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