31#ifndef XAOD_STANDALONE
38#include <TMethodCall.h>
40#include <ROOT/RNTuple.hxx>
59std::string getFirstFieldMatch(ROOT::RNTupleReader& reader,
60 const std::string& pre) {
62 const std::regex pattern(
".*" + pre +
".*");
63 for (
const auto& field : reader.GetDescriptor().GetTopLevelFields()) {
65 if (std::regex_match(field.GetFieldName(), pattern)) {
66 return field.GetFieldName();
73std::string getFieldNameFromKey(
const std::string& key ) {
77 std::string fieldName = key;
78 if (fieldName.rfind(
"Aux.") != std::string::npos || fieldName.rfind(
"AuxDyn.") != std::string::npos) {
79 std::replace(fieldName.begin(), fieldName.end(),
'.',
':');
86 std::string& fieldName, std::string& className ) {
89 fieldName = getFieldNameFromKey(key);
139 return StatusCode::SUCCESS;
148 :
Event(
"xAOD::Experimental::REvent", ctx)
167 return StatusCode::SUCCESS;
178 ATH_MSG_INFO(
"REvent::readFrom: fileName " << fileName);
203 <<
"\" in file: " << fileName);
208 ROOT::RNTupleDescriptor::RCreateModelOptions opts;
209 opts.SetEmulateUnknownTypes(
true);
213 <<
"\" tree in input file: " << fileName);
214 return StatusCode::FAILURE;
217 <<
"\" in file: " << fileName);
222 static const std::string eventFormatTypeName =
224 if (::TClass::GetClass(eventFormatTypeName.c_str()) ==
nullptr) {
231 auto readEventFormatMetadata = [&](std::string_view tupleName) -> StatusCode {
234 auto metaReader = ROOT::RNTupleReader::Open(tupleName, fileName);
237 << tupleName <<
"\" ntuple in input file: " << fileName);
238 return StatusCode::FAILURE;
241 << tupleName <<
"\" in file: " << fileName);
244 const std::string eventFormatFieldName =
249 for (
const auto& [key, element] : ef(0u)) {
252 }
catch (
const ROOT::RException&) {
254 return StatusCode::RECOVERABLE;
260 return StatusCode::SUCCESS;
265 if (
sc.isRecoverable()) {
267 return StatusCode::SUCCESS;
274 std::set<std::string> lOtherMetaTupleNames;
276 std::unique_ptr<TFile> inFile(TFile::Open(fileName.data(),
"READ"));
277 TList* lKeys = inFile->GetListOfKeys();
278 if (lKeys ==
nullptr) {
279 ATH_MSG_ERROR(
"Could not get list of keys for input file: " << fileName);
280 return StatusCode::FAILURE;
282 for (
const TObject* obj : *lKeys) {
283 const std::string keyName = obj->GetName();
288 (keyName.find(
"MetaData") != std::string::npos) &&
289 (keyName.find(
"MetaDataHdr") == std::string::npos)) {
291 const TKey* key =
dynamic_cast<const TKey*
>(obj);
292 if (key ==
nullptr) {
293 ATH_MSG_ERROR(
"Object describing \"" << keyName <<
"\" in file \""
295 <<
"\" is not a TKey?");
296 return StatusCode::FAILURE;
298 const char* className = key->GetClassName();
299 static constexpr bool LOAD = kFALSE;
300 static constexpr bool SILENT = kTRUE;
301 ::TClass* cl = ::TClass::GetClass(className, LOAD, SILENT);
302 if ((cl !=
nullptr) && cl->InheritsFrom(ROOT::RNTuple::Class())) {
303 lOtherMetaTupleNames.insert(std::move(keyName));
310 for (
const std::string& tupleName : lOtherMetaTupleNames) {
311 ATH_CHECK(readEventFormatMetadata(tupleName));
320 <<
"\" in file: " << fileName);
321 return StatusCode::FAILURE;
324 <<
"\" in file: " << fileName);
330 stats.setNEvents(stats.nEvents() +
m_eventReader->GetNEntries());
335 listener->handle(beginIncident);
344 listener->handle(endIncident);
348 return StatusCode::SUCCESS;
372 m_model = ROOT::RNTupleModel::Create();
376 m_model->SetDescription(rnTupleName);
379 return StatusCode::SUCCESS;
392 ATH_MSG_FATAL(
"File given to finishWritingTo does not match the file given in writeTo file!");
393 return StatusCode::FAILURE;
400 listener->handle(incident);
412 ATH_MSG_INFO(
"Metadata tree already exists, returning" );
414 return StatusCode::SUCCESS;
420 auto model = ROOT::RNTupleModel::Create();
423 model->SetDescription(outRNTupleName);
430 TClass* cl = TClass::GetClass( typeName.c_str() );
432 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
433 return StatusCode::FAILURE;
435 std::string efName = cl->GetName();
439 model->AddField( ROOT::RFieldBase::Create(
"EventFormat", efName ).Unwrap());
448 std::vector<std::pair<std::string, TVirtualManager*>> outputMetaObjects;
452 if (objMgr ==
nullptr) {
454 return StatusCode::FAILURE;
459 outputMetaObjects.emplace_back(key, objMgr);
464 for(
auto& itr : outputMetaObjects ) {
465 static constexpr bool IS_METADATA =
true;
473 std::string fieldName;
474 std::string className;
475 if (getInfoForFieldCreation( key, *mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
478 if ( className.empty() ) {
480 return StatusCode::FAILURE;
484 model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
489 auto metaDataWriter = ROOT::RNTupleWriter::Append(std::move(model), outRNTupleName, *
m_outputFile);
493 auto rnEntry = metaDataWriter->GetModel().CreateBareEntry();
500 auto fieldName = getFieldNameFromKey(key);
504 rnEntry->BindRawPtr(fieldName, mgr->object());
506 rnEntry->EmplaceNewValue(fieldName);
514 const ::Int_t ret = metaDataWriter->Fill(*rnEntry);
516 ATH_MSG_FATAL(
"Output rntuple filling failed with return value: " << ret );
519 ATH_MSG_INFO(
"Output meta data rntuple filled. nbytes = " << ret );
534 metaDataWriter.reset();
537 return StatusCode::SUCCESS;
579 ATH_MSG_DEBUG(
"Entry " << entry <<
" is already the active one");
594 result += inObj->getEntry(getall);
601 listener->handle(incident);
640 std::string unsetObjects;
641 std::vector<std::pair<std::string, TVirtualManager*>> outputObjectsCopy;
645 if (objMgr ==
nullptr) {
649 outputObjectsCopy.emplace_back(key, objMgr);
651 for (
auto &[key, mgr] : outputObjectsCopy) {
653 ATH_MSG_DEBUG(
"REvent::fill - checking and adding aux for " << key <<
", " << mgr <<
" isSet " << mgr->isSet());
656 if ((key.find(
"AuxDyn") == std::string::npos) && !mgr->isSet()) {
662 if (unsetObjects.size()) {
663 unsetObjects +=
", ";
665 unsetObjects.append(
"\"" + key +
"\"");
672 if(
putAux( *mgr ).isFailure() ) {
673 ATH_MSG_ERROR(
"Failed to put dynamic auxiliary variables in the output for object \"" << key <<
"\"" );
679 if (unsetObjects.size()) {
680 ATH_MSG_ERROR(
"The following objects were not set in the current event: "
700 ATH_MSG_DEBUG(
"REvent::fill - created writer and reset model " );
713 auto fieldName = getFieldNameFromKey(key);
717 bool isContainer = (omgr !=
nullptr);
719 ATH_MSG_DEBUG(
"REvent::fill - bind ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
720 <<
", is container " << isContainer);
725 rnEntry->BindRawPtr(fieldName, mgr->object());
728 ATH_MSG_DEBUG(
"REvent::fill - bind unSet ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
729 <<
", is container " << isContainer);
731 rnEntry->EmplaceNewValue(fieldName);
740 ATH_MSG_ERROR(
"Output RNTuple filling failed with return value: " << ret );
750 ATH_MSG_DEBUG(
"REvent::fill - after reset " << key <<
" is set " << mgr->isSet());
760 std::vector<std::string>& vkeys,
761 bool metadata)
const {
764 std::set<std::string>
keys;
770 if (reader ==
nullptr) {
772 return StatusCode::FAILURE;
774 if (metadata)
ATH_MSG_DEBUG(
"scanning input objects for metadata for type name " << targetClassName);
775 else ATH_MSG_DEBUG(
"scanning input objects for event data for type name " << targetClassName);
778 for (
const auto &topLevelField : reader->GetDescriptor().GetTopLevelFields()) {
779 std::string objClassName = topLevelField.GetTypeName();
780 std::string key = topLevelField.GetFieldName();
781 if (objClassName == targetClassName) {
783 keys.insert(std::move(key));
789 ATH_MSG_DEBUG(
"scanning output objects for type name " << targetClassName);
791 for (
const auto& topLevelFieldName :
m_eventWriter->GetModel().GetRegisteredSubfieldNames()) {
792 auto& topLevelField =
m_eventWriter->GetModel().GetConstField(topLevelFieldName);
793 std::string objClassName = topLevelField.GetTypeName();
794 std::string key = topLevelField.GetFieldName();
796 if (objClassName == targetClassName) {
798 keys.insert(std::move(key));
803 const Object_t& outAux = ( metadata ?
809 ATH_MSG_DEBUG(
"scanning output Aux objects for type name " << targetClassName);
811 for(
const auto&
object : outAux ) {
814 std::string objClassName;
817 if ( ! mgr )
continue;
818 objClassName = mgr->holder()->getClass()->GetName();
820 const std::string& key =
object.first;
822 if (objClassName == targetClassName) {
824 keys.insert(std::move(key));
828 vkeys.insert(vkeys.end(),
keys.begin(),
keys.end());
830 return StatusCode::SUCCESS;
855 return StatusCode::FAILURE;
863 return StatusCode::SUCCESS;
870 return StatusCode::RECOVERABLE;
880 const std::string fieldName =
892 if (
m_eventReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
893 ROOT::kInvalidDescriptorId) {
896 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
899 return StatusCode::RECOVERABLE;
906 ROOT::RNTupleView<void> view =
908 std::string className = view.GetField().GetTypeName();
909 if (className ==
"") {
913 className = ef->className();
916 "Couldn't find an appropriate type with a dictionary for field \""
917 << fieldName <<
"\"");
918 return StatusCode::FAILURE;
921 ::TClass* realClass = ::TClass::GetClass(className.c_str());
922 if (((!realClass) || (!realClass->IsLoaded())) && ef) {
926 className = ef->className();
927 realClass = ::TClass::GetClass(className.c_str());
929 if ((!realClass) || (!realClass->IsLoaded())) {
932 "Couldn't find an appropriate type with a dictionary for field \""
933 << fieldName <<
"\"");
934 return StatusCode::FAILURE;
938#ifndef XAOD_STANDALONE
939 SG::CurrentEventStore::Push save (SG::CurrentEventStore::store());
956 ATH_MSG_ERROR(
"Couldn't access output manager for: " << key );
957 return StatusCode::FAILURE;
960 ptr = mgr->holder()->get();
966 if (ptr ==
nullptr) {
967 ptr = realClass->New();
971 auto mgr = std::make_unique<RObjectManager>(
973 std::make_unique<THolder>(ptr, realClass));
989 return StatusCode::SUCCESS;
1005 return StatusCode::FAILURE;
1010 return StatusCode::SUCCESS;
1014 const std::string fieldName =
1018 if (
m_metaReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
1019 ROOT::kInvalidDescriptorId) {
1022 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
1024 return StatusCode::RECOVERABLE;
1031 ROOT::RNTupleView<void> view =
1032 m_metaReader->GetView<
void>(fieldName.c_str(),
nullptr);
1033 std::string className = view.GetField().GetTypeName();
1034 if (className ==
"") {
1036 "Couldn't find an appropriate type with a dictionary for field \""
1037 << fieldName <<
"\"");
1038 return StatusCode::FAILURE;
1040 ::TClass* realClass = ::TClass::GetClass(className.c_str());
1041 if ((!realClass) || (!realClass->IsLoaded())) {
1044 "Couldn't find an appropriate type with a dictionary for field \""
1045 << fieldName <<
"\"");
1046 return StatusCode::FAILURE;
1050 void* ptr = realClass->New();
1051 static const ::Long64_t FIRST_ENTRY = 0;
1052 auto mgr = std::make_unique<RObjectManager>(
1053 m_metaReader->GetView(fieldName, ptr, className), FIRST_ENTRY,
1054 std::make_unique<THolder>(ptr, realClass));
1070 static constexpr bool METADATA =
true;
1075 return StatusCode::SUCCESS;
1092 return StatusCode::FAILURE;
1097 return StatusCode::SUCCESS;
1101 static constexpr bool SILENT =
false;
1108 return StatusCode::FAILURE;
1112 if (omgr ==
nullptr) {
1114 return StatusCode::FAILURE;
1119 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1121 return StatusCode::SUCCESS;
1129 return StatusCode::FAILURE;
1138 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1140 << standalone <<
", getStoreType() = "
1142 return StatusCode::FAILURE;
1146 return StatusCode::SUCCESS;
1158 ::Bool_t standalone) {
1163 return StatusCode::FAILURE;
1168 return StatusCode::SUCCESS;
1172 static constexpr bool SILENT =
false;
1179 return StatusCode::FAILURE;
1183 if (omgr ==
nullptr) {
1185 return StatusCode::FAILURE;
1189 static const TClass*
const holderClass =
1191 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1193 return StatusCode::SUCCESS;
1201 return StatusCode::FAILURE;
1210 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1212 << standalone <<
", getStoreType() = "
1214 return StatusCode::FAILURE;
1218 return StatusCode::SUCCESS;
1238 return StatusCode::SUCCESS;
1251 auto itr = objects.find(key +
"Aux.");
1252 if (itr == objects.end()) {
1255 return StatusCode::SUCCESS;
1257 auxMgr = itr->second.get();
1258 auxKey = key +
"Aux:";
1265 <<
"\" is not of the right type");
1266 return StatusCode::FAILURE;
1270 if (store ==
nullptr) {
1272 return StatusCode::FAILURE;
1277 ::Int_t readBytes = auxMgr->
getEntry();
1281 const std::string dynAuxKey = auxKey +
"Dynamic";
1282 auto dynAuxMgr = objects.find(dynAuxKey);
1283 if ((dynAuxMgr != objects.end()) && (readBytes || (auxMgr == &mgr))) {
1286 dynAuxMgr->second->getEntry();
1289#ifndef XAOD_STANDALONE
1296 if (auxMgr == &mgr) {
1297 return StatusCode::SUCCESS;
1303 switch (mgr.holder()->typeKind()) {
1318 if (
vec && (!
vec->trackIndices())) {
1319 Details::forceTrackIndices(*
vec);
1323 if ((!
vec) && (!aux)) {
1325 << mgr.holder()->getClass()->GetName()
1326 <<
"\" as SG::AuxVectorBase or SG::AuxElement");
1327 return StatusCode::FAILURE;
1332 vec->setStore(store);
1334 aux->setStore(store);
1337 return StatusCode::FAILURE;
1341 return StatusCode::SUCCESS;
1362 const std::string& typeName,
1363 const std::string& key,
1371 ATH_MSG_FATAL(
"No output output file defined. Did you forget to call writeTo(...)?" );
1372 return StatusCode::FAILURE;
1376 ATH_MSG_DEBUG(
"REvent::record - key, type " << key <<
", " << typeName);
1383 if( ( ! overwrite ) &&
1386 ATH_MSG_FATAL(
"Meta-object " << typeName <<
"/" << key <<
" already recorded" );
1387 return StatusCode::FAILURE;
1390 TClass* cl = TClass::GetClass( typeName.c_str() );
1392 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1393 return StatusCode::FAILURE;
1396 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1399 return StatusCode::SUCCESS;
1404 if( ( ! overwrite ) &&
1407 " already accessed from the input, can't be overwritten in memory" );
1408 return StatusCode::FAILURE;
1416 TClass* cl = TClass::GetClass( typeName.c_str() );
1418 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1419 return StatusCode::FAILURE;
1427 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1431 ATH_MSG_DEBUG(
"REvent::record - save outObjMgr for key, type " << key <<
", " << typeName);
1442 return StatusCode::SUCCESS;
1448 ATH_MSG_FATAL(
"Manager object of the wrong type encountered" );
1449 return StatusCode::FAILURE;
1484 if (iomgr !=
nullptr) {
1486 static const bool OVERWRITE =
true;
1487 static const bool IS_OWNER =
true;
1489 key, OVERWRITE, metadata, IS_OWNER));
1490 return StatusCode::SUCCESS;
1494 ATH_MSG_ERROR(
"Unknown auxiliary store manager type encountered");
1495 return StatusCode::FAILURE;
1528 return StatusCode::SUCCESS;
1532 if( ! mgr->holder()->getClass()->InheritsFrom(
"SG::IAuxStoreIO" ) ) {
1536 return StatusCode::SUCCESS;
1551 sel.selectAux( item_itr->second );
1562 ATH_MSG_DEBUG(
"REvent::putAux - dynNamePrefix " << dynNamePrefix);
1572 typedef std::pair< std::string, SG::auxid_t > AuxVarSort_t;
1573 std::vector< AuxVarSort_t > varsort;
1574 varsort.reserve( auxids.size() );
1576 varsort.emplace_back(
r.getName(
id ),
id );
1578 std::sort( varsort.begin(), varsort.end() );
1581 for(
const auto& p : varsort ) {
1587 const std::string dynKey = dynNamePrefix + p.first;
1589 ATH_MSG_DEBUG(
"REvent::putAux - id, dynKey " <<
id <<
", " << dynKey);
1593 Object_t::iterator bmgr = objects.find( dynKey );
1596 if( bmgr == objects.end() ) {
1598 const std::type_info* brType = aux->
getIOType(
id );
1600 ATH_MSG_FATAL(
"No I/O type found for variable " << dynKey );
1601 return StatusCode::FAILURE;
1604 std::string brProperTypeName =
"<unknown>";
1607 bool isPrimitive =
false;
1610 if( strlen( brType->name() ) == 1 ) {
1613 ATH_MSG_DEBUG(
"REvent::putAux - primitive " <<
id <<
", " << brTypeName <<
" brType name " << brType->name());
1617 brProperTypeName = std::move(brTypeName);
1620 static constexpr bool IS_OWNER =
false;
1621 auto auxmgr = std::make_unique<RAuxFieldManager>(
1622 std::make_unique<THolder>(aux->
getIOData(
id ), *brType, IS_OWNER), isPrimitive );
1623 outmgrPtr = auxmgr.get();
1625 objects[ dynKey ] = std::move(auxmgr);
1629 ATH_MSG_DEBUG(
"REvent::putAux - not primitive " <<
id <<
", " << brTypeName);
1632 TClass* cl = TClass::GetClass( *brType, kTRUE, kTRUE );
1636 cl = TClass::GetClass( brTypeName.c_str() );
1639 ATH_MSG_FATAL(
"Dictionary not available for variable \"" << dynKey
1640 <<
"\" of type \"" << brTypeName <<
"\"" );
1641 return StatusCode::FAILURE;
1646 brProperTypeName = cl->GetName();
1649 static constexpr bool IS_OWNER =
false;
1650 auto auxmgr = std::make_unique<RAuxFieldManager>(
1651 std::make_unique<THolder>(aux->
getIOData(
id ), cl, IS_OWNER), isPrimitive );
1652 outmgrPtr = auxmgr.get();
1653 objects[ dynKey ] = std::move(auxmgr);
1680 bmgr = objects.find( dynKey );
1681 if( bmgr == objects.end() ) {
1682 ATH_MSG_FATAL(
"There is an internal logic error in the code..." );
1686 const_cast< void*
>(
static_cast< const void*
>( aux->
getIOData(
id ) ) );
1687 bmgr->second->setObject( nc_data );
1691 return StatusCode::SUCCESS;
1704 std::string fieldName;
1705 std::string className;
1706 if (getInfoForFieldCreation( key, mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
1708 if ( className.empty() ) {
1710 return StatusCode::FAILURE;
1715 m_model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
1719 ATH_MSG_ERROR(
"Internal logic error detected - no output found");
1720 return StatusCode::FAILURE;
1723 auto field = ROOT::RFieldBase::Create(fieldName, className).Unwrap();
1725 updater->BeginUpdate();
1726 updater->AddField(std::move(field));
1727 updater->CommitUpdate();
1731 return StatusCode::SUCCESS;
1746 ATH_MSG_ERROR(
"Function called on an uninitialised object");
1747 return StatusCode::FAILURE;
1756 ATH_MSG_DEBUG(
"Investigating object \"" << key <<
"\" of class \""
1757 << format.className() <<
"\"");
1760 if (key.ends_with(
"Aux.")) {
1765 TClass* cl = TClass::GetClass(format.className().c_str());
1766 if ((cl ==
nullptr) || (cl->IsLoaded() ==
false)) {
1768 "Couldn't find the dictionary for type: " << format.className());
1774 static TClass*
const auxInfoCl = TClass::GetClass(
1776 if (auxInfoCl ==
nullptr) {
1777 ATH_MSG_ERROR(
"Couldn't get dictionary for xAOD::AuxInfoBase");
1778 return StatusCode::FAILURE;
1780 const bool isInfo = cl->InheritsFrom(auxInfoCl);
1784 const std::string fieldName =
1789 static constexpr bool TOP_STORE =
true;
1796 stats.branch(fieldName,
id);
1800 stats.setBranchNum(stats.branchNum() + temp.
getAuxIDs().size());
1805 const ROOT::RNTupleDescriptor& descriptor =
1808 ROOT::kInvalidDescriptorId) {
1815 return StatusCode::SUCCESS;
1827 ROOT::RNTupleReader& reader) {
1830 const std::string fieldName = mgr.field().GetField().GetFieldName();
1833 ::TMethodCall setNameCall;
1834 setNameCall.InitWithPrototype(mgr.holder()->getClass(),
"setName",
1836 if (setNameCall.IsValid()) {
1839 const ::TString params = ::TString::Format(
"\"%s\"", fieldName.c_str());
1840 const char* charParams = params.Data();
1841 setNameCall.Execute(mgr.holder()->get(), charParams);
1844 ATH_MSG_WARNING(
"Couldn't find setName(...) function for container \""
1845 << fieldName <<
"\" (type: "
1846 << mgr.holder()->getClass()->GetName() <<
")");
1850 static const TClass*
const holderClass =
1852 if (!mgr.holder()->getClass()->InheritsFrom(holderClass)) {
1854 return StatusCode::SUCCESS;
1862 return StatusCode::FAILURE;
1869 static constexpr bool TOP_STORE =
false;
1871 auto store = std::make_unique<RAuxStore>(
1873 fieldName, TOP_STORE,
1889 static constexpr bool SHARED_OWNER =
false;
1891 std::make_unique<RAuxManager>(store.get(),
m_entry, SHARED_OWNER);
1894 storeHolder->
setStore(store.release());
1897 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
#define ATH_MSG_FATAL(x,...)
Base class for elements of a container that can have aux data.
Manage index tracking and synchronization of auxiliary data.
std::vector< size_t > vec
Hold a pointer to the current event store.
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
Handle mappings between names and auxid_t.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Manage index tracking and synchronization of auxiliary data.
Interface for objects taking part in direct ROOT I/O.
@ AST_ContainerStore
The store describes a container.
@ AST_ObjectStore
The store describes a single object.
virtual AuxStoreType getStoreType() const =0
Return the type of the store object.
virtual void setStore(IAuxStore *store)=0
Give an auxiliary store object to the holder object.
Interface providing I/O for a generic auxiliary store.
virtual SG::auxid_set_t getSelectedAuxIDs() const
Get a list of dynamic variables that need to be written out.
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.
virtual const void * getIOData(SG::auxid_t auxid) const =0
Return a pointer to the data to be stored for one aux data item.
Interface for non-const operations on an auxiliary store.
A set of aux data identifiers.
Common base class for auxiliary info objects.
Class helping in dealing with dynamic branch selection.
Manager for EDM objects created by ROOT.
const THolder * holder() const
Accessor to the Holder object.
EventFormat m_inputEventFormat
Format of the current input file.
std::set< std::string > m_inputMissingObjects
Objects that have been asked for, but were found to be missing in the current input.
upgrade_mutex_t m_branchesMutex
Mutex for multithread synchronization.
std::unordered_map< std::string, std::unique_ptr< TVirtualManager > > Object_t
Definition of the internal data structure type.
Object_t m_inputObjects
Collection of all the managed input objects.
Event(std::string_view name, const EventContext *ctx=nullptr)
Constructor with a name.
static const char *const METADATA_OBJECT_NAME
Name of the metadata tree or RNTuple.
StatusCode keys(std::vector< std::string > &vkeys, bool metadata) const
Provide a list of all data object keys associated with a specific type.
void setActive() const
Set this event object as the currently active one.
SG::sgkey_t getHash(const std::string &key) const override
Function returning the hash describing an object name.
static const char *const EVENT_RNTUPLE_NAME
Name of the event RNTuple.
Object_t m_inputMetaObjects
Collection of all the managed input meta-objects.
std::unordered_map< std::string, std::set< std::string > > m_auxItemList
Rules for selecting which auxiliary branches to write.
EventFormat * m_outputEventFormat
Format of the current output file.
Object_t m_outputObjects
Collection of all the managed output object.
SG::SGKeyMap< BranchInfo > m_branches ATLAS_THREAD_SAFE
Map from hashed sgkey to BranchInfo.
AthContainers_detail::upgrading_lock< upgrade_mutex_t > upgrading_lock_t
Lock type for multithread synchronization.
const EventContext & currentContext() const
Return the event context corresponding to this event.
std::vector< TVirtualIncidentListener * > m_listeners
Listeners who should be notified when certain incidents happen.
Object_t m_outputMetaObjects
Collection of all the managed output meta-objects.
Manager for auxiliary branches created dynamically.
::Bool_t isPrimitive() const
Accessor to whether the field is a primitive type, e.g. int, float, bool.
StatusCode finishWritingTo(TFile &file) override
Finish writing to an output file.
bool m_inputNTupleIsMissing
Whether the input has an event RNTuple or not.
StatusCode addField(const std::string &key, const TVirtualManager &mgr)
Add field to RNTuple model given the StoreGate key and output object manager.
StatusCode putAux(TVirtualManager &mgr, ::Bool_t metadata=kFALSE)
Method saving the dynamically created auxiliary properties.
::Int_t fill() override
Method filling one event into the output.
StatusCode setUpDynamicStore(RObjectManager &mgr, ROOT::RNTupleReader &ntupleReader)
event uses RNTupleReader:
std::unique_ptr< ROOT::RNTupleWriter > m_eventWriter
The main event writer: RNTupleWeader.
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.
std::unique_ptr< ROOT::RNTupleReader > m_eventReader
The main event data reader.
StatusCode connectMetaAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches for a metadata object.
::Int_t getEntry(::Long64_t entry, ::Int_t getall=0) override
Function loading a given entry of the input RNTuple.
std::unique_ptr< ROOT::RNTupleModel > m_model
The RNTuple model used for event fields.
StatusCode writeTo(TFile &file) override
Connect the object to an output file.
::TFile * m_outputFile
The output file for writing.
std::unique_ptr< ROOT::RNTupleReader > m_metaReader
The metadata reader.
StatusCode recordAux(TVirtualManager &mgr, const std::string &key, bool metadata) override
Record an auxiliary store into a connected output file.
StatusCode readFrom(TFile &inFile) override
Set up the reading of an input file from TFile This method implements the interface from Event.
StatusCode setAuxStore(const std::string &key, Details::IObjectManager &mgr, bool metadata) override
Function connecting a DV object to its auxiliary store.
::Long64_t getEntries() const override
Get how many entries are available from the current input file(s).
bool hasOutput() const override
Check if an output file is connected to the object.
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.
StatusCode connectObject(const std::string &key, bool silent) override
Function setting up access to a particular object.
::Long64_t m_entry
The entry to look at from the input.
REvent(const EventContext *ctx=nullptr)
Default constructor.
virtual ~REvent()
Destructor.
StatusCode connectAux(const std::string &prefix, bool standalone) override
Function setting up access to a set of auxiliary branches.
StatusCode initStats()
Function to initialise the statistics for all RNTuple content.
StatusCode connectMetaObject(const std::string &key, bool silent) override
Function setting up access to a particular metadata object.
bool hasInput() const override
Check if an input file is connected to the object.
Manager for EDM objects created by ROOT.
Manager for EDM objects to be written to RNTuple.
virtual void setObject(void *obj) override
Function replacing the object being handled.
ReadStats & stats()
Access the object belonging to the current thread.
static IOStats & instance()
Singleton object accessor.
"ROOT @c RNTuple implementation" of IAuxStore
StatusCode readFrom(ROOT::RNTupleReader &reader)
Connect the object to an input RNTuple.
Class describing the access statistics of a collection of branches.
void nextEvent()
Function incrementing the processed event counter.
BranchStats * container(const std::string &name)
Access the description of a container. Creating it if necessary.
void setBranchNum(::Int_t num)
Set the total number of branches on the input.
void readContainer(const std::string &name)
Function incrementing the read counter on a specific container.
void add(std::string_view fileName)
Add information about a new file that got accessed.
static TFileAccessTracer & instance()
Access the singleton instance of this class.
const std::type_info * getTypeInfo() const
const ::TClass * getClass() const
virtual void * getAs(const std::type_info &tid, ::Bool_t silent=kFALSE) const
Return the object as a specific pointer.
@ DATAVECTOR
A DataVector container.
@ AUXELEMENT
A type inheriting from SG::AuxElement.
Class describing a certain "incident" that is communicated to user code.
Class providing an interface for classes listening to xAOD incidents.
Interface class for the "manager classes".
virtual const void * object() const =0
Function getting a const pointer to the object being handled.
virtual::Int_t getEntry(::Int_t getall=0)=0
Function for updating the object in memory if needed.
EStructMode
"Structural" modes of the object
@ kObjectStore
The object describes a single object.
@ kContainerStore
The object describes an entire container.
virtual const SG::auxid_set_t & getAuxIDs() const override
Get the types(names) of variables handled by this container.
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...
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
size_t auxid_t
Identifier for a particular aux data item.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
bool hasAuxStore(const TClass &cl)
Helper function deciding if a given type "has an auxiliary store".
bool isAuxStore(const TClass &cl)
Helper function deciding if a given type "is an auxiliary store".
bool isStandalone(const TClass &cl)
Helper function deciding if a given type "is a standalone object".
static const ::Int_t BeginEvent
A new event was just loaded.
static const ::Int_t EndInputFile
The processing of an input file has finished.
static const ::Int_t MetaDataStop
The metadata for the output file should be written out.
static const ::Int_t BeginInputFile
A new input file was just opened.
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...
std::string getFieldName(const ROOT::RNTupleDescriptor &descriptor, const std::string &key)
This function is used to find the name of the field in an RNTuple that stores the object with a given...
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
EventFormat_v1 EventFormat
Definition of the current event format version.
Convert a type_info to a normalized string representation (matching the names used in the root dictio...