ATLAS Offline Software
Loading...
Searching...
No Matches
SignEnums.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#ifndef EVENT_SELECTOR_SIGN_ENUMS_H
8#define EVENT_SELECTOR_SIGN_ENUMS_H
9
10#include <stdexcept>
11#include <map>
12
14
15namespace SignEnum {
16
25
27 static const std::map<std::string, ComparisonOperator> stringToOperator = {
28 {"LT", ComparisonOperator::LT}, // <
29 {"GT", ComparisonOperator::GT}, // >
30 {"EQ", ComparisonOperator::EQ}, // ==
31 {"GE", ComparisonOperator::GE}, // >=
32 {"LE", ComparisonOperator::LE} // <=
33 };
34
36 template <typename T>
38 switch (sign) {
40 return test < reference;
42 return test > reference;
44 return test == reference;
46 return test >= reference;
48 return test <= reference;
49 }
50 throw std::runtime_error("SignEnum::checkValue did not recognise the sign argument! Make sure it is listed within SignEnum::ComparisonOperator.");
51 }
52
53} // namespace SignEnum
54
55#endif // EVENT_SELECTOR_SIGN_ENUMS_H
int sign(int a)
the conversion key for comparison operators for Event Selection Algorithms
Definition SignEnums.h:15
bool checkValue(T reference, ComparisonOperator sign, T test)
the comparison test given the specified sign and two test values
Definition SignEnums.h:37
ComparisonOperator
all possible comparison user inputs
Definition SignEnums.h:18
static const std::map< std::string, ComparisonOperator > stringToOperator
the map between user inputs and comparison operators
Definition SignEnums.h:27