34#include <TMethodCall.h>
36#include <ROOT/RNTuple.hxx>
55std::string getFirstFieldMatch(ROOT::RNTupleReader& reader,
56 const std::string& pre) {
58 const std::regex pattern(
".*" + pre +
".*");
59 for (
const auto& field : reader.GetDescriptor().GetTopLevelFields()) {
61 if (std::regex_match(field.GetFieldName(), pattern)) {
62 return field.GetFieldName();
69std::string getFieldNameFromKey(
const std::string& key ) {
73 std::string fieldName = key;
74 if (fieldName.rfind(
"Aux.") != std::string::npos || fieldName.rfind(
"AuxDyn.") != std::string::npos) {
75 std::replace(fieldName.begin(), fieldName.end(),
'.',
':');
82 std::string& fieldName, std::string& className ) {
85 fieldName = getFieldNameFromKey(key);
135 return StatusCode::SUCCESS;
157 return StatusCode::SUCCESS;
168 ATH_MSG_INFO(
"REvent::readFrom: fileName " << fileName);
193 <<
"\" in file: " << fileName);
198 ROOT::RNTupleDescriptor::RCreateModelOptions opts;
199 opts.SetEmulateUnknownTypes(
true);
203 <<
"\" tree in input file: " << fileName);
204 return StatusCode::FAILURE;
207 <<
"\" in file: " << fileName);
212 static const std::string eventFormatTypeName =
214 if (::TClass::GetClass(eventFormatTypeName.c_str()) ==
nullptr) {
221 auto readEventFormatMetadata = [&](std::string_view tupleName) -> StatusCode {
224 auto metaReader = ROOT::RNTupleReader::Open(tupleName, fileName);
227 << tupleName <<
"\" ntuple in input file: " << fileName);
228 return StatusCode::FAILURE;
231 << tupleName <<
"\" in file: " << fileName);
234 const std::string eventFormatFieldName =
239 for (
const auto& [key, element] : ef(0u)) {
242 }
catch (
const ROOT::RException&) {
244 return StatusCode::RECOVERABLE;
250 return StatusCode::SUCCESS;
255 if (
sc.isRecoverable()) {
257 return StatusCode::SUCCESS;
264 std::set<std::string> lOtherMetaTupleNames;
266 std::unique_ptr<TFile> inFile(TFile::Open(fileName.data(),
"READ"));
267 TList* lKeys = inFile->GetListOfKeys();
268 if (lKeys ==
nullptr) {
269 ATH_MSG_ERROR(
"Could not get list of keys for input file: " << fileName);
270 return StatusCode::FAILURE;
272 for (
const TObject* obj : *lKeys) {
273 const std::string keyName = obj->GetName();
278 (keyName.find(
"MetaData") != std::string::npos) &&
279 (keyName.find(
"MetaDataHdr") == std::string::npos)) {
281 const TKey* key =
dynamic_cast<const TKey*
>(obj);
282 if (key ==
nullptr) {
283 ATH_MSG_ERROR(
"Object describing \"" << keyName <<
"\" in file \""
285 <<
"\" is not a TKey?");
286 return StatusCode::FAILURE;
288 const char* className = key->GetClassName();
289 static constexpr bool LOAD = kFALSE;
290 static constexpr bool SILENT = kTRUE;
291 ::TClass* cl = ::TClass::GetClass(className, LOAD, SILENT);
292 if ((cl !=
nullptr) && cl->InheritsFrom(ROOT::RNTuple::Class())) {
293 lOtherMetaTupleNames.insert(std::move(keyName));
300 for (
const std::string& tupleName : lOtherMetaTupleNames) {
301 ATH_CHECK(readEventFormatMetadata(tupleName));
308 <<
"\" in file: " << fileName);
309 return StatusCode::FAILURE;
312 <<
"\" in file: " << fileName);
318 stats.setNEvents(stats.nEvents() +
m_eventReader->GetNEntries());
323 listener->handle(beginIncident);
332 listener->handle(endIncident);
336 return StatusCode::SUCCESS;
360 m_model = ROOT::RNTupleModel::Create();
364 m_model->SetDescription(rnTupleName);
367 return StatusCode::SUCCESS;
380 ATH_MSG_FATAL(
"File given to finishWritingTo does not match the file given in writeTo file!");
381 return StatusCode::FAILURE;
388 listener->handle(incident);
400 ATH_MSG_INFO(
"Metadata tree already exists, returning" );
402 return StatusCode::SUCCESS;
408 auto model = ROOT::RNTupleModel::Create();
411 model->SetDescription(outRNTupleName);
418 TClass* cl = TClass::GetClass( typeName.c_str() );
420 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
421 return StatusCode::FAILURE;
423 std::string efName = cl->GetName();
427 model->AddField( ROOT::RFieldBase::Create(
"EventFormat", efName ).Unwrap());
436 std::vector<std::pair<std::string, TVirtualManager*>> outputMetaObjects;
440 if (objMgr ==
nullptr) {
442 return StatusCode::FAILURE;
447 outputMetaObjects.emplace_back(key, objMgr);
452 for(
auto& itr : outputMetaObjects ) {
453 static constexpr bool IS_METADATA =
true;
461 std::string fieldName;
462 std::string className;
463 if (getInfoForFieldCreation( key, *mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
466 if ( className.empty() ) {
468 return StatusCode::FAILURE;
472 model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
477 auto metaDataWriter = ROOT::RNTupleWriter::Append(std::move(model), outRNTupleName, *
m_outputFile);
481 auto rnEntry = metaDataWriter->GetModel().CreateBareEntry();
488 auto fieldName = getFieldNameFromKey(key);
492 rnEntry->BindRawPtr(fieldName, mgr->object());
494 rnEntry->EmplaceNewValue(fieldName);
502 const ::Int_t ret = metaDataWriter->Fill(*rnEntry);
504 ATH_MSG_FATAL(
"Output rntuple filling failed with return value: " << ret );
507 ATH_MSG_INFO(
"Output meta data rntuple filled. nbytes = " << ret );
522 metaDataWriter.reset();
525 return StatusCode::SUCCESS;
567 ATH_MSG_DEBUG(
"Entry " << entry <<
" is already the active one");
582 result += inObj->getEntry(getall);
589 listener->handle(incident);
628 std::string unsetObjects;
629 std::vector<std::pair<std::string, TVirtualManager*>> outputObjectsCopy;
633 if (objMgr ==
nullptr) {
637 outputObjectsCopy.emplace_back(key, objMgr);
639 for (
auto &[key, mgr] : outputObjectsCopy) {
641 ATH_MSG_DEBUG(
"REvent::fill - checking and adding aux for " << key <<
", " << mgr <<
" isSet " << mgr->isSet());
644 if ((key.find(
"AuxDyn") == std::string::npos) && !mgr->isSet()) {
650 if (unsetObjects.size()) {
651 unsetObjects +=
", ";
653 unsetObjects.append(
"\"" + key +
"\"");
660 if(
putAux( *mgr ).isFailure() ) {
661 ATH_MSG_ERROR(
"Failed to put dynamic auxiliary variables in the output for object \"" << key <<
"\"" );
667 if (unsetObjects.size()) {
668 ATH_MSG_ERROR(
"The following objects were not set in the current event: "
688 ATH_MSG_DEBUG(
"REvent::fill - created writer and reset model " );
701 auto fieldName = getFieldNameFromKey(key);
705 bool isContainer = (omgr !=
nullptr);
707 ATH_MSG_DEBUG(
"REvent::fill - bind ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
708 <<
", is container " << isContainer);
713 rnEntry->BindRawPtr(fieldName, mgr->object());
716 ATH_MSG_DEBUG(
"REvent::fill - bind unSet ptr " << key <<
" mgr " << mgr <<
" is set " << mgr->isSet()
717 <<
", is container " << isContainer);
719 rnEntry->EmplaceNewValue(fieldName);
728 ATH_MSG_ERROR(
"Output RNTuple filling failed with return value: " << ret );
738 ATH_MSG_DEBUG(
"REvent::fill - after reset " << key <<
" is set " << mgr->isSet());
748 std::vector<std::string>& vkeys,
749 bool metadata)
const {
752 std::set<std::string>
keys;
758 if (reader ==
nullptr) {
760 return StatusCode::FAILURE;
762 if (metadata)
ATH_MSG_DEBUG(
"scanning input objects for metadata for type name " << targetClassName);
763 else ATH_MSG_DEBUG(
"scanning input objects for event data for type name " << targetClassName);
766 for (
const auto &topLevelField : reader->GetDescriptor().GetTopLevelFields()) {
767 std::string objClassName = topLevelField.GetTypeName();
768 std::string key = topLevelField.GetFieldName();
769 if (objClassName == targetClassName) {
771 keys.insert(std::move(key));
777 ATH_MSG_DEBUG(
"scanning output objects for type name " << targetClassName);
779 for (
const auto& topLevelFieldName :
m_eventWriter->GetModel().GetRegisteredSubfieldNames()) {
780 auto& topLevelField =
m_eventWriter->GetModel().GetConstField(topLevelFieldName);
781 std::string objClassName = topLevelField.GetTypeName();
782 std::string key = topLevelField.GetFieldName();
784 if (objClassName == targetClassName) {
786 keys.insert(std::move(key));
791 const Object_t& outAux = ( metadata ?
797 ATH_MSG_DEBUG(
"scanning output Aux objects for type name " << targetClassName);
799 for(
const auto&
object : outAux ) {
802 std::string objClassName;
805 if ( ! mgr )
continue;
806 objClassName = mgr->holder()->getClass()->GetName();
808 const std::string& key =
object.first;
810 if (objClassName == targetClassName) {
812 keys.insert(std::move(key));
816 vkeys.insert(vkeys.end(),
keys.begin(),
keys.end());
818 return StatusCode::SUCCESS;
843 return StatusCode::FAILURE;
851 return StatusCode::SUCCESS;
858 return StatusCode::RECOVERABLE;
868 std::string fieldName = key;
869 if (key.ends_with(
"Aux.")) {
870 fieldName.replace(fieldName.size() - 1, 1,
":");
882 if (
m_eventReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
883 ROOT::kInvalidDescriptorId) {
886 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
889 return StatusCode::RECOVERABLE;
896 ROOT::RNTupleView<void> view =
898 std::string className = view.GetField().GetTypeName();
899 if (className ==
"") {
903 className = ef->className();
906 "Couldn't find an appropriate type with a dictionary for field \""
907 << fieldName <<
"\"");
908 return StatusCode::FAILURE;
911 ::TClass* realClass = ::TClass::GetClass(className.c_str());
912 if (((!realClass) || (!realClass->IsLoaded())) && ef) {
916 className = ef->className();
917 realClass = ::TClass::GetClass(className.c_str());
919 if ((!realClass) || (!realClass->IsLoaded())) {
922 "Couldn't find an appropriate type with a dictionary for field \""
923 << fieldName <<
"\"");
924 return StatusCode::FAILURE;
943 ATH_MSG_ERROR(
"Couldn't access output manager for: " << key );
944 return StatusCode::FAILURE;
947 ptr = mgr->holder()->get();
953 if (ptr ==
nullptr) {
954 ptr = realClass->New();
958 auto mgr = std::make_unique<RObjectManager>(
960 std::make_unique<THolder>(ptr, realClass));
976 return StatusCode::SUCCESS;
992 return StatusCode::FAILURE;
997 return StatusCode::SUCCESS;
1001 std::string fieldName = key;
1002 if (key.ends_with(
"Aux.")) {
1003 fieldName.replace(fieldName.size() - 1, 1,
":");
1007 if (
m_metaReader->GetDescriptor().FindFieldId(fieldName.c_str()) ==
1008 ROOT::kInvalidDescriptorId) {
1011 ATH_MSG_WARNING(
"Field \"" << fieldName <<
"\" not available on input");
1013 return StatusCode::RECOVERABLE;
1020 ROOT::RNTupleView<void> view =
1021 m_metaReader->GetView<
void>(fieldName.c_str(),
nullptr);
1022 std::string className = view.GetField().GetTypeName();
1023 if (className ==
"") {
1025 "Couldn't find an appropriate type with a dictionary for field \""
1026 << fieldName <<
"\"");
1027 return StatusCode::FAILURE;
1029 ::TClass* realClass = ::TClass::GetClass(className.c_str());
1030 if ((!realClass) || (!realClass->IsLoaded())) {
1033 "Couldn't find an appropriate type with a dictionary for field \""
1034 << fieldName <<
"\"");
1035 return StatusCode::FAILURE;
1039 void* ptr = realClass->New();
1040 static const ::Long64_t FIRST_ENTRY = 0;
1041 auto mgr = std::make_unique<RObjectManager>(
1042 m_metaReader->GetView(fieldName, ptr, className), FIRST_ENTRY,
1043 std::make_unique<THolder>(ptr, realClass));
1059 static constexpr bool METADATA =
true;
1064 return StatusCode::SUCCESS;
1081 return StatusCode::FAILURE;
1086 return StatusCode::SUCCESS;
1090 static constexpr bool SILENT =
false;
1097 return StatusCode::FAILURE;
1101 if (omgr ==
nullptr) {
1103 return StatusCode::FAILURE;
1108 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1110 return StatusCode::SUCCESS;
1118 return StatusCode::FAILURE;
1127 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1129 << standalone <<
", getStoreType() = "
1131 return StatusCode::FAILURE;
1135 return StatusCode::SUCCESS;
1147 ::Bool_t standalone) {
1152 return StatusCode::FAILURE;
1157 return StatusCode::SUCCESS;
1161 static constexpr bool SILENT =
false;
1168 return StatusCode::FAILURE;
1172 if (omgr ==
nullptr) {
1174 return StatusCode::FAILURE;
1178 static const TClass*
const holderClass =
1180 if (omgr->
holder()->
getClass()->InheritsFrom(holderClass) ==
false) {
1182 return StatusCode::SUCCESS;
1190 return StatusCode::FAILURE;
1199 ATH_MSG_ERROR(
"Requested store types inconsistent for: " << prefix);
1201 << standalone <<
", getStoreType() = "
1203 return StatusCode::FAILURE;
1207 return StatusCode::SUCCESS;
1227 return StatusCode::SUCCESS;
1240 auto itr = objects.find(key +
"Aux.");
1241 if (itr == objects.end()) {
1244 return StatusCode::SUCCESS;
1246 auxMgr = itr->second.get();
1247 auxKey = key +
"Aux:";
1252 ::Int_t readBytes = auxMgr->
getEntry();
1256 const std::string dynAuxKey = auxKey +
"Dynamic";
1257 auto dynAuxMgr = objects.find(dynAuxKey);
1258 if ((dynAuxMgr != objects.end()) && (readBytes || (auxMgr == &mgr))) {
1261 dynAuxMgr->second->getEntry();
1266 if (auxMgr == &mgr) {
1267 return StatusCode::SUCCESS;
1273 switch (mgr.holder()->typeKind()) {
1288 if (
vec && (!
vec->trackIndices())) {
1289 Details::forceTrackIndices(*
vec);
1293 if ((!
vec) && (!aux)) {
1295 << mgr.holder()->getClass()->GetName()
1296 <<
"\" as SG::AuxVectorBase or SG::AuxElement");
1297 return StatusCode::FAILURE;
1304 <<
"\" is not of the right type");
1305 return StatusCode::FAILURE;
1310 if (store ==
nullptr) {
1312 return StatusCode::FAILURE;
1317 vec->setStore(store);
1322 return StatusCode::FAILURE;
1326 return StatusCode::SUCCESS;
1347 const std::string& typeName,
1348 const std::string& key,
1356 ATH_MSG_FATAL(
"No output output file defined. Did you forget to call writeTo(...)?" );
1357 return StatusCode::FAILURE;
1361 ATH_MSG_DEBUG(
"REvent::record - key, type " << key <<
", " << typeName);
1368 if( ( ! overwrite ) &&
1371 ATH_MSG_FATAL(
"Meta-object " << typeName <<
"/" << key <<
" already recorded" );
1372 return StatusCode::FAILURE;
1375 TClass* cl = TClass::GetClass( typeName.c_str() );
1377 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1378 return StatusCode::FAILURE;
1381 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1384 return StatusCode::SUCCESS;
1389 if( ( ! overwrite ) &&
1392 " already accessed from the input, can't be overwritten in memory" );
1393 return StatusCode::FAILURE;
1401 TClass* cl = TClass::GetClass( typeName.c_str() );
1403 ATH_MSG_ERROR(
"Didn't find dictionary for type: " << typeName );
1404 return StatusCode::FAILURE;
1412 auto outmgr = std::make_unique<ROutObjManager>( key, std::make_unique<THolder>(obj, cl, isOwner));
1416 ATH_MSG_DEBUG(
"REvent::record - save outObjMgr for key, type " << key <<
", " << typeName);
1427 return StatusCode::SUCCESS;
1433 ATH_MSG_FATAL(
"Manager object of the wrong type encountered" );
1434 return StatusCode::FAILURE;
1469 if (iomgr !=
nullptr) {
1471 static const bool OVERWRITE =
true;
1472 static const bool IS_OWNER =
true;
1474 key, OVERWRITE, metadata, IS_OWNER));
1475 return StatusCode::SUCCESS;
1479 ATH_MSG_ERROR(
"Unknown auxiliary store manager type encountered");
1480 return StatusCode::FAILURE;
1513 return StatusCode::SUCCESS;
1517 if( ! mgr->holder()->getClass()->InheritsFrom(
"SG::IAuxStoreIO" ) ) {
1521 return StatusCode::SUCCESS;
1536 sel.selectAux( item_itr->second );
1547 ATH_MSG_DEBUG(
"REvent::putAux - dynNamePrefix " << dynNamePrefix);
1557 typedef std::pair< std::string, SG::auxid_t > AuxVarSort_t;
1558 std::vector< AuxVarSort_t > varsort;
1559 varsort.reserve( auxids.
size() );
1561 varsort.emplace_back(
r.getName(
id ),
id );
1563 std::sort( varsort.begin(), varsort.end() );
1566 for(
const auto& p : varsort ) {
1572 const std::string dynKey = dynNamePrefix + p.first;
1574 ATH_MSG_DEBUG(
"REvent::putAux - id, dynKey " <<
id <<
", " << dynKey);
1578 Object_t::iterator bmgr = objects.find( dynKey );
1581 if( bmgr == objects.end() ) {
1583 const std::type_info* brType = aux->
getIOType(
id );
1585 ATH_MSG_FATAL(
"No I/O type found for variable " << dynKey );
1586 return StatusCode::FAILURE;
1589 std::string brProperTypeName =
"<unknown>";
1592 bool isPrimitive =
false;
1595 if( strlen( brType->name() ) == 1 ) {
1598 ATH_MSG_DEBUG(
"REvent::putAux - primitive " <<
id <<
", " << brTypeName <<
" brType name " << brType->name());
1602 brProperTypeName = std::move(brTypeName);
1605 static constexpr bool IS_OWNER =
false;
1606 auto auxmgr = std::make_unique<RAuxFieldManager>(
1607 std::make_unique<THolder>(aux->
getIOData(
id ), *brType, IS_OWNER), isPrimitive );
1608 outmgrPtr = auxmgr.get();
1610 objects[ dynKey ] = std::move(auxmgr);
1614 ATH_MSG_DEBUG(
"REvent::putAux - not primitive " <<
id <<
", " << brTypeName);
1617 TClass* cl = TClass::GetClass( *brType, kTRUE, kTRUE );
1621 cl = TClass::GetClass( brTypeName.c_str() );
1624 ATH_MSG_FATAL(
"Dictionary not available for variable \"" << dynKey
1625 <<
"\" of type \"" << brTypeName <<
"\"" );
1626 return StatusCode::FAILURE;
1631 brProperTypeName = cl->GetName();
1634 static constexpr bool IS_OWNER =
false;
1635 auto auxmgr = std::make_unique<RAuxFieldManager>(
1636 std::make_unique<THolder>(aux->
getIOData(
id ), cl, IS_OWNER), isPrimitive );
1637 outmgrPtr = auxmgr.get();
1638 objects[ dynKey ] = std::move(auxmgr);
1665 bmgr = objects.find( dynKey );
1666 if( bmgr == objects.end() ) {
1667 ATH_MSG_FATAL(
"There is an internal logic error in the code..." );
1671 const_cast< void*
>(
static_cast< const void*
>( aux->
getIOData(
id ) ) );
1672 bmgr->second->setObject( nc_data );
1676 return StatusCode::SUCCESS;
1689 std::string fieldName;
1690 std::string className;
1691 if (getInfoForFieldCreation( key, mgr, fieldName, className ).isFailure())
return StatusCode::FAILURE;
1693 if ( className.empty() ) {
1695 return StatusCode::FAILURE;
1700 m_model->AddField( ROOT::RFieldBase::Create( fieldName, className ).Unwrap());
1704 ATH_MSG_ERROR(
"Internal logic error detected - no output found");
1705 return StatusCode::FAILURE;
1708 auto field = ROOT::RFieldBase::Create(fieldName, className).Unwrap();
1710 updater->BeginUpdate();
1711 updater->AddField(std::move(field));
1712 updater->CommitUpdate();
1716 return StatusCode::SUCCESS;
1731 ATH_MSG_ERROR(
"Function called on an uninitialised object");
1732 return StatusCode::FAILURE;
1741 ATH_MSG_DEBUG(
"Investigating object \"" << key <<
"\" of class \""
1742 << format.className() <<
"\"");
1745 if (key.ends_with(
"Aux.")) {
1750 TClass* cl = TClass::GetClass(format.className().c_str());
1751 if ((cl ==
nullptr) || (cl->IsLoaded() ==
false)) {
1753 "Couldn't find the dictionary for type: " << format.className());
1759 static TClass*
const auxContCl = TClass::GetClass(
1761 static TClass*
const auxInfoCl = TClass::GetClass(
1763 if ((auxContCl ==
nullptr) || (auxInfoCl ==
nullptr)) {
1765 "Couldn't get dictionary for xAOD::AuxContainerBase or "
1766 "xAOD::AuxInfoBase");
1767 return StatusCode::FAILURE;
1769 const bool isContainer = cl->InheritsFrom(auxContCl);
1770 const bool isInfo = cl->InheritsFrom(auxInfoCl);
1771 if ((isContainer ==
false) && (isInfo ==
false)) {
1774 <<
"\" is of an unknown type: " << format.className());
1778 <<
", isInfo = " << isInfo);
1781 const std::string fieldName = key.substr(0, key.size() - 1) +
":";
1785 static constexpr bool TOP_STORE =
true;
1786 RAuxStore temp(fieldName, TOP_STORE, mode);
1792 stats.branch(fieldName,
id);
1796 stats.setBranchNum(stats.branchNum() + temp.getAuxIDs().size());
1802 ROOT::kInvalidDescriptorId) {
1809 return StatusCode::SUCCESS;
1821 ROOT::RNTupleReader& reader) {
1824 const std::string fieldName = mgr.field().GetField().GetFieldName();
1827 ::TMethodCall setNameCall;
1828 setNameCall.InitWithPrototype(mgr.holder()->getClass(),
"setName",
1830 if (setNameCall.IsValid()) {
1833 const ::TString params = ::TString::Format(
"\"%s\"", fieldName.c_str());
1834 const char* charParams = params.Data();
1835 setNameCall.Execute(mgr.holder()->get(), charParams);
1838 ATH_MSG_WARNING(
"Couldn't find setName(...) function for container \""
1839 << fieldName <<
"\" (type: "
1840 << mgr.holder()->getClass()->GetName() <<
")");
1844 static const TClass*
const holderClass =
1846 if (!mgr.holder()->getClass()->InheritsFrom(holderClass)) {
1848 return StatusCode::SUCCESS;
1856 return StatusCode::FAILURE;
1863 static constexpr bool TOP_STORE =
false;
1864 auto store = std::make_unique<RAuxStore>(
1865 fieldName, TOP_STORE,
1881 static constexpr bool SHARED_OWNER =
false;
1883 std::make_unique<RAuxManager>(store.get(),
m_entry, SHARED_OWNER);
1886 storeHolder->
setStore(store.release());
1889 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.
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
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 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.
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...
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...