ATLAS Offline Software
Classes | Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
RootAuxDynIO::RNTupleAuxDynReader Class Reference

#include <RNTupleAuxDynReader.h>

Inheritance diagram for RootAuxDynIO::RNTupleAuxDynReader:
Collaboration diagram for RootAuxDynIO::RNTupleAuxDynReader:

Classes

struct  FieldInfo
 

Public Member Functions

 RNTupleAuxDynReader (const std::string &field_name, const std::string &field_type, RNTupleReader *reader)
 create Reader for Aux attributes of an AuxContainer object stored in a given field More...
 
void init (bool standalone)
 initialize once the mode of the Aux store is known More...
 
virtual void addReaderToObject (void *object, size_t row, std::recursive_mutex *iomtx=nullptr) override final
 attach RNTupleAuxStore to the current Aux container @object More...
 
virtual const SG::auxid_set_tauxIDs () const override final
 Aux IDs of all the Aux attributes belonging to the Aux container being read. More...
 
void addBytes (size_t bytes)
 
virtual size_t getBytesRead () const override final
 
virtual void resetBytesRead () override final
 
FieldInfogetFieldInfo (const SG::auxid_t &auxid, const SG::AuxStoreInternal &store)
 get field informatino for auxid More...
 
RNTupleReadergetNativeReader ()
 
virtual ~RNTupleAuxDynReader ()
 
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...
 

Protected Attributes

SG::auxid_set_t m_auxids
 
std::string m_storeFieldName
 
size_t m_bytesRead = 0
 
int m_storeHolderOffset = -1
 
bool m_initialized = false
 
std::string m_key
 
std::map< SG::auxid_t, FieldInfom_fieldInfos
 
RNTupleReaderm_ntupleReader
 

Private Member Functions

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

Private Attributes

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 28 of file RNTupleAuxDynReader.h.

Constructor & Destructor Documentation

◆ RNTupleAuxDynReader()

RootAuxDynIO::RNTupleAuxDynReader::RNTupleAuxDynReader ( const std::string &  field_name,
const std::string &  field_type,
RNTupleReader reader 
)

create Reader for Aux attributes of an AuxContainer object stored in a given field

Definition at line 157 of file RNTupleAuxDynReader.cxx.

160  : AthMessaging( std::string("RNTupleAuxDynReader[")+field_name+"]" ),
161  m_storeFieldName( field_name ),
163  {
164  const std::string field_prefix = field_type + "_";
165  if( m_storeFieldName.rfind( field_type, 0 ) != std::string::npos ) {
166  m_key = m_storeFieldName.substr( field_type.size()+1 );
167  }
168  else if( m_storeFieldName.ends_with( "Aux:" ) ) {
169  m_key = m_storeFieldName.substr( 0, m_storeFieldName.size() - 4 );
170  }
171  ATH_MSG_VERBOSE("field name=" << m_storeFieldName << " field_prefix=" << field_prefix << " key=" << m_key);
172  TClass *tc = TClass::GetClass( field_type.c_str() );
173  if( tc ) {
174  TClass *storeTC = tc->GetBaseClass("SG::IAuxStoreHolder");
175  if( storeTC ) {
176  m_storeHolderOffset = tc->GetBaseClassOffset( storeTC );
177  } else {
178  throw std::runtime_error(string("Class ") + tc->GetName() +" does not implement SG::IAuxStoreHolder");
179  }
180  } else {
181  throw std::runtime_error(string("Class ") + field_type +" could not be found");
182  }
183  }

◆ ~RNTupleAuxDynReader()

virtual RootAuxDynIO::RNTupleAuxDynReader::~RNTupleAuxDynReader ( )
inlinevirtual

Definition at line 77 of file RNTupleAuxDynReader.h.

77 {}

Member Function Documentation

◆ addBytes()

void RootAuxDynIO::RNTupleAuxDynReader::addBytes ( size_t  bytes)
inline

Definition at line 100 of file RNTupleAuxDynReader.h.

100  {
101  m_bytesRead += bytes;
102  }

◆ addReaderToObject()

void RootAuxDynIO::RNTupleAuxDynReader::addReaderToObject ( void *  object,
size_t  row,
std::recursive_mutex *  iomtx = nullptr 
)
finaloverridevirtual

attach RNTupleAuxStore to the current Aux container @object

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 288 of file RNTupleAuxDynReader.cxx.

289  {
290  auto store_holder = reinterpret_cast<SG::IAuxStoreHolder*>((char*)object + m_storeHolderOffset);
291  bool standalone { store_holder->getStoreType()==SG::IAuxStoreHolder::AST_ObjectStore };
292  if( !m_initialized )
293  init(standalone);
294  store_holder->setStore( new RNTupleAuxDynStore(*this, row, standalone, iomtx) );
295  }

◆ auxIDs()

const SG::auxid_set_t & RootAuxDynIO::RNTupleAuxDynReader::auxIDs ( ) const
inlinefinaloverridevirtual

Aux IDs of all the Aux attributes belonging to the Aux container being read.

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 112 of file RNTupleAuxDynReader.h.

112  {
113  return m_auxids;
114  }

◆ getBytesRead()

size_t RootAuxDynIO::RNTupleAuxDynReader::getBytesRead ( ) const
inlinefinaloverridevirtual

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 104 of file RNTupleAuxDynReader.h.

104  {
105  return m_bytesRead;
106  }

◆ getFieldInfo()

RNTupleAuxDynReader::FieldInfo & RootAuxDynIO::RNTupleAuxDynReader::getFieldInfo ( const SG::auxid_t auxid,
const SG::AuxStoreInternal store 
)

get field informatino for auxid

Definition at line 223 of file RNTupleAuxDynReader.cxx.

224  {
225  FieldInfo& fieldInfo = m_fieldInfos[auxid];
226  if( fieldInfo.status == FieldInfo::NotInitialized )
227  {
229  fieldInfo.auxid = auxid;
230  fieldInfo.attribName = reg.getName(auxid);
231  // Don't match this attribute if it's been renamed.
232  // For example, suppose we've renamed attribute `foo' to `foo_old',
233  // and someone then comes and asks for `foo'.
234  // `foo' will not be found in the m_fieldMap test below
235  // (`foo_old' will be in this map). However, in the following
236  // else clause, we'll recreate the field name from `foo'.
237  // This field exists (renaming is only in the transient store),
238  // so if we didn't have the condition here, then we'd then
239  // make a `foo' attribute from that field.
240  if( reg.inputRename(m_key, fieldInfo.attribName) != fieldInfo.attribName ) {
241  fieldInfo.status = FieldInfo::NotFound;
242  return fieldInfo;
243  }
244 
245  if( fieldInfo.fieldName.empty() ) {
246  // mark initialized here so it remembers this field was not found
247  fieldInfo.status = FieldInfo::NotFound;
248  return fieldInfo;
249  }
250 
251  if( !store.standalone() and fieldInfo.fieldName.rfind("SG::PackedContainer<", 0) == 0 )
252  fieldInfo.isPackedContainer = true;
253 
254  /*
255  string elem_tname, branch_tname;
256  const type_info* ti = getAuxElementType( fieldInfo.tclass, typ, store.standalone(),
257  elem_tname, branch_tname );
258  const type_info* reg_ti = reg.getType(auxid);
259  if( ti && ti != reg_ti && strcmp(ti->name(), reg_ti->name()) != 0 )
260  {
261  // type in registry is different than type in the file.
262  // will need to use ROOT auto schema evolution
263  fieldInfo.needsSE = true;
264  errorcheck::ReportMessage msg (MSG::INFO, ERRORCHECK_ARGS, "RNTupleAuxDynReader");
265  msg << "attribute " << fieldInfo.attribName << " (id=" << auxid <<
266  " typename=" << SG::AuxTypeRegistry::instance().getType(auxid)->name()
267  << ") has different type than the branch " << branch_tname;
268 
269  const std::type_info *tinf = store.getIOType(auxid);
270  fieldInfo.SE_tclass = TClass::GetClass(*tinf);
271  fieldInfo.SE_edt = kOther_t;
272  if( !fieldInfo.SE_tclass ) {
273  fieldInfo.SE_edt = TDataType::GetType(*tinf);
274  if( fieldInfo.SE_edt <=0 ) {
275  fieldInfo.status = FieldInfo::TypeError;
276  throw string("Error getting ROOT type for AUX branch ") + fieldInfo.branch->GetName()
277  + " typeinfo=" + tinf->name();
278  }
279  }
280  }
281  */
282  fieldInfo.status = FieldInfo::Initialized;
283  }
284  return fieldInfo;
285  }

◆ getNativeReader()

RNTupleReader * RootAuxDynIO::RNTupleAuxDynReader::getNativeReader ( )
inline

Definition at line 116 of file RNTupleAuxDynReader.h.

116  {
117  return m_ntupleReader;
118  }

◆ init()

void RootAuxDynIO::RNTupleAuxDynReader::init ( bool  standalone)

initialize once the mode of the Aux store is known

Definition at line 188 of file RNTupleAuxDynReader.cxx.

189  {
190  if( m_initialized ) return;
191 
193  const string field_prefix = RootAuxDynIO::auxFieldName("", m_storeFieldName);
194  const auto& desc = m_ntupleReader->GetDescriptor();
195  for( const auto &f : desc.GetTopLevelFields() ) {
196  const string field_name = f.GetFieldName();
197  if( field_name.rfind(field_prefix,0) == 0 ) {
198  const string attr_infile = field_name.substr(field_prefix.size());
199  const string attr_name = reg.inputRename(m_key, attr_infile);
200  const string field_type = f.GetTypeName();
201 
202  SG::auxid_t auxid = getAuxIdForAttribute(reg, desc, field_prefix,
203  attr_name, field_type, standalone);
204  // add AuxID to the list
205  // May still be null if we don't have a dictionary for this field
206  if( auxid != SG::null_auxid ) {
207  m_auxids.insert(auxid);
208  m_fieldInfos[auxid].fieldName = field_name;
209  m_fieldInfos[auxid].view = m_ntupleReader->GetView<void>(field_name, nullptr);
210  } else {
211  errorcheck::ReportMessage msg (MSG::WARNING, ERRORCHECK_ARGS, "RNTupleAuxDynReader::init");
212  msg << "Could not find auxid for " << attr_infile << " type: " << field_type
213  << " standalone=" << standalone;
214  }
215  }
216  }
217  m_initialized = true;
218  }

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

◆ resetBytesRead()

void RootAuxDynIO::RNTupleAuxDynReader::resetBytesRead ( )
inlinefinaloverridevirtual

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 108 of file RNTupleAuxDynReader.h.

108  {
109  m_bytesRead = 0;
110  }

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

SG::auxid_set_t RootAuxDynIO::RNTupleAuxDynReader::m_auxids
protected

Definition at line 81 of file RNTupleAuxDynReader.h.

◆ m_bytesRead

size_t RootAuxDynIO::RNTupleAuxDynReader::m_bytesRead = 0
protected

Definition at line 85 of file RNTupleAuxDynReader.h.

◆ m_fieldInfos

std::map<SG::auxid_t, FieldInfo> RootAuxDynIO::RNTupleAuxDynReader::m_fieldInfos
protected

Definition at line 92 of file RNTupleAuxDynReader.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_initialized

bool RootAuxDynIO::RNTupleAuxDynReader::m_initialized = false
protected

Definition at line 88 of file RNTupleAuxDynReader.h.

◆ m_key

std::string RootAuxDynIO::RNTupleAuxDynReader::m_key
protected

Definition at line 89 of file RNTupleAuxDynReader.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.

◆ m_ntupleReader

RNTupleReader* RootAuxDynIO::RNTupleAuxDynReader::m_ntupleReader
protected

Definition at line 95 of file RNTupleAuxDynReader.h.

◆ m_storeFieldName

std::string RootAuxDynIO::RNTupleAuxDynReader::m_storeFieldName
protected

Definition at line 83 of file RNTupleAuxDynReader.h.

◆ m_storeHolderOffset

int RootAuxDynIO::RNTupleAuxDynReader::m_storeHolderOffset = -1
protected

Definition at line 87 of file RNTupleAuxDynReader.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
query_example.row
row
Definition: query_example.py:24
SGTest::store
TestStore store
Definition: TestStore.cxx:23
RNTupleAuxDynStore
Definition: RNTupleAuxDynStore.h:23
L1CaloPhase1Monitoring.standalone
standalone
Definition: L1CaloPhase1Monitoring.py:112
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
RootAuxDynIO::RNTupleAuxDynReader::m_ntupleReader
RNTupleReader * m_ntupleReader
Definition: RNTupleAuxDynReader.h:95
RootAuxDynIO::RNTupleAuxDynReader::m_storeHolderOffset
int m_storeHolderOffset
Definition: RNTupleAuxDynReader.h:87
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::Initialized
@ Initialized
Definition: RNTupleAuxDynReader.h:34
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:881
SG::AuxTypeRegistry::inputRename
const std::string & inputRename(const std::string &key, const std::string &name) const
Check for an input renaming of an auxiliary variable.
Definition: AuxTypeRegistry.cxx:1273
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RootAuxDynIO::RNTupleAuxDynReader::m_key
std::string m_key
Definition: RNTupleAuxDynReader.h:89
errorcheck::ReportMessage
Helper class to use to report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:173
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
RootAuxDynIO::RNTupleAuxDynReader::m_auxids
SG::auxid_set_t m_auxids
Definition: RNTupleAuxDynReader.h:81
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::NotFound
@ NotFound
Definition: RNTupleAuxDynReader.h:34
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
collListGuids.attr_name
attr_name
Definition: collListGuids.py:72
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
RootAuxDynIO::RNTupleAuxDynReader::m_bytesRead
size_t m_bytesRead
Definition: RNTupleAuxDynReader.h:85
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:54
CxxUtils::ConcurrentBitset::insert
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
RootAuxDynIO::auxFieldName
std::string auxFieldName(const std::string &attr_name, const std::string &baseName)
Construct field name for a given dynamic attribute.
Definition: RootAuxDynDefs.h:69
hist_file_dump.f
f
Definition: hist_file_dump.py:135
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
RootAuxDynIO::RNTupleAuxDynReader::init
void init(bool standalone)
initialize once the mode of the Aux store is known
Definition: RNTupleAuxDynReader.cxx:188
RootAuxDynIO::RNTupleAuxDynReader::m_initialized
bool m_initialized
Definition: RNTupleAuxDynReader.h:88
RootAuxDynIO::RNTupleAuxDynReader::m_fieldInfos
std::map< SG::auxid_t, FieldInfo > m_fieldInfos
Definition: RNTupleAuxDynReader.h:92
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::NotInitialized
@ NotInitialized
Definition: RNTupleAuxDynReader.h:34
RootAuxDynIO::RNTupleAuxDynReader::m_storeFieldName
std::string m_storeFieldName
Definition: RNTupleAuxDynReader.h:83
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
collisions.reader
reader
read the goodrunslist xml file(s)
Definition: collisions.py:22
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
SG::IAuxStoreHolder::AST_ObjectStore
@ AST_ObjectStore
The store describes a single object.
Definition: IAuxStoreHolder.h:67
SG::IAuxStoreHolder
Interface for objects taking part in direct ROOT I/O.
Definition: IAuxStoreHolder.h:36
ERRORCHECK_ARGS
#define ERRORCHECK_ARGS
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:323