1 #if !defined(XAOD_STANDALONE) && !defined(XAOD_ANALYSIS) // Full athena
4 Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement* te, std::string label) const {
6 std::vector<Trig::Feature<T> > data;
7 FeatureAccessImpl::collect<T>(te, data, label, TrigDefs::alsoDeactivateTEs, "", cgm()->navigation());
9 for( Feature<T>& f : data ) {
11 cgm()->deleteAtTheEndOfEvent( f.cptr() );
22 std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::TriggerElement* te, std::string label, unsigned int condition, const std::string& teName) const {
23 std::vector<Trig::Feature<T> > data;
24 FeatureAccessImpl::collect<T>(te, data, label, condition, teName, cgm()->navigation());
25 for( Feature<T>& f : data ) {
27 cgm()->deleteAtTheEndOfEvent( f.cptr() );
36 Trig::Feature<T> Trig::DecisionAccess::ancestor(const HLT::TriggerElement* /*te*/, std::string /*label*/) const {
37 ATH_MSG_WARNING("DecisionAccess::ancestor not implemented in Standalone mode, since it needs compile-time type information. Returning empty Feature");
38 return Trig::Feature<T>();
42 std::vector<Trig::Feature<T> > Trig::DecisionAccess::ancestors(const HLT::TriggerElement* /*te*/, std::string /*label*/, unsigned int /*condition*/, const std::string& /*teName*/) const {
43 ATH_MSG_WARNING("DecisionAccess::ancestor not implemented in Standalone mode, since it needs compile-time type information. Returning empty vector");
44 return std::vector<Trig::Feature<T> >();
49 template<class CONTAINER>
50 std::vector< TrigCompositeUtils::LinkInfo<CONTAINER> > Trig::DecisionAccess::features(const Trig::FeatureRequestDescriptor& featureRequest) const {
51 return features<CONTAINER>(featureRequest.chainGroup(), featureRequest.condition(), featureRequest.SGKey(),
52 featureRequest.featureCollectionMode(), featureRequest.linkName(), featureRequest.restrictRequestToLeg());
55 template<class CONTAINER>
56 std::vector< TrigCompositeUtils::LinkInfo<CONTAINER> > Trig::DecisionAccess::features(const Trig::ChainGroup* group,
57 const unsigned int condition,
58 const std::string& containerSGKey,
59 const unsigned int featureCollectionMode,
60 const std::string& navElementLinkKey,
61 const int restrictToLegIndex) const {
62 const SG::ReadHandleKey<TrigCompositeUtils::DecisionContainer>* navRHK = cgm()->getRun3NavigationKeyPtr();
63 if (!navRHK || navRHK->empty()) {
64 ATH_MSG_ERROR("Trig::DecisionAccess::features: Run 3 Trigger Navigation ReadHandleKey not set. " << (navRHK == nullptr ? "(nullptr)." : "(empty).") << " Check that the TDT's 'NavigationFormat' property is set to 'TrigComposite' for R3, "
65 "and the 'HLTSummary' property is set to the correct HLTNav_Summary_OnlineSlimmed / HLTNav_Summary_AODSlimmed / HLTNav_Summary_DAODSlimmed collection for the given input file.");
66 return std::vector< TrigCompositeUtils::LinkInfo<CONTAINER> >();
68 return group->features<CONTAINER>(cgm()->store(), cgm()->getRun3NavigationKey(), condition, containerSGKey, featureCollectionMode, navElementLinkKey, restrictToLegIndex);
71 template<class CONTAINER>
72 std::vector< TrigCompositeUtils::LinkInfo<CONTAINER> > Trig::DecisionAccess::features(const std::string& chainName,
73 const unsigned int condition,
74 const std::string& containerSGKey,
75 const unsigned int featureCollectionMode,
76 const std::string& navElementLinkKey,
77 const int restrictToLegIndex) const {
78 const Trig::ChainGroup *g = cgm()->createChainGroup(Trig::convertStringToVector(chainName));
79 return features<CONTAINER>(g, condition, containerSGKey, featureCollectionMode, navElementLinkKey, restrictToLegIndex);
82 template<class CONTAINER, class FEATURE_CONTAINER>
83 std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator >
84 Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer,
85 const TrigCompositeUtils::LinkInfo<FEATURE_CONTAINER> linkInfo,
86 const std::string& roiName) const {
87 return associateToEventView(inViewContainer, linkInfo.source, roiName);
90 template<class CONTAINER>
91 std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator >
92 Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer,
93 const TrigCompositeUtils::Decision* decisionObject,
94 const std::string& roiName) const {
95 using TrigCompositeUtils::LinkInfo;
96 using TrigCompositeUtils::findLink;
97 LinkInfo<TrigRoiDescriptorCollection> roiLI = findLink<TrigRoiDescriptorCollection>(decisionObject, roiName);
98 // We don't actually need to be able to resolve the ElementLink, but we should check that one was returned from the Navigation.
99 if (roiLI.link.key() == 0) {
100 ATH_MSG_ERROR("Unable to locate an ElementLink with name " << roiName << " from given Decision object.");
101 throw std::runtime_error("Trig::DecisionAccess::associateToEventView Unable to locate an ElementLink with name "+roiName+
102 " from given Decision object.");
104 return associateToEventView(inViewContainer, roiLI.link);
107 template<class CONTAINER>
108 std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator >
109 Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer,
110 const ElementLink<TrigRoiDescriptorCollection>& matchROI) const {
111 // If we can resolve the link, then we can also check the fullscan flag.
112 bool isFullscan = false;
113 if (matchROI.isValid()) {
114 isFullscan = (*matchROI)->isFullscan();
116 return associateToEventView(inViewContainer, matchROI.index(), matchROI.key(), isFullscan);
119 template<class CONTAINER>
120 std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator >
121 Trig::DecisionAccess::associateToEventView(SG::ReadHandle<CONTAINER>& inViewContainer,
122 const uint32_t matchIndex,
123 const uint32_t matchKey,
124 const bool isFullscan) const {
125 if (!inViewContainer.isValid()) {
126 std::stringstream ss;
127 ss << "Supplied ReadHandle '" << inViewContainer.key() << "' of type '" << ClassID_traits<CONTAINER>::typeName() << "' is not valid.";
128 ATH_MSG_ERROR(ss.str());
129 throw std::runtime_error("Trig::DecisionAccess::associateToEventView "+ss.str());
131 const CONTAINER* container = inViewContainer.cptr();
132 const typename CONTAINER::const_iterator end = container->end();
133 typename CONTAINER::const_iterator foundStartIt = end, foundEndIt = end;
134 static const SG::AuxElement::ConstAccessor< ElementLink<TrigRoiDescriptorCollection> > accessor("viewIndex");
135 for (typename CONTAINER::const_iterator it = container->begin(); it != end; ++it) {
136 if (!accessor.isAvailable(**it)) { // iterator dereferences to an OBJECT*, OBJECT* dereferences to an OBJECT
138 ATH_MSG_DEBUG("Supplied container has no viewIndex decoration. But isFullscan flag is TRUE. "
139 << "Returning a pair of iterators over the whole of the container.");
140 return std::make_pair(container->begin(), end);
142 ATH_MSG_WARNING("Unable to read the viewIndex decoration from the supplied container. Was it created inside an EventView? "
143 << "Returning a pair of iterators from the end of the container.");
144 return std::make_pair(end, end);
147 const ElementLink<TrigRoiDescriptorCollection> objectROI = accessor( **it );
149 if (objectROI.index() != matchIndex) { // Always match on the Index
152 if (matchKey != 0 && objectROI.key() != matchKey ) { // Matching on the Key is optional
155 if (match && foundStartIt == end) { // Found the start of this ROI's objects
158 if (!match && foundStartIt != end) { // Found the end of this ROI's objects
163 return std::make_pair(foundStartIt, foundEndIt);