10 #ifndef XAOD_STANDALONE
21 const EventContext& ctx,
23 const bool printWarningMessages)
27 bool errState =
false;
28 if ( frd.
condition() != TrigDefs::Physics && frd.
condition() != TrigDefs::includeFailedDecisions ) {
29 msg << MSG::ERROR <<
"features may only be called with: "
30 "TrigDefs::Physics - features from the legs of the chain(s) which passed the trigger. "
31 "TrigDefs::includeFailedDecisions - all features from the chain(s) irrespective of pass/fail of each Step." <<
endmsg;
36 msg << MSG::ERROR <<
"featureCollectionMode may only be called with: "
37 "TrigDefs::lastFeatureOfType - stop exploring each route through the navigation once a feature matching all requirements is found. "
38 "TrigDefs::allFeaturesOfType - always fully explore each route through the navigation graph and collect all matching features." <<
endmsg;
44 msg << MSG::ERROR <<
"Unable to read trigger navigation from " << navRHKey.
key() <<
". Cannot retrieve features." <<
endmsg;
52 if (terminusNode ==
nullptr) {
53 msg << MSG::ERROR <<
"Unable to locate HLTPassRaw element of " << navRHKey.
key()
54 <<
", collection contains " << navigationRH->
size() <<
" nodes." <<
endmsg;
60 msg << MSG::ERROR <<
"Encountered one or more errors in FeatureRequestHelpers::typelessFeaturesImplimentation" <<
endmsg;
61 throw std::runtime_error(
"Encountered one or more errors in FeatureRequestHelpers::typelessFeaturesImplimentation");
69 chainIDs.insert( chainID.
numeric() );
72 if (legMultiplicites.size() == 0) {
73 msg << MSG::ERROR <<
"chain " << chainID <<
" has invalid configuration, no parsed multiplicity data." <<
endmsg;
74 throw std::runtime_error(
"Encountered chain which could not be parsed in FeatureRequestHelpers::typelessFeaturesImplimentation");
75 }
else if (legMultiplicites.size() > 1) {
76 if (frd.
restrictRequestToLeg() >=
static_cast<int>(legMultiplicites.size()) && printWarningMessages) {
77 msg << MSG::WARNING <<
"Requested features from leg index " << frd.
restrictRequestToLeg() <<
" for chain " << chainID <<
78 " but this chain only has " << legMultiplicites.size() <<
" legs" <<
endmsg;
82 for (
size_t legNumeral = 0; legNumeral < legMultiplicites.size(); ++legNumeral) {
88 chainIDs.insert( legID.
numeric() );
91 if (
msg.level() <=
MSG::DEBUG)
msg <<
MSG::DEBUG <<
"Fetching navigation data for chain " << chainID <<
" with " << legMultiplicites.size() <<
" leg(s)." <<
endmsg;
103 msg <<
"Added all passed navigation data for chain " << chainID
104 <<
", total nodes:" << navGraph.
nodes() <<
" total edges:" << navGraph.
edges() <<
" final nodes:" << navGraph.
finalNodes().size() <<
endmsg;
111 if (frd.
condition() == TrigDefs::includeFailedDecisions) {
112 std::vector<const TrigCompositeUtils::Decision*> rejectedDecisionNodes =
116 msg <<
MSG::DEBUG <<
"Chain " << chainID <<
" has " << rejectedDecisionNodes.size()
117 <<
" dangling nodes in the graph from objects which were rejected." <<
endmsg;
126 msg <<
MSG::DEBUG <<
"Added all failed navigation data for chain " << chainID
127 <<
", total nodes:" << navGraph.
nodes() <<
" total edges:" << navGraph.
edges() <<
" final nodes:" << navGraph.
finalNodes().size() <<
endmsg;
133 <<
"Total nodes:" << navGraph.
nodes() <<
" total edges:" << navGraph.
edges() <<
" final nodes:" << navGraph.
finalNodes().size() <<
endmsg;
157 const EventContext& ctx,
160 std::vector<TrigCompositeUtils::TypelessLinkInfo> features;
161 std::set<const TrigCompositeUtils::NavGraphNode*> fullyExploredFrom;
182 std::vector<TrigCompositeUtils::TypelessLinkInfo>& features,
183 std::set<const TrigCompositeUtils::NavGraphNode*>& fullyExploredFrom,
189 const EventContext& ctx,
196 std::vector<sgkey_t> featureKeys;
197 std::vector<CLID> featureClids;
198 std::vector<TrigCompositeUtils::Decision::index_type> featureIndices;
201 std::vector<std::string> availableLinkNames;
203 const std::vector<std::string> getSingleLinkNames = decisionObj->
getObjectNames(clid);
205 std::copy(getSingleLinkNames.begin(), getSingleLinkNames.end(), std::back_inserter(availableLinkNames));
206 std::copy(getCollectionLinkNames.begin(), getCollectionLinkNames.end(), std::back_inserter(availableLinkNames));
208 availableLinkNames.push_back( frd.
linkName() );
212 for (
const std::string& featureNameToGet : availableLinkNames) {
215 #ifndef XAOD_STANDALONE
220 std::vector<sgkey_t> keyVec;
221 std::vector<CLID> clidVec;
222 std::vector<TrigCompositeUtils::Decision::index_type> indexVec;
225 std::copy(keyVec.begin(), keyVec.end(), std::back_inserter(featureKeys));
226 std::copy(clidVec.begin(), clidVec.end(), std::back_inserter(featureClids));
227 std::copy(indexVec.begin(), indexVec.end(), std::back_inserter(featureIndices));
229 #ifndef XAOD_STANDALONE
243 std::vector<sgkey_t> keyVec = {fKey};
244 std::vector<CLID> clidVec = {fClid};
245 std::vector<TrigCompositeUtils::Decision::index_type> indexVec = {fIndex};
247 std::copy(keyVec.begin(), keyVec.end(), std::back_inserter(featureKeys));
248 std::copy(clidVec.begin(), clidVec.end(), std::back_inserter(featureClids));
249 std::copy(indexVec.begin(), indexVec.end(), std::back_inserter(featureIndices));
251 #ifndef XAOD_STANDALONE
260 if (chainIDs.size() > 0) {
282 for (
size_t i = 0;
i < featureKeys.size(); ++
i) {
284 std::find_if(features.begin(), features.end(), [&](
const auto& li) { return li.key == featureKeys[i] and li.clid == featureClids[i] and li.index == featureIndices[i]; } );
285 if (vecIt == features.end()) {
287 features.emplace_back( decisionObj, featureKeys[
i], featureClids[
i], featureIndices[
i], state );
295 vecIt->decisions->insert(
ids.begin(),
ids.end());
306 if (fullyExploredFrom.count(seedNavNode) == 1) {
323 fullyExploredFrom.insert( navGraphNode );
328 std::vector<sgkey_t>& keyVec,
329 std::vector<CLID>& clidVec,
330 std::vector<TrigCompositeUtils::Decision::index_type>& indexVec,
331 [[maybe_unused]]
const EventContext& ctx,
337 std::vector<size_t> indicesToRemove;
338 for (
size_t i = 0;
i < keyVec.size(); ++
i) {
339 #ifdef XAOD_STANDALONE
340 const std::string keyStr = eventStore->event()->getName(keyVec[
i]);
341 const std::string* keyStrPtr = (keyStr.empty() ? nullptr : &keyStr);
348 if (not keyStrPtr or not std::regex_match(*keyStrPtr,
expression)) {
349 indicesToRemove.push_back(
i);
353 for (
auto it = indicesToRemove.rbegin();
it != indicesToRemove.rend(); ++
it) {
354 keyVec.erase(keyVec.begin() + *
it);
355 clidVec.erase(clidVec.begin() + *
it);
356 indexVec.erase(indexVec.begin() + *
it);