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)
81 ATH_MSG_DEBUG(
"Begin testing chain " << chain << (chainPassed ?
" and will dive into details as the chain passed " :
" but will not do anything as the chain did not pass"));
82 if (!chainPassed)
continue;
85 bool isExcluded =
false;
87 if (chain == excludedChain) {
104 ATH_MSG_DEBUG(
"###### checking features of CHAIN " << chain);
106 auto combsRun2 = vectorToSet(vecCombinationsRun2);
109 if (combsRun2.size() == 0)
111 ATH_MSG_DEBUG(
"Chain " << chain <<
" testing discarded due to detected Run 2 size == 0");
114 for (
auto& c : combsRun2 ) {
119 auto combsRun3 = vectorToSet(vecCombinationsRun3);
123 ATH_MSG_DEBUG(
"Both, Run2 and Run3 combinations are effectively empty");
128 for (
auto& c : combsRun3 ) {
144 return StatusCode::SUCCESS;
149 std::set<const xAOD::IParticle*> particlesRun3;
150 for (
auto l: run3) {
151 if ( l.link.isValid() )
152 particlesRun3.insert(*(l.link));
157 std::set<const xAOD::IParticle*> particlesRun2;
158 for (
auto& comb: vecCombinationsRun2) {
159 for (
auto el: comb) {
160 particlesRun2.insert(el);
164 for (
auto f2: particlesRun2 ) {
166 for (
auto f3: particlesRun3 ) {
172 ATH_MSG_ERROR(
"Missing feature in Run 3 that is present in Run 2 " << f2 <<
" chain " << chain <<
" enable DEBUG to see more details" );
174 return StatusCode::FAILURE;
178 return StatusCode::SUCCESS;
183 if (run2.size() > run3.size()) {
185 <<
" using Run 2 navigation " << run2.size()
186 <<
" Run 3 navigation " << run3.size());
187 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");
189 return StatusCode::FAILURE;
192 return StatusCode::SUCCESS;
200 auto isSubsetPresent = [](
const std::set<xAODParticle*>& subset,
const CombinationsSet& run2) {
201 for (
const auto& setInRun2 : run2) {
203 bool allFound =
true;
204 for (
auto particle : subset) {
205 if (setInRun2.find(particle) == setInRun2.end()) {
210 if (allFound)
return true;
217 for (
const auto& subset : run3) {
218 if (isSubsetPresent(subset, run2)) {
225 bool result {
false };
232 result = isAnySubsetPresent(run3, run2);
235 result = isAnySubsetPresent(run2, run3);
251 return StatusCode::FAILURE;
255 return StatusCode::SUCCESS;
260 for (
const std::vector<const xAOD::IParticle*>& outerc: combs )
261 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
static const unsigned int allowResurrectedDecision
static const unsigned int Physics
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.