ATLAS Offline Software
Loading...
Searching...
No Matches
eEmSelector.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "./eEmSelector.h"
6#include <sstream>
7
8namespace GlobalSim {
9
10 class lt: public ICutter {
11 public:
12 lt(const ulong& c): m_cut(c) {}
13 virtual bool cut(const ulong& v) const override {
14 return v < m_cut;
15 };
16
17 virtual std::string to_string() const override {
18 std::stringstream ss;
19 ss << "cut: " << m_cut << " op: < ";
20 return ss.str();
21 }
22
23 private:
24 ulong m_cut;
25 };
26
27 class leq: public ICutter {
28 public:
29 leq(const ulong& c): m_cut(c) {}
30 virtual bool cut(const ulong& v) const override {
31 return v <= m_cut;
32 };
33
34 virtual std::string to_string() const override {
35 std::stringstream ss;
36 ss << "cut: " << m_cut << " op: <= ";
37 return ss.str();
38 }
39
40 private:
41 ulong m_cut;
42 };
43
44 class gt: public ICutter {
45 public:
46 gt(const ulong& c): m_cut(c) {}
47 virtual bool cut(const ulong& v) const override {
48 return v > m_cut;
49 };
50
51 virtual std::string to_string() const override {
52 std::stringstream ss;
53 ss << "cut: " << m_cut << " op: > ";
54 return ss.str();
55 }
56
57 private:
58 ulong m_cut;
59 };
60
61
62 class geq: public ICutter {
63 public:
64 geq(const ulong& c): m_cut(c) {}
65 virtual bool cut(const ulong& v) const override {
66 return v >= m_cut;
67 };
68
69 virtual std::string to_string() const override {
70 std::stringstream ss;
71 ss << "cut: " << m_cut << " op: >= ";
72 return ss.str();
73 }
74
75 private:
76 ulong m_cut;
77 };
78
79
80
81
82 std::unique_ptr<ICutter> make_cutter(const ulong& cut,
83 const std::string& op) {
84
85 auto cutter = std::unique_ptr<ICutter>(nullptr);
86
87 if (op == ">"){
88 cutter.reset(new gt(cut));
89 } else if (op == ">="){
90 cutter.reset(new geq(cut));
91 } else if (op == "<"){
92 cutter.reset(new lt(cut));
93 } else if (op == "<="){
94 cutter.reset(new leq(cut));
95 } else {
96 throw std::invalid_argument("unown operator " + op);
97 }
98
99
100
101 return cutter;
102 }
103
104 using namespace GlobalSim::IOBitwise;
105
107 const std::string& rhad_op,
108 ulong reta_cut,
109 const std::string& reta_op,
110 ulong wstot_cut,
111 const std::string& wstot_op) :
112 m_rhad_cutter{make_cutter(rhad_cut, rhad_op)},
113 m_reta_cutter{make_cutter(reta_cut, reta_op)},
114 m_wstot_cutter{make_cutter(wstot_cut, wstot_op)}{
115 }
116
117
118 bool eEmSelector::select(const IeEmTOB& tob) const {
119
120 if(!m_rhad_cutter->cut(tob.RHad_bits().to_ulong())) {return false;}
121 if(!m_reta_cutter->cut(tob.REta_bits().to_ulong())) {return false;}
122 if(!m_wstot_cutter->cut(tob.WsTot_bits().to_ulong())) {return false;}
123
124 return true;
125 };
126
127
128 std::string eEmSelector::to_string() const {
129
130 auto ss = std::stringstream();
131 ss << "rhad cutter: " << m_rhad_cutter->to_string() << ' '
132 << "reta cutter: " << m_reta_cutter->to_string() << ' '
133 << "wstot cutter: " << m_wstot_cutter->to_string();
134 return ss.str();
135 };
136
137
138}
static Double_t ss
Class to hold eFexROI TOB bits.
Definition IeEmTOB.h:29
virtual const std::bitset< s_RHad_width > & RHad_bits() const =0
Returns the eFexRoI Rhad threshold bits.
virtual const std::bitset< s_WsTot_width > & WsTot_bits() const =0
Returns the eFexRoI Wstot threshold bits.
virtual const std::bitset< s_REta_width > & REta_bits() const =0
Returns the eFexRoI REta threshold bits.
virtual std::string to_string() const override
std::unique_ptr< ICutter > m_wstot_cutter
Definition eEmSelector.h:53
std::unique_ptr< ICutter > m_rhad_cutter
Definition eEmSelector.h:51
virtual bool select(const IeEmTOB &) const override
eEmSelector()=default
Passes all.
std::unique_ptr< ICutter > m_reta_cutter
Definition eEmSelector.h:52
virtual bool cut(const ulong &v) const override
virtual std::string to_string() const override
geq(const ulong &c)
virtual std::string to_string() const override
gt(const ulong &c)
virtual bool cut(const ulong &v) const override
virtual bool cut(const ulong &v) const override
virtual std::string to_string() const override
leq(const ulong &c)
lt(const ulong &c)
virtual bool cut(const ulong &v) const override
virtual std::string to_string() const override
AlgTool that to test whether expected the TIP values generated by data supplied by eEmMultTestBench c...
std::unique_ptr< ICutter > make_cutter(const ulong &cut, const std::string &op)