Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
39 bool isContainerField(
const ROOT::RFieldDescriptor& fieldDesc,
54 TClass*
cl = TClass::GetClass(fieldDesc.GetTypeName().c_str());
60 ::Warning(
"::isPContainerField",
61 XAOD_MESSAGE(
"Couldn't get a dictionary for type \"%s\""),
62 fieldDesc.GetTypeName().c_str());
67 const std::type_info* root_ti =
cl->GetTypeInfo();
75 typeName.ReplaceAll(
"basic_string<char>",
"string");
76 ::TClass* newCl = ::TClass::GetClass(
typeName);
78 root_ti = newCl->GetTypeInfo();
83 XAOD_MESSAGE(
"Couldn't get an std::type_info object out of "
90 const std::type_info* aux_obj_ti =
96 static_cast<int>(auxid));
99 const std::type_info* aux_vec_ti =
105 static_cast<int>(auxid));
110 if (*root_ti == *aux_obj_ti) {
113 }
else if (*root_ti == *aux_vec_ti) {
121 if (
cl->GetCollectionProxy() && (*aux_vec_ti ==
typeid(std::vector<int>))) {
127 if (*cl2->GetTypeInfo() == *aux_vec_ti) {
143 aux_vec_cl->GetConversionStreamerInfo(
cl,
cl->GetClassVersion())) {
149 aux_obj_cl->GetConversionStreamerInfo(
cl,
cl->GetClassVersion())) {
155 XAOD_MESSAGE(
"Couldn't determine if field describes a single "
156 "object or a container"));
172 std::string_view
prefix,
void*
object,
const std::type_info* ti)
173 : m_field(std::move(
field)),
183 if ((m_entry ==
entry) && (!m_needsRead)) {
184 return StatusCode::SUCCESS;
190 }
catch (
const ROOT::RException&
e) {
191 ::Error(
"::RFieldInfo::getEntry",
192 "Failed to load entry %lld for field %s.%s: %s",
entry,
196 return StatusCode::FAILURE;
202 return StatusCode::SUCCESS;
211 void* objectPtr() {
return m_object; }
214 const std::type_info* typeInfo()
const {
return m_typeInfo; }
217 void reset() { m_needsRead =
true; }
221 ROOT::RNTupleView<void> m_field;
225 std::string_view m_prefix;
227 void* m_object =
nullptr;
229 const std::type_info* m_typeInfo =
nullptr;
231 ::Long64_t m_entry = -1;
233 bool m_needsRead =
true;
237 bool fieldExists(std::string_view
fieldName,
238 ROOT::RNTupleReader& ntupleReader) {
241 return (ntupleReader.GetDescriptor().FindFieldId(
fieldName) !=
263 return StatusCode::SUCCESS;
268 return StatusCode::SUCCESS;
272 for (
const ROOT::RFieldBase*
field :
273 #
if ROOT_VERSION_CODE >= ROOT_VERSION(6, 35, 0)
274 m_inTuple->GetModel().GetConstFieldZero().GetConstSubfields()
276 m_inTuple->GetModel().GetConstFieldZero().GetSubFields()
287 for (
const ROOT::RFieldBase* subField :
288 #
if ROOT_VERSION_CODE >= ROOT_VERSION(6, 35, 0)
289 field->GetConstSubfields()
291 field->GetSubFields()
296 const std::string subFieldName = subField->GetQualifiedFieldName();
297 const std::string subAuxName =
298 subFieldName.substr(subFieldName.find(
".") + 1);
301 if (subAuxName.starts_with(
"xAOD::") ||
302 subAuxName.starts_with(
"SG::") ||
303 subAuxName.starts_with(
"ILockable")) {
320 ::Error(
"xAOD::RAuxStore::impl::scanInputNtuple",
321 "Dynamic field with empty name found on container: %s",
335 return StatusCode::SUCCESS;
348 std::string* expectedClassName =
nullptr) {
353 ::TClass* expectedClass = ::TClass::GetClass(
typeName.c_str());
354 if (expectedClassName) {
356 *expectedClassName = expectedClass->GetName();
370 const std::type_info* ti =
nullptr;
373 ti = expectedClass->GetTypeInfo();
378 if (!expectedClass) {
379 ::Warning(
"xAOD::RAuxStore::impl::auxFieldType",
380 "Couldn't get the type of field \"%s\"",
381 field.GetFieldName().c_str());
383 ::TVirtualCollectionProxy* prox = expectedClass->GetCollectionProxy();
388 prox = cl2->GetCollectionProxy();
393 ::Warning(
"xAOD::RAuxStore::impl::auxFieldType",
394 "Couldn't get the type of field \"%s\"",
395 field.GetFieldName().c_str());
397 if (prox->GetValueClass()) {
398 ti = prox->GetValueClass()->GetTypeInfo();
422 std::string_view auxName) {
425 std::string expectedClassName;
429 return StatusCode::SUCCESS;
439 regAuxid != SG::null_auxid) {
441 return StatusCode::SUCCESS;
450 const std::string linkedAttr =
452 const std::string linkedFieldName =
454 const std::type_info* linkedTi =
nullptr;
455 if (::fieldExists(linkedFieldName, *
m_inTuple)) {
461 *linkedTi, linkedAttr,
"",
464 if (linkedAuxId == SG::null_auxid) {
465 ::Error(
"xAOD::RAuxStore::setupAuxField",
466 "Could not find linked variable for %s type %s", auxName.data(),
467 expectedClassName.c_str());
473 registry.getAuxID(*ti, std::string{auxName},
"",
flags, linkedAuxId);
476 if (auxid == SG::null_auxid) {
484 if (
typeName.starts_with(
"std::vector<"))
486 std::string factoryClassName =
488 if (factoryClassName[factoryClassName.size() - 1] ==
'>') {
489 factoryClassName +=
' ';
491 factoryClassName +=
"> >";
494 ::TClass* factoryClass = TClass::GetClass(factoryClassName.c_str());
495 if (factoryClass && factoryClass->IsLoaded()) {
496 ::TClass* baseClass = ::TClass::GetClass(
"SG::IAuxTypeVectorFactory");
497 if (baseClass && baseClass->IsLoaded()) {
498 const Int_t
offset = factoryClass->GetBaseClassOffset(baseClass);
500 void* factoryVoidPointer = factoryClass->New();
501 if (factoryVoidPointer) {
503 reinterpret_cast<unsigned long>(factoryVoidPointer) +
offset;
508 std::unique_ptr<SG::IAuxTypeVectorFactory>(factory));
509 auxid =
registry.getAuxID(*ti, std::string{auxName},
"",
flags,
518 if (auxid == SG::null_auxid && linkedAuxId == SG::null_auxid) {
521 if (vectorClassName[vectorClassName.size() - 1] ==
'>') {
522 vectorClassName +=
' ';
524 vectorClassName +=
'>';
527 ::TClass* vectorClass = ::TClass::GetClass(vectorClassName.c_str());
528 if (vectorClass && vectorClass->IsLoaded()) {
529 auto factory = std::make_unique<TAuxVectorFactory>(vectorClass);
530 if (factory->tiAlloc()) {
531 const std::type_info* tiAlloc = factory->tiAlloc();
532 registry.addFactory(*ti, *tiAlloc, std::move(factory));
534 std::string tiAllocName = factory->tiAllocName();
535 registry.addFactory(*ti, tiAllocName, std::move(factory));
537 auxid =
registry.getAuxID(*ti, std::string{auxName},
"",
540 ::Warning(
"xAOD::RAuxStore::setupAuxField",
541 "Couldn't find dictionary for type: %s",
542 vectorClassName.c_str());
547 if (auxid == SG::null_auxid) {
548 if (linkedAuxId != SG::null_auxid) {
549 ::Error(
"xAOD::RAuxStore::setupAuxField",
550 XAOD_MESSAGE(
"Dynamic ROOT vector factory not implemented for "
551 "linked types; field \"%s\""),
552 field.GetFieldName().c_str());
554 ::Error(
"xAOD::RAuxStore::setupAuxField",
555 XAOD_MESSAGE(
"Couldn't assign auxiliary ID to field \"%s\""),
556 field.GetFieldName().c_str());
558 return StatusCode::FAILURE;
563 return StatusCode::SUCCESS;
581 std::vector<std::unique_ptr<RFieldHandle> >
m_fields;
594 m_impl{std::make_unique<impl>(
m_data)} {
623 m_impl->m_missingFields.clear();
632 return StatusCode::SUCCESS;
660 return StatusCode::SUCCESS;
698 return StatusCode::SUCCESS;
709 return StatusCode::SUCCESS;
722 void* fieldPtr =
const_cast<void*
>(
getIOData(
id));
731 return StatusCode::SUCCESS;
743 m_impl->m_inputScanned =
false;
749 return ((
m_impl->m_fields.size() > auxid) &&
m_impl->m_fields[auxid]);
755 assert(
m_impl->m_fields.size() > auxid);
756 assert(
m_impl->m_fields[auxid]);
759 return StatusCode::SUCCESS;
765 return (
m_impl->m_outTuple !=
nullptr);
778 if ((auxid < m_impl->m_missingFields.size()) &&
779 m_impl->m_missingFields[auxid]) {
780 return StatusCode::RECOVERABLE;
785 if (
m_impl->m_inTuple ==
nullptr) {
786 return StatusCode::RECOVERABLE;
793 if (
m_impl->m_fields.size() <= auxid) {
794 m_impl->m_fields.resize(auxid + 1);
802 return (
m_impl->m_fields[auxid] ? StatusCode::SUCCESS
803 : StatusCode::RECOVERABLE);
810 const std::string statFieldName =
812 const std::string dynFieldName =
817 ROOT::DescriptorId_t fieldId;
818 if ((fieldId =
m_impl->m_inTuple->GetDescriptor().FindFieldId(
820 if ((fieldId =
m_impl->m_inTuple->GetDescriptor().FindFieldId(
823 if (
m_impl->m_missingFields.size() <= auxid) {
824 m_impl->m_missingFields.resize(auxid + 1);
826 m_impl->m_missingFields[auxid] =
true;
829 return StatusCode::RECOVERABLE;
836 const ROOT::RFieldDescriptor& fieldDesc =
837 m_impl->m_inTuple->GetDescriptor().GetFieldDescriptor(fieldId);
842 const bool containerField =
843 (primitiveField ? false : isContainerField(fieldDesc, auxid));
852 if ((containerField &&
854 !
r.isLinked(auxid)) ||
855 ((!containerField) &&
857 ::Error(
"xAOD::RAuxStore::setupInputData",
859 "differ for field: %s"),
861 return StatusCode::FAILURE;
865 const std::type_info* fieldType =
nullptr;
868 fieldType = (containerField ?
r.getVecType(auxid) :
r.getType(auxid));
871 TClass* clDummy = ::TClass::GetClass(fieldDesc.GetTypeName().c_str());
872 fieldType = (clDummy ? clDummy->GetTypeInfo()
876 ::Error(
"xAOD::RAuxStore::setupInputData",
878 fieldDesc.GetTypeName().c_str());
879 return StatusCode::RECOVERABLE;
884 ::TClass* fieldClass =
nullptr;
885 if (!primitiveField) {
887 fieldClass = ::TClass::GetClass(*fieldType,
true,
true);
889 fieldClass = ::TClass::GetClass(fieldTypeName);
892 ::Error(
"xAOD::RAuxStore::setupInputData",
893 XAOD_MESSAGE(
"No dictionary available for class \"%s\""),
894 fieldTypeName.Data());
895 return StatusCode::FAILURE;
901 m_data.
m_vecs[auxid] =
r.makeVector(auxid, (
size_t)0, (
size_t)0);
902 if (!containerField) {
906 strncmp(fieldClass->GetName(),
"SG::PackedContainer<", 20) == 0) {
907 std::unique_ptr<SG::IAuxTypeVector>
packed =
912 ::Error(
"xAOD::RAuxStore::setupInputData",
915 fieldName.c_str(),
static_cast<int>(auxid));
916 return StatusCode::FAILURE;
920 void* objectPtr = (containerField ?
m_data.
m_vecs[auxid]->toVector()
922 m_impl->m_fields[auxid] = std::make_unique<RFieldHandle>(
936 const std::string auxname =
r.getName(auxid);
948 const std::string testname =
r.getName(
i);
950 if (testname != auxname) {
955 ::Error(
"xAOD::RAuxStore::setupInputData",
967 if (linked_auxid != SG::null_auxid) {
972 return StatusCode::SUCCESS;
987 if (!
m_impl->m_outTuple) {
988 return StatusCode::SUCCESS;
993 return StatusCode::SUCCESS;
1000 if (
m_impl->m_fieldsWritten.size() <= auxid) {
1001 m_impl->m_fieldsWritten.resize(auxid + 1);
1005 if (
m_impl->m_fieldsWritten[auxid]) {
1006 return StatusCode::SUCCESS;
1012 m_impl->m_fieldsWritten[auxid] =
true;
1025 ::Fatal(
"xAOD::RAuxStore::setupOutputData",
1027 return StatusCode::FAILURE;
1034 ::Error(
"xAOD::RAuxStore::setupOutputData",
1037 return StatusCode::FAILURE;
1043 ::Error(
"xAOD::RAuxStore::setupOutputData",
1046 static_cast<int>(auxid));
1047 return StatusCode::FAILURE;
1052 ::Error(
"xAOD::RAuxStore::setupOutputData",
1053 XAOD_MESSAGE(
"No factory found for transient variable "
1055 static_cast<int>(auxid));
1056 return StatusCode::FAILURE;
1074 (!
m_impl->m_fields[auxid])) {
1081 ::Error(
"xAOD::RAuxStore::setupOutputData",
1082 XAOD_MESSAGE(
"Structure mode unknown for variable %s"),
1084 return StatusCode::FAILURE;
1106 auto updater =
m_impl->m_outTuple->CreateModelUpdater();
1107 updater->BeginUpdate();
1108 updater->AddField(std::move(
field));
1109 updater->CommitUpdate();
1116 return StatusCode::SUCCESS;
1122 assert(
m_impl->m_fields.size() > auxid);
1123 assert(
m_impl->m_fields[auxid]);
1124 return m_impl->m_fields[auxid]->objectPtr();
1130 assert(
m_impl->m_fields.size() > auxid);
1131 assert(
m_impl->m_fields[auxid]);
1132 return m_impl->m_fields[auxid]->typeInfo();
const IAuxTypeVectorFactory * getFactory(const std::type_info &ti, const std::type_info &ti_alloc)
Return the vector factory for a given vector element type.
virtual bool hasOutput() const override
Check if an output is being written by the object.
const std::string & prefix() const
Get the currently configured object name prefix.
std::vector< bool > m_fieldsWritten
"Write status" of the different variables
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
::Long64_t m_entry
The entry to load from the ntuple.
StatusCode setupAuxField(const ROOT::RFieldBase &field, std::string_view auxName)
This function sets up an auxiliary field by determining its type and attempting to register it with t...
TClass * lookupVectorType(TClass &cl)
Internal function used by xAOD::TAuxStore and xAOD::RAuxStore.
std::vector< std::unique_ptr< SG::IAuxTypeVector > > m_vecs
Variables handled currently by the object (indexed by auxiliary ID)
virtual void setPrefix(std::string_view prefix) override
Set the object name prefix.
std::vector< bool > m_missingFields
Mark fields we've found to be missing.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Make an AuxVectorData object from either a raw vector or an aux store.
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...
std::string getName(SG::auxid_t auxid) const
Return the name of an aux data item.
SG::auxid_set_t m_auxIDs
Internal list of auxiliary variable IDs handled currently by the object.
EStructMode
"Structural" modes of the object
virtual ~RAuxStore()
Destructor.
virtual const void * getInputObject(SG::auxid_t auxid) const override
Get a pointer to an input object, as it is in memory, for getIOData()
AthContainers_detail::lock_guard< mutex_t > guard_t
Guard type for multithreaded synchronisation.
std::unique_ptr< SG::AuxStoreInternal > m_transientStore
Store for the in-memory-only variables.
ROOT::RNTupleWriter * m_outTuple
The ntuple being written to.
std::string dynFieldPrefix(const std::string &key)
This function is used to figure out what to name dynamic auxiliary field coming from a container call...
mutex_t m_mutex
Mutex object used for multithreaded synchronisation.
std::size_t m_size
The current size of the container being described.
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
std::vector< std::unique_ptr< RFieldHandle > > m_fields
Fields containing the various auxiliary variables.
bool isRegisteredType(SG::auxid_t auxid)
Check if the auxiliary variable has a registered type.
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
bool isPrimitiveType(std::string_view typeName)
Check if the type name describes a primitive type.
virtual StatusCode getEntryFor(SG::auxid_t auxid) override
Load a single variable from the input.
StatusCode getEntry(std::int64_t entry, int getall=0)
Get entry from the input RNTuple.
static bool classNameHasLink(const std::string &className)
Test to see if a class name corresponds to a class with a linked variable.
Members & m_data
Variables coming from AuxStoreBase.
@ kObjectStore
The object describes a single object.
virtual StatusCode setupOutputData(SG::auxid_t auxid) override
Connect a variable to the output.
@ kContainerStore
The object describes an entire container.
StatusCode scanInputTuple()
Scans the input ntuple for auxiliary data fields and sets up the necessary structures to access them.
SG::auxid_set_t m_decorIDs
Internal list of auxiliary decoration IDs handled currently by the object.
Handle mappings between names and auxid_t.
@ Linked
Mark that this variable is linked to another one.
ROOT::RNTupleReader * m_inTuple
The ntuple being read from.
size_t auxid_t
Identifier for a particular aux data item.
const std::type_info * getType(SG::auxid_t auxid) const
Return the type of an aux data item.
H5::CompType packed(H5::CompType in)
Members m_data
Member variables of the base class.
virtual bool hasEntryFor(SG::auxid_t auxid) const override
Check if a given variable is available from the input.
AthContainers_detail::mutex mutex_t
Mutex type for multithread synchronization.
std::string getTypeName(const std::type_info &ti)
This function is necessary in order to create type names that ROOT can understand.
ConcurrentBitset & insert(bit_t bit, bit_t new_nbits=0)
Set a bit to 1.
::StatusCode StatusCode
StatusCode definition for legacy code.
Interface for factory objects that create vectors.
virtual const std::type_info * tiAlloc() const =0
Return the type_info of the vector allocator.
std::string m_prefix
Static prefix for the branch names.
static bool isLinkedName(const std::string &name)
Test if a variable name corresponds to a linked variable.
virtual void copy(SG::auxid_t auxid, AuxVectorData &dst, size_t dst_index, const AuxVectorData &src, size_t src_index, size_t n) const =0
Copy elements between vectors.
const std::type_info * getVecType(SG::auxid_t auxid) const
Return the type of the STL vector used to hold an aux data item.
virtual const std::type_info * getInputType(SG::auxid_t auxid) const override
Get the type of an input object, for getIOType()
AuxVarFlags
Additional flags to qualify an auxiliary variable.
virtual SG::auxid_set_t getSelectedAuxIDs() const override
Get the IDs of the selected aux variables.
bool isAuxIDSelected(SG::auxid_t auxid) const
Check if an auxiliary variable is selected for ouput writing.
StatusCode readFrom(ROOT::RNTupleReader &reader)
Connect the object to an input RNTuple.
std::unique_ptr< IAuxTypeVector > makeVector(SG::auxid_t auxid, size_t size, size_t capacity) const
Construct a new vector to hold an aux item.
EStructMode m_structMode
The "structural" mode of the object.
virtual StatusCode setupInputData(SG::auxid_t auxid) override
Connect a variable to the input.
const std::type_info * auxFieldType(const ROOT::RFieldBase &field, std::string *expectedClassName=nullptr)
This function retrieves the type information for a given auxiliary field.
const std::type_info & getTypeInfo(EDataType type)
This function is used when reading a primitive branch from an input file without the user explicitly ...
Make an AuxVectorData object from either a raw array or an aux store.
constexpr std::enable_if_t< is_bitmask_v< E >, E & > reset(E &lhs, E rhs)
Convenience function to clear bits in a class enum bitmask.
Handle mappings between names and auxid_t.
virtual const void * getIOData(SG::auxid_t auxid) const override
Get a pointer to the data being stored for one aux data item.
virtual void reset() override
Tell the object that all branches will need to be re-read.
RAuxStore(std::string_view prefix="", bool topStore=true, EStructMode mode=EStructMode::kUndefinedStore)
Constructor.
@ kUndefinedStore
The structure mode is not defined.
StatusCode writeTo(ROOT::RNTupleWriter &writer)
Add the variables of the store to an output RNTuple.
A set of aux data identifiers.
Error
The different types of error that can be flagged in the L1TopoRDO.
std::unique_ptr< impl > m_impl
Pointer to the internal object.
reader
read the goodrunslist xml file(s)
ConcurrentBitset & erase(bit_t bit)
Turn off one bit.
std::vector< bool > m_isDecoration
Per variable lock status (indexed by auxiliary ID)
writer
show summary of content
An auxiliary data store that holds data internally.
std::string m_dynPrefix
Dynamic prefix for the branch names.
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
bool m_topStore
Flag stating whether this is a "top store".
StatusCode commitTo(ROOT::REntry &entry)
Commit a new entry to the output RNTuple.
bool m_inputScanned
"Scan status" of the input RNTuple
Struct collecting all member variables of this base class.
bool test(bit_t bit) const
Test to see if a bit is set.