9#include <gtest/gtest.h>
12#include <tracking/trackFindingVXD/filterMap/filterFramework/Shortcuts.h>
21namespace VXDTFfilterTest {
27 spacePoint(
float x,
float y,
float z): tuple<float, float, float>(x, y, z)
40 static const std::string
name(
void) {
return "SquaredDistance3D"; };
46 pow(get<0>(p1) - get<0>(p2), 2) +
47 pow(get<1>(p1) - get<1>(p2), 2) +
48 pow(get<2>(p1) - get<2>(p2), 2) ;
57 static const std::string
name(
void) {
return "SquaredDistance2Dxy"; };
63 pow(get<0>(p1) - get<0>(p2), 2) +
64 pow(get<1>(p1) - get<1>(p2), 2) ;
73 static const std::string
name(
void) {
return "SquaredDistance1Dx"; };
79 pow(get<0>(p1) - get<0>(p2), 2);
88 static const std::string
name(
void) {
return "BooleanVariable"; };
94 get<0>(p1) - get<0>(p2) == 0.;
100 template <
class T>
class counter {
127 template<
class Var,
typename ... otherTypes>
129 const otherTypes& ...)
148 EXPECT_TRUE(range.contains(0.5));
149 EXPECT_FALSE(range.contains(-1.));
150 EXPECT_FALSE(range.contains(0.));
151 EXPECT_FALSE(range.contains(1.));
152 EXPECT_FALSE(range.contains(2.));
153 EXPECT_EQ(0., range.getInf());
154 EXPECT_EQ(1., range.getSup());
162 EXPECT_TRUE(range.contains(0.5));
163 EXPECT_FALSE(range.contains(-1.));
164 EXPECT_TRUE(range.contains(0.));
165 EXPECT_TRUE(range.contains(1.));
166 EXPECT_FALSE(range.contains(2.));
167 EXPECT_EQ(0., range.getInf());
168 EXPECT_EQ(1., range.getSup());
176 UpperBoundedSet<double> upperBoundedSet(0.);
177 EXPECT_TRUE(upperBoundedSet.contains(-1.));
178 EXPECT_FALSE(upperBoundedSet.contains(0.));
179 EXPECT_FALSE(upperBoundedSet.contains(1.));
180 EXPECT_EQ(0., upperBoundedSet.getSup());
187 ClosedUpperBoundedSet<double> upperBoundedSet(0.);
188 EXPECT_TRUE(upperBoundedSet.contains(-1.));
189 EXPECT_TRUE(upperBoundedSet.contains(0.));
190 EXPECT_FALSE(upperBoundedSet.contains(1.));
191 EXPECT_EQ(0., upperBoundedSet.getSup());
199 LowerBoundedSet<double> lowerBoundedSet(0.);
200 EXPECT_TRUE(lowerBoundedSet.contains(1.));
201 EXPECT_FALSE(lowerBoundedSet.contains(0.));
202 EXPECT_FALSE(lowerBoundedSet.contains(-1.));
203 EXPECT_EQ(0., lowerBoundedSet.getInf());
210 ClosedLowerBoundedSet<double> lowerBoundedSet(0.);
211 EXPECT_TRUE(lowerBoundedSet.contains(1.));
212 EXPECT_TRUE(lowerBoundedSet.contains(0.));
213 EXPECT_FALSE(lowerBoundedSet.contains(-1.));
214 EXPECT_EQ(0., lowerBoundedSet.getInf());
230 Filter< SquaredDistance3D, Range<double, double>, VoidObserver >
filter(Range<double, double>(0., 1.));
236 EXPECT_TRUE(
filter.accept(x1, x2));
237 EXPECT_FALSE(
filter.accept(x1, x3));
246 Filter< SquaredDistance3D, Range<double, double>, VoidObserver > unobservedFilter(Range<double, double>(0., 1.));
248 Filter< SquaredDistance3D, Range<double, double>,
Observer >
filter(unobservedFilter);
254 EXPECT_TRUE(
filter.accept(x1, x2));
255 EXPECT_FALSE(
filter.accept(x1, x3));
279 dummyFilter.accept(x1, x2);
280 dummyFilter.accept(x1, x3);
290 auto observedDummyFilter = dummyFilter.observe(
Observer());
291 observedDummyFilter.accept(x1, x2);
292 observedDummyFilter.accept(x1, x3);
304 bool bypassControl(
false);
306 Filter< SquaredDistance3D, Range<double, double>,
Observer > nonBypassableFilter(Range<double, double>(0., 1.));
307 auto filter = nonBypassableFilter.bypass(bypassControl);
312 EXPECT_FALSE(
filter.accept(x1, x2));
319#ifndef __clang_analyzer__
320 bypassControl =
true;
322 EXPECT_TRUE(
filter.accept(x1, x2));
338 EXPECT_TRUE(filterSup.accept(x1, x2));
339 EXPECT_FALSE(filterSup.accept(x1, x4));
340 EXPECT_FALSE(filterSup.accept(x1, x3));
343 EXPECT_TRUE(filterMax.accept(x1, x2));
344 EXPECT_TRUE(filterMax.accept(x1, x4));
345 EXPECT_FALSE(filterMax.accept(x1, x3));
349 EXPECT_TRUE(filterSup2.accept(x1, x2));
350 EXPECT_FALSE(filterSup2.accept(x1, x3));
351 EXPECT_FALSE(filterSup2.accept(x1, x4));
354 EXPECT_TRUE(filterMax2.accept(x1, x2));
355 EXPECT_FALSE(filterMax2.accept(x1, x3));
356 EXPECT_TRUE(filterMax2.accept(x1, x4));
359 EXPECT_TRUE(filterInf.accept(x1, x3));
360 EXPECT_FALSE(filterInf.accept(x1, x2));
361 EXPECT_FALSE(filterInf.accept(x1, x4));
364 EXPECT_TRUE(filterMin.accept(x1, x3));
365 EXPECT_FALSE(filterMin.accept(x1, x2));
366 EXPECT_TRUE(filterMin.accept(x1, x4));
369 EXPECT_TRUE(filterInf2.accept(x1, x3));
370 EXPECT_FALSE(filterInf2.accept(x1, x2));
371 EXPECT_FALSE(filterInf2.accept(x1, x4));
374 EXPECT_TRUE(filterMin2.accept(x1, x3));
375 EXPECT_FALSE(filterMin2.accept(x1, x2));
376 EXPECT_TRUE(filterMin2.accept(x1, x4));
379 EXPECT_FALSE(filterRange.accept(x1, x1));
380 EXPECT_TRUE(filterRange.accept(x1, x2));
381 EXPECT_FALSE(filterRange.accept(x1, x3));
382 EXPECT_FALSE(filterRange.accept(x1, x4));
386 EXPECT_TRUE(filterClosedRange.accept(x1, x1));
387 EXPECT_TRUE(filterClosedRange.accept(x1, x2));
388 EXPECT_FALSE(filterClosedRange.accept(x1, x3));
389 EXPECT_TRUE(filterClosedRange.accept(x1, x4));
404 EXPECT_TRUE(
filter.accept(x1, x2));
405 EXPECT_TRUE(
filter.accept(x1, x1));
406 EXPECT_FALSE(
filter.accept(x1, x3));
412 EXPECT_TRUE(filter2.accept(x1, x2));
413 EXPECT_FALSE(filter2.accept(x1, x1));
414 EXPECT_FALSE(filter2.accept(x1, x3));
421 EXPECT_FALSE(filter3.accept(x1, x2));
422 EXPECT_TRUE(filter3.accept(x1, x1));
423 EXPECT_TRUE(filter3.accept(x1, x3));
443 EXPECT_FALSE(
filter.accept(x1, x3));
450 EXPECT_TRUE(
filter.accept(x1, x1));
467 EXPECT_TRUE(filter1.accept(x1, x1));
468 EXPECT_FALSE(filter1.accept(x1, x2));
471 EXPECT_FALSE(filter2.accept(x1, x1));
472 EXPECT_TRUE(filter2.accept(x1, x2));
Represents a closed set of arithmetic types.
Represents a range of arithmetic types.
VoidObserver()
An empty constructor for an empty class.
a small filter illustrating the behavior of a filter which is compatible with boolean comparisons
static float value(const spacePoint &p1, const spacePoint &p2)
value function does the actual calculation of this class.
static const std::string name(void)
return name of the class
Test class for Filter object.
this observer does simply count the number of times, the attached Filter was used
static void notify(const Var &, const otherTypes &...)
notify function is called by the filter, this one increases the counter.
a small filter illustrating the behavior of a distance1D-filter in X
static float value(const spacePoint &p1, const spacePoint &p2)
value function does the actual calculation of this class.
static const std::string name(void)
return name of the class
a small filter illustrating the behavior of a distance2D-filter in XY
static float value(const spacePoint &p1, const spacePoint &p2)
value function does the actual calculation of this class.
static const std::string name(void)
return name of the class
a small filter illustrating the behavior of a distance3D-filter
static float value(const spacePoint &p1, const spacePoint &p2)
value function does the actual calculation of this class.
static const std::string name(void)
return name of the class
just a small proto-container storing coordinates
spacePoint(const spacePoint &)=delete
private copy constructor to test that all the arguments are passed by reference.
spacePoint(float x, float y, float z)
Constructor accepting coordinates.
std::map< ExpRun, std::pair< double, double > > filter(const std::map< ExpRun, std::pair< double, double > > &runs, double cut, std::map< ExpRun, std::pair< double, double > > &runsRemoved)
filter events to remove runs shorter than cut, it stores removed runs in runsRemoved
Abstract base class for different kinds of events.