Belle II Software  release-05-02-19
softwareTriggerVariableManager.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
12 #include <gtest/gtest.h>
13 
14 using namespace std;
15 
16 namespace Belle2 {
21  namespace SoftwareTrigger {
22 
24  TEST(SoftwareTriggerVarialeManagerTest, pickVariables)
25  {
26  SoftwareTriggerObject softwareTriggerObject;
27  softwareTriggerObject["one_variable"] = 1.1;
28 
29  // Normal user case
30  const auto compiledFirstCut = SoftwareTriggerCut::compile("one_variable == 1.1", 1);
31  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, compiledFirstCut->checkPreScaled(softwareTriggerObject));
32 
33  // Unregistered variable
34  EXPECT_THROW(SoftwareTriggerCut::compile("two_variable == 1.1", 1)->checkPreScaled(softwareTriggerObject),
35  std::out_of_range);
36 
37  softwareTriggerObject["two_variable"] = 2.2;
38 
39  // Now it is registered
40  const auto compiledSecondCut = SoftwareTriggerCut::compile("two_variable == 2.2", 1);
41  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, compiledSecondCut->checkPreScaled(softwareTriggerObject));
42 
43  // Check should fail
44  softwareTriggerObject["two_variable"] = 2.3;
45  EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, compiledSecondCut->checkPreScaled(softwareTriggerObject));
46  }
47  }
49 }
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TEST
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Definition: utilityFunctions.cc:18