26#include <TBranchElement.h>
30#include <TStreamerElement.h>
31#include <TStreamerInfo.h>
34#include <TVirtualCollectionProxy.h>
45bool isPrimitiveBranch(TBranch& br) {
48 ::TClass*
cl =
nullptr;
49 ::EDataType dType = kOther_t;
52 if (
br.GetExpectedType(cl, dType)) {
53 ::Error(
"::isPrimitiveBranch",
61 return ((dType != kOther_t) && (dType != kNoType_t) && (dType != kVoid_t));
81bool isContainerBranch(TBranch& br,
SG::auxid_t auxid) {
90 ::TClass*
cl =
nullptr;
91 ::EDataType dType = kOther_t;
94 if (
br.GetExpectedType(cl, dType)) {
95 ::Error(
"::isContainerBranch",
96 XAOD_MESSAGE(
"Couldn't determine the type of branch \"%s\""),
109 const std::type_info* root_ti =
cl->GetTypeInfo();
117 typeName.ReplaceAll(
"basic_string<char>",
"string");
118 ::TClass* newCl = ::TClass::GetClass(typeName);
120 root_ti = newCl->GetTypeInfo();
124 ::Error(
"::isContainerBranch",
125 XAOD_MESSAGE(
"Couldn't get an std::type_info object out of "
126 "branch \"%s\" of type \"%s\""),
127 br.GetName(),
cl->GetName());
132 const std::type_info* aux_obj_ti =
135 ::Error(
"::isContainerBranch",
138 static_cast<int>(auxid));
141 const std::type_info* aux_vec_ti =
144 ::Error(
"::isContainerBranch",
147 static_cast<int>(auxid));
152 if (*root_ti == *aux_obj_ti) {
155 }
else if (*root_ti == *aux_vec_ti) {
163 if (
cl->GetCollectionProxy() && (*aux_vec_ti ==
typeid(std::vector<int>))) {
169 if (*cl2->GetTypeInfo() == *aux_vec_ti) {
185 aux_vec_cl->GetConversionStreamerInfo(cl,
cl->GetClassVersion())) {
191 aux_obj_cl->GetConversionStreamerInfo(cl,
cl->GetClassVersion())) {
196 ::Error(
"::isContainerBranch",
197 XAOD_MESSAGE(
"Couldn't determine if branch describes a single "
198 "object or a container"));
199 ::Error(
"::isContainerBranch",
XAOD_MESSAGE(
"ROOT type : %s"),
201 ::Error(
":isContainerBranch",
XAOD_MESSAGE(
"Object type: %s"),
203 ::Error(
"::isContainerBranch",
XAOD_MESSAGE(
"Vector type: %s"),
217 TBranchHandle(
bool staticBranch,
bool primitiveBranch,
218 const std::type_info* ti,
void* obj,
SG::auxid_t auxid,
219 std::string_view prefix)
223 m_static(staticBranch),
224 m_primitive(primitiveBranch),
252 if (!m_branch->GetTree()) {
254 "xAOD::TAuxStore::TBranchHandle::getEntry",
255 XAOD_MESSAGE(
"Branch=%s is not associated to any tree while reading "
256 "of branches within this class relies on that"),
257 m_branch->GetName());
267 ::Long64_t
entry = m_branch->GetTree()->GetReadEntry();
275 Error(
"xAOD::TAuxStore::TBranchHandle::getEntry",
277 "Entry to read is not set for branch=%s from tree=%s. "
278 "It is either because TTree::LoadTree(entry) was not called "
279 "beforehand in the TEvent class OR "
280 "the entry requested to be read for the main tree is not "
281 "corresponding to an event for the friend tree"),
282 m_branch->GetName(), m_branch->GetTree()->GetName());
287 if ((entry == m_entry) && (!m_needsRead)) {
293 if ((m_branch->GetMakeClass() != m_static) &&
294 (!m_branch->SetMakeClass(m_static))) {
295 ::Error(
"xAOD::TAuxStore::TBranchHandle::getEntry",
298 static_cast<int>(m_static), m_branch->GetName());
304 const ::Int_t nbytes = m_branch->GetEntry(entry);
325 ::TBranch** branchPtr() {
return &m_branch; }
335 void* objectPtr() {
return m_object; }
354 void* inputObjectPtr() {
356 if (m_static || m_primitive) {
373 void* outputObjectPtr() {
382 const std::type_info* typeInfo()
const {
return m_typeInfo; }
396 void reset() { m_needsRead =
true; }
414 const std::type_info* m_typeInfo;
420 std::string_view m_prefix;
452 return StatusCode::SUCCESS;
457 return StatusCode::SUCCESS;
461 TObjArray* branches =
m_inTree->GetListOfBranches();
464 for (Int_t i = 0; i < branches->GetEntriesFast(); ++i) {
467 const TString brName = branches->At(i)->GetName();
470 TBranch* br =
dynamic_cast<TBranch*
>(branches->At(i));
472 ::Fatal(
"xAOD::TAuxStore::impl::scanInputTree",
484 TObjArray* sbranches = br->GetListOfBranches();
487 for (Int_t j = 0; j < sbranches->GetEntriesFast(); ++j) {
490 const TString brName = sbranches->At(j)->GetName();
493 const TString auxName =
494 brName(brName.Index(
".") + 1, brName.Length());
497 if (auxName.BeginsWith(
"xAOD::") || auxName.BeginsWith(
"SG::") ||
498 (auxName ==
"ILockable")) {
503 ::TBranch* sbr =
dynamic_cast< ::TBranch*
>(sbranches->At(j));
505 ::Fatal(
"xAOD::TAuxStore::impl::scanInputTree",
520 if (!brName.BeginsWith(
m_data.m_dynPrefix.data())) {
526 if (brName ==
m_data.m_dynPrefix) {
527 ::Warning(
"xAOD::TAuxStore::impl::scanInputTree",
528 "Dynamic branch with empty name found on container: %s",
534 const TString auxName = brName(brName.Index(
".") + 1, brName.Length());
546 return StatusCode::SUCCESS;
551 ::TBranch& br, std::string_view auxName,
bool staticBranch,
552 std::string* expectedClassName =
nullptr) {
555 ::TClass* expectedClass =
nullptr;
556 ::EDataType expectedType = kOther_t;
557 if (br.GetExpectedType(expectedClass, expectedType) &&
558 ((!staticBranch) || (!auxName.starts_with(
"m_")))) {
559 ::Warning(
"xAOD::TAuxStore::impl::auxBranchType",
560 "Couldn't get the type of branch \"%s\"", br.GetName());
568 if (TBranchElement* bre =
dynamic_cast<TBranchElement*
>(&br)) {
569 TClass* newClass = bre->GetCurrentClass();
570 if (newClass && newClass != expectedClass) {
571 expectedClass = newClass;
574 if (expectedClassName) {
575 *expectedClassName = expectedClass->GetName();
581 if ((!expectedClass) &&
587 const std::type_info* ti =
nullptr;
590 ti = expectedClass->GetTypeInfo();
595 if (!expectedClass) {
596 if ((!staticBranch) || (!auxName.starts_with(
"m_"))) {
597 ::Warning(
"xAOD::TAuxStore::impl::auxBranchType",
598 "Couldn't get the type of branch \"%s\"", br.GetName());
601 ::TVirtualCollectionProxy* prox = expectedClass->GetCollectionProxy();
606 prox = cl2->GetCollectionProxy();
611 if ((!staticBranch) || (!auxName.starts_with(
"m_"))) {
612 ::Warning(
"xAOD::TAuxStore::impl::auxBranchType",
613 "Couldn't get the type of branch \"%s\"", br.GetName());
616 if (prox->GetValueClass()) {
617 ti = prox->GetValueClass()->GetTypeInfo();
650 std::string expectedClassName;
651 const std::type_info* ti =
652 auxBranchType(br, auxName, staticBranch, &expectedClassName);
655 return StatusCode::SUCCESS;
666 m_data.m_auxIDs.insert(regAuxid);
667 return StatusCode::SUCCESS;
674 flags |= SG::AuxVarFlags::Linked;
676 std::string linkedAttr =
679 ::TBranch* lbr =
m_inTree->GetBranch(linkedBranch.c_str());
680 const std::type_info* lti =
nullptr;
686 *lti, linkedAttr,
"",
687 SG::AuxVarFlags::SkipNameCheck | SG::AuxVarFlags::Linked);
690 ::Error(
"xAOD::TAuxStore::impl::setupAuxBranch",
691 "Could not find linked variable for %s type %s", auxName.data(),
692 expectedClassName.c_str());
698 registry.
getAuxID(*ti, std::string{auxName},
"", flags, linked_auxid);
709 if (tn.starts_with(
"std::vector<")) {
712 std::string fac_class_name =
713 "SG::AuxTypeVectorFactory<" + tn +
",allocator<" + tn;
714 if (fac_class_name[fac_class_name.size() - 1] ==
'>') {
715 fac_class_name +=
' ';
717 fac_class_name +=
"> >";
720 ::TClass* fac_class = TClass::GetClass(fac_class_name.c_str());
721 if (fac_class && fac_class->IsLoaded()) {
722 ::TClass* base_class = ::TClass::GetClass(
"SG::IAuxTypeVectorFactory");
723 if (base_class && base_class->IsLoaded()) {
724 const Int_t offs = fac_class->GetBaseClassOffset(base_class);
726 void* fac_vp = fac_class->New();
729 reinterpret_cast<unsigned long>(fac_vp) + offs;
734 std::unique_ptr<SG::IAuxTypeVectorFactory>(fac));
735 auxid = registry.
getAuxID(*ti, std::string{auxName},
"", flags,
748 if (vec_class_name[vec_class_name.size() - 1] ==
'>') {
749 vec_class_name +=
' ';
751 vec_class_name +=
'>';
754 ::TClass* vec_class = ::TClass::GetClass(vec_class_name.c_str());
755 if (vec_class && vec_class->IsLoaded()) {
756 auto fac = std::make_unique<TAuxVectorFactory>(vec_class);
757 if (fac->tiAlloc()) {
758 const std::type_info* tiAlloc = fac->tiAlloc();
759 registry.
addFactory(*ti, *tiAlloc, std::move(fac));
761 std::string tiAllocName = fac->tiAllocName();
762 registry.
addFactory(*ti, tiAllocName, std::move(fac));
764 auxid = registry.
getAuxID(*ti, std::string{auxName},
"",
765 SG::AuxVarFlags::SkipNameCheck);
767 ::Warning(
"xAOD::TAuxStore::impl::setupAuxBranch",
768 "Couldn't find dictionary for type: %s",
769 vec_class_name.c_str());
776 ::Error(
"xAOD::TAuxStore::impl::setupAuxBranch",
777 XAOD_MESSAGE(
"Dynamic ROOT vector factory not implemented for "
778 "linked types; branch "
782 ::Error(
"xAOD::TAuxStore::impl::setupAuxBranch",
787 return StatusCode::FAILURE;
791 m_data.m_auxIDs.insert(auxid);
792 return StatusCode::SUCCESS;
852 return m_impl->m_basketSize;
858 m_impl->m_basketSize = value;
864 return m_impl->m_splitLevel;
870 m_impl->m_splitLevel = value;
886 m_impl->m_missingBranches.clear();
896 assert(
m_impl->m_inTree !=
nullptr);
897 TBranch* br =
m_impl->m_inTree->GetBranch(
m_data.m_prefix.data());
901 return StatusCode::SUCCESS;
906 if ((br->GetSplitLevel() != 1) &&
m_data.m_topStore && printWarnings) {
907 ::Warning(
"xAOD::TAuxStore::readFrom",
908 "Static branch (%s) with split level %i discovered",
909 m_data.m_prefix.data(), br->GetSplitLevel());
910 ::Warning(
"xAOD::TAuxStore::readFrom",
911 "The reading of complex variables from it may/will fail!");
915 return StatusCode::SUCCESS;
942 return StatusCode::SUCCESS;
957 if (
m_data.m_transientStore && (getall != 99)) {
959 m_data.m_auxIDs -=
m_data.m_transientStore->getAuxIDs();
960 m_data.m_decorIDs -=
m_data.m_transientStore->getDecorIDs();
962 m_data.m_transientStore.reset();
968 if (!
m_data.m_isDecoration[auxid]) {
971 m_data.m_auxIDs.erase(auxid);
972 m_data.m_decorIDs.erase(auxid);
983 for (
auto& branchHandle :
m_impl->m_branches) {
985 bytesRead += branchHandle->getEntry();
986#ifndef XAOD_STANDALONE
987 m_data.m_vecs[branchHandle->auxid()]->toTransient(
m_impl->m_ctx );
998 for (
auto& branchHandle :
m_impl->m_branches) {
1000 branchHandle->reset();
1003 m_impl->m_inputScanned =
false;
1009 return ((
m_impl->m_branches.size() > auxid) &&
m_impl->m_branches[auxid]);
1015 assert(
m_impl->m_branches.size() > auxid);
1016 assert(
m_impl->m_branches[auxid]);
1017 const ::Int_t readBytes =
m_impl->m_branches[auxid]->getEntry();
1018 if (readBytes < 0) {
1019 ::Error(
"xAOD::TAuxStore::getEntryFor",
1022 return StatusCode::FAILURE;
1024#ifndef XAOD_STANDALONE
1027 return StatusCode::SUCCESS;
1033 return (
m_impl->m_outTree !=
nullptr);
1051 if ((auxid < m_impl->m_missingBranches.size()) &&
1052 m_impl->m_missingBranches[auxid]) {
1053 return StatusCode::RECOVERABLE;
1057 if (
m_data.m_vecs.size() <= auxid) {
1058 m_data.m_vecs.resize(auxid + 1);
1060 if (
m_impl->m_branches.size() <= auxid) {
1061 m_impl->m_branches.resize(auxid + 1);
1065 if (
m_data.m_vecs[auxid] &&
m_impl->m_branches[auxid]) {
1066 return StatusCode::SUCCESS;
1070 if (
m_impl->m_inTree ==
nullptr) {
1071 ::Error(
"xAOD::TAuxStore::setupInputData",
1073 return StatusCode::FAILURE;
1077 if (
m_data.m_vecs[auxid] ||
m_impl->m_branches[auxid]) {
1078 ::Error(
"xAOD::TAuxStore::setupInputData",
1080 return StatusCode::FAILURE;
1087 const TString statBrName =
1088 std::format(
"{}{}",
m_data.m_prefix,
r.getName(auxid));
1089 const TString dynBrName =
1090 std::format(
"{}{}",
m_data.m_dynPrefix,
r.getName(auxid));
1093 Bool_t staticBranch =
true;
1094 TString brName = statBrName;
1096 TBranch* br =
m_impl->m_inTree->GetBranch(statBrName);
1098 br =
m_impl->m_inTree->GetBranch(dynBrName);
1102 if (
m_impl->m_missingBranches.size() <= auxid) {
1103 m_impl->m_missingBranches.resize(auxid + 1);
1105 m_impl->m_missingBranches[auxid] =
true;
1108 return StatusCode::RECOVERABLE;
1111 staticBranch =
false;
1116 const Bool_t primitiveBranch = isPrimitiveBranch(*br);
1118 const Bool_t containerBranch =
1119 (primitiveBranch ? false : isContainerBranch(*br, auxid));
1128 if ((containerBranch &&
1130 !
r.isLinked(auxid)) ||
1131 ((!containerBranch) &&
1133 ::Error(
"xAOD::TAuxStore::setupInputData",
1134 XAOD_MESSAGE(
"Branch type and requested structure mode "
1135 "differ for branch: %s"),
1137 return StatusCode::FAILURE;
1141 ::TClass* clDummy = 0;
1142 ::EDataType dType = kOther_t;
1143 if (br->GetExpectedType(clDummy, dType)) {
1144 ::Error(
"xAOD::TAuxStore::setupInputData",
1145 XAOD_MESSAGE(
"Couldn't determine the type of branch \"%s\""),
1147 return StatusCode::FAILURE;
1151 const std::type_info* brType = 0;
1154 brType = (containerBranch ?
r.getVecType(auxid) :
r.getType(auxid));
1160 ::Error(
"xAOD::TAuxStore::setupInputData",
1161 XAOD_MESSAGE(
"Can't read/copy variable %s (%s)"), brName.Data(),
1162 clDummy->GetName());
1163 return StatusCode::RECOVERABLE;
1168 ::TClass* brClass = 0;
1169 if (!primitiveBranch) {
1171 brClass = ::TClass::GetClass(*brType,
true,
true);
1173 brClass = ::TClass::GetClass(brTypeName);
1176 ::Error(
"xAOD::TAuxStore::setupInputData",
1177 XAOD_MESSAGE(
"No dictionary available for class \"%s\""),
1179 return StatusCode::FAILURE;
1185 m_data.m_vecs[auxid] =
r.makeVector(auxid, (
size_t)0, (
size_t)0);
1186 if (!containerBranch) {
1187 m_data.m_vecs[auxid]->resize(1);
1190 strncmp(clDummy->GetName(),
"SG::PackedContainer<", 20) == 0) {
1191 std::unique_ptr<SG::IAuxTypeVector> packed =
1192 m_data.m_vecs[auxid]->toPacked();
1196 ::Error(
"xAOD::TAuxStore::setupInputData",
1198 "variable %s (%i)"),
1199 brName.Data(),
static_cast<int>(auxid));
1200 return StatusCode::FAILURE;
1204 const std::type_info* objType = brType;
1205 if (containerBranch) {
1206 objType =
m_data.m_vecs[auxid]->objType();
1208 objType =
r.getType(auxid);
1210 m_impl->m_branches[auxid] = std::make_unique<TBranchHandle>(
1211 staticBranch, primitiveBranch, objType,
1212 (containerBranch ?
m_data.m_vecs[auxid]->toVector()
1213 :
m_data.m_vecs[auxid]->toPtr()),
1223 if (clDummy && ::TString(clDummy->GetName()).Contains(
"basic_string<char>")) {
1230 status =
m_impl->m_inTree->SetBranchAddress(
1231 brName,
m_impl->m_branches[auxid]->inputObjectPtr(),
1232 m_impl->m_branches[auxid]->branchPtr());
1234 status =
m_impl->m_inTree->SetBranchAddress(
1235 brName,
m_impl->m_branches[auxid]->inputObjectPtr(),
1236 m_impl->m_branches[auxid]->branchPtr(), brClass, dType,
1237 ((!staticBranch) && (!primitiveBranch)));
1240 ::Error(
"xAOD::TAuxStore::setupInputData",
1241 XAOD_MESSAGE(
"Coulnd't connect to branch \"%s\""), brName.Data());
1242 ::Error(
"xAOD::TAuxStore::setupInputData",
XAOD_MESSAGE(
"Return code: %i"),
1244 m_data.m_vecs[auxid].reset();
1245 m_impl->m_branches[auxid].reset();
1246 return StatusCode::FAILURE;
1250 m_impl->m_branches[auxid]->getEntry();
1251#ifndef XAOD_STANDALONE
1256 m_data.m_auxIDs.insert(auxid);
1261 const std::string auxname =
r.getName(auxid);
1273 const std::string testname =
r.getName(i);
1275 if (testname != auxname) {
1280 ::Error(
"xAOD::TAuxStore::setupInputData",
1285 m_data.m_vecs[i].reset();
1286 m_impl->m_branches[i].reset();
1287 m_data.m_auxIDs.erase(i);
1297 return StatusCode::SUCCESS;
1314 if (!
m_impl->m_outTree) {
1315 return StatusCode::SUCCESS;
1320 return StatusCode::SUCCESS;
1324 if (
m_data.m_vecs.size() <= auxid) {
1325 m_data.m_vecs.resize(auxid + 1);
1327 if (
m_impl->m_branches.size() <= auxid) {
1328 m_impl->m_branches.resize(auxid + 1);
1330 if (
m_impl->m_branchesWritten.size() <= auxid) {
1331 m_impl->m_branchesWritten.resize(auxid + 1);
1335 if (
m_impl->m_branchesWritten[auxid]) {
1336 return StatusCode::SUCCESS;
1344 if ((!
m_data.m_vecs[auxid]) &&
m_data.m_transientStore &&
1345 (
m_data.m_transientStore->getAuxIDs().test(auxid))) {
1348 const void* pptr =
m_data.m_transientStore->getData(auxid);
1350 ::Fatal(
"xAOD::TAuxStore::setupOutputData",
1352 return StatusCode::FAILURE;
1357 void* ptr =
m_data.m_vecs[auxid]->toPtr();
1359 ::Error(
"xAOD::TAuxStore::setupOutputData",
1362 return StatusCode::FAILURE;
1366 const std::type_info*
type = reg.getType(auxid);
1368 ::Error(
"xAOD::TAuxStore::setupOutputData",
1371 static_cast<int>(auxid));
1372 return StatusCode::FAILURE;
1377 ::Error(
"xAOD::TAuxStore::setupOutputData",
1378 XAOD_MESSAGE(
"No factory found for transient variable "
1380 static_cast<int>(auxid));
1381 return StatusCode::FAILURE;
1385 if (
m_data.m_isDecoration.size() <= auxid) {
1386 m_data.m_isDecoration.resize(auxid + 1);
1388 m_data.m_isDecoration[auxid] =
true;
1398 if ((
m_data.m_auxIDs.test(auxid)) && (!
m_data.m_vecs[auxid]) &&
1399 (!
m_impl->m_branches[auxid])) {
1406 ::Error(
"xAOD::TAuxStore::setupOutputData",
1407 XAOD_MESSAGE(
"Structure mode unknown for variable %s"),
1409 return StatusCode::FAILURE;
1413 if (!
m_data.m_vecs[auxid]) {
1417 m_data.m_vecs[auxid]->resize(1);
1422 if (!
m_impl->m_branches[auxid]) {
1424 const std::type_info* brType =
1429 bool primitiveBranch = (strlen(brType->name()) == 1);
1430 m_impl->m_branches[auxid] = std::make_unique<TBranchHandle>(
1431 false, (strlen(brType->name()) == 1),
1432 (primitiveBranch ? brType :
m_data.m_vecs[auxid]->objType()),
1434 ?
m_data.m_vecs[auxid]->toPtr()
1435 :
m_data.m_vecs[auxid]->toVector()),
1440 const TString brName =
1441 std::format(
"{}{}",
m_data.m_dynPrefix,
1446 ::TBranch* br =
m_impl->m_outTree->GetBranch(brName);
1451 br->SetAddress(
m_impl->m_branches[auxid]->outputObjectPtr());
1455 m_impl->m_branchesWritten[auxid] =
true;
1457 return StatusCode::SUCCESS;
1461 const std::type_info* brType =
m_impl->m_branches[auxid]->typeInfo();
1463 ::Error(
"xAOD::TAuxStore::setupOutputData",
1466 return StatusCode::FAILURE;
1471 const Bool_t primitiveBranch = (strlen(brType->name()) == 1);
1474 if (primitiveBranch) {
1478 if (rootType ==
'\0') {
1479 ::Error(
"xAOD::TAuxStore::setupOutputData",
1482 brName.Data(), brTypeName.c_str());
1483 return StatusCode::FAILURE;
1487 std::ostringstream typeDesc;
1488 typeDesc << brName <<
"/" << rootType;
1491 br =
m_impl->m_outTree->Branch(
1492 brName,
m_impl->m_branches[auxid]->outputObjectPtr(),
1493 typeDesc.str().c_str(),
m_impl->m_basketSize);
1498 TClass* cl = TClass::GetClass(*brType);
1500 cl = TClass::GetClass(brTypeName.c_str());
1503 ::Error(
"xAOD::TAuxStore::setupOutputData",
1505 brTypeName.c_str());
1506 return StatusCode::FAILURE;
1508 if (!cl->GetStreamerInfo()) {
1509 ::Error(
"xAOD::TAuxStore::setupOutputData",
1510 XAOD_MESSAGE(
"No streamer info available for type %s"),
1512 return StatusCode::FAILURE;
1516 br =
m_impl->m_outTree->Branch(brName, cl->GetName(),
1517 m_impl->m_branches[auxid]->outputObjectPtr(),
1523 ::Error(
"xAOD::TAuxStore::setupOutputData",
1526 brName.Data(), brTypeName.c_str());
1527 return StatusCode::FAILURE;
1532 for (Long64_t i = 0; i <
m_impl->m_outTree->GetEntries(); ++i) {
1537 m_impl->m_branchesWritten[auxid] =
true;
1540 m_data.m_auxIDs.insert(auxid);
1543 return StatusCode::SUCCESS;
1549 assert(
m_impl->m_branches.size() > auxid);
1550 assert(
m_impl->m_branches[auxid]);
1551 return m_impl->m_branches[auxid]->objectPtr();
1557 assert(
m_impl->m_branches.size() > auxid);
1558 assert(
m_impl->m_branches[auxid]);
1559 return m_impl->m_branches[auxid]->typeInfo();
An auxiliary data store that holds data internally.
Handle mappings between names and auxid_t.
Make an AuxVectorData object from either a raw vector or an aux store.
Exceptions that can be thrown from AthContainers.
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
Helper for getting a const version of a pointer.
Define macros for attributes used to control the static checker.
Handle mappings between names and auxid_t.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
SG::auxid_t getAuxID(const std::string &name, const std::string &clsname="", const Flags flags=Flags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Look up a name -> auxid_t mapping.
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
static bool isLinkedName(const std::string &name)
Test if a variable name corresponds to a linked variable.
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
static bool classNameHasLink(const std::string &className)
Test to see if a class name corresponds to a class with a linked variable.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
const IAuxTypeVectorFactory * addFactory(const std::type_info &ti, const std::type_info &ti_alloc, std::unique_ptr< const IAuxTypeVectorFactory > factory)
Add a new type -> factory mapping.
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.
Make an AuxVectorData object from either a raw array or an aux store.
Interface for factory objects that create vectors.
virtual const std::type_info * tiAlloc() const =0
Return the type_info of the vector allocator.
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.
A set of aux data identifiers.
ReadStats & stats()
Access the object belonging to the current thread.
static IOStats & instance()
Singleton object accessor.
void readBranch(const std::string &prefix, SG::auxid_t auxid)
Function incrementing the read counter on a specific branch.
int getEntry(int getall=0)
Read the values from the TTree entry that was loaded with TTree::LoadTree().
virtual ~TAuxStore()
Destructor.
virtual const std::type_info * getInputType(SG::auxid_t auxid) const override
Get the type of an input object, for getIOType().
virtual void reset() override
Tell the object that all branches will need to be re-read.
virtual bool hasEntryFor(SG::auxid_t auxid) const override
Check if a given variable is available from the input.
virtual bool hasOutput() const override
Check if an output is being written by the object.
void setSplitLevel(int value)
Set the split level of the output branches.
TAuxStore(const EventContext &ctx, std::string_view prefix="", bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore, int basketSize=2048, int splitLevel=0)
Constructor.
virtual StatusCode setupInputData(SG::auxid_t auxid) override
Connect a variable to the input.
StatusCode readFrom(::TTree &tree, bool printWarnings=true)
Connect the object to an input TTree.
int splitLevel() const
Get the split level of the output branches.
virtual StatusCode setupOutputData(SG::auxid_t auxid) override
Connect a variable to the output.
virtual void setPrefix(std::string_view prefix) override
Set the object name prefix.
StatusCode writeTo(::TTree &tree)
Connect the object to an output TTree.
virtual StatusCode getEntryFor(SG::auxid_t auxid) override
Load a single variable from the input.
std::unique_ptr< impl > m_impl
Pointer to the internal object.
void setBasketSize(int value)
Set the size of the baskets created for the output branches.
int basketSize() const
Get the size of the baskets created for the output branches.
virtual const void * getInputObject(SG::auxid_t auxid) const override
Get a pointer to an input object, as it is in memory, for getIOData().
const std::string & prefix() const
Get the currently configured object name prefix.
bool isAuxIDSelected(SG::auxid_t auxid) const
Check if an auxiliary variable is selected for ouput writing.
virtual SG::auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected aux variables.
AthContainers_detail::mutex mutex_t
Mutex type for multithread synchronization.
EStructMode
"Structural" modes of the object
@ kUndefinedStore
The structure mode is not defined.
@ kObjectStore
The object describes a single object.
@ kContainerStore
The object describes an entire container.
AuxStoreBase(bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore)
Constructor.
Members m_data
Member variables of the base class.
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
Error
The different types of error that can be flagged in the L1TopoRDO.
AuxVarFlags
Additional flags to qualify an auxiliary variable.
static const auxid_t null_auxid
To signal no aux data item.
SG::auxid_t auxid() const
Return the aux id for this variable.
virtual void reset() override
Free all allocated elements.
size_t auxid_t
Identifier for a particular aux data item.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
const std::type_info & getTypeInfo(EDataType type)
This function is used when reading a primitive branch from an input file without the user explicitly ...
std::string dynBranchPrefix(const std::string &key)
This function is used to figure out what to name dynamic auxiliary branches coming from a container c...
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
TClass * lookupVectorType(TClass &cl)
Internal function used by xAOD::TAuxStore and xAOD::RAuxStore.
bool isRegisteredType(SG::auxid_t auxid)
Check if the auxiliary variable has a registered type.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
int m_basketSize
The basket size for the output branches.
Members & m_data
Variables coming from AuxStoreBase.
StatusCode setupAuxBranch(::TBranch &br, std::string_view auxName, bool staticBranch)
Register one input branch as an available auxiliary variable.
std::vector< bool > m_branchesWritten
"Write status" of the different variables
std::vector< bool > m_missingBranches
Mark branches we've found to be missing.
StatusCode scanInputTree()
Scan the input TTree for auxiliary branches.
::TTree * m_inTree
The TTree being read from.
impl(const EventContext &ctx, Members &data, int basketSize, int splitLevel)
std::vector< std::unique_ptr< TBranchHandle > > m_branches
Branches reading the various auxiliary variables.
mutex_t m_mutex
Mutex object used for multithreaded synchronisation.
const std::type_info * auxBranchType(::TBranch &br, std::string_view auxName, bool staticBranch, std::string *expectedClassName=nullptr)
Find the type_info to use as the aux type for a given branch.
bool m_inputScanned
"Scan status" of the input TTree
::TTree * m_outTree
The TTree being written to.
int m_splitLevel
The split level for the output branches.
const EventContext & m_ctx
The context for this event.
Struct collecting all member variables of this base class.