Belle II Software development
finalTriggerDecisionCalculator.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <hlt/softwaretrigger/core/FinalTriggerDecisionCalculator.h>
10#include <mdst/dataobjects/SoftwareTriggerResult.h>
11#include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
12#include <gtest/gtest.h>
13
14using namespace std;
15
16namespace Belle2 {
21 namespace SoftwareTrigger {
23 TEST(FinalTriggerDecisionCalculatorTest, basic)
24 {
25 SoftwareTriggerResult result;
26
27 // No results stored
30
31 // First result: an accept result
33
34 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutOne")));
35 EXPECT_THROW(result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutTwo")), std::out_of_range);
36
39
40 // Another first result: a reject result
41 result.clear();
43
44 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutOne")));
47
48 // Another first result: a don't know result
49 result.clear();
51
52 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutOne")));
55
56 // Add an unrelated result: should not change anything
58
59 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("other_test", "cutOne")));
60
63
64 // Three result
68
69 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutOne")));
70 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutTwo")));
71 EXPECT_EQ(SoftwareTriggerCutResult::c_reject, result.getResult(SoftwareTriggerDBHandler::makeFullCutName("test", "cutThree")));
72
75
76 // Add another accept result: should not change anything
78
81
82 // More accept than reject: should be the same
83 result.clear();
87
90
91 // More reject than accept: should be the same
92 result.clear();
96
99
100 // Add two other accept result: should not change anything
103
106 }
107
109 TEST(FinalTriggerDecisionCalculatorTest, result)
110 {
111 SoftwareTriggerResult result;
112
113 // No results stored -> ne event is accepted.
115
116 // No total results should not change anything.
119
120 // Revision 2
121 // filter has rejected -> reject
122 result.clear();
125
126 // filter has accepted and skim also -> accept
127 result.clear();
131
132 // filter has rejected and skim should not change anything -> reject
133 result.clear();
137
138 // filter has accepted, skim does not matter -> accept
139 result.clear();
143
144 // Revision 1
145 // fast reco has rejected -> reject
146 result.clear();
149
150 // fast reco has accepted and hlt also -> accept
151 result.clear();
155
156 // fast reco has rejected and hlt should not change anything -> reject
157 result.clear();
161
162 // fast reco and hlt have accepted, calib does not matter -> accept
163 result.clear();
167
168 }
169 }
171}
static SoftwareTriggerCutResult getModuleResult(const SoftwareTriggerResult &result, const std::string &baseIdentifier, bool acceptOverridesReject)
Calculate the "total_result" for a given base identifier by looping through all results with the give...
static bool getFinalTriggerDecision(const SoftwareTriggerResult &result, bool forgetTotalResult=false)
Calculate the final cut decision using all "total_results" of all sub triggers in the software trigge...
static std::string makeFullCutName(const std::string &baseCutIdentifier, const std::string &cutIdentifier)
Helper function to compile the full identifier from the base and the specific cut name.
static std::string makeTotalResultName(const std::string &baseIdentifier="all")
Handy function to create the name related to the total result of a specific trigger stage (either fil...
@ c_accept
Accept this event.
@ c_reject
Reject this event.
@ c_noResult
There were not enough information to decide on what to do with the event.
Abstract base class for different kinds of events.
STL namespace.