ATLAS Offline Software
Loading...
Searching...
No Matches
PdgConditional.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "PdgConditional.h"
6#include <cmath>//for std::abs
7
8
9namespace DerivationFramework {
14 //nop
15 }
16 PdgConditional::PdgConditional(unsigned equalInt):m_condition(equalInt){
17 //nop
18 }
19
20 PdgConditional::PdgConditional(std::function<bool(int)> b):m_condition(b){
21 //nop
22 }
23
24 bool
26 //compare with the held integer
27 if (std::holds_alternative<int>(m_condition)){
28 auto rawValue = std::get<0>(m_condition);
29 return v == rawValue;
30 }
31 //use abs(value) if the held integer is unsigned
32 if (std::holds_alternative<unsigned>(m_condition)){
33 auto rawValue = std::get<1>(m_condition);
34 return unsigned(std::abs(v)) == rawValue;
35 }
36 //otherwise use user-defined binary predicate
37 return std::get<2>(m_condition)(v);
38 }
39
40}
const std::variant< int, unsigned, std::function< bool(int)> > m_condition
THE reconstruction tool.