35#include <TMethodCall.h>
37#include <ROOT/RNTuple.hxx>
56std::string getFirstFieldMatch(ROOT::RNTupleReader& reader,
57 const std::string& pre) {
59 const std::regex pattern(
".*" + pre +
".*");
60 for (
const auto& field : reader.GetDescriptor().GetTopLevelFields()) {
62 if (std::regex_match(field.GetFieldName(), pattern)) {
63 return field.GetFieldName();
70std::string getFieldNameFromKey(
const std::string& key ) {
74 std::string fieldName = key;
75 if (fieldName.rfind(
"Aux.") != std::string::npos || fieldName.rfind(
"AuxDyn.") != std::string::npos) {
76 std::replace(fieldName.begin(), fieldName.end(),
'.',
':');
83 std::string& fieldName, std::string& className ) {
86 fieldName = getFieldNameFromKey(key);
136 return StatusCode::SUCCESS;
158 return StatusCode::SUCCESS;
169 ATH_MSG_INFO(
"REvent::readFrom: fileName " << fileName);
194 <<
"\" in file: " << fileName);
199 ROOT::RNTupleDescriptor::RCreateModelOptions opts;
200 opts.SetEmulateUnknownTypes(
true);
204 <<
"\" tree in input file: " << fileName);
205 return StatusCode::FAILURE;
208 <<
"\" in file: " << fileName);
213 static const std::string eventFormatTypeName =
215 if (::TClass::GetClass(eventFormatTypeName.c_str()) ==
nullptr) {
222 auto readEventFormatMetadata = [&](std::string_view tupleName) -> StatusCode {
225 auto metaReader = ROOT::RNTupleReader::Open(tupleName, fileName);
228 << tupleName <<
"\" ntuple in input file: " << fileName);
229 return StatusCode::FAILURE;
232 << tupleName <<
"\" in file: " << fileName);
235 const std::string eventFormatFieldName =
240 for (
const auto& [key, element] : ef(0u)) {
243 }
catch (
const ROOT::RException&) {
245 return StatusCode::RECOVERABLE;
251 return StatusCode::SUCCESS;
256 if (
sc.isRecoverable()) {
258 return StatusCode::SUCCESS;
265 std::set<std::string> lOtherMetaTupleNames;
267 std::unique_ptr<TFile> inFile(TFile::Open(fileName.data(),
"READ"));
268 TList* lKeys = inFile->GetListOfKeys();
269 if (lKeys ==
nullptr) {
270 ATH_MSG_ERROR(
"Could not get list of keys for input file: " << fileName);
271 return StatusCode::FAILURE;
273 for (
const TObject* obj : *lKeys) {
274 const std::string keyName = obj->GetName();
279 (keyName.find(
"MetaData") != std::string::npos) &&
280 (keyName.find(
"MetaDataHdr") == std::string::npos)) {
282 const TKey* key =
dynamic_cast<const TKey*
>(obj);
283 if (key ==
nullptr) {
284 ATH_MSG_ERROR(
"Object describing \"" << keyName <<
"\" in file \""
286 <<
"\" is not a TKey?");
287 return StatusCode::FAILURE;
289 const char* className = key->GetClassName();
290 static constexpr bool LOAD = kFALSE;
291 static constexpr bool SILENT = kTRUE;
292 ::TClass* cl = ::TClass::GetClass(className, LOAD, SILENT);
293 if ((cl !=
nullptr) && cl->InheritsFrom(ROOT::RNTuple::Class())) {
294 lOtherMetaTupleNames.insert(std::move(keyName));
301 for (
const std::string& tupleName : lOtherMetaTupleNames) {
302 ATH_CHECK(readEventFormatMetadata(tupleName));
309 <<
"\" in file: " << fileName);
310 return StatusCode::FAILURE;
313 <<
"\" in file: " << fileName);
319 stats.setNEvents(stats.nEvents() +
m_eventReader->GetNEntries());
324 listener->handle(beginIncident);
333 listener->handle(endIncident);
337 return StatusCode::SUCCESS;
361 m_model = ROOT::RNTupleModel::Create();
365 m_model->SetDescription(rnTupleName);
368 return StatusCode::SUCCESS;
381 ATH_MSG_FATAL(
"File given to finishWritingTo does not match the file given in writeTo file!");
382 return StatusCode::FAILURE;
389 listener->handle(incident);
401 ATH_MSG_INFO(
"Metadata tree already exists, returning" );
403 return StatusCode::SUCCESS;
409 auto model = ROOT::RNTupleModel::Create();
412 model->SetDescription(outRNTupleName);
419 TClass* cl = TClass::GetClass( typeName.c_str() );
421 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
422 return StatusCode::FAILURE;
424 std::string efName = cl->GetName();
428 model->AddField( ROOT::RFieldBase::Create(
"EventFormat", efName ).Unwrap());
437 std::vector<std::pair<std::string, TVirtualManager*>> outputMetaObjects;
441 if (objMgr ==
nullptr) {
443 return StatusCode::FAILURE;
448 outputMetaObjects.emplace_back(key, objMgr);
453 for(
auto& itr : outputMetaObjects ) {
454 static constexpr bool IS_METADATA =
true;
462 std::string fieldName;
463 std::string className;
464 if (getInfoForFieldCreation( key, *mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
467 if ( className.empty() ) {
469 return StatusCode::FAILURE;
473 model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
478 auto metaDataWriter = ROOT::RNTupleWriter::Append(std::move(model), outRNTupleName, *
m_outputFile);
482 auto rnEntry = metaDataWriter->GetModel().CreateBareEntry();
489 auto fieldName = getFieldNameFromKey(key);
493 rnEntry->BindRawPtr(fieldName, mgr->object());
495 rnEntry->EmplaceNewValue(fieldName);
503 const ::Int_t ret = metaDataWriter->Fill(*rnEntry);
505 ATH_MSG_FATAL(
"Output rntuple filling failed with return value: " << ret );
508 ATH_MSG_INFO(
"Output meta data rntuple filled. nbytes = " << ret );
523 metaDataWriter.reset();
526 return StatusCode::SUCCESS;
568 ATH_MSG_DEBUG(
"Entry " << entry <<
" is already the active one");
583 result += inObj->getEntry(getall);
590 listener->handle(incident);
629 std::string unsetObjects;
630 std::vector<std::pair<std::string, TVirtualManager*>> outputObjectsCopy;
634 if (objMgr ==
nullptr) {
638 outputObjectsCopy.emplace_back(key, objMgr);
640 for (
auto &[key, mgr] : outputObjectsCopy) {
642 ATH_MSG_DEBUG(
"REvent::fill - checking and adding aux for " << key <<
", " << mgr <<
" isSet " << mgr->isSet());
645 if ((key.find(
"AuxDyn") == std::string::npos) && !mgr->isSet()) {
651 if (unsetObjects.size()) {
652 unsetObjects +=
", ";
654 unsetObjects.append(
"\"" + key +
"\"");
661 if(
putAux( *mgr ).isFailure() ) {
662 ATH_MSG_ERROR(
"Failed to put dynamic auxiliary variables in the output for object \"" << key <<
"\"" );
668 if (unsetObjects.size()) {
669 ATH_MSG_ERROR(
"The following objects were not set in the current event: "
689 ATH_MSG_DEBUG(
"REvent::fill - created writer and reset model " );
702 auto fieldName = getFieldNameFromKey(key);
706 bool isContainer = (omgr !=
nullptr);
708 ATH_MSG_DEBUG(
"REvent::fill - bind ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
709 <<
", is container " << isContainer);
714 rnEntry->BindRawPtr(fieldName, mgr->object());
717 ATH_MSG_DEBUG(
"REvent::fill - bind unSet ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
718 <<
", is container " << isContainer);
720 rnEntry->EmplaceNewValue(fieldName);
729 ATH_MSG_ERROR(
"Output RNTuple filling failed with return value: " << ret );
739 ATH_MSG_DEBUG(
"REvent::fill - after reset " << key <<
" is set " << mgr->isSet());
749 std::vector<std::string>& vkeys,
750 bool metadata)
const {
753 std::set<std::string>
keys;
759 if (reader ==
nullptr) {
761 return StatusCode::FAILURE;
763 if (metadata)
ATH_MSG_DEBUG(
"scanning input objects for metadata for type name " << targetClassName);
764 else ATH_MSG_DEBUG(
"scanning input objects for event data for type name " << targetClassName);
767 for (
const auto &topLevelField : reader->GetDescriptor().GetTopLevelFields()) {
768 std::string objClassName = topLevelField.GetTypeName();
769 std::string key = topLevelField.GetFieldName();
770 if (objClassName == targetClassName) {
772 keys.insert(std::move(key));
778 ATH_MSG_DEBUG(
"scanning output objects for type name " << targetClassName);
780 for (
const auto& topLevelFieldName :
m_eventWriter->GetModel().GetRegisteredSubfieldNames()) {
781 auto& topLevelField =
m_eventWriter->GetModel().GetConstField(topLevelFieldName);
782 std::string objClassName = topLevelField.GetTypeName();
783 std::string key = topLevelField.GetFieldName();
785 if (objClassName == targetClassName) {
787 keys.insert(std::move(key));
792 const Object_t& outAux = ( metadata ?
798 ATH_MSG_DEBUG(
"scanning output Aux objects for type name " << targetClassName);
800 for(
const auto&
object : outAux ) {
803 std::string objClassName;
806 if ( ! mgr )
continue;
807 objClassName = mgr->holder()->getClass()->GetName();
809 const std::string& key =
object.first;
811 if (objClassName == targetClassName) {
813 keys.insert(std::move(key));
817 vkeys.insert(vkeys.end(),
keys.begin(),
keys.end());
819 return StatusCode::SUCCESS;
844 return StatusCode::FAILURE;
852 return StatusCode::SUCCESS;
859 return StatusCode::RECOVERABLE;
869 std::string fieldName = key;
870 if (key.ends_with(
"Aux.")) {
871 fieldName.replace(fieldName.size() - 1, 1,
":");
883 if (
m_eventReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
884 ROOT::kInvalidDescriptorId) {
887 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
890 return StatusCode::RECOVERABLE;
897 ROOT::RNTupleView<void> view =
899 std::string className = view.GetField().GetTypeName();
900 if (className ==
"") {
904 className = ef->className();
907 "Couldn't find an appropriate type with a dictionary for field \""
908 << fieldName <<
"\"");
909 return StatusCode::FAILURE;
912 ::TClass* realClass = ::TClass::GetClass(className.c_str());
913 if (((!realClass) || (!realClass->IsLoaded())) && ef) {
917 className = ef->className();
918 realClass = ::TClass::GetClass(className.c_str());
920 if ((!realClass) || (!realClass->IsLoaded())) {
923 "Couldn't find an appropriate type with a dictionary for field \""
924 << fieldName <<
"\"");
925 return StatusCode::FAILURE;
944 ATH_MSG_ERROR(
"Couldn't access output manager for: " << key );
945 return StatusCode::FAILURE;
948 ptr = mgr->holder()->get();
954 if (ptr ==
nullptr) {
955 ptr = realClass->New();
959 auto mgr = std::make_unique<RObjectManager>(
961 std::make_unique<THolder>(ptr, realClass));
977 return StatusCode::SUCCESS;
993 return StatusCode::FAILURE;
998 return StatusCode::SUCCESS;
1002 std::string fieldName = key;
1003 if (key.ends_with(
"Aux.")) {
1004 fieldName.replace(fieldName.size() - 1, 1,
":");
1008 if (
m_metaReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
1009 ROOT::kInvalidDescriptorId) {
1012 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
1014 return StatusCode::RECOVERABLE;
1021 ROOT::RNTupleView<void> view =
1022 m_metaReader->GetView<
void>(fieldName.c_str(),
nullptr);
1023 std::string className = view.GetField().GetTypeName();
1024 if (className ==
"") {
1026 "Couldn't find an appropriate type with a dictionary for field \""
1027 << fieldName <<
"\"");
1028 return StatusCode::FAILURE;
1030 ::TClass* realClass = ::TClass::GetClass(className.c_str());
1031 if ((!realClass) || (!realClass->IsLoaded())) {
1034 "Couldn't find an appropriate type with a dictionary for field \""
1035 << fieldName <<
"\"");
1036 return StatusCode::FAILURE;
1040 void* ptr = realClass->New();
1041 static const ::Long64_t FIRST_ENTRY = 0;
1042 auto mgr = std::make_unique<RObjectManager>(
1043 m_metaReader->GetView(fieldName, ptr, className), FIRST_ENTRY,
1044 std::make_unique<THolder>(ptr, realClass));
1060 static constexpr bool METADATA =
true;
1065 return StatusCode::SUCCESS;
1082 return StatusCode::FAILURE;
1087 return StatusCode::SUCCESS;
1091 static constexpr bool SILENT =
false;
1098 return StatusCode::FAILURE;
1102 if (omgr ==
nullptr) {
1104 return StatusCode::FAILURE;
1109 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1111 return StatusCode::SUCCESS;
1119 return StatusCode::FAILURE;
1128 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1130 << standalone <<
", getStoreType() = "
1132 return StatusCode::FAILURE;
1136 return StatusCode::SUCCESS;
1148 ::Bool_t standalone) {
1153 return StatusCode::FAILURE;
1158 return StatusCode::SUCCESS;
1162 static constexpr bool SILENT =
false;
1169 return StatusCode::FAILURE;
1173 if (omgr ==
nullptr) {
1175 return StatusCode::FAILURE;
1179 static const TClass*
const holderClass =
1181 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1183 return StatusCode::SUCCESS;
1191 return StatusCode::FAILURE;
1200 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1202 << standalone <<
", getStoreType() = "
1204 return StatusCode::FAILURE;
1208 return StatusCode::SUCCESS;
1228 return StatusCode::SUCCESS;
1241 auto itr = objects.find(key +
"Aux.");
1242 if (itr == objects.end()) {
1245 return StatusCode::SUCCESS;
1247 auxMgr = itr->second.get();
1248 auxKey = key +
"Aux:";
1255 <<
"\" is not of the right type");
1256 return StatusCode::FAILURE;
1260 if (store ==
nullptr) {
1262 return StatusCode::FAILURE;
1267 ::Int_t readBytes = auxMgr->
getEntry();
1271 const std::string dynAuxKey = auxKey +
"Dynamic";
1272 auto dynAuxMgr = objects.find(dynAuxKey);
1273 if ((dynAuxMgr != objects.end()) && (readBytes || (auxMgr == &mgr))) {
1276 dynAuxMgr->second->getEntry();
1279#ifndef XAOD_STANDALONE
1286 if (auxMgr == &mgr) {
1287 return StatusCode::SUCCESS;
1293 switch (mgr.holder()->typeKind()) {
1308 if (
vec && (!
vec->trackIndices())) {
1309 Details::forceTrackIndices(*
vec);
1313 if ((!
vec) && (!aux)) {
1315 << mgr.holder()->getClass()->GetName()
1316 <<
"\" as SG::AuxVectorBase or SG::AuxElement");
1317 return StatusCode::FAILURE;
1322 vec->setStore(store);
1324 aux->setStore(store);
1327 return StatusCode::FAILURE;
1331 return StatusCode::SUCCESS;
1352 const std::string& typeName,
1353 const std::string& key,
1361 ATH_MSG_FATAL(
"No output output file defined. Did you forget to call writeTo(...)?" );
1362 return StatusCode::FAILURE;
1366 ATH_MSG_DEBUG(
"REvent::record - key, type " << key <<
", " << typeName);
1373 if( ( ! overwrite ) &&
1376 ATH_MSG_FATAL(
"Meta-object " << typeName <<
"/" << key <<
" already recorded" );
1377 return StatusCode::FAILURE;
1380 TClass* cl = TClass::GetClass( typeName.c_str() );
1382 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1383 return StatusCode::FAILURE;
1386 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1389 return StatusCode::SUCCESS;
1394 if( ( ! overwrite ) &&
1397 " already accessed from the input, can't be overwritten in memory" );
1398 return StatusCode::FAILURE;
1406 TClass* cl = TClass::GetClass( typeName.c_str() );
1408 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1409 return StatusCode::FAILURE;
1417 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1421 ATH_MSG_DEBUG(
"REvent::record - save outObjMgr for key, type " << key <<
", " << typeName);
1432 return StatusCode::SUCCESS;
1438 ATH_MSG_FATAL(
"Manager object of the wrong type encountered" );
1439 return StatusCode::FAILURE;
1474 if (iomgr !=
nullptr) {
1476 static const bool OVERWRITE =
true;
1477 static const bool IS_OWNER =
true;
1479 key, OVERWRITE, metadata, IS_OWNER));
1480 return StatusCode::SUCCESS;
1484 ATH_MSG_ERROR(
"Unknown auxiliary store manager type encountered");
1485 return StatusCode::FAILURE;
1518 return StatusCode::SUCCESS;
1522 if( ! mgr->holder()->getClass()->InheritsFrom(
"SG::IAuxStoreIO" ) ) {
1526 return StatusCode::SUCCESS;
1541 sel.selectAux( item_itr->second );
1552 ATH_MSG_DEBUG(
"REvent::putAux - dynNamePrefix " << dynNamePrefix);
1562 typedef std::pair< std::string, SG::auxid_t > AuxVarSort_t;
1563 std::vector< AuxVarSort_t > varsort;
1564 varsort.reserve( auxids.size() );
1566 varsort.emplace_back(
r.getName(
id ),
id );
1568 std::sort( varsort.begin(), varsort.end() );
1571 for(
const auto& p : varsort ) {
1577 const std::string dynKey = dynNamePrefix + p.first;
1579 ATH_MSG_DEBUG(
"REvent::putAux - id, dynKey " <<
id <<
", " << dynKey);
1583 Object_t::iterator bmgr = objects.find( dynKey );
1586 if( bmgr == objects.end() ) {
1588 const std::type_info* brType = aux->
getIOType(
id );
1590 ATH_MSG_FATAL(
"No I/O type found for variable " << dynKey );
1591 return StatusCode::FAILURE;
1594 std::string brProperTypeName =
"<unknown>";
1597 bool isPrimitive =
false;
1600 if( strlen( brType->name() ) == 1 ) {
1603 ATH_MSG_DEBUG(
"REvent::putAux - primitive " <<
id <<
", " << brTypeName <<
" brType name " << brType->name());
1607 brProperTypeName = std::move(brTypeName);
1610 static constexpr bool IS_OWNER =
false;
1611 auto auxmgr = std::make_unique<RAuxFieldManager>(
1612 std::make_unique<THolder>(aux->
getIOData(
id ), *brType, IS_OWNER), isPrimitive );
1613 outmgrPtr = auxmgr.get();
1615 objects[ dynKey ] = std::move(auxmgr);
1619 ATH_MSG_DEBUG(
"REvent::putAux - not primitive " <<
id <<
", " << brTypeName);
1622 TClass* cl = TClass::GetClass( *brType, kTRUE, kTRUE );
1626 cl = TClass::GetClass( brTypeName.c_str() );
1629 ATH_MSG_FATAL(
"Dictionary not available for variable \"" << dynKey
1630 <<
"\" of type \"" << brTypeName <<
"\"" );
1631 return StatusCode::FAILURE;
1636 brProperTypeName = cl->GetName();
1639 static constexpr bool IS_OWNER =
false;
1640 auto auxmgr = std::make_unique<RAuxFieldManager>(
1641 std::make_unique<THolder>(aux->
getIOData(
id ), cl, IS_OWNER), isPrimitive );
1642 outmgrPtr = auxmgr.get();
1643 objects[ dynKey ] = std::move(auxmgr);
1670 bmgr = objects.find( dynKey );
1671 if( bmgr == objects.end() ) {
1672 ATH_MSG_FATAL(
"There is an internal logic error in the code..." );
1676 const_cast< void*
>(
static_cast< const void*
>( aux->
getIOData(
id ) ) );
1677 bmgr->second->setObject( nc_data );
1681 return StatusCode::SUCCESS;
1694 std::string fieldName;
1695 std::string className;
1696 if (getInfoForFieldCreation( key, mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
1698 if ( className.empty() ) {
1700 return StatusCode::FAILURE;
1705 m_model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
1709 ATH_MSG_ERROR(
"Internal logic error detected - no output found");
1710 return StatusCode::FAILURE;
1713 auto field = ROOT::RFieldBase::Create(fieldName, className).Unwrap();
1715 updater->BeginUpdate();
1716 updater->AddField(std::move(field));
1717 updater->CommitUpdate();
1721 return StatusCode::SUCCESS;
1736 ATH_MSG_ERROR(
"Function called on an uninitialised object");
1737 return StatusCode::FAILURE;
1746 ATH_MSG_DEBUG(
"Investigating object \"" << key <<
"\" of class \""
1747 << format.className() <<
"\"");
1750 if (key.ends_with(
"Aux.")) {
1755 TClass* cl = TClass::GetClass(format.className().c_str());
1756 if ((cl ==
nullptr) || (cl->IsLoaded() ==
false)) {
1758 "Couldn't find the dictionary for type: " << format.className());
1764 static TClass*
const auxContCl = TClass::GetClass(
1766 static TClass*
const auxInfoCl = TClass::GetClass(
1768 if ((auxContCl ==
nullptr) || (auxInfoCl ==
nullptr)) {
1770 "Couldn't get dictionary for xAOD::AuxContainerBase or "
1771 "xAOD::AuxInfoBase");
1772 return StatusCode::FAILURE;
1774 const bool isContainer = cl->InheritsFrom(auxContCl);
1775 const bool isInfo = cl->InheritsFrom(auxInfoCl);
1776 if ((isContainer ==
false) && (isInfo ==
false)) {
1779 <<
"\" is of an unknown type: " << format.className());
1783 <<
", isInfo = " << isInfo);
1786 const std::string fieldName = key.substr(0, key.size() - 1) +
":";
1790 static constexpr bool TOP_STORE =
true;
1797 stats.branch(fieldName,
id);
1801 stats.setBranchNum(stats.branchNum() + temp.getAuxIDs().size());
1807 ROOT::kInvalidDescriptorId) {
1814 return StatusCode::SUCCESS;
1826 ROOT::RNTupleReader& reader) {
1829 const std::string fieldName = mgr.field().GetField().GetFieldName();
1832 ::TMethodCall setNameCall;
1833 setNameCall.InitWithPrototype(mgr.holder()->getClass(),
"setName",
1835 if (setNameCall.IsValid()) {
1838 const ::TString params = ::TString::Format(
"\"%s\"", fieldName.c_str());
1839 const char* charParams = params.Data();
1840 setNameCall.Execute(mgr.holder()->get(), charParams);
1843 ATH_MSG_WARNING(
"Couldn't find setName(...) function for container \""
1844 << fieldName <<
"\" (type: "
1845 << mgr.holder()->getClass()->GetName() <<
")");
1849 static const TClass*
const holderClass =
1851 if (!mgr.holder()->getClass()->InheritsFrom(holderClass)) {
1853 return StatusCode::SUCCESS;
1861 return StatusCode::FAILURE;
1866#ifndef XAOD_STANDALONE
1868 istore->toTransient( ctx );
1876 static constexpr bool TOP_STORE =
false;
1877 auto store = std::make_unique<RAuxStore>(
1879 fieldName, TOP_STORE,
1895 static constexpr bool SHARED_OWNER =
false;
1897 std::make_unique<RAuxManager>(store.get(),
m_entry, SHARED_OWNER);
1900 storeHolder->
setStore(store.release());
1903 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(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
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 the auxiliary containers.
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.
static const char *const METADATA_OBJECT_NAME
Name of the metadata tree or RNTuple.
Event(std::string_view name)
Constructor with a name.
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()
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
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.
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 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...