ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor Class Reference

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

Collaboration diagram for CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor:

Public Member Functions

StatusCode setup (TTree &tree, const std::string &auxName, const std::string &branchName, MsgStream &msg)
 Function setting up the object, and the branch. More...
 
StatusCode resize (size_t size, MsgStream &msg)
 Function (re)sizing the variable for a new event. More...
 
StatusCode process (const SG::AuxElement &element, size_t index, MsgStream &msg)
 Function processing the object, filling the variable. More...
 

Public Attributes

std::string m_branchName
 Name of the branch being written. More...
 
std::unique_ptr< SG::AuxElement::TypelessConstAccessorm_acc
 Object accessing the variable in question. More...
 
const SG::IAuxTypeVectorFactorym_factory = nullptr
 Pointer to the helper object that handles this variable. More...
 
std::unique_ptr< SG::IAuxTypeVectorm_data
 The object managing the memory of the written variable. More...
 
void * m_dataPtr = nullptr
 Helper variable, pointing at the object to be written. More...
 

Detailed Description

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

It is used for both setting up the branch in the outut TTree during the setup of the tree, and then to fill the "output variable" with the right payload during the event processing.

Note that since we may have a lot of such objects, I didn't want to make it inherit from asg::AsgMessaging. Which means that all of the class's functions need to receive its parent's message stream object to be able to log error messages "nicely".

Also note that since this is very much an internal class, all of its members are public. Since the owner of such objects should know perfectly well how they behave.

Finally, note that it is more complicated than the ElementProcessor::BranchProcessor class. Since in this case we need to explicitly deal with std::vector types, which we need to fill explicitly when extracting the variables from the xAOD objects.

Definition at line 301 of file AsgxAODNTupleMakerAlg.h.

Member Function Documentation

◆ process()

StatusCode CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::process ( const SG::AuxElement element,
size_t  index,
MsgStream &  msg 
)

Function processing the object, filling the variable.

Definition at line 1010 of file AsgxAODNTupleMakerAlg.cxx.

1011  {
1012 
1013  // A security check.
1014  if( ( ! m_acc ) || ( ! m_factory ) || ( ! m_data ) ) {
1015  msg << MSG::FATAL << "Internal logic error detected" << endmsg;
1016  return StatusCode::FAILURE;
1017  }
1018 
1019  // Get the data out of the xAOD object.
1020  //const void* auxData = ( *m_acc )( element );
1021 
1022  // Copy it into the output variable.
1023  TempInterface dstiface (m_data->size(), m_acc->auxid(), m_data->toPtr());
1024  m_factory->copy( m_acc->auxid(), dstiface, index,
1025  *element.container(), element.index(), 1 );
1026 
1027  // Return gracefully.
1028  return StatusCode::SUCCESS;
1029  }

◆ resize()

StatusCode CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::resize ( size_t  size,
MsgStream &  msg 
)

Function (re)sizing the variable for a new event.

Definition at line 993 of file AsgxAODNTupleMakerAlg.cxx.

994  {
995 
996  // A security check.
997  if( ! m_data ) {
998  msg << MSG::FATAL << "Internal logic error detected" << endmsg;
999  return StatusCode::FAILURE;
1000  }
1001 
1002  // Do the deed.
1003  m_data->resize( 0 );
1004  m_data->resize( size );
1005 
1006  // Return gracefully.
1007  return StatusCode::SUCCESS;
1008  }

◆ setup()

StatusCode CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::setup ( TTree &  tree,
const std::string &  auxName,
const std::string &  branchName,
MsgStream &  msg 
)

Function setting up the object, and the branch.

Definition at line 930 of file AsgxAODNTupleMakerAlg.cxx.

932  {
933 
934  // Remember the branch name.
935  m_branchName = branchName;
936 
937  // Create the accessor.
938  m_acc.reset( new SG::AuxElement::TypelessConstAccessor( auxName ) );
939 
940  // Get a pointer to the vector factory.
942  const std::type_info* ti = reg.getType( m_acc->auxid() );
943  const std::type_info* vecTi = reg.getVecType( m_acc->auxid() );
944  if( ( ! ti ) || ( ! vecTi ) ) {
945  msg << MSG::ERROR
946  << "No std::type_info available for auxiliary variable: "
947  << auxName << endmsg;
948  return StatusCode::FAILURE;
949  }
950  m_factory = reg.getFactory( m_acc->auxid() );
951  if( ! m_factory ) {
952  msg << MSG::ERROR << "No factory found for auxiliary variable: "
953  << auxName << endmsg;
954  return StatusCode::FAILURE;
955  }
956 
957  // Create the data object.
958  m_data = m_factory->create( m_acc->auxid(), 0, 0, false );
959 
960  // Get a proper type name for the variable.
961  const std::string typeName = SG::normalizedTypeinfoName( *vecTi );
962 
963  // Access the dictionary for the type.
964  TClass* cl = TClass::GetClass( *vecTi );
965  if( ! cl ) {
966  cl = TClass::GetClass( typeName.c_str() );
967  }
968  if( ! cl ) {
969  msg << MSG::ERROR << "Couldn't find dictionary for type: "
970  << typeName << endmsg;
971  return StatusCode::FAILURE;
972  }
973  if( ! cl->GetStreamerInfo() ) {
974  msg << MSG::ERROR << "No streamer info available for type: "
975  << cl->GetName() << endmsg;
976  return StatusCode::FAILURE;
977  }
978 
979  // Create the branch.
980  m_dataPtr = m_data->toVector();
981  TBranch* br = tree.Branch( branchName.c_str(), cl->GetName(),
982  &m_dataPtr );
983  if( ! br ) {
984  msg << MSG::ERROR << "Failed to create branch: " << branchName
985  << endmsg;
986  return StatusCode::FAILURE;
987  }
988 
989  // Return gracefully.
990  return StatusCode::SUCCESS;
991  }

Member Data Documentation

◆ m_acc

std::unique_ptr< SG::AuxElement::TypelessConstAccessor > CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_acc

Object accessing the variable in question.

Definition at line 317 of file AsgxAODNTupleMakerAlg.h.

◆ m_branchName

std::string CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_branchName

Name of the branch being written.

Definition at line 315 of file AsgxAODNTupleMakerAlg.h.

◆ m_data

std::unique_ptr< SG::IAuxTypeVector > CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_data

The object managing the memory of the written variable.

Definition at line 321 of file AsgxAODNTupleMakerAlg.h.

◆ m_dataPtr

void* CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_dataPtr = nullptr

Helper variable, pointing at the object to be written.

Definition at line 323 of file AsgxAODNTupleMakerAlg.h.

◆ m_factory

const SG::IAuxTypeVectorFactory* CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_factory = nullptr

Pointer to the helper object that handles this variable.

Definition at line 319 of file AsgxAODNTupleMakerAlg.h.


The documentation for this class was generated from the following files:
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_acc
std::unique_ptr< SG::AuxElement::TypelessConstAccessor > m_acc
Object accessing the variable in question.
Definition: AsgxAODNTupleMakerAlg.h:317
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_factory
const SG::IAuxTypeVectorFactory * m_factory
Pointer to the helper object that handles this variable.
Definition: AsgxAODNTupleMakerAlg.h:319
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
SG::normalizedTypeinfoName
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Definition: normalizedTypeinfoName.cxx:120
index
Definition: index.py:1
SG::IAuxTypeVectorFactory::create
virtual std::unique_ptr< IAuxTypeVector > create(SG::auxid_t auxid, size_t size, size_t capacity, bool isLinked) const =0
Create a vector object of this type.
SG::TypelessConstAccessor
Helper class to provide const generic access to aux data.
Definition: TypelessConstAccessor.h:44
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_branchName
std::string m_branchName
Name of the branch being written.
Definition: AsgxAODNTupleMakerAlg.h:315
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_dataPtr
void * m_dataPtr
Helper variable, pointing at the object to be written.
Definition: AsgxAODNTupleMakerAlg.h:323
asg::AsgMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AsgMessaging.cxx:49
SG::IAuxTypeVectorFactory::copy
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
CP::AsgxAODNTupleMakerAlg::ContainerProcessor::BranchProcessor::m_data
std::unique_ptr< SG::IAuxTypeVector > m_data
The object managing the memory of the written variable.
Definition: AsgxAODNTupleMakerAlg.h:321
ReadCalibFromCool.typeName
typeName
Definition: ReadCalibFromCool.py:477
SG::AuxElement::container
const SG::AuxVectorData * container() const
Return the container holding this element.
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
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
PlotCalibFromCool.br
br
Definition: PlotCalibFromCool.py:355