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, ROOT::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...
 
FieldInfogetFieldInfo (const SG::auxid_t &auxid, const SG::AuxStoreInternal &store)
 get field informatino for auxid More...
 
ROOT::RNTupleReader * getNativeReader ()
 
virtual ~RNTupleAuxDynReader ()=default
 
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...
 
const SG::auxid_set_tauxIDs () const
 Aux IDs of all the Aux attributes belonging to the Aux container being read. More...
 
bool addAuxID (const SG::auxid_t &id)
 
void addBytes (size_t bytes)
 
size_t getBytesRead () const
 
void resetBytesRead ()
 

Protected Attributes

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

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

Constructor & Destructor Documentation

◆ RNTupleAuxDynReader()

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

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

Definition at line 161 of file RNTupleAuxDynReader.cxx.

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

◆ ~RNTupleAuxDynReader()

virtual RootAuxDynIO::RNTupleAuxDynReader::~RNTupleAuxDynReader ( )
virtualdefault

Member Function Documentation

◆ addAuxID()

bool RootAuxDynReader::addAuxID ( const SG::auxid_t id)
inlineinherited

Definition at line 60 of file RootAuxDynReader.h.

60  {
61  if( id != SG::null_auxid ) {
62  m_auxids.insert(id);
63  return true;
64  }
65  return false;
66 }

◆ addBytes()

void RootAuxDynReader::addBytes ( size_t  bytes)
inlineinherited

Definition at line 40 of file RootAuxDynReader.h.

40  {
41  m_bytesRead += bytes;
42 }

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

299  {
300  auto store_holder = reinterpret_cast<SG::IAuxStoreHolder*>((char*)object + m_storeHolderOffset);
301  bool standalone { store_holder->getStoreType()==SG::IAuxStoreHolder::AST_ObjectStore };
302  if( !m_initialized )
303  init(standalone);
304  store_holder->setStore( new RNTupleAuxDynStore(*this, row, standalone, iomtx) );
305  }

◆ auxIDs()

const SG::auxid_set_t & RootAuxDynReader::auxIDs ( ) const
inlineinherited

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

Definition at line 55 of file RootAuxDynReader.h.

55  {
56  return m_auxids;
57 }

◆ getBytesRead()

size_t RootAuxDynReader::getBytesRead ( ) const
inlinevirtualinherited

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 45 of file RootAuxDynReader.h.

45  {
46  return m_bytesRead;
47 }

◆ getFieldInfo()

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

get field informatino for auxid

Definition at line 233 of file RNTupleAuxDynReader.cxx.

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

◆ getNativeReader()

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

Definition at line 83 of file RNTupleAuxDynReader.h.

83  {
84  return m_ntupleReader;
85  }

◆ init()

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

initialize once the mode of the Aux store is known

Definition at line 192 of file RNTupleAuxDynReader.cxx.

193  {
194  if( m_initialized ) return;
195 
197  const string field_prefix = RootAuxDynIO::auxFieldName("", m_storeFieldName);
198  const auto& desc = m_ntupleReader->GetDescriptor();
199  for( const auto &f : desc.GetTopLevelFields() ) {
200  const string field_name = f.GetFieldName();
201  if( field_name.starts_with(field_prefix) ) {
202  const string attr_infile = field_name.substr(field_prefix.size());
203  const string attr_name = reg.inputRename(m_key, attr_infile);
204  const string field_type = f.GetTypeName();
205 
206  SG::auxid_t auxid = getAuxIdForAttribute(reg, desc, field_prefix,
207  attr_name, field_type, standalone);
208  // add AuxID to the list
209  // May still be null if we don't have a dictionary for this field
210  if( auxid != SG::null_auxid ) {
211  addAuxID(auxid);
212  m_fieldInfos[auxid].fieldName = field_name;
213 #if ROOT_VERSION_CODE < ROOT_VERSION( 6, 35, 0 )
214  m_fieldInfos[auxid].view = m_ntupleReader->GetView<void>(field_name, nullptr);
215 #else
216  // Can't use type_info because of default template argument in DataVectors ATEAM-1087
217  const std::string& tiname = (standalone and !reg.isLinked(auxid))? reg.getTypeName(auxid) : reg.getVecTypeName(auxid);
218  m_fieldInfos[auxid].view = m_ntupleReader->GetView(field_name, nullptr, tiname);
219 #endif
220  } else {
221  errorcheck::ReportMessage msg (MSG::WARNING, ERRORCHECK_ARGS, "RNTupleAuxDynReader::init");
222  msg << "Could not find auxid for " << attr_infile << " type: " << field_type
223  << " standalone=" << standalone;
224  }
225  }
226  }
227  m_initialized = true;
228  }

◆ 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 RootAuxDynReader::resetBytesRead ( )
inlinevirtualinherited

Implements RootAuxDynIO::IRootAuxDynReader.

Definition at line 50 of file RootAuxDynReader.h.

50  {
51  m_bytesRead = 0;
52 }

◆ 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 RootAuxDynReader::m_auxids
protectedinherited

Definition at line 31 of file RootAuxDynReader.h.

◆ m_bytesRead

size_t RootAuxDynReader::m_bytesRead = 0
protectedinherited

Definition at line 34 of file RootAuxDynReader.h.

◆ m_fieldInfos

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

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

◆ m_key

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

Definition at line 73 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

ROOT::RNTupleReader* RootAuxDynIO::RNTupleAuxDynReader::m_ntupleReader
protected

Definition at line 79 of file RNTupleAuxDynReader.h.

◆ m_storeFieldName

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

Definition at line 69 of file RNTupleAuxDynReader.h.

◆ m_storeHolderOffset

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

Definition at line 71 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
SGTest::store
TestStore store
Definition: TestStore.cxx:23
RNTupleAuxDynStore
Definition: RNTupleAuxDynStore.h:19
L1CaloPhase1Monitoring.standalone
standalone
Definition: L1CaloPhase1Monitoring.py:139
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:639
RootAuxDynIO::RNTupleAuxDynReader::m_storeHolderOffset
int m_storeHolderOffset
Definition: RNTupleAuxDynReader.h:71
TrigInDetValidation_menu_test.tc
tc
Definition: TrigInDetValidation_menu_test.py:8
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::Initialized
@ Initialized
Definition: RNTupleAuxDynReader.h:36
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::getVecTypeName
std::string getVecTypeName(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
Definition: AuxTypeRegistry.cxx:951
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
keylayer_zslicemap.row
row
Definition: keylayer_zslicemap.py:155
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
RootAuxDynIO::RNTupleAuxDynReader::m_key
std::string m_key
Definition: RNTupleAuxDynReader.h:73
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
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::NotFound
@ NotFound
Definition: RNTupleAuxDynReader.h:36
RootAuxDynReader::m_bytesRead
size_t m_bytesRead
Definition: RootAuxDynReader.h:34
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
AthMessaging::AthMessaging
AthMessaging()
Default constructor:
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
CaloCondBlobAlgs_fillNoiseFromASCII.desc
desc
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:53
SG::AuxTypeRegistry::getTypeName
std::string getTypeName(SG::auxid_t auxid) const
Return the type name of an aux data item.
Definition: AuxTypeRegistry.cxx:923
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
RootAuxDynReader::m_auxids
SG::auxid_set_t m_auxids
Definition: RootAuxDynReader.h:31
hist_file_dump.f
f
Definition: hist_file_dump.py:140
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:192
RootAuxDynIO::RNTupleAuxDynReader::m_initialized
bool m_initialized
Definition: RNTupleAuxDynReader.h:72
SG::AuxTypeRegistry::isLinked
bool isLinked(SG::auxid_t auxid) const
Test whether this is a linked variable.
RootAuxDynIO::RNTupleAuxDynReader::m_fieldInfos
std::map< SG::auxid_t, FieldInfo > m_fieldInfos
Definition: RNTupleAuxDynReader.h:76
RootAuxDynIO::RNTupleAuxDynReader::m_ntupleReader
ROOT::RNTupleReader * m_ntupleReader
Definition: RNTupleAuxDynReader.h:79
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::NotInitialized
@ NotInitialized
Definition: RNTupleAuxDynReader.h:36
RootAuxDynReader::addAuxID
bool addAuxID(const SG::auxid_t &id)
Definition: RootAuxDynReader.h:60
RootAuxDynIO::RNTupleAuxDynReader::m_storeFieldName
std::string m_storeFieldName
Definition: RNTupleAuxDynReader.h:69
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
python.SystemOfUnits.ms
float ms
Definition: SystemOfUnits.py:148