ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaRoot
RootAuxDynIO
src
RNTupleAuxDynStore.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
AthContainers/AuxTypeRegistry.h
"
6
#include "
AthContainers/tools/error.h
"
7
#include "
AthContainers/exceptions.h
"
8
#include "
AthContainersInterfaces/AuxDataOption.h
"
9
10
#include "
RNTupleAuxDynStore.h
"
11
#include "
RNTupleAuxDynReader.h
"
12
13
#include "ROOT/RNTupleReader.hxx"
14
15
using namespace
RootAuxDynIO
;
16
17
RNTupleAuxDynStore::RNTupleAuxDynStore
(
RNTupleAuxDynReader
& aux_reader,
18
long
long
entry,
bool
standalone,
19
std::recursive_mutex* iomtx )
20
:
RootAuxDynStore
( aux_reader, entry, standalone, iomtx ),
21
m_reader
( aux_reader )
22
{
23
}
24
25
26
bool
RNTupleAuxDynStore::readData
(
SG::auxid_t
auxid)
27
{
28
try
{
29
auto
& fieldInfo =
m_reader
.getFieldInfo(auxid, *
this
);
30
if
( fieldInfo.status ==
RNTupleAuxDynReader::FieldInfo::NotFound
)
return
false
;
31
32
// Make a 1-element vector in the underlying AuxStore for the given auxid
33
SG::AuxStoreInternal::getDataInternal(auxid, 1, 1,
true
);
34
if
( fieldInfo.isPackedContainer ) {
35
setOption (auxid,
SG::AuxDataOption
(
"nbits"
, 32));
36
}
37
38
// get memory location where to write data from the branch entry
39
// const_cast because Field::CaptureValue() requires void*
40
[[maybe_unused]]
void
* data
ATLAS_THREAD_SAFE
=
const_cast<
void
*
>
(SG::AuxStoreInternal::getIOData(auxid));
41
42
// if have mutex, lock to prevent potential concurrent I/O from elsewhere
43
auto
io_lock =
m_iomutex
? std::unique_lock<std::recursive_mutex>(*
m_iomutex
)
44
: std::unique_lock<std::recursive_mutex>();
45
46
fieldInfo.view->BindRawPtr(data);
47
(*fieldInfo.view)(
m_entry
);
48
49
int
nbytes = 1;
// MN: TODO how to get this?
50
if
( nbytes <= 0 ) {
51
throw
std::string(
"Error reading field "
) + fieldInfo.fieldName;
52
}
53
// read OK
54
m_reader
.addBytes(nbytes);
55
}
56
catch
(
const
std::string& e_str) {
57
ATHCONTAINERS_ERROR
(
"RNTupleAuxDynStore::getData"
, e_str);
58
return
false
;
59
}
60
61
SG::AuxStoreInternal::toTransient (
m_ctx
, auxid);
62
SG::AuxTypeRegistry
&
r
=
SG::AuxTypeRegistry::instance
();
63
SG::auxid_t
linked_auxid =
r
.linkedVariable (auxid);
64
if
(linked_auxid !=
SG::null_auxid
) {
65
return
readData
(linked_auxid);
66
}
67
68
return
true
;
69
}
AuxDataOption.h
Hold information about an option setting request.
AuxTypeRegistry.h
Handle mappings between names and auxid_t.
exceptions.h
Exceptions that can be thrown from AthContainers.
RNTupleAuxDynReader.h
RNTupleAuxDynStore.h
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
RNTupleAuxDynStore::RNTupleAuxDynStore
RNTupleAuxDynStore(RootAuxDynIO::RNTupleAuxDynReader &aux_reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
Definition
RNTupleAuxDynStore.cxx:17
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:26
RNTupleAuxDynStore::m_reader
RootAuxDynIO::RNTupleAuxDynReader & m_reader
Definition
RNTupleAuxDynStore.h:31
RootAuxDynIO::RNTupleAuxDynReader
Definition
RNTupleAuxDynReader.h:23
RootAuxDynStore::RootAuxDynStore
RootAuxDynStore(RootAuxDynReader &reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
Definition
RootAuxDynStore.cxx:13
RootAuxDynStore::m_iomutex
std::recursive_mutex * m_iomutex
Optional mutex used to serialize I/O with RootStorageSvc (not owned).
Definition
RootAuxDynStore.h:75
RootAuxDynStore::m_entry
long long m_entry
Definition
RootAuxDynStore.h:64
RootAuxDynStore::m_ctx
EventContext m_ctx
Event context associated with the event store.
Definition
RootAuxDynStore.h:67
SG::AuxDataOption
Hold information about an option setting request.
Definition
AuxDataOption.h:37
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition
AuxTypeRegistry.h:61
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition
AuxTypeRegistry.cxx:640
error.h
Helper for emitting error messages.
ATHCONTAINERS_ERROR
#define ATHCONTAINERS_ERROR(ctx, msg)
Definition
error.h:54
r
int r
Definition
globals.cxx:22
RootAuxDynIO
Specialization of RootAuxDynStore for reading Aux Dynamic attributes from RNTuple.
Definition
RNTupleContainer.h:28
SG::null_auxid
static const auxid_t null_auxid
To signal no aux data item.
Definition
AuxTypes.h:30
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition
AuxTypes.h:27
RootAuxDynIO::RNTupleAuxDynReader::FieldInfo::NotFound
@ NotFound
Definition
RNTupleAuxDynReader.h:28
Generated on
for ATLAS Offline Software by
1.17.0