ATLAS Offline Software
RNTupleAuxDynStore.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
10 
11 #include "RNTupleAuxDynStore.h"
12 #include "RNTupleAuxDynReader.h"
13 
14 #include "ROOT/RNTupleReader.hxx"
15 
16 using namespace RootAuxDynIO;
17 
19  long long entry, bool standalone,
20  std::recursive_mutex* iomtx )
21  : RootAuxDynStore( aux_reader, entry, standalone, iomtx ),
22  m_reader( aux_reader )
23 {
24 }
25 
26 
28 {
29  try {
30  auto& fieldInfo = m_reader.getFieldInfo(auxid, *this);
31  if( fieldInfo.status == RNTupleAuxDynReader::FieldInfo::NotFound ) return false;
32 
33  // Make a 1-element vector in the underlying AuxStore for the given auxid
34  SG::AuxStoreInternal::getDataInternal(auxid, 1, 1, true);
35  if( fieldInfo.isPackedContainer ) {
36  setOption (auxid, SG::AuxDataOption ("nbits", 32));
37  }
38 
39  // get memory location where to write data from the branch entry
40  // const_cast because Field::CaptureValue() requires void*
41  [[maybe_unused]] void* data ATLAS_THREAD_SAFE = const_cast<void*>(SG::AuxStoreInternal::getIOData(auxid));
42 
43  // if have mutex, lock to prevent potential concurrent I/O from elsewhere
44  auto io_lock = m_iomutex? std::unique_lock<std::recursive_mutex>(*m_iomutex)
45  : std::unique_lock<std::recursive_mutex>();
46 
47  //auto view = m_reader.getNativeReader()->GetView<void>(fieldInfo.fieldName, nullptr);
48  fieldInfo.view_p->BindRawPtr(data);
49  (*fieldInfo.view_p)(m_entry);
50 
51  int nbytes = 1; // MN: TODO how to get this?
52  if( nbytes <= 0 ) {
53  throw std::string("Error reading field ") + fieldInfo.fieldName;
54  }
55  // read OK
56  m_reader.addBytes(nbytes);
57  }
58  catch(const std::string& e_str) {
59  ATHCONTAINERS_ERROR("RNTupleAuxDynStore::getData", e_str);
60  return false;
61  }
62 
64  SG::auxid_t linked_auxid = r.linkedVariable (auxid);
65  if (linked_auxid != SG::null_auxid) {
66  return readData (linked_auxid);
67  }
68 
69  return true;
70 }
beamspotman.r
def r
Definition: beamspotman.py:676
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
RootAuxDynIO::RNTupleAuxDynReader
Definition: RNTupleAuxDynReader.h:28
RNTupleAuxDynStore::readData
virtual bool readData(SG::auxid_t auxid) override final
read data from ROOT and store it in m_vecs. Returns False on error
Definition: RNTupleAuxDynStore.cxx:27
RNTupleAuxDynStore::RNTupleAuxDynStore
RNTupleAuxDynStore(RootAuxDynIO::RNTupleAuxDynReader &aux_reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
Definition: RNTupleAuxDynStore.cxx:18
L1CaloPhase1Monitoring.standalone
standalone
Definition: L1CaloPhase1Monitoring.py:112
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:640
RNTupleAuxDynStore::m_reader
RootAuxDynIO::RNTupleAuxDynReader & m_reader
Definition: RNTupleAuxDynStore.h:35
ATHCONTAINERS_ERROR
#define ATHCONTAINERS_ERROR(ctx, msg)
Definition: error.h:50
exceptions.h
Exceptions that can be thrown from AthContainers.
RootAuxDynIO::RNTupleAuxDynReader::getFieldInfo
const FieldInfo & getFieldInfo(const SG::auxid_t &auxid, const SG::AuxStoreInternal &store)
get field informatino for auxid
Definition: RNTupleAuxDynReader.cxx:228
RootAuxDynStore
Definition: RootAuxDynStore.h:16
AuxDataOption.h
Hold information about an option setting request.
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:61
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
RootAuxDynStore::m_entry
long long m_entry
Definition: RootAuxDynStore.h:62
lumiFormat.e_str
e_str
Definition: lumiFormat.py:81
error.h
Helper for emitting error messages.
SG::AuxStoreInternal::setOption
virtual bool setOption(auxid_t id, const AuxDataOption &option) override
Set an option for an auxiliary data variable.
Definition: AuxStoreInternal.cxx:636
SG::AuxStoreInternal::getDataInternal
virtual void * getDataInternal(SG::auxid_t auxid, size_t size, size_t capacity, bool no_lock_check)
Return the data vector for one aux data item.
Definition: AuxStoreInternal.cxx:735
SG::AuxStoreInternal::getIOData
virtual const void * getIOData(SG::auxid_t auxid) const override
Return a pointer to the data to be stored for one aux data item.
Definition: AuxStoreInternal.cxx:515
SG::AuxDataOption
Hold information about an option setting request.
Definition: AuxDataOption.h:37
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
RNTupleAuxDynReader.h
RNTupleAuxDynStore.h
RootAuxDynIO
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Definition: RNTupleContainer.h:25
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
RootAuxDynStore::m_iomutex
std::recursive_mutex * m_iomutex
Optional mutex used to serialize I/O with RootStorageSvc (not owned)
Definition: RootAuxDynStore.h:70
RootAuxDynIO::RNTupleAuxDynReader::addBytes
void addBytes(size_t bytes)
Definition: RNTupleAuxDynReader.h:99