33#include <TMethodCall.h>
35#include <ROOT/RNTuple.hxx>
54std::string getFirstFieldMatch(ROOT::RNTupleReader& reader,
55 const std::string& pre) {
57 const std::regex pattern(
".*" + pre +
".*");
58 for (
const auto& field : reader.GetDescriptor().GetTopLevelFields()) {
60 if (std::regex_match(field.GetFieldName(), pattern)) {
61 return field.GetFieldName();
68std::string getFieldNameFromKey(
const std::string& key ) {
72 std::string fieldName = key;
73 if (fieldName.rfind(
"Aux.") != std::string::npos || fieldName.rfind(
"AuxDyn.") != std::string::npos) {
74 std::replace(fieldName.begin(), fieldName.end(),
'.',
':');
81 std::string& fieldName, std::string& className ) {
84 fieldName = getFieldNameFromKey(key);
134 return StatusCode::SUCCESS;
156 return StatusCode::SUCCESS;
167 ATH_MSG_INFO(
"REvent::readFrom: fileName " << fileName);
189 <<
"\" in file: " << fileName);
194 ROOT::RNTupleDescriptor::RCreateModelOptions opts;
195 opts.SetEmulateUnknownTypes(
true);
199 <<
"\" tree in input file: " << fileName);
200 return StatusCode::FAILURE;
203 <<
"\" in file: " << fileName);
208 static const std::string eventFormatTypeName =
210 if (::TClass::GetClass(eventFormatTypeName.c_str()) ==
nullptr) {
217 auto readEventFormatMetadata = [&](std::string_view tupleName) -> StatusCode {
220 auto metaReader = ROOT::RNTupleReader::Open(tupleName, fileName);
223 << tupleName <<
"\" ntuple in input file: " << fileName);
224 return StatusCode::FAILURE;
227 << tupleName <<
"\" in file: " << fileName);
230 const std::string eventFormatFieldName =
235 for (
const auto& [key, element] : ef(0u)) {
238 }
catch (
const ROOT::RException&) {
240 return StatusCode::RECOVERABLE;
246 return StatusCode::SUCCESS;
251 if (
sc.isRecoverable()) {
253 return StatusCode::SUCCESS;
260 std::set<std::string> lOtherMetaTupleNames;
262 std::unique_ptr<TFile> inFile(TFile::Open(fileName.data(),
"READ"));
263 TList* lKeys = inFile->GetListOfKeys();
264 if (lKeys ==
nullptr) {
265 ATH_MSG_ERROR(
"Could not get list of keys for input file: " << fileName);
266 return StatusCode::FAILURE;
268 for (
const TObject* obj : *lKeys) {
269 const std::string keyName = obj->GetName();
274 (keyName.find(
"MetaData") != std::string::npos) &&
275 (keyName.find(
"MetaDataHdr") == std::string::npos)) {
277 const TKey* key =
dynamic_cast<const TKey*
>(obj);
278 if (key ==
nullptr) {
279 ATH_MSG_ERROR(
"Object describing \"" << keyName <<
"\" in file \""
281 <<
"\" is not a TKey?");
282 return StatusCode::FAILURE;
284 const char* className = key->GetClassName();
285 static constexpr bool LOAD = kFALSE;
286 static constexpr bool SILENT = kTRUE;
287 ::TClass* cl = ::TClass::GetClass(className, LOAD, SILENT);
288 if ((cl !=
nullptr) && cl->InheritsFrom(ROOT::RNTuple::Class())) {
289 lOtherMetaTupleNames.insert(std::move(keyName));
296 for (
const std::string& tupleName : lOtherMetaTupleNames) {
297 ATH_CHECK(readEventFormatMetadata(tupleName));
304 <<
"\" in file: " << fileName);
305 return StatusCode::FAILURE;
308 <<
"\" in file: " << fileName);
314 stats.setNEvents(stats.nEvents() +
m_eventReader->GetNEntries());
319 listener->handle(beginIncident);
328 listener->handle(endIncident);
332 return StatusCode::SUCCESS;
356 m_model = ROOT::RNTupleModel::Create();
360 m_model->SetDescription(rnTupleName);
363 return StatusCode::SUCCESS;
376 ATH_MSG_FATAL(
"File given to finishWritingTo does not match the file given in writeTo file!");
377 return StatusCode::FAILURE;
384 listener->handle(incident);
396 ATH_MSG_INFO(
"Metadata tree already exists, returning" );
398 return StatusCode::SUCCESS;
404 auto model = ROOT::RNTupleModel::Create();
407 model->SetDescription(outRNTupleName);
414 TClass* cl = TClass::GetClass( typeName.c_str() );
416 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
417 return StatusCode::FAILURE;
419 std::string efName = cl->GetName();
423 model->AddField( ROOT::RFieldBase::Create(
"EventFormat", efName ).Unwrap());
432 std::vector<std::pair<std::string, TVirtualManager*>> outputMetaObjects;
436 if (objMgr ==
nullptr) {
438 return StatusCode::FAILURE;
443 outputMetaObjects.emplace_back(key, objMgr);
448 for(
auto& itr : outputMetaObjects ) {
449 static constexpr bool IS_METADATA =
true;
457 std::string fieldName;
458 std::string className;
459 if (getInfoForFieldCreation( key, *mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
462 if ( className.empty() ) {
464 return StatusCode::FAILURE;
468 model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
473 auto metaDataWriter = ROOT::RNTupleWriter::Append(std::move(model), outRNTupleName, *
m_outputFile);
477 auto rnEntry = metaDataWriter->GetModel().CreateBareEntry();
484 auto fieldName = getFieldNameFromKey(key);
488 rnEntry->BindRawPtr(fieldName, mgr->object());
490 rnEntry->EmplaceNewValue(fieldName);
498 const ::Int_t ret = metaDataWriter->Fill(*rnEntry);
500 ATH_MSG_FATAL(
"Output rntuple filling failed with return value: " << ret );
503 ATH_MSG_INFO(
"Output meta data rntuple filled. nbytes = " << ret );
518 metaDataWriter.reset();
521 return StatusCode::SUCCESS;
563 ATH_MSG_DEBUG(
"Entry " << entry <<
" is already the active one");
578 result += inObj->getEntry(getall);
585 listener->handle(incident);
624 std::string unsetObjects;
625 std::vector<std::pair<std::string, TVirtualManager*>> outputObjectsCopy;
629 if (objMgr ==
nullptr) {
633 outputObjectsCopy.emplace_back(key, objMgr);
635 for (
auto &[key, mgr] : outputObjectsCopy) {
637 ATH_MSG_DEBUG(
"REvent::fill - checking and adding aux for " << key <<
", " << mgr <<
" isSet " << mgr->isSet());
640 if ((key.find(
"AuxDyn") == std::string::npos) && !mgr->isSet()) {
646 if (unsetObjects.size()) {
647 unsetObjects +=
", ";
649 unsetObjects.append(
"\"" + key +
"\"");
656 if(
putAux( *mgr ).isFailure() ) {
657 ATH_MSG_ERROR(
"Failed to put dynamic auxiliary variables in the output for object \"" << key <<
"\"" );
663 if (unsetObjects.size()) {
664 ATH_MSG_ERROR(
"The following objects were not set in the current event: "
684 ATH_MSG_DEBUG(
"REvent::fill - created writer and reset model " );
697 auto fieldName = getFieldNameFromKey(key);
701 bool isContainer = (omgr !=
nullptr);
703 ATH_MSG_DEBUG(
"REvent::fill - bind ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
704 <<
", is container " << isContainer);
709 rnEntry->BindRawPtr(fieldName, mgr->object());
712 ATH_MSG_DEBUG(
"REvent::fill - bind unSet ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
713 <<
", is container " << isContainer);
715 rnEntry->EmplaceNewValue(fieldName);
724 ATH_MSG_ERROR(
"Output RNTuple filling failed with return value: " << ret );
734 ATH_MSG_DEBUG(
"REvent::fill - after reset " << key <<
" is set " << mgr->isSet());
744 std::vector<std::string>& vkeys,
745 bool metadata)
const {
748 std::set<std::string>
keys;
754 if (reader ==
nullptr) {
756 return StatusCode::FAILURE;
758 if (metadata)
ATH_MSG_DEBUG(
"scanning input objects for metadata for type name " << targetClassName);
759 else ATH_MSG_DEBUG(
"scanning input objects for event data for type name " << targetClassName);
762 for (
const auto &topLevelField : reader->GetDescriptor().GetTopLevelFields()) {
763 std::string objClassName = topLevelField.GetTypeName();
764 std::string key = topLevelField.GetFieldName();
765 if (objClassName == targetClassName) {
767 keys.insert(std::move(key));
773 ATH_MSG_DEBUG(
"scanning output objects for type name " << targetClassName);
775 for (
const auto& topLevelFieldName :
m_eventWriter->GetModel().GetRegisteredSubfieldNames()) {
776 auto& topLevelField =
m_eventWriter->GetModel().GetConstField(topLevelFieldName);
777 std::string objClassName = topLevelField.GetTypeName();
778 std::string key = topLevelField.GetFieldName();
780 if (objClassName == targetClassName) {
782 keys.insert(std::move(key));
787 const Object_t& outAux = ( metadata ?
793 ATH_MSG_DEBUG(
"scanning output Aux objects for type name " << targetClassName);
795 for(
const auto&
object : outAux ) {
798 std::string objClassName;
801 if ( ! mgr )
continue;
802 objClassName = mgr->holder()->getClass()->GetName();
804 const std::string& key =
object.first;
806 if (objClassName == targetClassName) {
808 keys.insert(std::move(key));
812 vkeys.insert(vkeys.end(),
keys.begin(),
keys.end());
814 return StatusCode::SUCCESS;
839 return StatusCode::FAILURE;
847 return StatusCode::SUCCESS;
854 return StatusCode::RECOVERABLE;
864 std::string fieldName = key;
865 if (key.ends_with(
"Aux.")) {
866 fieldName.replace(fieldName.size() - 1, 1,
":");
878 if (
m_eventReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
879 ROOT::kInvalidDescriptorId) {
882 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
885 return StatusCode::RECOVERABLE;
892 ROOT::RNTupleView<void> view =
894 std::string className = view.GetField().GetTypeName();
895 if (className ==
"") {
899 className = ef->className();
902 "Couldn't find an appropriate type with a dictionary for field \""
903 << fieldName <<
"\"");
904 return StatusCode::FAILURE;
907 ::TClass* realClass = ::TClass::GetClass(className.c_str());
908 if (((!realClass) || (!realClass->IsLoaded())) && ef) {
912 className = ef->className();
913 realClass = ::TClass::GetClass(className.c_str());
915 if ((!realClass) || (!realClass->IsLoaded())) {
918 "Couldn't find an appropriate type with a dictionary for field \""
919 << fieldName <<
"\"");
920 return StatusCode::FAILURE;
939 ATH_MSG_ERROR(
"Couldn't access output manager for: " << key );
940 return StatusCode::FAILURE;
943 ptr = mgr->holder()->get();
949 if (ptr ==
nullptr) {
950 ptr = realClass->New();
954 auto mgr = std::make_unique<RObjectManager>(
956 std::make_unique<THolder>(ptr, realClass));
972 return StatusCode::SUCCESS;
988 return StatusCode::FAILURE;
993 return StatusCode::SUCCESS;
997 std::string fieldName = key;
998 if (key.ends_with(
"Aux.")) {
999 fieldName.replace(fieldName.size() - 1, 1,
":");
1003 if (
m_metaReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
1004 ROOT::kInvalidDescriptorId) {
1007 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
1009 return StatusCode::RECOVERABLE;
1016 ROOT::RNTupleView<void> view =
1017 m_metaReader->GetView<
void>(fieldName.c_str(),
nullptr);
1018 std::string className = view.GetField().GetTypeName();
1019 if (className ==
"") {
1021 "Couldn't find an appropriate type with a dictionary for field \""
1022 << fieldName <<
"\"");
1023 return StatusCode::FAILURE;
1025 ::TClass* realClass = ::TClass::GetClass(className.c_str());
1026 if ((!realClass) || (!realClass->IsLoaded())) {
1029 "Couldn't find an appropriate type with a dictionary for field \""
1030 << fieldName <<
"\"");
1031 return StatusCode::FAILURE;
1035 void* ptr = realClass->New();
1036 static const ::Long64_t FIRST_ENTRY = 0;
1037 auto mgr = std::make_unique<RObjectManager>(
1038 m_metaReader->GetView(fieldName, ptr, className), FIRST_ENTRY,
1039 std::make_unique<THolder>(ptr, realClass));
1055 static constexpr bool METADATA =
true;
1060 return StatusCode::SUCCESS;
1077 return StatusCode::FAILURE;
1082 return StatusCode::SUCCESS;
1086 static constexpr bool SILENT =
false;
1093 return StatusCode::FAILURE;
1097 if (omgr ==
nullptr) {
1099 return StatusCode::FAILURE;
1104 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1106 return StatusCode::SUCCESS;
1114 return StatusCode::FAILURE;
1123 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1125 << standalone <<
", getStoreType() = "
1127 return StatusCode::FAILURE;
1131 return StatusCode::SUCCESS;
1143 ::Bool_t standalone) {
1148 return StatusCode::FAILURE;
1153 return StatusCode::SUCCESS;
1157 static constexpr bool SILENT =
false;
1164 return StatusCode::FAILURE;
1168 if (omgr ==
nullptr) {
1170 return StatusCode::FAILURE;
1174 static const TClass*
const holderClass =
1176 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1178 return StatusCode::SUCCESS;
1186 return StatusCode::FAILURE;
1195 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1197 << standalone <<
", getStoreType() = "
1199 return StatusCode::FAILURE;
1203 return StatusCode::SUCCESS;
1223 return StatusCode::SUCCESS;
1236 auto itr = objects.find(key +
"Aux.");
1237 if (itr == objects.end()) {
1240 return StatusCode::SUCCESS;
1242 auxMgr = itr->second.get();
1243 auxKey = key +
"Aux:";
1248 ::Int_t readBytes = auxMgr->
getEntry();
1252 const std::string dynAuxKey = auxKey +
"Dynamic";
1253 auto dynAuxMgr = objects.find(dynAuxKey);
1254 if ((dynAuxMgr != objects.end()) && (readBytes || (auxMgr == &mgr))) {
1257 dynAuxMgr->second->getEntry();
1262 if (auxMgr == &mgr) {
1263 return StatusCode::SUCCESS;
1269 switch (mgr.holder()->typeKind()) {
1284 if (
vec && (!
vec->trackIndices())) {
1285 Details::forceTrackIndices(*
vec);
1291 << mgr.holder()->getClass()->GetName()
1292 <<
"\" as SG::AuxVectorBase or SG::AuxElement");
1293 return StatusCode::FAILURE;
1300 <<
"\" is not of the right type");
1301 return StatusCode::FAILURE;
1306 if (store ==
nullptr) {
1308 return StatusCode::FAILURE;
1313 vec->setStore(store);
1315 aux->setStore(store);
1318 return StatusCode::FAILURE;
1322 return StatusCode::SUCCESS;
1343 const std::string& typeName,
1344 const std::string& key,
1352 ATH_MSG_FATAL(
"No output output file defined. Did you forget to call writeTo(...)?" );
1353 return StatusCode::FAILURE;
1357 ATH_MSG_DEBUG(
"REvent::record - key, type " << key <<
", " << typeName);
1364 if( ( ! overwrite ) &&
1367 ATH_MSG_FATAL(
"Meta-object " << typeName <<
"/" << key <<
" already recorded" );
1368 return StatusCode::FAILURE;
1371 TClass* cl = TClass::GetClass( typeName.c_str() );
1373 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1374 return StatusCode::FAILURE;
1377 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1380 return StatusCode::SUCCESS;
1385 if( ( ! overwrite ) &&
1388 " already accessed from the input, can't be overwritten in memory" );
1389 return StatusCode::FAILURE;
1397 TClass* cl = TClass::GetClass( typeName.c_str() );
1399 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1400 return StatusCode::FAILURE;
1408 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1412 ATH_MSG_DEBUG(
"REvent::record - save outObjMgr for key, type " << key <<
", " << typeName);
1423 return StatusCode::SUCCESS;
1429 ATH_MSG_FATAL(
"Manager object of the wrong type encountered" );
1430 return StatusCode::FAILURE;
1465 if (iomgr !=
nullptr) {
1467 static const bool OVERWRITE =
true;
1468 static const bool IS_OWNER =
true;
1470 key, OVERWRITE, metadata, IS_OWNER));
1471 return StatusCode::SUCCESS;
1475 ATH_MSG_ERROR(
"Unknown auxiliary store manager type encountered");
1476 return StatusCode::FAILURE;
1509 return StatusCode::SUCCESS;
1513 if( ! mgr->holder()->getClass()->InheritsFrom(
"SG::IAuxStoreIO" ) ) {
1517 return StatusCode::SUCCESS;
1532 sel.selectAux( item_itr->second );
1543 ATH_MSG_DEBUG(
"REvent::putAux - dynNamePrefix " << dynNamePrefix);
1553 typedef std::pair< std::string, SG::auxid_t > AuxVarSort_t;
1554 std::vector< AuxVarSort_t > varsort;
1555 varsort.reserve( auxids.
size() );
1557 varsort.emplace_back(
r.getName(
id ),
id );
1559 std::sort( varsort.begin(), varsort.end() );
1562 for(
const auto& p : varsort ) {
1568 const std::string dynKey = dynNamePrefix + p.first;
1570 ATH_MSG_DEBUG(
"REvent::putAux - id, dynKey " <<
id <<
", " << dynKey);
1574 Object_t::iterator bmgr = objects.find( dynKey );
1577 if( bmgr == objects.end() ) {
1579 const std::type_info* brType =
aux->getIOType(
id );
1581 ATH_MSG_FATAL(
"No I/O type found for variable " << dynKey );
1582 return StatusCode::FAILURE;
1585 std::string brProperTypeName =
"<unknown>";
1588 bool isPrimitive =
false;
1591 if( strlen( brType->name() ) == 1 ) {
1594 ATH_MSG_DEBUG(
"REvent::putAux - primitive " <<
id <<
", " << brTypeName <<
" brType name " << brType->name());
1598 brProperTypeName = brTypeName;
1601 static constexpr bool IS_OWNER =
false;
1602 auto auxmgr = std::make_unique<RAuxFieldManager>(
1603 std::make_unique<THolder>(
aux->getIOData(
id ), *brType, IS_OWNER), isPrimitive );
1604 outmgrPtr = auxmgr.get();
1606 objects[ dynKey ] = std::move(auxmgr);
1610 ATH_MSG_DEBUG(
"REvent::putAux - not primitive " <<
id <<
", " << brTypeName);
1613 TClass* cl = TClass::GetClass( *brType, kTRUE, kTRUE );
1617 cl = TClass::GetClass( brTypeName.c_str() );
1620 ATH_MSG_FATAL(
"Dictionary not available for variable \"" << dynKey
1621 <<
"\" of type \"" << brTypeName <<
"\"" );
1622 return StatusCode::FAILURE;
1627 brProperTypeName = cl->GetName();
1630 static constexpr bool IS_OWNER =
false;
1631 auto auxmgr = std::make_unique<RAuxFieldManager>(
1632 std::make_unique<THolder>(
aux->getIOData(
id ), cl, IS_OWNER), isPrimitive );
1633 outmgrPtr = auxmgr.get();
1634 objects[ dynKey ] = std::move(auxmgr);
1661 bmgr = objects.find( dynKey );
1662 if( bmgr == objects.end() ) {
1663 ATH_MSG_FATAL(
"There is an internal logic error in the code..." );
1667 const_cast< void*
>(
static_cast< const void*
>(
aux->getIOData(
id ) ) );
1668 bmgr->second->setObject( nc_data );
1672 return StatusCode::SUCCESS;
1685 std::string fieldName;
1686 std::string className;
1687 if (getInfoForFieldCreation( key, mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
1689 if ( className.empty() ) {
1691 return StatusCode::FAILURE;
1696 m_model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
1700 ATH_MSG_ERROR(
"Internal logic error detected - no output found");
1701 return StatusCode::FAILURE;
1704 auto field = ROOT::RFieldBase::Create(fieldName, className).Unwrap();
1706 updater->BeginUpdate();
1707 updater->AddField(std::move(field));
1708 updater->CommitUpdate();
1712 return StatusCode::SUCCESS;
1727 ATH_MSG_ERROR(
"Function called on an uninitialised object");
1728 return StatusCode::FAILURE;
1737 ATH_MSG_DEBUG(
"Investigating object \"" << key <<
"\" of class \""
1738 << format.className() <<
"\"");
1741 if (key.ends_with(
"Aux.")) {
1746 TClass* cl = TClass::GetClass(format.className().c_str());
1747 if ((cl ==
nullptr) || (cl->IsLoaded() ==
false)) {
1749 "Couldn't find the dictionary for type: " << format.className());
1755 static TClass*
const auxContCl = TClass::GetClass(
1757 static TClass*
const auxInfoCl = TClass::GetClass(
1759 if ((auxContCl ==
nullptr) || (auxInfoCl ==
nullptr)) {
1761 "Couldn't get dictionary for xAOD::AuxContainerBase or "
1762 "xAOD::AuxInfoBase");
1763 return StatusCode::FAILURE;
1765 const bool isContainer = cl->InheritsFrom(auxContCl);
1766 const bool isInfo = cl->InheritsFrom(auxInfoCl);
1767 if ((isContainer ==
false) && (isInfo ==
false)) {
1770 <<
"\" is of an unknown type: " << format.className());
1774 <<
", isInfo = " << isInfo);
1777 const std::string fieldName = key.substr(0, key.size() - 1) +
":";
1781 static constexpr bool TOP_STORE =
true;
1782 RAuxStore temp(fieldName, TOP_STORE, mode);
1788 stats.branch(fieldName,
id);
1792 stats.setBranchNum(stats.branchNum() + temp.getAuxIDs().size());
1798 ROOT::kInvalidDescriptorId) {
1805 return StatusCode::SUCCESS;
1817 ROOT::RNTupleReader& reader) {
1820 const std::string fieldName = mgr.field().GetField().GetFieldName();
1823 ::TMethodCall setNameCall;
1824 setNameCall.InitWithPrototype(mgr.holder()->getClass(),
"setName",
1826 if (setNameCall.IsValid()) {
1829 const ::TString params = ::TString::Format(
"\"%s\"", fieldName.c_str());
1830 const char* charParams = params.Data();
1831 setNameCall.Execute(mgr.holder()->get(), charParams);
1834 ATH_MSG_WARNING(
"Couldn't find setName(...) function for container \""
1835 << fieldName <<
"\" (type: "
1836 << mgr.holder()->getClass()->GetName() <<
")");
1840 static const TClass*
const holderClass =
1842 if (!mgr.holder()->getClass()->InheritsFrom(holderClass)) {
1844 return StatusCode::SUCCESS;
1852 return StatusCode::FAILURE;
1859 static constexpr bool TOP_STORE =
false;
1860 auto store = std::make_unique<RAuxStore>(
1861 fieldName, TOP_STORE,
1877 static constexpr bool SHARED_OWNER =
false;
1879 std::make_unique<RAuxManager>(store.get(),
m_entry, SHARED_OWNER);
1882 storeHolder->
setStore(store.release());
1885 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
void upgrade()
Convert the lock from upgrade to exclusive.
bit_t size() const
Count the number of 1 bits in the set.
Base class for elements of a container that can have aux data.
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.
Interface for 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.
AthContainers_detail::upgrading_lock< upgrade_mutex_t > upgrading_lock_t
Lock type for multithread synchronization.
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.
std::unordered_map< std::string, std::unique_ptr< TVirtualManager > > Object_t
Definition of the internal data structure type.
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.
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.
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...
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...