Belle II Software development
softwareTriggerVariableManager.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/SoftwareTriggerCut.h>
10#include <gtest/gtest.h>
11
12using namespace std;
13
14namespace Belle2 {
19 namespace SoftwareTrigger {
20
22 TEST(SoftwareTriggerVarialeManagerTest, pickVariables)
23 {
24 SoftwareTriggerObject softwareTriggerObject;
25 softwareTriggerObject["one_variable"] = 1.1;
26
27 // Normal user case
28 const auto compiledFirstCut = SoftwareTriggerCut::compile("one_variable == 1.1", 1);
29 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, compiledFirstCut->checkPreScaled(softwareTriggerObject));
30
31 // Unregistered variable
32 EXPECT_THROW(SoftwareTriggerCut::compile("two_variable == 1.1", 1)->checkPreScaled(softwareTriggerObject),
33 std::out_of_range);
34
35 softwareTriggerObject["two_variable"] = 2.2;
36
37 // Now it is registered
38 const auto compiledSecondCut = SoftwareTriggerCut::compile("two_variable == 2.2", 1);
39 EXPECT_EQ(SoftwareTriggerCutResult::c_accept, compiledSecondCut->checkPreScaled(softwareTriggerObject));
40
41 // Check should fail
42 softwareTriggerObject["two_variable"] = 2.3;
43 EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, compiledSecondCut->checkPreScaled(softwareTriggerObject));
44 }
45 }
47}
static std::unique_ptr< SoftwareTriggerCut > compile(const std::string &cut_string, const unsigned int prescaleFactor, const bool rejectCut=false)
Compile a new SoftwareTriggerCut from a cut string (by using the GeneralCut::compile function) and an...
@ c_accept
Accept 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.