21 m_trigDecTool.setTypeAndName(
"Trig::TrigDecisionTool/TrigDecisionTool");
31 return StatusCode::SUCCESS;
35 const std::vector<const xAOD::IParticle *> &recoObjects,
36 std::string_view chain,
37 double matchThreshold,
40 if (recoObjects.size() == 0)
45 using VecLinkInfo_t = std::vector<IPartLinkInfo_t>;
55 std::vector<std::map<std::pair<uint32_t, uint32_t>,
bool>> cachedComparisons(recoObjects.size());
86 features.insert(features.end(), subfeatures.begin(), subfeatures.end());
87 ATH_MSG_DEBUG(
"Added " << subfeatures.size() <<
" subfeatures for chain " << chainName);
94 for (IPartLinkInfo_t &linkInfo : features)
96 if (!linkInfo.isValid())
98 ATH_MSG_ERROR(
"Chain " << chainName <<
" has invalid link info!");
99 throw std::runtime_error(
"Bad link info");
111 if (combinations.size() < recoObjects.size())
114 "Chain " << chainName <<
" (matching pattern " << chain <<
") has too few objects ("
115 << combinations.size() <<
") to match the number of provided reco objects (" << recoObjects.size() <<
")");
119 for (
const VecLinkInfo_t &combination : combinations)
122 std::vector<std::size_t> onlineIndices(combination.size());
123 std::iota(onlineIndices.begin(), onlineIndices.end(), 0);
127 for (std::size_t recoIdx = 0; recoIdx < recoObjects.size(); ++recoIdx)
129 std::size_t onlineIdx = onlineIndices[recoIdx];
131 recoObjects[recoIdx],
132 combination[onlineIdx].link,
133 chainInfo.second[onlineIdx],
134 cachedComparisons[recoIdx],
143 }
while (std::next_permutation(onlineIndices.begin(), onlineIndices.end()));
153 std::string_view chain,
154 double matchThreshold,
157 std::vector<const xAOD::IParticle *> tmpVec{&recoObject};
158 return match(tmpVec, chain, matchThreshold, rerun);
165 std::map<std::pair<uint32_t, uint32_t>,
bool> &cache,
166 double scoreThreshold)
const
173 std::pair<uint32_t, uint32_t> linkIndices(onlineLink.
persKey(), onlineLink.
persIndex());
174 auto cacheItr = cache.find(linkIndices);
175 if (cacheItr == cache.end())
178 ATH_MSG_DEBUG(
"Match online " << onlineType <<
" to offline " << reco->type());
179 bool match = onlineType == reco->type();
187 throw std::runtime_error(
"Failed to cast to egamma object");
192 ATH_MSG_WARNING(
"Cannot retrieve egamma object's primary calorimeter cluster, will match to the egamma object");
198 cacheItr = cache.insert(std::make_pair(linkIndices,
match)).first;
200 return cacheItr->second;
205 std::lock_guard<std::mutex> guard(m_chainInfoMutex);
206 auto cacheItr = m_chainInfoCache.find(chain);
207 if (cacheItr == m_chainInfoCache.end())
216 info.first.push_back(0);
220 info.first.push_back(legInfo.multiplicity);
221 for (std::size_t idx = 0; idx < legInfo.multiplicity; ++idx)
222 info.second.push_back(
type);
225 cacheItr = m_chainInfoCache.insert(std::make_pair(chain, std::move(info))).first;
227 return cacheItr->second;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Helper class that provides access to information about individual legs.
stored_index_type persIndex() const
Return the index of the link.
sgkey_t persKey() const
Return the SG key that we reference, as a hash.
ElementLink implementation for ROOT usage.
bool isValid() const
Check if the element can be found.
std::vector< std::string > getListOfTriggers() const
FeatureRequestDescriptor & setLinkName(const std::string &navElementLinkKey)
Set the Link Name Key.
Class providing the definition of the 4-vector interface.
Combinations buildCombinations(const std::string &chainName, const std::vector< LinkInfo< xAOD::IParticleContainer > > &features, const std::vector< std::size_t > &legMultiplicities, const IPartCombItr::FilterFunc_t &filter)
Produce the combinations for a set of features.
@ UniqueObjects
Do not allow any repeated objects.
static const unsigned int allowResurrectedDecision
static const unsigned int Physics
The common trigger namespace for trigger analysis tools.
ObjectType
Type of objects that have a representation in the xAOD EDM.
@ Photon
The object is a photon.
@ Other
An object not falling into any of the other categories.
@ CaloCluster
The object is a calorimeter cluster.
@ TruthParticle
The object is a truth particle.
@ Electron
The object is an electron.
Egamma_v1 Egamma
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.
Struct containing information on each leg of a chain.
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...