12 #include <tracking/trackFindingCDC/utilities/WeightedRelation.h>
13 #include <tracking/trackFindingCDC/utilities/Relation.h>
14 #include <tracking/trackFindingCDC/numerics/Weight.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <mdst/dataobjects/EventLevelTrackingInfo.h>
19 #include <tracking/ckf/pxd/entities/CKFToPXDState.h>
20 #include <tracking/ckf/svd/entities/CKFToSVDState.h>
22 #include <framework/logging/Logger.h>
33 namespace TrackFindingCDC {
59 struct RelationFilterUtil {
62 template <
class AObject,
class ARelationFilter>
63 static void appendUsing(ARelationFilter& relationFilter,
64 const std::vector<AObject*>& froms,
65 const std::vector<AObject*>& tos,
66 std::vector<WeightedRelation<AObject>>& weightedRelations,
67 unsigned int maximumNumberOfRelations = std::numeric_limits<unsigned int>::max())
69 for (AObject* from : froms) {
72 std::vector<AObject*> possibleTos = relationFilter.getPossibleTos(from, tos);
74 for (AObject* to : possibleTos) {
75 if (from == to)
continue;
77 Weight weight = relationFilter(relation);
78 if (std::isnan(weight))
continue;
79 weightedRelations.emplace_back(from, weight, to);
81 if (weightedRelations.size() == maximumNumberOfRelations) {
82 B2WARNING(
"Relations Creator reached maximal number of items. Aborting");
83 if (m_eventLevelTrackingInfo.
isValid()) {
84 if (std::is_base_of<AObject, CKFToPXDState>::value) {
85 m_eventLevelTrackingInfo->setPXDCKFAbortionFlag();
86 }
else if (std::is_base_of<AObject, CKFToSVDState>::value) {
87 m_eventLevelTrackingInfo->setSVDCKFAbortionFlag();
89 B2WARNING(
"Undefined class used for CKFStates. Could not set AbortionFlag.");
93 weightedRelations.clear();
99 std::sort(std::begin(weightedRelations), std::end(weightedRelations));
104 template <
class AObject,
class ARelationFilter>
105 static void appendUsing(ARelationFilter& relationFilter,
106 const std::vector<AObject*>& objects,
107 std::vector<WeightedRelation<AObject>>& weightedRelations)
109 appendUsing(relationFilter, objects, objects, weightedRelations);