Skip to content
Snippets Groups Projects
Commit f7633b1e authored by Tim Martin's avatar Tim Martin
Browse files

Add deduplication checking to typelessFindLinks

parent 4d807e12
No related branches found
No related tags found
No related merge requests found
Pipeline #2185136 passed
......@@ -351,24 +351,54 @@ namespace TrigCompositeUtils {
{
using namespace msgFindLink;
if (visitedCache != nullptr) {
// We only need to recursivly explore back from each node in the graph once.
// We only need to recursively explore back from each node in the graph once.
// We can keep a record of nodes which we have already explored, these we can safely skip over.
if (visitedCache->count(start) == 1) {
return false; // Early exit
}
}
// As the append vectors are user-supplied, perform some input validation.
if (keyVec.size() != clidVec.size() or clidVec.size() != indexVec.size()) {
ANA_MSG_WARNING("In typelessFindLinks, keyVec, clidVec, indexVec must all be the same size. Instead have:"
<< keyVec.size() << ", " << clidVec.size() << ", " << indexVec.size());
return false;
}
// Locate named links. Both collections of links and individual links are supported.
bool found = false;
std::vector<uint32_t> tmpKeyVec;
std::vector<uint32_t> tmpClidVec;
std::vector<uint16_t> tmpIndexVec;
if (start->hasObjectCollectionLinks(linkName)) {
found = start->typelessGetObjectCollectionLinks(linkName, keyVec, clidVec, indexVec);
found = start->typelessGetObjectCollectionLinks(linkName, tmpKeyVec, tmpClidVec, tmpIndexVec);
}
if (start->hasObjectLink(linkName)) {
uint32_t key, clid;
uint16_t index;
found |= start->typelessGetObjectLink(linkName, key, clid, index);
keyVec.push_back(key);
clidVec.push_back(clid);
indexVec.push_back(index);
uint32_t tmpKey, tmpClid;
uint16_t tmpIndex;
found |= start->typelessGetObjectLink(linkName, tmpKey, tmpClid, tmpIndex);
tmpKeyVec.push_back(tmpKey);
tmpClidVec.push_back(tmpClid);
tmpIndexVec.push_back(tmpIndex);
}
// De-duplicate
for (size_t tmpi = 0; tmpi < tmpKeyVec.size(); ++tmpi) {
bool alreadyAdded = false;
const uint32_t tmpKey = tmpKeyVec.at(tmpi);
const uint32_t tmpClid = tmpClidVec.at(tmpi);
const uint16_t tmpIndex = tmpIndexVec.at(tmpi);
for (size_t veci = 0; veci < keyVec.size(); ++veci) {
if (keyVec.at(veci) == tmpKey
and clidVec.at(veci) == tmpClid
and indexVec.at(veci) == tmpIndex)
{
alreadyAdded = true;
break;
}
}
if (!alreadyAdded) {
keyVec.push_back( tmpKey );
clidVec.push_back( tmpClid );
indexVec.push_back( tmpIndex );
}
}
// Early exit
if (found && behaviour == TrigDefs::lastFeatureOfType) {
......@@ -395,7 +425,7 @@ namespace TrigCompositeUtils {
// only want the most recent.
// Hence we can supply TrigDefs::lastFeatureOfType. /--> parent3(link)
// We can still have more then one link found if there is a branch in the navigation. E.g. start --> parent1 --> parent2(link)
// If both parent2 and parent3 posessed an admisable ElementLink, then the warning below will trigger, and only one of the
// If both parent2 and parent3 possessed an admissible ElementLink, then the warning below will trigger, and only one of the
// links will be returned (whichever of parent2 or parent3 happened to be the first seed of parent1).
std::vector<uint32_t> keyVec;
std::vector<uint32_t> clidVec;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment