9 #include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
10 #include <gtest/gtest.h>
20 namespace SoftwareTrigger {
28 SoftwareTriggerObject object;
30 auto cut = SoftwareTriggerCut::compile(
"1 == 1", 1,
false);
31 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, cut->checkPreScaled(
object));
33 cut = SoftwareTriggerCut::compile(
"1 == 1", 1,
true);
34 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, cut->checkPreScaled(
object));
36 cut = SoftwareTriggerCut::compile(
"-1 == 1", 1,
false);
37 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, cut->checkPreScaled(
object));
39 cut = SoftwareTriggerCut::compile(
"-1 == 1", 1,
true);
40 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, cut->checkPreScaled(
object));
44 TEST_F(SoftwareTriggerCutTest, prescalingRandom)
47 SoftwareTriggerObject object;
50 auto cut = SoftwareTriggerCut::compile(
"1 == 1", 0,
false);
51 for (
unsigned int i = 0; i < 1e3; i++) {
52 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, cut->checkPreScaled(
object));
56 cut = SoftwareTriggerCut::compile(
"1 == 1", 0,
true);
57 for (
unsigned int i = 0; i < 1e3; i++) {
58 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, cut->checkPreScaled(
object));
61 cut = SoftwareTriggerCut::compile(
"1 == 1", 1,
true);
62 for (
unsigned int i = 0; i < 1e3; i++) {
63 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, cut->checkPreScaled(
object));
66 cut = SoftwareTriggerCut::compile(
"1 == 1", 1);
67 for (
unsigned int i = 0; i < 1e3; i++) {
68 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, cut->checkPreScaled(
object));
71 cut = SoftwareTriggerCut::compile(
"1 == 1", 10);
73 unsigned int numberOfYes = 0;
74 unsigned int numberOfNo = 0;
75 for (
unsigned int i = 0; i < 1e4; i++) {
76 const auto cutResult = cut->checkPreScaled(
object);
77 EXPECT_NE(SoftwareTriggerCutResult::c_reject, cutResult);
79 if (cutResult == SoftwareTriggerCutResult::c_accept) {
81 }
else if (cutResult == SoftwareTriggerCutResult::c_noResult) {
87 EXPECT_EQ(numberOfYes, 1022);
88 EXPECT_EQ(numberOfNo, 1e4 - 1022);
92 TEST_F(SoftwareTriggerCutTest, prescalingCounter)
95 SoftwareTriggerObject object;
98 auto cut = SoftwareTriggerCut::compile(
"1 == 1", 0,
false);
99 for (uint32_t i = 0; i < 1e3; i++) {
100 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, cut->check(
object).first);
104 cut = SoftwareTriggerCut::compile(
"1 == 1", 0,
true);
105 for (uint32_t i = 0; i < 1e3; i++) {
106 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, cut->check(
object).first);
109 cut = SoftwareTriggerCut::compile(
"1 == 1", 1,
true);
110 for (uint32_t i = 0; i < 1e3; i++) {
111 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, cut->check(
object).first);
114 cut = SoftwareTriggerCut::compile(
"1 == 1", 1);
115 for (uint32_t i = 0; i < 1e3; i++) {
116 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, cut->check(
object).first);
120 cut = SoftwareTriggerCut::compile(
"1 == 1", 10);
121 uint32_t counter = 0;
122 uint32_t numberOfYes = 0;
123 uint32_t numberOfNo = 0;
125 for (uint32_t i = 0; i < 729; i++) {
126 const auto cutResult = cut->check(
object, &counter).first;
127 EXPECT_NE(SoftwareTriggerCutResult::c_reject, cutResult);
128 if (cutResult == SoftwareTriggerCutResult::c_accept) {
130 }
else if (cutResult == SoftwareTriggerCutResult::c_noResult) {
134 uint32_t expectedYes = (729 / 10) + 1;
135 EXPECT_EQ(numberOfYes, expectedYes);
136 EXPECT_EQ(numberOfNo, 729 - expectedYes);
138 cut = SoftwareTriggerCut::compile(
"1 == 1", 7);
143 for (uint32_t i = 1; i <= 544; i++) {
144 const auto cutResult = cut->check(
object, &counter).first;
145 EXPECT_NE(SoftwareTriggerCutResult::c_reject, cutResult);
146 if (cutResult == SoftwareTriggerCutResult::c_accept) {
148 }
else if (cutResult == SoftwareTriggerCutResult::c_noResult) {
152 expectedYes = (544 / 7);
153 EXPECT_EQ(numberOfYes, expectedYes);
154 EXPECT_EQ(numberOfNo, 544 - expectedYes);
Base class for the cut tests.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Abstract base class for different kinds of events.