5#include <GaudiKernel/StatusCode.h>
16 std::set<std::set<const xAOD::IParticle *>> vectorToSet(
17 const std::vector<std::vector<const xAOD::IParticle *>>&
vec)
19 std::set<std::set<const xAOD::IParticle *>> ret;
20 for (
const std::vector<const xAOD::IParticle *> &combination :
vec)
21 ret.emplace(combination.begin(), combination.end());
31 <<
"type = " << p->type() <<
", "
32 <<
"pt = " << p->pt() <<
", "
33 <<
"eta = " << p->eta() <<
", "
34 <<
"phi = " << p->phi() <<
", "
35 <<
"ptr = " <<
reinterpret_cast<const void*
>(p)
44 std::ostream &
operator<<(std::ostream &os,
const std::set<T> &s)
47 for (
auto itr = s.begin(); itr != s.end(); ++itr)
73 return StatusCode::SUCCESS;
78 for (
const std::string &chain :
m_chains)
80 ATH_MSG_DEBUG(
"Begin testing chain " << chain << (
m_tdt->isPassed(chain) ?
" and will dive into details as the chain passed " :
" but will not do anything as the chain did not pass"));
81 if (!
m_tdt->isPassed(chain))
continue;
84 bool isExcluded =
false;
86 if (chain == excludedChain) {
103 ATH_MSG_DEBUG(
"###### checking features of CHAIN " << chain);
105 auto combsRun2 = vectorToSet(vecCombinationsRun2);
108 if (combsRun2.size() == 0)
110 ATH_MSG_DEBUG(
"Chain " << chain <<
" testing discarded due to detected Run 2 size == 0");
113 for (
auto& c : combsRun2 ) {
118 auto combsRun3 = vectorToSet(vecCombinationsRun3);
122 ATH_MSG_DEBUG(
"Both, Run2 and Run3 combinations are effectively empty");
127 for (
auto& c : combsRun3 ) {
143 return StatusCode::SUCCESS;
148 std::set<const xAOD::IParticle*> particlesRun3;
149 for (
auto l: run3) {
150 if ( l.link.isValid() )
151 particlesRun3.insert(*(l.link));
156 std::set<const xAOD::IParticle*> particlesRun2;
157 for (
auto& comb: vecCombinationsRun2) {
158 for (
auto el: comb) {
159 particlesRun2.insert(el);
163 for (
auto f2: particlesRun2 ) {
165 for (
auto f3: particlesRun3 ) {
171 ATH_MSG_ERROR(
"Missing feature in Run 3 that is present in Run 2 " << f2 <<
" chain " << chain <<
" enable DEBUG to see more details" );
173 return StatusCode::FAILURE;
177 return StatusCode::SUCCESS;
182 if (run2.size() > run3.size()) {
184 <<
" using Run 2 navigation " << run2.size()
185 <<
" Run 3 navigation " << run3.size());
186 ATH_MSG_WARNING(
"Mismatched sizes of combinations for chain " << chain <<
" (enable WARNING messages for more details), this may be a false positive if chain is incorrectly decoded");
188 return StatusCode::FAILURE;
191 return StatusCode::SUCCESS;
199 auto isSubsetPresent = [](
const std::set<xAODParticle*>& subset,
const CombinationsSet& run2) {
200 for (
const auto& setInRun2 : run2) {
202 bool allFound =
true;
203 for (
auto particle : subset) {
204 if (setInRun2.find(particle) == setInRun2.end()) {
209 if (allFound)
return true;
216 for (
const auto& subset : run3) {
217 if (isSubsetPresent(subset, run2)) {
231 result = isAnySubsetPresent(run3, run2);
234 result = isAnySubsetPresent(run2, run3);
250 return StatusCode::FAILURE;
254 return StatusCode::SUCCESS;
259 for (
const std::vector<const xAOD::IParticle*>& outerc: combs )
260 counter += outerc.size();
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
std::vector< size_t > vec
An algorithm that can be simultaneously executed in multiple threads.
StatusCode verifyFlatContent(const std::string &chain) const
PublicToolHandle< Trig::TrigDecisionTool > m_tdtRun3
StatusCode verifyCombinationsSize(const CombinationsVector &run2, const CombinationsVector &run3, const std::string &chain) const
PublicToolHandle< Trig::TrigDecisionTool > m_tdtRun2
PublicToolHandle< Trig::TrigDecisionTool > m_tdt
ToolHandle< Trig::IIParticleRetrievalTool > m_toolRun3
std::vector< std::vector< const xAOD::IParticle * > > CombinationsVector
StatusCode execute(const EventContext &context) const override
StatusCode initialize() override
std::set< std::set< const xAOD::IParticle * > > CombinationsSet
StatusCode verifyCombinationsContent(const CombinationsSet &run2, const CombinationsSet &run3, const std::string &chain) const
Gaudi::Property< bool > m_verifyCombinations
Gaudi::Property< bool > m_verifyCombinationsSize
Gaudi::Property< bool > m_failOnDifference
bool combinationsEmpty(const CombinationsVector &combs) const
ToolHandle< Trig::IIParticleRetrievalTool > m_toolRun2
Gaudi::Property< std::vector< std::string > > m_chains
NavigationTesterAlg(const std::string &name, ISvcLocator *pSvcLocator)
Class providing the definition of the 4-vector interface.
std::vector< int > multiplicities(const std::string &chain)
const std::regex gammaXeChain
const std::regex specialElMuChain
const std::vector< std::string > excludedChains
const std::regex specialEchain
const std::regex mu2MunoL1Special
The common trigger namespace for trigger analysis tools.
ostream & operator<<(ostream &s, const SG::VarHandleKey &m)
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
std::ostream & operator<<(std::ostream &out, const std::pair< FIRST, SECOND > &pair)
Helper print operator.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.