 |
ATLAS Offline Software
|
|
| StatusCode | scanInputTree () |
| | Scan the input TTree for auxiliary branches. More...
|
| |
| const std::type_info * | auxBranchType (::TBranch &br, std::string_view auxName, bool staticBranch, std::string *expectedClassName=nullptr) |
| | Find the type_info to use as the aux type for a given branch. More...
|
| |
| StatusCode | setupAuxBranch (::TBranch &br, std::string_view auxName, bool staticBranch) |
| | Register one input branch as an available auxiliary variable. More...
|
| |
Definition at line 423 of file TAuxStore.cxx.
◆ auxBranchType()
| const std::type_info* xAOD::TAuxStore::impl::auxBranchType |
( |
::TBranch & |
br, |
|
|
std::string_view |
auxName, |
|
|
bool |
staticBranch, |
|
|
std::string * |
expectedClassName = nullptr |
|
) |
| |
|
inline |
Find the type_info to use as the aux type for a given branch.
Definition at line 545 of file TAuxStore.cxx.
550 ::TClass* expectedClass =
nullptr;
551 ::EDataType expectedType = kOther_t;
552 if (
br.GetExpectedType(expectedClass, expectedType) &&
553 ((!staticBranch) || (!auxName.starts_with(
"m_")))) {
554 ::Warning(
"xAOD::TAuxStore::impl::auxBranchType",
555 "Couldn't get the type of branch \"%s\"",
br.GetName());
563 if (TBranchElement* bre =
dynamic_cast<TBranchElement*
>(&
br)) {
564 TClass* newClass = bre->GetCurrentClass();
565 if (newClass && newClass != expectedClass) {
566 expectedClass = newClass;
569 if (expectedClassName) {
570 *expectedClassName = expectedClass->GetName();
576 if ((!expectedClass) &&
582 const std::type_info* ti =
nullptr;
585 ti = expectedClass->GetTypeInfo();
590 if (!expectedClass) {
591 if ((!staticBranch) || (!auxName.starts_with(
"m_"))) {
592 ::Warning(
"xAOD::TAuxStore::impl::auxBranchType",
593 "Couldn't get the type of branch \"%s\"",
br.GetName());
596 ::TVirtualCollectionProxy* prox = expectedClass->GetCollectionProxy();
601 prox = cl2->GetCollectionProxy();
606 if ((!staticBranch) || (!auxName.starts_with(
"m_"))) {
607 ::Warning(
"xAOD::TAuxStore::impl::auxBranchType",
608 "Couldn't get the type of branch \"%s\"",
br.GetName());
611 if (prox->GetValueClass()) {
612 ti = prox->GetValueClass()->GetTypeInfo();
◆ scanInputTree()
| StatusCode xAOD::TAuxStore::impl::scanInputTree |
( |
| ) |
|
|
inline |
Scan the input TTree for auxiliary branches.
When writing an output tree, while reading information from an input tree, it can often happen that we want to copy the contents of some variables that we don't actually need during the event processing of this particular job. Since the user doesn't ask for all the possible input variables, this function needs to look at the input TTree, and try to figure out which of the branches in the tree belong to this object.
The function creates a "proper" or "virtual" auxiliary ID for each of the branches found, so they can be referenced in the "usual way" in the other parts of the code later on.
- Returns
StatusCode::SUCCESS if the function was successful, something else otherwise
Definition at line 442 of file TAuxStore.cxx.
447 return StatusCode::SUCCESS;
452 return StatusCode::SUCCESS;
459 for (Int_t
i = 0;
i <
branches->GetEntriesFast(); ++
i) {
465 TBranch*
br =
dynamic_cast<TBranch*
>(
branches->At(
i));
467 ::Fatal(
"xAOD::TAuxStore::impl::scanInputTree",
479 TObjArray* sbranches =
br->GetListOfBranches();
482 for (Int_t j = 0; j < sbranches->GetEntriesFast(); ++j) {
485 const TString
brName = sbranches->At(j)->GetName();
488 const TString auxName =
492 if (auxName.BeginsWith(
"xAOD::") || auxName.BeginsWith(
"SG::") ||
493 (auxName ==
"ILockable")) {
498 ::TBranch* sbr =
dynamic_cast< ::TBranch*
>(sbranches->At(j));
500 ::Fatal(
"xAOD::TAuxStore::impl::scanInputTree",
522 ::Warning(
"xAOD::TAuxStore::impl::scanInputTree",
523 "Dynamic branch with empty name found on container: %s",
541 return StatusCode::SUCCESS;
◆ setupAuxBranch()
| StatusCode xAOD::TAuxStore::impl::setupAuxBranch |
( |
::TBranch & |
br, |
|
|
std::string_view |
auxName, |
|
|
bool |
staticBranch |
|
) |
| |
|
inline |
Register one input branch as an available auxiliary variable.
This function takes care of assigning an auxiliary ID to a given branch. It tries its best to find an auxiliary vector factory for the branch's type, but if it fails, it still falls back to using SG::AuxTypePlaceholder as the type. In which case of course only dumb copying will be possible for the given branch. (And no vector operations on the branch's payload until the variable of the branch is accessed explicitly.)
- Parameters
-
| br | Pointer to the branch under investigation |
| auxName | The name of the auxiliary property, extracted from the branch's name |
| staticBranch | kTRUE if this is a "static branch", and kFALSE if it's a dynamic one |
- Returns
StatusCode::SUCCESS if the function was successful, something else otherwise
Definition at line 641 of file TAuxStore.cxx.
645 std::string expectedClassName;
646 const std::type_info* ti =
650 return StatusCode::SUCCESS;
660 regAuxid != SG::null_auxid) {
662 return StatusCode::SUCCESS;
671 std::string linkedAttr =
674 ::TBranch* lbr =
m_inTree->GetBranch(linkedBranch.c_str());
675 const std::type_info* lti =
nullptr;
681 *lti, linkedAttr,
"",
684 if (linked_auxid == SG::null_auxid) {
685 ::Error(
"xAOD::TAuxStore::impl::setupAuxBranch",
686 "Could not find linked variable for %s type %s", auxName.data(),
687 expectedClassName.c_str());
693 registry.
getAuxID(*ti, std::string{auxName},
"",
flags, linked_auxid);
696 if (auxid == SG::null_auxid) {
704 if (tn.starts_with(
"std::vector<")) {
707 std::string fac_class_name =
708 "SG::AuxTypeVectorFactory<" + tn +
",allocator<" + tn;
709 if (fac_class_name[fac_class_name.size() - 1] ==
'>') {
710 fac_class_name +=
' ';
712 fac_class_name +=
"> >";
715 ::TClass* fac_class = TClass::GetClass(fac_class_name.c_str());
716 if (fac_class && fac_class->IsLoaded()) {
717 ::TClass* base_class = ::TClass::GetClass(
"SG::IAuxTypeVectorFactory");
718 if (base_class && base_class->IsLoaded()) {
719 const Int_t offs = fac_class->GetBaseClassOffset(base_class);
721 void* fac_vp = fac_class->New();
724 reinterpret_cast<unsigned long>(fac_vp) + offs;
729 std::unique_ptr<SG::IAuxTypeVectorFactory>(fac));
730 auxid = registry.
getAuxID(*ti, std::string{auxName},
"",
flags,
739 if (auxid == SG::null_auxid && linked_auxid == SG::null_auxid) {
743 if (vec_class_name[vec_class_name.size() - 1] ==
'>') {
744 vec_class_name +=
' ';
746 vec_class_name +=
'>';
749 ::TClass* vec_class = ::TClass::GetClass(vec_class_name.c_str());
750 if (vec_class && vec_class->IsLoaded()) {
751 auto fac = std::make_unique<TAuxVectorFactory>(vec_class);
752 if (fac->tiAlloc()) {
753 const std::type_info* tiAlloc = fac->tiAlloc();
754 registry.
addFactory(*ti, *tiAlloc, std::move(fac));
757 registry.
addFactory(*ti, tiAllocName, std::move(fac));
759 auxid = registry.
getAuxID(*ti, std::string{auxName},
"",
762 ::Warning(
"xAOD::TAuxStore::impl::setupAuxBranch",
763 "Couldn't find dictionary for type: %s",
764 vec_class_name.c_str());
769 if (auxid == SG::null_auxid) {
770 if (linked_auxid != SG::null_auxid) {
771 ::Error(
"xAOD::TAuxStore::impl::setupAuxBranch",
772 XAOD_MESSAGE(
"Dynamic ROOT vector factory not implemented for "
773 "linked types; branch "
777 ::Error(
"xAOD::TAuxStore::impl::setupAuxBranch",
782 return StatusCode::FAILURE;
787 return StatusCode::SUCCESS;
◆ m_basketSize
| int xAOD::TAuxStore::impl::m_basketSize = 2048 |
The basket size for the output branches.
Definition at line 794 of file TAuxStore.cxx.
◆ m_branches
| std::vector<std::unique_ptr<TBranchHandle> > xAOD::TAuxStore::impl::m_branches |
Branches reading the various auxiliary variables.
Definition at line 807 of file TAuxStore.cxx.
◆ m_branchesWritten
| std::vector<bool> xAOD::TAuxStore::impl::m_branchesWritten |
"Write status" of the different variables
Definition at line 809 of file TAuxStore.cxx.
◆ m_data
| Members& xAOD::TAuxStore::impl::m_data |
Variables coming from AuxStoreBase.
Definition at line 791 of file TAuxStore.cxx.
◆ m_inputScanned
| bool xAOD::TAuxStore::impl::m_inputScanned = false |
◆ m_inTree
| ::TTree* xAOD::TAuxStore::impl::m_inTree = nullptr |
◆ m_missingBranches
| std::vector<bool> xAOD::TAuxStore::impl::m_missingBranches |
Mark branches we've found to be missing.
(Because TTree::GetBranch is very expensive.)
Definition at line 812 of file TAuxStore.cxx.
◆ m_mutex
| mutex_t xAOD::TAuxStore::impl::m_mutex |
|
mutable |
Mutex object used for multithreaded synchronisation.
Definition at line 815 of file TAuxStore.cxx.
◆ m_outTree
| ::TTree* xAOD::TAuxStore::impl::m_outTree = nullptr |
◆ m_splitLevel
| int xAOD::TAuxStore::impl::m_splitLevel = 0 |
The split level for the output branches.
Definition at line 796 of file TAuxStore.cxx.
The documentation for this struct was generated from the following file:
#define RETURN_CHECK(CONTEXT, EXP)
Helper macro for checking return codes in a compact form in the code.
const IAuxTypeVectorFactory * addFactory(const std::type_info &ti, const std::type_info &ti_alloc, std::unique_ptr< const IAuxTypeVectorFactory > factory)
Add a new type -> factory mapping.
TClass * lookupVectorType(TClass &cl)
Internal function used by xAOD::TAuxStore and xAOD::RAuxStore.
static AuxTypeRegistry & instance()
Return the singleton registry instance.
SG::auxid_t findAuxID(const std::string &name, const std::string &clsname="") const
Look up a name -> auxid_t mapping.
SG::auxid_set_t m_auxIDs
Internal list of auxiliary variable IDs handled currently by the object.
const std::type_info * auxBranchType(::TBranch &br, std::string_view auxName, bool staticBranch, std::string *expectedClassName=nullptr)
Find the type_info to use as the aux type for a given branch.
static std::string linkedName(const std::string &name)
Given a variable name, return the name of the corresponding linked variable.
static bool classNameHasLink(const std::string &className)
Test to see if a class name corresponds to a class with a linked variable.
@ kObjectStore
The object describes a single object.
virtual std::string tiAllocName() const =0
Return the (demangled) name of the vector allocator.
Handle mappings between names and auxid_t.
::TTree * m_inTree
The TTree being read from.
@ Linked
Mark that this variable is linked to another one.
size_t auxid_t
Identifier for a particular aux data item.
StatusCode setupAuxBranch(::TBranch &br, std::string_view auxName, bool staticBranch)
Register one input branch as an available auxiliary variable.
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.
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.
AuxVarFlags
Additional flags to qualify an auxiliary variable.
EStructMode m_structMode
The "structural" mode of the object.
const std::type_info & getTypeInfo(EDataType type)
This function is used when reading a primitive branch from an input file without the user explicitly ...
@ kUndefinedStore
The structure mode is not defined.
Members & m_data
Variables coming from AuxStoreBase.
bool m_inputScanned
"Scan status" of the input TTree
std::string m_dynPrefix
Dynamic prefix for the branch names.
bool m_topStore
Flag stating whether this is a "top store".
SG::auxid_t getAuxID(const std::string &name, const std::string &clsname="", const Flags flags=Flags::None, const SG::auxid_t linkedVariable=SG::null_auxid)
Look up a name -> auxid_t mapping.