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-2026 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
// if have mutex, lock to prevent potential concurrent I/O from elsewhere;
29
// also protects the branch infos of the reader, which is shared between events
30
auto
io_lock =
m_iomutex
? std::unique_lock<std::recursive_mutex>(*
m_iomutex
)
31
: std::unique_lock<std::recursive_mutex>();
32
auto
& brInfo =
m_reader
.getBranchInfo(auxid, *
this
);
33
if
( !brInfo.branch )
return
false
;
34
35
// Make a 1-element vector.
36
SG::AuxStoreInternal::getDataInternal(auxid, 1, 1,
true
);
37
if
( brInfo.isPackedContainer ) {
38
setOption (auxid,
SG::AuxDataOption
(
"nbits"
, 32));
39
}
40
41
// get memory location where to write data from the branch entry
42
// const_cast because TTree::SetBranchAddress requires void*
43
void
*
vector
ATLAS_THREAD_SAFE
=
const_cast<
void
*
>
(SG::AuxStoreInternal::getIOData (auxid));
44
void
* data = &
vector
;
45
if
( standalone() && !brInfo.tclass ) {
46
// reading fundamental type - ROOT expects a direct pointer
47
data =
vector
;
48
}
49
50
// read branch
51
brInfo.setAddress(data);
52
int
nbytes = brInfo.branch->GetEntry(
m_entry
);
53
if
( nbytes <= 0 )
54
throw
std::string(
"Error reading branch "
) + brInfo.branch->GetName();
55
// read OK
56
m_reader
.addBytes(nbytes);
57
TTree::TClusterIterator clusterIterator = brInfo.branch->GetTree()->GetClusterIterator(
m_entry
);
58
clusterIterator.Next();
59
if
(
m_entry
== clusterIterator.GetStartEntry() && brInfo.branch->GetTree()->GetMaxVirtualSize() != 0) {
60
for
(
int
i = brInfo.branch->GetReadBasket(); i < brInfo.branch->GetMaxBaskets()
61
&& brInfo.branch->GetBasketEntry()[i] < clusterIterator.GetNextEntry(); i++) {
62
brInfo.branch->GetBasket(i);
63
}
64
}
65
}
66
catch
(
const
std::string& e_str) {
67
ATHCONTAINERS_ERROR
(
"TBranchAuxDynStore::getData"
, e_str);
68
return
false
;
69
}
70
71
SG::AuxStoreInternal::toTransient (
m_ctx
, auxid);
72
SG::AuxTypeRegistry
&
r
=
SG::AuxTypeRegistry::instance
();
73
SG::auxid_t
linked_auxid =
r
.linkedVariable (auxid);
74
if
(linked_auxid !=
SG::null_auxid
) {
75
return
readData
(linked_auxid);
76
}
77
return
true
;
78
}
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:62
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