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 22 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 152 of file RNTupleAuxDynReader.cxx.

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

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

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

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

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

◆ getNativeReader()

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

Definition at line 75 of file RNTupleAuxDynReader.h.

75  {
76  return m_ntupleReader;
77  }

◆ init()

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

initialize once the mode of the Aux store is known

Definition at line 183 of file RNTupleAuxDynReader.cxx.

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

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

◆ m_key

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

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

◆ m_storeFieldName

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

Definition at line 61 of file RNTupleAuxDynReader.h.

◆ m_storeHolderOffset

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

Definition at line 63 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:640
RootAuxDynIO::RNTupleAuxDynReader::m_storeHolderOffset
int m_storeHolderOffset
Definition: RNTupleAuxDynReader.h:63
TrigInDetValidation_menu_test.tc
tc
Definition: TrigInDetValidation_menu_test.py:8
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::Initialized
@ Initialized
Definition: RNTupleAuxDynReader.h:28
SG::AuxTypeRegistry::getName
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
Definition: AuxTypeRegistry.cxx:882
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:952
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:1274
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:65
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:28
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:924
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:183
RootAuxDynIO::RNTupleAuxDynReader::m_initialized
bool m_initialized
Definition: RNTupleAuxDynReader.h:64
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:68
RootAuxDynIO::RNTupleAuxDynReader::m_ntupleReader
ROOT::RNTupleReader * m_ntupleReader
Definition: RNTupleAuxDynReader.h:71
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:28
RootAuxDynReader::addAuxID
bool addAuxID(const SG::auxid_t &id)
Definition: RootAuxDynReader.h:60
RootAuxDynIO::RNTupleAuxDynReader::m_storeFieldName
std::string m_storeFieldName
Definition: RNTupleAuxDynReader.h:61
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