|  | ATLAS Offline Software
    | 
 
 
 
Go to the documentation of this file.
   17 #include <TChainElement.h> 
   20 #include <TFriendElement.h> 
   22 #include <TMethodCall.h> 
   33 #ifndef XAOD_STANDALONE 
   36 #endif  // not XAOD_STANDALONE 
   71 static const ::Int_t CACHE_SIZE = -1;
 
   75 static const char* 
const METADATA_TREE_NAME = 
"MetaData";
 
   96         "Did not call finishWritingTo() before destroying the TEvent object!");
 
  126   if (
file == 
nullptr) {
 
  128     return StatusCode::SUCCESS;
 
  155     ATH_MSG_ERROR(
"Couldn't find metadata tree on input. Object is unusable!");
 
  156     return StatusCode::FAILURE;
 
  163     return StatusCode::FAILURE;
 
  168     ATH_MSG_WARNING(
"Was expecting a metadata tree with size 1, instead of " 
  170     ATH_MSG_WARNING(
"The input file was most probably produced by hadd...");
 
  176   static const std::string eventFormatTypeName =
 
  178   ::TClass* 
cl = ::TClass::GetClass(eventFormatTypeName.c_str());
 
  185   auto readEventFormatMetadata = [&](std::string_view thisTreeName) -> 
StatusCode {
 
  187     TTree* metaTree = 
file->Get<TTree>(thisTreeName.data());
 
  188     if (metaTree == 
nullptr) {
 
  189       ATH_MSG_ERROR(
"Couldn't find metadata tree \"" << thisTreeName
 
  191       return StatusCode::FAILURE;
 
  194     if (metaTree->LoadTree(0) < 0) {
 
  195       ATH_MSG_ERROR(
"Failed to load entry 0 for metadata tree \"" << thisTreeName
 
  197       return StatusCode::FAILURE;
 
  201     const std::string eventFormatBranchName =
 
  203     if (!metaTree->GetBranch(eventFormatBranchName.c_str())) {
 
  207       ATH_MSG_INFO(
"Input file provides no event or metadata");
 
  208       return StatusCode::RECOVERABLE;
 
  215         metaTree->SetBranchAddress(eventFormatBranchName.c_str(), &
format, &
br);
 
  217       ATH_MSG_ERROR(
"Failed to connect to xAOD::EventFormat object");
 
  218       return StatusCode::FAILURE;
 
  223     for (
const auto& [
key, element] : *
format) {
 
  234     return StatusCode::SUCCESS;
 
  239   const StatusCode sc = readEventFormatMetadata(METADATA_TREE_NAME);
 
  240   if (
sc.isRecoverable()) {
 
  243     return StatusCode::SUCCESS;
 
  250   std::set<std::string> lOtherMetaTreeNames = {};
 
  251   TList* lKeys = 
file->GetListOfKeys();
 
  254     for (
int iKey = 0; iKey < lKeys->GetEntries(); iKey++) {
 
  256       std::string 
keyName = lKeys->At(iKey)->GetName();
 
  260       if ((
keyName != METADATA_TREE_NAME) &&
 
  261           (
keyName.find(
"MetaData") != std::string::npos) &&
 
  262           !(
keyName.find(
"MetaDataHdr") != std::string::npos)) {
 
  264         const char* 
className = ((::TKey*)lKeys->At(iKey))->GetClassName();
 
  265         static constexpr Bool_t LOAD = kFALSE;
 
  266         static constexpr Bool_t SILENT = kTRUE;
 
  267         ::TClass* 
cl = ::TClass::GetClass(
className, LOAD, SILENT);
 
  268         if ((
cl != 
nullptr) && 
cl->InheritsFrom(::TTree::Class())) {
 
  270           lOtherMetaTreeNames.insert(std::move(
keyName));
 
  277   for (
const std::string& metaTreeName : lOtherMetaTreeNames) {
 
  278     ATH_CHECK(readEventFormatMetadata(metaTreeName));
 
  305   const TIncident beginIncident(IncidentType::BeginInputFile);
 
  307     listener->handle(beginIncident);
 
  314   const TIncident endIncident(IncidentType::EndInputFile);
 
  316     listener->handle(endIncident);
 
  320   return StatusCode::SUCCESS;
 
  343     if (useTreeCache && (!
m_inChain->GetCacheSize())) {
 
  353       ATH_MSG_ERROR(
"Couldn't get the list of files from the input TChain");
 
  354       return StatusCode::FAILURE;
 
  356     if (!
files->GetEntries()) {
 
  357       ATH_MSG_ERROR(
"No files are present in the received TChain");
 
  358       return StatusCode::FAILURE;
 
  360     const ::TChainElement* chEl =
 
  361         dynamic_cast<const ::TChainElement*
>(
files->At(0));
 
  364       return StatusCode::FAILURE;
 
  367       std::unique_ptr<TFile> dummyFile{TFile::Open(chEl->GetTitle())};
 
  370         return StatusCode::FAILURE;
 
  385     return StatusCode::SUCCESS;
 
  395     ::TFile* 
file = 
tree->GetCurrentFile();
 
  414     return StatusCode::FAILURE;
 
  419     ATH_MSG_ERROR(
"Object already writing to a file. Close that file first!");
 
  420     return StatusCode::FAILURE;
 
  438   return StatusCode::SUCCESS;
 
  451     ATH_MSG_ERROR(
"The object doesn't seem to be connected to an output file!");
 
  452     return StatusCode::FAILURE;
 
  460   const TIncident incident(IncidentType::MetaDataStop);
 
  462     listener->handle(incident);
 
  474   if (
file->Get(METADATA_TREE_NAME)) {
 
  476     return StatusCode::SUCCESS;
 
  481       std::make_unique<TTree>(METADATA_TREE_NAME, 
"xAOD metadata tree");
 
  482   metatree->SetAutoSave(10000);
 
  483   metatree->SetAutoFlush(-30000000);
 
  484   metatree->SetDirectory(
file);
 
  493     ::Error(
"xAOD::TEvent::finishWritingTo",
 
  494             XAOD_MESSAGE(
"Class name parsing fails for %s ! "), 
e.what());
 
  495     return StatusCode::FAILURE;
 
  501   std::vector<std::pair<std::string, TObjectManager*>> outputMetaObjects;
 
  505     if (objMgr == 
nullptr) {
 
  507       return StatusCode::FAILURE;
 
  509     outputMetaObjects.emplace_back(
key, objMgr);
 
  514   for (
auto& [
key, 
mgr] : outputMetaObjects) {
 
  518     const ::Int_t splitLevel = (
key.ends_with(
"Aux.") ? 1 : 0);
 
  520     *(
mgr->branchPtr()) =
 
  521         metatree->Branch(
key.c_str(), 
mgr->holder()->getClass()->GetName(),
 
  522                          mgr->holder()->getPtr(), 32000, splitLevel);
 
  523     if (!
mgr->branch()) {
 
  525                     << 
mgr->holder()->getClass()->GetName() << 
"/" << 
key 
  527       return StatusCode::FAILURE;
 
  531     static constexpr 
bool METADATA = 
true;
 
  536   if (metatree->Fill() <= 0) {
 
  537     ATH_MSG_ERROR(
"Failed to write event format metadata into the output");
 
  538     metatree->SetDirectory(
nullptr);
 
  539     return StatusCode::FAILURE;
 
  544   metatree->SetDirectory(
nullptr);
 
  550   return StatusCode::SUCCESS;
 
  589     static constexpr 
bool TOP_STORE = 
true;
 
  592       ATH_MSG_ERROR(
"Couldn't connect TAuxStore object to the output");
 
  664                                                 << 
" from the input chain");
 
  678       static constexpr 
bool USE_TREE_CACHE = 
false;
 
  703                                               << 
" from the input file");
 
  719         static const std::string dynStorePostfix = 
"Aux.Dynamic";
 
  720         if (
key.ends_with(dynStorePostfix)) {
 
  728           static constexpr 
bool SILENT = 
true;
 
  729           static constexpr 
bool METADATA = 
false;
 
  742   const TIncident incident(IncidentType::BeginEvent);
 
  744     listener->handle(incident);
 
  763     return m_inChain->GetListOfFiles()->GetEntries();
 
  799   ::Long64_t 
entry = 0;
 
  800   for (::Long64_t 
i = 0; 
i < 
file; ++
i) {
 
  841   std::string unsetObjects;
 
  842   std::vector<std::pair<std::string, TVirtualManager*>> outputObjectsCopy;
 
  845     outputObjectsCopy.emplace_back(
key, 
mgr.get());
 
  847   for (
auto& [
key, 
mgr] : outputObjectsCopy) {
 
  849     if (!
mgr->create()) {
 
  852       if (unsetObjects.size()) {
 
  853         unsetObjects += 
", ";
 
  855       unsetObjects.append(
"\"" + 
key + 
"\"");
 
  861     static constexpr 
bool METADATA = 
false;
 
  864           "Failed to put dynamic auxiliary variables " 
  865           "in the output for object \"" 
  872   if (unsetObjects.size()) {
 
  873     ATH_MSG_ERROR(
"The following objects were not set in the current event: " 
  881     ATH_MSG_ERROR(
"Output tree filling failed with return value: " << ret);
 
  904                             std::vector<std::string>& vkeys,
 
  907   std::set<std::string> 
keys;
 
  911   std::vector<TObjArray*> fullListOfBranches = {};
 
  917       fullListOfBranches.push_back(
m_inMetaTree->GetListOfBranches());
 
  923       fullListOfBranches.push_back(
m_inTree->GetListOfBranches());
 
  928         TList* fList = 
m_inTree->GetListOfFriends();
 
  930         for (TObject* feObj : *fList) {
 
  933             auto* pElement = 
dynamic_cast<TFriendElement*
>(feObj);
 
  934             if (pElement == 
nullptr) {
 
  937             TTree* friendTree = pElement->GetTree();
 
  939             fullListOfBranches.push_back(friendTree->GetListOfBranches());
 
  947   for (
const TObjArray* in : fullListOfBranches) {
 
  949     for (
const TObject* 
obj : *in) {
 
  951       if (
obj == 
nullptr) {
 
  954       const TBranch* element = 
dynamic_cast<const TBranch*
>(
obj);
 
  957         return StatusCode::FAILURE;
 
  959       const std::string objClassName = element->GetClassName();
 
  960       const std::string 
key = 
obj->GetName();
 
  963       if (objClassName == targetClassName) {
 
  973   ATH_MSG_DEBUG(
"Scanning input objects for \"" << targetClassName << 
"\"");
 
  974   for (
const auto& [
key, vmgr] : inAux) {
 
  977     if (
mgr == 
nullptr) {
 
  980     const std::string& objClassName = 
mgr->holder()->getClass()->GetName();
 
  983     if (objClassName == targetClassName) {
 
  995     for (
const TObject* 
obj : *
out) {
 
  996       if (
obj == 
nullptr) {
 
  999       const TBranch* element = 
dynamic_cast<const TBranch*
>(
obj);
 
 1000       if (element == 
nullptr) {
 
 1002         return StatusCode::FAILURE;
 
 1004       const std::string objClassName = element->GetClassName();
 
 1005       const std::string 
key = 
obj->GetName();
 
 1008       if (objClassName == targetClassName) {
 
 1019   ATH_MSG_DEBUG(
"Scanning output objects for \"" << targetClassName << 
"\"");
 
 1020   for (
const auto& [
key, vmgr] : outAux) {
 
 1023     if (
mgr == 
nullptr) {
 
 1026     const std::string& objClassName = 
mgr->holder()->getClass()->GetName();
 
 1029     if (objClassName == targetClassName) {
 
 1036   vkeys.insert(vkeys.end(), 
keys.begin(), 
keys.end());
 
 1039   return StatusCode::SUCCESS;
 
 1064     return StatusCode::FAILURE;
 
 1072     return StatusCode::SUCCESS;
 
 1079     return StatusCode::RECOVERABLE;
 
 1094   if (
br == 
nullptr) {
 
 1099     return StatusCode::RECOVERABLE;
 
 1103   br->SetMakeClass(0);
 
 1115           "Couldn't find an appropriate type with a dictionary for branch \"" 
 1117       return StatusCode::FAILURE;
 
 1120   ::TClass* realClass = ::TClass::GetClass(
className.c_str());
 
 1121   if (((!realClass) || (!realClass->IsLoaded())) && 
ef) {
 
 1126     realClass = ::TClass::GetClass(
className.c_str());
 
 1128   if ((!realClass) || (!realClass->IsLoaded())) {
 
 1131         "Couldn't find an appropriate type with a dictionary for branch \"" 
 1133     return StatusCode::FAILURE;
 
 1140   static const ::EDataType 
dataType = kOther_t;
 
 1146   void* 
ptr = 
nullptr;
 
 1151     if (
mgr == 
nullptr) {
 
 1153       return StatusCode::FAILURE;
 
 1156     ptr = 
mgr->holder()->get();
 
 1162   if (
ptr == 
nullptr) {
 
 1163     ptr = realClass->New();
 
 1168   auto mgr = std::make_unique<TObjectManager>(
 
 1169       nullptr, std::make_unique<THolder>(
ptr, realClass), renewOnRead);
 
 1178                   << 
key << 
"\" is " << 
br->GetSplitLevel()
 
 1179                   << 
". This can only be read in kAthenaAccess mode.");
 
 1181     *(
mgr->holder()->getPtr()) = 
nullptr;
 
 1183     return StatusCode::FAILURE;
 
 1193                   << 
"\". Return code: " << 
status);
 
 1195     *(
mgr->holder()->getPtr()) = 0;
 
 1197     return StatusCode::FAILURE;
 
 1217   return StatusCode::SUCCESS;
 
 1233     return StatusCode::FAILURE;
 
 1238     return StatusCode::SUCCESS;
 
 1243   if (
br == 
nullptr) {
 
 1246                                            << 
"\" not available on input");
 
 1248     return StatusCode::RECOVERABLE;
 
 1252   if (
br->GetEntries() == 0) {
 
 1255                                            << 
"\" doesn't hold any data");
 
 1257     return StatusCode::RECOVERABLE;
 
 1261   br->SetMakeClass(0);
 
 1265   ::EDataType 
dt = kOther_t;
 
 1266   if (
br->GetExpectedType(
cl, 
dt) || (!
cl)) {
 
 1269     return StatusCode::FAILURE;
 
 1273   void* 
ptr = 
cl->New();
 
 1275   auto mgr = std::make_unique<TObjectManager>(
 
 1276       nullptr, std::make_unique<THolder>(
ptr, 
cl), renewOnRead);
 
 1280       key.c_str(), 
mgr->holder()->getPtr(), 
mgr->branchPtr(), 
cl, 
dt, kTRUE);
 
 1283                   << 
cl->GetName() << 
"\" to input branch \"" << 
key 
 1284                   << 
"\". Return code: " << 
status);
 
 1286     *(
mgr->holder()->getPtr()) = 0;
 
 1288     return StatusCode::FAILURE;
 
 1299     return StatusCode::FAILURE;
 
 1312     static constexpr 
bool METADATA = 
true;
 
 1317   return StatusCode::SUCCESS;
 
 1334     return StatusCode::FAILURE;
 
 1342     return StatusCode::SUCCESS;
 
 1347     return StatusCode::SUCCESS;
 
 1355     static constexpr 
bool SILENT = 
false;
 
 1359     return StatusCode::SUCCESS;
 
 1365     static constexpr 
bool TOP_STORE = 
true;
 
 1366     auto store = std::make_unique<TAuxStore>(
 
 1379     static constexpr 
bool IS_OWNER = 
true;
 
 1381         std::make_unique<TAuxManager>(
store.release(), IS_OWNER);
 
 1384     return StatusCode::SUCCESS;
 
 1389   return StatusCode::FAILURE;
 
 1405     return StatusCode::SUCCESS;
 
 1411     return StatusCode::FAILURE;
 
 1419     static constexpr 
bool SILENT = 
false;
 
 1423     return StatusCode::SUCCESS;
 
 1429     static constexpr 
bool TOP_STORE = 
true;
 
 1430     auto store = std::make_unique<TAuxStore>(
 
 1443     static constexpr 
bool IS_OWNER = 
true;
 
 1445         std::make_unique<TAuxManager>(
store.release(), IS_OWNER);
 
 1448     return StatusCode::SUCCESS;
 
 1453   return StatusCode::FAILURE;
 
 1474     return StatusCode::SUCCESS;
 
 1491       return StatusCode::SUCCESS;
 
 1493     auxMgr = itr->second.get();
 
 1494     auxKey = 
key + 
"Aux.";
 
 1499     const ::Int_t readBytes = auxMgr->
getEntry();
 
 1500     if (readBytes < 0) {
 
 1502           "Couldn't load current entry for auxiliary object with key \"" 
 1504       return StatusCode::FAILURE;
 
 1509     const std::string dynAuxKey = auxKey + 
"Dynamic";
 
 1510     auto dynAuxMgr = 
objects.find(dynAuxKey);
 
 1512     if ((dynAuxMgr != 
objects.end()) &&
 
 1518         dynAuxMgr->second->getEntry();
 
 1529         auto dynAuxMgr = 
objects.find(dynAuxKey);
 
 1530         if (dynAuxMgr == 
objects.end()) {
 
 1532           return StatusCode::FAILURE;
 
 1534         dynAuxMgr->second->getEntry();
 
 1541     return StatusCode::SUCCESS;
 
 1547   switch (
mgr.holder()->typeKind()) {
 
 1562   if (
vec && (!
vec->trackIndices())) {
 
 1563     Details::forceTrackIndices(*
vec);
 
 1567   if ((!
vec) && (!aux)) {
 
 1569                   << 
mgr.holder()->getClass()->GetName()
 
 1570                   << 
"\" as SG::AuxVectorBase or SG::AuxElement");
 
 1571     return StatusCode::FAILURE;
 
 1581                     << auxKey << 
"\" is not of the right type");
 
 1582       return StatusCode::FAILURE;
 
 1598                     << auxKey << 
"\" is not of the right type");
 
 1599       return StatusCode::FAILURE;
 
 1606     return StatusCode::FAILURE;
 
 1616     return StatusCode::FAILURE;
 
 1620   return StatusCode::SUCCESS;
 
 1639                           const std::string& 
key, 
bool overwrite, 
bool metadata,
 
 1645         "No output tree defined. Did you forget to call writeTo(...)?");
 
 1646     return StatusCode::FAILURE;
 
 1657                                      << 
"\" already recorded");
 
 1658       return StatusCode::FAILURE;
 
 1661     TClass* 
cl = TClass::GetClass(
typeName.c_str());
 
 1664       return StatusCode::FAILURE;
 
 1669         nullptr, std::make_unique<THolder>(
obj, 
cl, isOwner), renewOnRead);
 
 1671     return StatusCode::SUCCESS;
 
 1678                               << 
"\" already accessed from the input, can't be " 
 1679                                  "overwritten in memory");
 
 1680     return StatusCode::FAILURE;
 
 1684   const Int_t splitLevel = (
key.ends_with(
"Aux.") ? 1 : 0);
 
 1691     TClass* 
cl = TClass::GetClass(
typeName.c_str());
 
 1692     if (
cl == 
nullptr) {
 
 1694       return StatusCode::FAILURE;
 
 1705     auto mgr = std::make_unique<TObjectManager>(
 
 1706         nullptr, std::make_unique<THolder>(
obj, 
cl, isOwner), renewOnRead);
 
 1711     static constexpr Int_t basketSize = 32000;
 
 1717                                                  << 
cl->GetName() << 
"\"");
 
 1720       return StatusCode::FAILURE;
 
 1725     static constexpr 
bool METADATA = 
false;
 
 1730     return StatusCode::SUCCESS;
 
 1736     ATH_MSG_ERROR(
"Manager object of the wrong type encountered");
 
 1737     return StatusCode::FAILURE;
 
 1746     TClass* 
cl = TClass::GetClass(
typeName.c_str());
 
 1750                     << 
key << 
"\" the previous type was \"" 
 1752                     << 
"\", but the newly requested type is \"" << 
typeName 
 1754       return StatusCode::FAILURE;
 
 1762   static constexpr 
bool METADATA = 
false;
 
 1766   return StatusCode::SUCCESS;
 
 1774   if (iomgr != 
nullptr) {
 
 1776     static const bool OVERWRITE = 
true;
 
 1777     static const bool IS_OWNER = 
true;
 
 1780     return StatusCode::SUCCESS;
 
 1785   if (auxmgr != 
nullptr) {
 
 1789           "TAuxStore auxiliary objects can only be recorded for event data");
 
 1790       return StatusCode::FAILURE;
 
 1794     return StatusCode::SUCCESS;
 
 1798   ATH_MSG_ERROR(
"Unknown auxiliary store manager type encountered");
 
 1799   return StatusCode::FAILURE;
 
 1812     return StatusCode::SUCCESS;
 
 1817     ATH_MSG_ERROR(
"Function called on an uninitialised object");
 
 1818     return StatusCode::FAILURE;
 
 1827   for (; itr != 
end; ++itr) {
 
 1830     const std::string& branchName = itr->second.branchName();
 
 1833     if (branchName.find(
"Aux.") != std::string::npos) {
 
 1842       const std::string intName = branchName.substr(0, branchName.size() - 4);
 
 1850         ::Bool_t auxFound = kFALSE;
 
 1853         std::vector<TObjArray*> fullListOfBranches = {};
 
 1855         fullListOfBranches.push_back(
m_inTree->GetListOfBranches());
 
 1858         if (
m_inTree->GetListOfFriends()) {
 
 1860           TList* fList = 
m_inTree->GetListOfFriends();
 
 1862           for (TObject* feObj : *fList) {
 
 1865               auto* pElement = 
dynamic_cast<TFriendElement*
>(feObj);
 
 1868               TTree* friendTree = pElement->GetTree();
 
 1870               fullListOfBranches.push_back(friendTree->GetListOfBranches());
 
 1875         for (TObjArray* 
branches : fullListOfBranches) {
 
 1876           for (Int_t 
i = 0; 
i < 
branches->GetEntriesFast(); ++
i) {
 
 1881             if (
name.BeginsWith(branchName) || 
name.BeginsWith(dynName)) {
 
 1889                           << intName << 
"\" belonging to branch \"" 
 1890                           << branchName << 
"\"");
 
 1897       ::TClass* 
cl = ::TClass::GetClass(
el->className().c_str());
 
 1898       if ((!
cl) || (!
cl->IsLoaded())) {
 
 1900                         << 
el->className() << 
"\"");
 
 1907       static ::TClass* 
const baseCl = ::TClass::GetClass(baseName.c_str());
 
 1909         ATH_MSG_ERROR(
"Couldn't get dictionary for type \"" << baseName
 
 1911         return StatusCode::FAILURE;
 
 1921       static constexpr 
bool TOP_STORE = 
true;
 
 1923       static constexpr 
bool PRINT_WARNINGS = 
false;
 
 1931         stats.branch(branchName, 
id);
 
 1940       const ::TBranch* container = 
m_inTree->GetBranch(branchName.c_str());
 
 1949   return StatusCode::SUCCESS;
 
 1965                           const std::string& 
key) {
 
 1970         "No output tree defined. Did you forget to call writeTo(...)?");
 
 1971     return StatusCode::FAILURE;
 
 1975   const std::set<std::string>* 
filter = 0;
 
 1978     filter = &(filter_itr->second);
 
 1992     static constexpr 
bool OWNS_STORE = 
true;
 
 1994         std::make_unique<TAuxManager>(
store.release(), OWNS_STORE);
 
 1997     return StatusCode::SUCCESS;
 
 2001   if (vitr->second->object() == 
store.get()) {
 
 2003     return StatusCode::SUCCESS;
 
 2012   if (
mgr == 
nullptr) {
 
 2014                   << 
key << 
"\" already exists, and is not of type TAuxStore");
 
 2015     return StatusCode::FAILURE;
 
 2030   return StatusCode::SUCCESS;
 
 2044   ::TMethodCall setNameCall;
 
 2048     setNameCall.InitWithPrototype(
mgr.holder()->getClass(), 
"setName",
 
 2050     if (setNameCall.IsValid()) {
 
 2055       const char* charParams = 
params.Data();
 
 2056       setNameCall.Execute(
mgr.holder()->get(), charParams);
 
 2059       ATH_MSG_WARNING(
"Couldn't find setName(...) function for container \"" 
 2060                       << 
mgr.branch()->GetName() << 
"\"  (type: " 
 2061                       << 
mgr.holder()->getClass()->GetName() << 
")");
 
 2066   static const TClass* 
const holderClass =
 
 2068   if (!
mgr.holder()->getClass()->InheritsFrom(holderClass)) {
 
 2070     return StatusCode::SUCCESS;
 
 2078     return StatusCode::FAILURE;
 
 2085   static constexpr 
bool TOP_STORE = 
false;
 
 2086   auto store = std::make_unique<TAuxStore>(
 
 2087       mgr.branch()->GetName(), TOP_STORE,
 
 2106   static constexpr 
bool SHARED_OWNER = 
false;
 
 2108       std::make_unique<TAuxManager>(
store.get(), SHARED_OWNER);
 
 2114   return StatusCode::SUCCESS;
 
 2137     return StatusCode::SUCCESS;
 
 2141   if (!
mgr->holder()->getClass()->InheritsFrom(
"SG::IAuxStoreIO")) {
 
 2142     return StatusCode::SUCCESS;
 
 2150     return StatusCode::FAILURE;
 
 2159       sel.selectAux(item_itr->second);
 
 2170   if (auxids.
empty()) {
 
 2171     return StatusCode::SUCCESS;
 
 2175   const std::string dynNamePrefix =
 
 2184   typedef std::pair<std::string, SG::auxid_t> AuxVarSort_t;
 
 2185   std::vector<AuxVarSort_t> varsort;
 
 2186   varsort.reserve(auxids.
size());
 
 2188     varsort.emplace_back(
r.getName(
id), 
id);
 
 2190   std::sort(varsort.begin(), varsort.end());
 
 2193   for (
const auto& 
p : varsort) {
 
 2199     const std::string 
brName = dynNamePrefix + 
p.first;
 
 2208       const std::type_info* brType = aux->
getIOType(
id);
 
 2211         return StatusCode::FAILURE;
 
 2214       std::string brProperTypeName = 
"<unknown>";
 
 2220       if (strlen(brType->name()) == 1) {
 
 2223         brProperTypeName = brTypeName;
 
 2229                         << 
brName << 
"\" of type \"" << brTypeName << 
"\"");
 
 2230           return StatusCode::FAILURE;
 
 2234         std::ostringstream leaflist;
 
 2238         static constexpr 
bool IS_OWNER = 
false;
 
 2239         auto auxmgr = std::make_unique<TPrimitiveAuxBranchManager>(
 
 2243         static constexpr Int_t BASKET_SIZE = 32000;
 
 2244         *(auxmgr->branchPtr()) =
 
 2245             outTree.Branch(
brName.c_str(), auxmgr->holder()->get(),
 
 2246                            leaflist.str().c_str(), BASKET_SIZE);
 
 2247         if (!auxmgr->branch()) {
 
 2249                         << 
brName << 
"\" out of type \"" << brProperTypeName
 
 2252           *(auxmgr->holder()->getPtr()) = 0;
 
 2253           return StatusCode::FAILURE;
 
 2255         br = auxmgr->branch();
 
 2263         static constexpr Bool_t LOAD_IF_NOT_FOUND = kTRUE;
 
 2264         static constexpr Bool_t SILENT = kTRUE;
 
 2265         TClass* 
cl = TClass::GetClass(*brType, LOAD_IF_NOT_FOUND, SILENT);
 
 2266         if (
cl == 
nullptr) {
 
 2269           cl = TClass::GetClass(brTypeName.c_str());
 
 2271           if (
cl == 
nullptr) {
 
 2273                           << 
brName << 
"\" of type \"" << brTypeName << 
"\"");
 
 2274             return StatusCode::FAILURE;
 
 2279         brProperTypeName = 
cl->GetName();
 
 2282         static constexpr 
bool IS_OWNER = 
false;
 
 2283         auto auxmgr = std::make_unique<TAuxBranchManager>(
 
 2287         static constexpr Int_t BASKET_SIZE = 32000;
 
 2288         static constexpr Int_t SPLIT_LEVEL = 0;
 
 2289         *(auxmgr->branchPtr()) = outTree.Branch(
brName.c_str(), 
cl->GetName(),
 
 2290                                                 auxmgr->holder()->getPtr(),
 
 2291                                                 BASKET_SIZE, SPLIT_LEVEL);
 
 2292         if (!auxmgr->branch()) {
 
 2294                         << 
brName << 
"\" out of type \"" << brProperTypeName
 
 2297           *(auxmgr->holder()->getPtr()) = 0;
 
 2298           return StatusCode::FAILURE;
 
 2300         br = auxmgr->branch();
 
 2308       if (outTree.GetEntries()) {
 
 2309         void* 
ptr = 
br->GetAddress();
 
 2311         for (::Long64_t 
i = 0; 
i < outTree.GetEntries(); ++
i) {
 
 2314         br->SetAddress(
ptr);
 
 2321                                                     mgr->branch()->GetName(),
 
 2332       ATH_MSG_FATAL(
"There is an internal logic error in the code...");
 
 2333       return StatusCode::FAILURE;
 
 2339         const_cast<void*
>(
static_cast<const void*
>(aux->
getIOData(
id)));
 
 2340     bmgr->second->setObject(nc_data);
 
 2344   return StatusCode::SUCCESS;
 
 2352     return StatusCode::FAILURE;
 
 2356   const std::set<std::string>* 
filter = 0;
 
 2359     filter = &(filter_itr->second);
 
 2373     static constexpr 
bool OWNS_STORE = 
false;
 
 2377     return StatusCode::SUCCESS;
 
 2381   if (vitr->second->object() == 
store) {
 
 2383     return StatusCode::SUCCESS;
 
 2392   if (
mgr == 
nullptr) {
 
 2394                   << 
key << 
"\" already exists, and is not of type TAuxStore");
 
 2395     return StatusCode::FAILURE;
 
 2410   return StatusCode::SUCCESS;
 
  
::Int_t m_inTreeNumber
The number of the currently open tree in the input chain.
bool m_inTreeMissing
Internal status flag showing that an input file is open, but it doesn't contain an event tree.
JetConstituentVector::iterator iterator
StatusCode keys(std::vector< std::string > &vkeys, bool metadata) const
Provide a list of all data object keys associated with a specific type.
StatusCode finishWritingTo(::TFile *file)
Finish writing to an output file.
@ AUXELEMENT
A type inheriting from SG::AuxElement.
Recursively separate out template arguments in a C++ class name.
std::unique_ptr< TChainStateTracker > m_inChainTracker
Optional object for tracking the state changes of an input TChain.
TEvent(EAuxMode mode=kClassAccess)
Default constructor.
SG::SGKeyMap< BranchInfo > m_branches ATLAS_THREAD_SAFE
Map from hashed sgkey to BranchInfo.
EAuxMode m_auxMode
The auxiliary access mode.
virtual AuxStoreType getStoreType() const =0
Return the type of the store object.
ReadStats & stats()
Access the object belonging to the current thread.
const std::string & name() const override
Get the name of the instance.
TAuxStore * getStore()
Get a type-specific pointer to the managed object.
StatusCode record(void *obj, const std::string &typeName, const std::string &key, bool overwrite, bool metadata, bool isOwner) override
Record an object into a connected output file.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
virtual const SG::auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
void setOwner(::Bool_t state=kTRUE)
Set whether the holder should own its object.
Object_t m_inputObjects
Collection of all the managed input objects.
std::string normalizedTypeinfoName(const std::type_info &info)
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
Object_t m_outputMetaObjects
Collection of all the managed output meta-objects.
EventFormat m_inputEventFormat
Format of the current input file.
Base class for elements of a container that can have aux data.
@ DATAVECTOR
A DataVector container.
virtual void * getAs(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Return the object as a specific pointer.
This class takes care of holding EDM objects in memory.
@ kAthenaAccess
Access containers/objects like Athena does.
const THolder * holder() const
Accessor to the Holder object.
void setActive() const
Set this event object as the currently active one.
::Int_t getFile(::Long64_t file, ::Int_t getall=0)
Load the first event for a given file from the input TChain.
::TChain * m_inChain
The (optional) chain provided as input.
virtual ::Int_t getEntry(::Int_t getall=0)=0
Function for updating the object in memory if needed.
StatusCode getNames(const std::string &targetClassName, std::vector< std::string > &vkeys, bool metadata) const override
Function determining the list keys associated with a type name.
EStructMode
"Structural" modes of the object
void ** getPtr()
Return a typeless pointer to the held object's pointer.
Helper class for making sure the current directory is preserved.
bool hasInput() const override
Check if an input file is connected to the object.
const SG::IConstAuxStore * getConstStore() const
Get a convenience pointer to the managed object.
"ROOT @c TTree implementation" of IAuxStore
::TBranch ** branchPtr()
Pointer to the branch's pointer.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
BranchStats * container(const std::string &name)
Access the description of a container. Creating it if necessary.
Class providing an interface for classes listening to xAOD incidents.
std::vector< size_t > vec
virtual ~TEvent()
Destructor.
Interface class for the "manager classes".
#define ATH_MSG_VERBOSE(x)
@ kClassAccess
Access auxiliary data using the aux containers.
virtual const std::type_info * getIOType(SG::auxid_t auxid) const =0
Return the type of the data to be stored for one aux data item.
@ kObjectStore
The object describes a single object.
EStructMode structMode() const
Get what structure mode the object was constructed with.
std::vector< TVirtualIncidentListener * > m_listeners
Listeners who should be notified when certain incidents happen.
Manage index tracking and synchronization of auxiliary data.
@ kContainerStore
The object describes an entire container.
Manage index tracking and synchronization of auxiliary data.
::TTree * m_inMetaTree
Pointer to the metadata tree in the input file.
StatusCode connectAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches.
std::unordered_map< std::string, std::unique_ptr< TVirtualManager > > Object_t
Definition of the internal data structure type.
Object_t m_inputMetaObjects
Collection of all the managed input meta-objects.
Interface providing I/O for a generic auxiliary store.
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...
void nextEvent()
Function incrementing the processed event counter.
const ::TClass * getClass() const
bool hasOutput() const override
Check if an output file is connected to the object.
StatusCode connectMetaAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches for a metadata object.
Handle mappings between names and auxid_t.
EAuxMode auxMode() const
Get what auxiliary access mode the object was constructed with.
AuxStoreType
Type of the auxiliary store.
size_t auxid_t
Identifier for a particular aux data item.
bit_t size() const
Count the number of 1 bits in the set.
void setStructMode(EStructMode mode)
Set the structure mode of the object to a new value.
std::unordered_map< std::string, std::set< std::string > > m_auxItemList
Rules for selecting which auxiliary branches to write.
::TTree * m_inTree
The main tree that we are reading from.
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
StatusCode readFrom(::TTree &tree, bool printWarnings=true)
Connect the object to an input TTree.
::Long64_t getEntries() const
Get how many entries are available from the current input file(s)
Interface providing I/O for a generic auxiliary store.
::StatusCode StatusCode
StatusCode definition for legacy code.
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0)
Function loading a given entry of the input TTree.
Class describing a certain "incident" that is communicated to user code.
virtual SG::auxid_set_t getSelectedAuxIDs() const
Get a list of dynamic variables that need to be written out.
upgrade_mutex_t m_branchesMutex
Mutex for multithread synchronization.
bool isStandalone(const TClass &cl)
Helper function deciding if a given type "is a standalone object".
void setBranchNum(::Int_t num)
Set the total number of branches on the input.
bool empty() const
Return true if there are no 1 bits in the set.
static IOStats & instance()
Singleton object accessor.
const void * getInputObject(SG::sgkey_t key, const std::type_info &ti, bool silent) override
Function for retrieving an input object in a non-template way.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...
static const char *const EVENT_TREE_NAME
Default name of the event tree.
virtual void setStore(IAuxStore *store)=0
Give an auxiliary store object to the holder object.
std::unique_ptr<::TTree > m_outTree
The tree that we are writing to.
std::set< std::string > m_inputMissingObjects
Objects that have been asked for, but were found to be missing in the current input.
Class helping in dealing with dynamic branch selection.
Object_t m_outputObjects
Collection of all the managed output object.
StatusCode readFrom(::TFile *file, bool useTreeCache=true, std::string_view treeName=EVENT_TREE_NAME)
Connect the object to a new input file.
void readContainer(const std::string &name)
Function incrementing the read counter on a specific container.
Helper class keeping track of the files that got accessed.
StatusCode initStats()
Function to initialise the statistics for all Tree content.
Manager for EDM objects created by ROOT.
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.
Manager for TAuxStore objects.
::Int_t fill()
Function filling one event into the output tree.
virtual ::Int_t getEntry(::Int_t getall=0) override
Function for updating the object in memory if needed.
Interface for non-const operations on an auxiliary store.
StatusCode putAux(::TTree &outTree, TVirtualManager &mgr, bool metadata)
Function saving the dynamically created auxiliary properties.
StatusCode setUpDynamicStore(TObjectManager &mgr, ::TTree *tree)
Function adding dynamic variable reading capabilities to an auxiliary store object.
EAuxMode
Auxiliary store "mode".
::Long64_t getFiles() const
Get how many files are available on the currently defined input.
Exception to signal a malformed class name.
EventFormat * m_outputEventFormat
Format of the current output file.
def silent(func)
Redirect stdout/err to /dev/null Useful wrapper to get rid of ROOT verbosity...
#define ATH_MSG_WARNING(x)
std::string getFirstBranchMatch(TTree *tree, const std::string &pre)
This function is used to search for a branch in a TTree that contains a given substring.
::Long64_t m_entry
The entry to look at from the input tree.
StatusCode connectMetaObject(const std::string &key, bool silent) override
Function setting up access to a particular metadata object.
Handle mappings between names and auxid_t.
SG::IAuxStore * recordAux(const std::string &key, SG::IAuxStoreHolder::AuxStoreType type=SG::IAuxStoreHolder::AST_ContainerStore)
Add an auxiliary store object to the output.
virtual const void * object() const =0
Function getting a const pointer to the object being handled.
StatusCode setAuxStore(const std::string &key, Details::IObjectManager &mgr, bool metadata) override
Function connecting a DV object to its auxiliary store.
@ kUndefinedStore
The structure mode is not defined.
SG::sgkey_t getHash(const std::string &key) const override
Function returning the hash describing an object name.
A set of aux data identifiers.
Lock object for taking out upgradable locks.
bool hasAuxStore(const TClass &cl)
Helper function deciding if a given type "has an auxiliary store".
@ kBranchAccess
Access auxiliary data branch-by-branch.
Helper to disable undefined behavior sanitizer for a function.
StatusCode connectObject(const std::string &key, bool silent) override
Function setting up access to a particular object.
::TBranch * branch()
Accessor to the branch.
Manager for EDM objects created by ROOT.
Class describing the access statistics of a collection of branches.
Base class for the event (xAOD::TEvent and xAOD::REvent) classes.
Interface for const operations on an auxiliary store.
@ AST_ObjectStore
The store describes a single object.
Interface for objects taking part in direct ROOT I/O.
virtual void setObject(void *obj) override
Function replacing the object being handled.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
char rootType(char typeidType)
This function is used internally in the code when creating primitive dynamic auxiliary branches.
Tool for accessing xAOD files outside of Athena.
StatusCode writeTo(::TFile *file, int autoFlush=200, std::string_view treeName=EVENT_TREE_NAME)
Connect the object to an output file.
Base class for elements of a container that can have aux data.
@ AST_ContainerStore
The store describes a container.
bool isAuxStore(const TClass &cl)
Helper function deciding if a given type "is an auxiliary store".