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
 
const 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 27 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 113 of file RNTupleAuxDynReader.cxx.

116  : AthMessaging( std::string("RNTupleAuxDynReader[")+field_name+"]" ),
117  m_storeFieldName( field_name ),
119  {
120  const std::string field_prefix = field_type + "_";
121  if( m_storeFieldName.rfind( field_type, 0 ) != std::string::npos ) {
122  m_key = m_storeFieldName.substr( field_type.size()+1 );
123  }
124  ATH_MSG_VERBOSE("field name=" << m_storeFieldName << " field_prefix=" << field_prefix << " key=" << m_key);
125  TClass *tc = TClass::GetClass( field_type.c_str() );
126  if( tc ) {
127  TClass *storeTC = tc->GetBaseClass("SG::IAuxStoreHolder");
128  if( storeTC ) {
129  m_storeHolderOffset = tc->GetBaseClassOffset( storeTC );
130  } else {
131  throw std::runtime_error(string("Class ") + tc->GetName() +" does not implement SG::IAuxStoreHolder");
132  }
133  } else {
134  throw std::runtime_error(string("Class ") + field_type +" could not be found");
135  }
136  }

◆ ~RNTupleAuxDynReader()

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

Definition at line 74 of file RNTupleAuxDynReader.h.

74 {}

Member Function Documentation

◆ addBytes()

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

Definition at line 97 of file RNTupleAuxDynReader.h.

97  {
98  m_bytesRead += bytes;
99  }

◆ 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 255 of file RNTupleAuxDynReader.cxx.

256  {
257  auto store_holder = reinterpret_cast<SG::IAuxStoreHolder*>((char*)object + m_storeHolderOffset);
258  bool standalone { store_holder->getStoreType()==SG::IAuxStoreHolder::AST_ObjectStore };
259  if( !m_initialized )
260  init(standalone);
261  store_holder->setStore( new RNTupleAuxDynStore(*this, row, standalone, iomtx) );
262  }

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

109  {
110  return m_auxids;
111  }

◆ getBytesRead()

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

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 101 of file RNTupleAuxDynReader.h.

101  {
102  return m_bytesRead;
103  }

◆ getFieldInfo()

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

get field informatino for auxid

Definition at line 182 of file RNTupleAuxDynReader.cxx.

183  {
184  FieldInfo& fieldInfo = m_fieldInfos[auxid];
185  if( fieldInfo.status == FieldInfo::NotInitialized )
186  {
188  fieldInfo.auxid = auxid;
189  fieldInfo.attribName = reg.getName(auxid);
190  // Don't match this attribute if it's been renamed.
191  // For example, suppose we've renamed attribute `foo' to `foo_old',
192  // and someone then comes and asks for `foo'.
193  // `foo' will not be found in the m_fieldMap test below
194  // (`foo_old' will be in this map). However, in the following
195  // else clause, we'll recreate the field name from `foo'.
196  // This field exists (renaming is only in the transient store),
197  // so if we didn't have the condition here, then we'd then
198  // make a `foo' attribute from that field.
199  if( reg.inputRename(m_key, fieldInfo.attribName) != fieldInfo.attribName ) {
200  fieldInfo.status = FieldInfo::NotFound;
201  return fieldInfo;
202  }
203 
204  bool isFieldFound = false;
205 
206  if( !fieldInfo.fieldName.empty() ) {
207  const string field_prefix = m_storeFieldName + ':';
208  const string attr_infile = fieldInfo.fieldName.substr(field_prefix.size());
209  isFieldFound = (attr_infile == fieldInfo.attribName);
210  }
211 
212  if( !isFieldFound ) {
213  // mark initialized here so it remembers this field was not found
214  fieldInfo.status = FieldInfo::NotFound;
215  return fieldInfo;
216  }
217 
218  if( !store.standalone() and fieldInfo.fieldName.rfind("SG::PackedContainer<", 0) == 0 )
219  fieldInfo.isPackedContainer = true;
220 
221  /*
222  string elem_tname, branch_tname;
223  const type_info* ti = getAuxElementType( fieldInfo.tclass, typ, store.standalone(),
224  elem_tname, branch_tname );
225  const type_info* reg_ti = reg.getType(auxid);
226  if( ti && ti != reg_ti && strcmp(ti->name(), reg_ti->name()) != 0 )
227  {
228  // type in registry is different than type in the file.
229  // will need to use ROOT auto schema evolution
230  fieldInfo.needsSE = true;
231  errorcheck::ReportMessage msg (MSG::INFO, ERRORCHECK_ARGS, "RNTupleAuxDynReader");
232  msg << "attribute " << fieldInfo.attribName << " (id=" << auxid <<
233  " typename=" << SG::AuxTypeRegistry::instance().getType(auxid)->name()
234  << ") has different type than the branch " << branch_tname;
235 
236  const std::type_info *tinf = store.getIOType(auxid);
237  fieldInfo.SE_tclass = TClass::GetClass(*tinf);
238  fieldInfo.SE_edt = kOther_t;
239  if( !fieldInfo.SE_tclass ) {
240  fieldInfo.SE_edt = TDataType::GetType(*tinf);
241  if( fieldInfo.SE_edt <=0 ) {
242  fieldInfo.status = FieldInfo::TypeError;
243  throw string("Error getting ROOT type for AUX branch ") + fieldInfo.branch->GetName()
244  + " typeinfo=" + tinf->name();
245  }
246  }
247  }
248  */
249  fieldInfo.status = FieldInfo::Initialized;
250  }
251  return fieldInfo;
252  }

◆ getNativeReader()

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

Definition at line 113 of file RNTupleAuxDynReader.h.

113  {
114  return m_ntupleReader;
115  }

◆ init()

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

initialize once the mode of the Aux store is known

Definition at line 141 of file RNTupleAuxDynReader.cxx.

142  {
143  if( m_initialized ) return;
144 
146  const string field_prefix = m_storeFieldName + ':';
147  const auto& desc = m_ntupleReader->GetDescriptor();
148 #if ROOT_VERSION_CODE >= ROOT_VERSION( 6, 31, 0 )
149  for( const auto &f : desc.GetTopLevelFields() ) {
150 #else
151  for( const auto &f : desc->GetTopLevelFields() ) {
152 #endif
153  const string field_name = f.GetFieldName();
154  if( field_name.rfind(field_prefix,0) == 0 ) {
155  const string attr_infile = field_name.substr(field_prefix.size());
156  const string attr_name = reg.inputRename(m_key, attr_infile);
157  const string field_type = f.GetTypeName();
158 
159  SG::auxid_t auxid = getAuxIdForAttribute(attr_name, field_type, standalone);
160  // add AuxID to the list
161  // May still be null if we don't have a dictionary for this field
162  if( auxid != SG::null_auxid ) {
163  m_auxids.insert(auxid);
164  m_fieldInfos[auxid].fieldName = field_name;
165 #if ROOT_VERSION_CODE >= ROOT_VERSION( 6, 31, 0 )
166  m_fieldInfos[auxid].view_p = std::make_unique<RNTupleView<void,true>>(
167  m_ntupleReader->GetView<void>(field_name, nullptr) );
168 #endif
169  } else {
170  errorcheck::ReportMessage msg (MSG::WARNING, ERRORCHECK_ARGS, "RNTupleAuxDynReader::init");
171  msg << "Could not find auxid for " << attr_infile << " type: " << field_type
172  << " standalone=" << standalone;
173  }
174  }
175  }
176  m_initialized = true;
177  }

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

105  {
106  m_bytesRead = 0;
107  }

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

◆ m_bytesRead

size_t RootAuxDynIO::RNTupleAuxDynReader::m_bytesRead = 0
protected

Definition at line 82 of file RNTupleAuxDynReader.h.

◆ m_fieldInfos

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

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

◆ m_key

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

Definition at line 86 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 92 of file RNTupleAuxDynReader.h.

◆ m_storeFieldName

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

Definition at line 80 of file RNTupleAuxDynReader.h.

◆ m_storeHolderOffset

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

Definition at line 84 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
store
StoreGateSvc * store
Definition: fbtTestBasics.cxx:69
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
SG::IAuxStoreHolder::getStoreType
virtual AuxStoreType getStoreType() const =0
Return the type of the store object.
RNTupleAuxDynStore
Definition: RNTupleAuxDynStore.h:23
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
RootAuxDynIO::RNTupleAuxDynReader::m_ntupleReader
RNTupleReader * m_ntupleReader
Definition: RNTupleAuxDynReader.h:92
RootAuxDynIO::RNTupleAuxDynReader::m_storeHolderOffset
int m_storeHolderOffset
Definition: RNTupleAuxDynReader.h:84
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::Initialized
@ Initialized
Definition: RNTupleAuxDynReader.h:33
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RootAuxDynIO::RNTupleAuxDynReader::m_key
std::string m_key
Definition: RNTupleAuxDynReader.h:86
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
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
RootAuxDynIO::RNTupleAuxDynReader::m_auxids
SG::auxid_set_t m_auxids
Definition: RNTupleAuxDynReader.h:78
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:33
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
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:82
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.
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:141
RootAuxDynIO::RNTupleAuxDynReader::m_initialized
bool m_initialized
Definition: RNTupleAuxDynReader.h:85
RootAuxDynIO::RNTupleAuxDynReader::m_fieldInfos
std::map< SG::auxid_t, FieldInfo > m_fieldInfos
Definition: RNTupleAuxDynReader.h:89
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::NotInitialized
@ NotInitialized
Definition: RNTupleAuxDynReader.h:33
RootAuxDynIO::RNTupleAuxDynReader::m_storeFieldName
std::string m_storeFieldName
Definition: RNTupleAuxDynReader.h:80
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