1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
#include <cassert>
#include <cmath>
#include <iostream>
#include "DataFormats/HGCalReco/interface/TICLLayerTile.h"
#define CATCH_CONFIG_MAIN
#include <catch.hpp>
using namespace ticl;
int countEntries(const TICLLayerTile &t, const std::array<int, 4> &limits) {
int entries = 0;
for (int e = limits[0]; e <= limits[1]; ++e) {
for (int p = limits[2]; p <= limits[3]; ++p) {
int phi = (p % TICLLayerTile::type::nPhiBins);
auto global_bin = t.globalBin(e, phi);
entries += t[global_bin].size();
}
}
return entries;
}
TEST_CASE("Check the correct phi wrapping", "searchBoxEtaPhi") {
auto constexpr phiBins = TICLLayerTile::type::nPhiBins;
auto constexpr phi_bin_width = 2. * M_PI / phiBins;
auto constexpr phi_transition_left = M_PI - phi_bin_width / 2.;
auto constexpr phi_transition_right = M_PI + phi_bin_width / 2.;
auto constexpr phi_transition_right2 = -M_PI + 3. * phi_bin_width / 2.;
auto constexpr phi_transition_right3 = M_PI + 3. * phi_bin_width / 2.;
unsigned int constexpr entries_left = 11;
unsigned int constexpr entries_right = 7;
float constexpr eta = 2.0f;
float constexpr eta_neg = -2.4f;
TICLLayerTile t, t2, t_neg;
std::cout << "Testing a Tile with " << phiBins << " bins with binwidth: " << phi_bin_width << " at bin transition"
<< std::endl;
std::cout << "Filling left-pi bin: " << t.phiBin(phi_transition_left) << std::endl;
std::cout << "Filling right-pi bin: " << t.phiBin(phi_transition_right) << std::endl;
std::cout << "Filling right2-pi bin: " << t.phiBin(phi_transition_right2) << std::endl;
std::cout << "Filling right3-pi bin: " << t.phiBin(phi_transition_right3) << std::endl;
for (unsigned int i = 0; i < entries_left; ++i) {
t.fill(eta, phi_transition_left, i);
t2.fill(eta, phi_transition_left, i);
t_neg.fill(eta_neg, phi_transition_left, i);
}
for (unsigned int i = 0; i < entries_right; ++i) {
t.fill(eta, phi_transition_right, i);
t2.fill(eta, phi_transition_right2, i);
t_neg.fill(eta_neg, phi_transition_right, i);
}
SECTION("Phi bins from positive and negative pi") {
REQUIRE(t.phiBin(phi_transition_right2) == t.phiBin(phi_transition_right3));
}
SECTION("Symmetric case around pi") {
auto limits = t.searchBoxEtaPhi(1.95, 2.05, phi_transition_left, phi_transition_right);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] <= limits[1]);
REQUIRE(limits[2] <= limits[3]);
auto entries = countEntries(t, limits);
REQUIRE(entries == entries_left + entries_right);
}
SECTION("Asymmetric case around pi, negative") {
auto limits = t2.searchBoxEtaPhi(1.95, 2.05, phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] <= limits[1]);
REQUIRE(limits[2] <= limits[3]);
auto entries = countEntries(t2, limits);
REQUIRE(entries == entries_left + entries_right);
}
SECTION("Asymmetric case around pi, positive") {
auto limits = t2.searchBoxEtaPhi(1.95, 2.05, phi_transition_left, phi_transition_right3);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] <= limits[1]);
REQUIRE(limits[2] <= limits[3]);
auto entries = countEntries(t2, limits);
REQUIRE(entries == entries_left + entries_right);
}
SECTION("Correct all negative eta searchRange") {
auto limits = t_neg.searchBoxEtaPhi(-2.45, -2.35, phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] <= limits[1]);
REQUIRE(limits[2] <= limits[3]);
auto entries = countEntries(t_neg, limits);
REQUIRE(entries == entries_left + entries_right);
}
SECTION("Correct all positive overflow eta searchRange") {
auto limits = t.searchBoxEtaPhi(0., 5., phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] <= limits[1]);
REQUIRE(limits[2] <= limits[3]);
auto entries = countEntries(t, limits);
REQUIRE(entries == entries_left + entries_right);
}
SECTION("Wrong mixed signs (neg,pos) eta searchRange") {
auto limits = t.searchBoxEtaPhi(-2.05, 1.95, phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] == limits[1]);
REQUIRE(limits[2] == limits[3]);
REQUIRE(limits[0] == 0);
REQUIRE(limits[2] == 0);
auto entries = countEntries(t, limits);
REQUIRE(entries == 0);
}
SECTION("Wrong mixed signs (pos,neg) eta searchRange") {
auto limits = t.searchBoxEtaPhi(2.05, -1.95, phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] == limits[1]);
REQUIRE(limits[2] == limits[3]);
REQUIRE(limits[0] == 0);
REQUIRE(limits[2] == 0);
auto entries = countEntries(t, limits);
REQUIRE(entries == 0);
}
SECTION("Wrong all positive eta searchRange") {
auto limits = t.searchBoxEtaPhi(2.05, 1.95, phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] == limits[1]);
REQUIRE(limits[2] == limits[3]);
REQUIRE(limits[0] == 0);
REQUIRE(limits[2] == 0);
auto entries = countEntries(t, limits);
REQUIRE(entries == 0);
}
SECTION("Wrong all negative eta searchRange") {
auto limits = t.searchBoxEtaPhi(-1.95, -2.05, phi_transition_left, phi_transition_right2);
std::cout << "Limits are: " << limits[0] << " " << limits[1] << " " << limits[2] << " " << limits[3] << std::endl;
REQUIRE(limits[0] == limits[1]);
REQUIRE(limits[2] == limits[3]);
REQUIRE(limits[0] == 0);
REQUIRE(limits[2] == 0);
auto entries = countEntries(t, limits);
REQUIRE(entries == 0);
}
}
|