ATLAS Offline Software
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
RootStorageSvc::RNTupleWriterHelper Class Reference

#include <RNTupleWriterHelper.h>

Inheritance diagram for RootStorageSvc::RNTupleWriterHelper:
Collaboration diagram for RootStorageSvc::RNTupleWriterHelper:

Public Types

typedef std::tuple< std::string, std::string, void * > attrDataTuple
 Add a new field to the RNTuple, collect the data pointer for the commit. More...
 

Public Member Functions

 RNTupleWriterHelper (TFile *file, const std::string &ntupleName, bool enableBufferedWrite, bool enableMetrics)
 Constructor. More...
 
 ~RNTupleWriterHelper ()=default
 Default Destructor. More...
 
void makeNewEntry ()
 Create a new empty RNTuple row with the current model (fields) More...
 
void addAttribute (const attrDataTuple &in)
 
void addField (const std::string &field_name, const std::string &attr_type)
 Add a new field to the RNTuple. More...
 
void addFieldValue (const std::string &field_name, void *attr_data)
 Supply data address for a given field. More...
 
int commit ()
 Commit the data. More...
 
const std::string & getName () const
 Name of the RNTuple. More...
 
size_t size () const
 Size of the RNTuple. More...
 
bool needsCommit () const
 Check if any data needs to be committed. More...
 
bool isGrouped () const
 Is this RNTuple used by more than one APR container? More...
 
void increaseClientCount ()
 Keep track of how many APR containers are writing to this RNTuple. More...
 
void close ()
 Close the writer. More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. 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::map< std::string, void * > m_attrDataMap
 Store data ptr for the first row, when only creating the model. More...
 
std::unique_ptr< RNTupleModelm_model
 Internal cache for the RNTuple model Before first commit the fields are added to the model At the first commit the model passed to the RNTupleWriter which takes its ownership. More...
 
std::unique_ptr< REntrym_entry
 Internal cache for the RNEntry. More...
 
std::unique_ptr< RNTupleWriterm_ntupleWriter
 Internal cache for the native RNTupleWriter. More...
 
std::string m_ntupleName
 
TFile * m_tfile
 
RNTupleWriteOptions m_opts
 
int m_rowN = 0
 
int m_clients = 0
 Count how many APR Containers are writing to this RNTuple (more than one makes a Group) More...
 
bool m_needsCommit = false
 
bool m_collectMetrics
 Enable/Disable Metric Collection. 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

Definition at line 36 of file RNTupleWriterHelper.h.

Member Typedef Documentation

◆ attrDataTuple

typedef std::tuple<std::string, std::string, void*> RootStorageSvc::RNTupleWriterHelper::attrDataTuple

Add a new field to the RNTuple, collect the data pointer for the commit.

Definition at line 50 of file RNTupleWriterHelper.h.

Constructor & Destructor Documentation

◆ RNTupleWriterHelper()

RootStorageSvc::RNTupleWriterHelper::RNTupleWriterHelper ( TFile *  file,
const std::string &  ntupleName,
bool  enableBufferedWrite,
bool  enableMetrics 
)

Constructor.

◆ ~RNTupleWriterHelper()

RootStorageSvc::RNTupleWriterHelper::~RNTupleWriterHelper ( )
default

Default Destructor.

Member Function Documentation

◆ addAttribute()

void RootStorageSvc::RNTupleWriterHelper::addAttribute ( const attrDataTuple in)

◆ addField()

void RootStorageSvc::RNTupleWriterHelper::addField ( const std::string &  field_name,
const std::string &  attr_type 
)

Add a new field to the RNTuple.

◆ addFieldValue()

void RootStorageSvc::RNTupleWriterHelper::addFieldValue ( const std::string &  field_name,
void *  attr_data 
)

Supply data address for a given field.

◆ close()

void RootStorageSvc::RNTupleWriterHelper::close ( )

Close the writer.

◆ commit()

int RootStorageSvc::RNTupleWriterHelper::commit ( )

Commit the data.

◆ getName()

const std::string& RootStorageSvc::RNTupleWriterHelper::getName ( ) const
inline

Name of the RNTuple.

Definition at line 63 of file RNTupleWriterHelper.h.

63 { return m_ntupleName; }

◆ increaseClientCount()

void RootStorageSvc::RNTupleWriterHelper::increaseClientCount ( )
inline

Keep track of how many APR containers are writing to this RNTuple.

Definition at line 75 of file RNTupleWriterHelper.h.

75 { m_clients++; }

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

◆ isGrouped()

bool RootStorageSvc::RNTupleWriterHelper::isGrouped ( ) const
inline

Is this RNTuple used by more than one APR container?

Definition at line 72 of file RNTupleWriterHelper.h.

72 { return m_clients > 1; }

◆ makeNewEntry()

void RootStorageSvc::RNTupleWriterHelper::makeNewEntry ( )

Create a new empty RNTuple row with the current model (fields)

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ needsCommit()

bool RootStorageSvc::RNTupleWriterHelper::needsCommit ( ) const
inline

Check if any data needs to be committed.

Definition at line 69 of file RNTupleWriterHelper.h.

69 { return m_needsCommit; }

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

◆ size()

size_t RootStorageSvc::RNTupleWriterHelper::size ( ) const
inline

Size of the RNTuple.

Definition at line 66 of file RNTupleWriterHelper.h.

66 { return m_rowN; }

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_attrDataMap

std::map<std::string, void*> RootStorageSvc::RNTupleWriterHelper::m_attrDataMap
private

Store data ptr for the first row, when only creating the model.

Definition at line 82 of file RNTupleWriterHelper.h.

◆ m_clients

int RootStorageSvc::RNTupleWriterHelper::m_clients = 0
private

Count how many APR Containers are writing to this RNTuple (more than one makes a Group)

Definition at line 103 of file RNTupleWriterHelper.h.

◆ m_collectMetrics

bool RootStorageSvc::RNTupleWriterHelper::m_collectMetrics
private

Enable/Disable Metric Collection.

Definition at line 107 of file RNTupleWriterHelper.h.

◆ m_entry

std::unique_ptr<REntry> RootStorageSvc::RNTupleWriterHelper::m_entry
private

Internal cache for the RNEntry.

Definition at line 91 of file RNTupleWriterHelper.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_model

std::unique_ptr<RNTupleModel> RootStorageSvc::RNTupleWriterHelper::m_model
private

Internal cache for the RNTuple model Before first commit the fields are added to the model At the first commit the model passed to the RNTupleWriter which takes its ownership.

Definition at line 88 of file RNTupleWriterHelper.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_needsCommit

bool RootStorageSvc::RNTupleWriterHelper::m_needsCommit = false
private

Definition at line 104 of file RNTupleWriterHelper.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_ntupleName

std::string RootStorageSvc::RNTupleWriterHelper::m_ntupleName
private

Definition at line 96 of file RNTupleWriterHelper.h.

◆ m_ntupleWriter

std::unique_ptr<RNTupleWriter> RootStorageSvc::RNTupleWriterHelper::m_ntupleWriter
private

Internal cache for the native RNTupleWriter.

Definition at line 94 of file RNTupleWriterHelper.h.

◆ m_opts

RNTupleWriteOptions RootStorageSvc::RNTupleWriterHelper::m_opts
private

Definition at line 98 of file RNTupleWriterHelper.h.

◆ m_rowN

int RootStorageSvc::RNTupleWriterHelper::m_rowN = 0
private

Definition at line 99 of file RNTupleWriterHelper.h.

◆ m_tfile

TFile* RootStorageSvc::RNTupleWriterHelper::m_tfile
private

Definition at line 97 of file RNTupleWriterHelper.h.


The documentation for this class was generated from the following file:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
RootStorageSvc::RNTupleWriterHelper::m_ntupleName
std::string m_ntupleName
Definition: RNTupleWriterHelper.h:96
RootStorageSvc::RNTupleWriterHelper::m_needsCommit
bool m_needsCommit
Definition: RNTupleWriterHelper.h:104
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
RootStorageSvc::RNTupleWriterHelper::m_rowN
int m_rowN
Definition: RNTupleWriterHelper.h:99
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
RootStorageSvc::RNTupleWriterHelper::m_clients
int m_clients
Count how many APR Containers are writing to this RNTuple (more than one makes a Group)
Definition: RNTupleWriterHelper.h:103
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132