ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaRoot
RootAuxDynIO
src
TBranchAuxDynStore.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
6
#include "
AthContainers/AuxTypeRegistry.h
"
7
#include "
AthContainers/tools/error.h
"
8
#include "
AthContainers/exceptions.h
"
9
#include "
AthContainersInterfaces/AuxDataOption.h
"
10
11
#include "
TBranchAuxDynStore.h
"
12
#include "
TBranchAuxDynReader.h
"
13
14
#include "TTree.h"
15
16
17
TBranchAuxDynStore::TBranchAuxDynStore
(
TBranchAuxDynReader
& reader,
long
long
entry,
bool
standalone,
18
std::recursive_mutex* iomtx)
19
:
RootAuxDynStore
( reader, entry, standalone, iomtx ),
20
m_reader
(reader)
21
{
22
}
23
24
25
bool
TBranchAuxDynStore::readData
(
SG::auxid_t
auxid)
26
{
27
try
{
28
auto
& brInfo =
m_reader
.getBranchInfo(auxid, *
this
);
29
if
( !brInfo.branch )
return
false
;
30
31
// Make a 1-element vector.
32
SG::AuxStoreInternal::getDataInternal(auxid, 1, 1,
true
);
33
if
( brInfo.isPackedContainer ) {
34
setOption (auxid,
SG::AuxDataOption
(
"nbits"
, 32));
35
}
36
37
// get memory location where to write data from the branch entry
38
// const_cast because TTree::SetBranchAddress requires void*
39
void
*
vector
ATLAS_THREAD_SAFE
=
const_cast<
void
*
>
(SG::AuxStoreInternal::getIOData (auxid));
40
void
* data = &
vector
;
41
if
( standalone() && !brInfo.tclass ) {
42
// reading fundamental type - ROOT expects a direct pointer
43
data =
vector
;
44
}
45
46
// if have mutex, lock to prevent potential concurrent I/O from elsewhere
47
auto
io_lock =
m_iomutex
? std::unique_lock<std::recursive_mutex>(*
m_iomutex
)
48
: std::unique_lock<std::recursive_mutex>();
49
// read branch
50
brInfo.setAddress(data);
51
int
nbytes = brInfo.branch->GetEntry(
m_entry
);
52
if
( nbytes <= 0 )
53
throw
std::string(
"Error reading branch "
) + brInfo.branch->GetName();
54
// read OK
55
m_reader
.addBytes(nbytes);
56
TTree::TClusterIterator clusterIterator = brInfo.branch->GetTree()->GetClusterIterator(
m_entry
);
57
clusterIterator.Next();
58
if
(
m_entry
== clusterIterator.GetStartEntry() && brInfo.branch->GetTree()->GetMaxVirtualSize() != 0) {
59
for
(
int
i = brInfo.branch->GetReadBasket(); i < brInfo.branch->GetMaxBaskets()
60
&& brInfo.branch->GetBasketEntry()[i] < clusterIterator.GetNextEntry(); i++) {
61
brInfo.branch->GetBasket(i);
62
}
63
}
64
}
65
catch
(
const
std::string& e_str) {
66
ATHCONTAINERS_ERROR
(
"TBranchAuxDynStore::getData"
, e_str);
67
return
false
;
68
}
69
70
SG::AuxStoreInternal::toTransient (
m_ctx
, auxid);
71
SG::AuxTypeRegistry
&
r
=
SG::AuxTypeRegistry::instance
();
72
SG::auxid_t
linked_auxid =
r
.linkedVariable (auxid);
73
if
(linked_auxid !=
SG::null_auxid
) {
74
return
readData
(linked_auxid);
75
}
76
return
true
;
77
}
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.
TBranchAuxDynReader.h
TBranchAuxDynStore.h
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
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
TBranchAuxDynReader
Definition
TBranchAuxDynReader.h:20
TBranchAuxDynStore::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
TBranchAuxDynStore.cxx:25
TBranchAuxDynStore::TBranchAuxDynStore
TBranchAuxDynStore(TBranchAuxDynReader &reader, long long entry, bool standalone, std::recursive_mutex *iomtx=nullptr)
Definition
TBranchAuxDynStore.cxx:17
TBranchAuxDynStore::m_reader
TBranchAuxDynReader & m_reader
Definition
TBranchAuxDynStore.h:32
vector
Definition
MultiHisto.h:13
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
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
Generated on
for ATLAS Offline Software by
1.17.0