Belle II Software  release-08-01-10
softwareTriggerResult.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 <mdst/dataobjects/SoftwareTriggerResult.h>
10 #include <gtest/gtest.h>
11 
12 using namespace std;
13 
14 namespace Belle2 {
19  namespace SoftwareTrigger {
21  TEST(SoftwareTriggerResultTest, basic)
22  {
23  SoftwareTriggerResult result;
24 
25  // First result: an accept result
26  result.addResult("cutOne", SoftwareTriggerCutResult::c_accept, SoftwareTriggerCutResult::c_accept);
27 
28  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getResult("cutOne"));
29  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getNonPrescaledResult("cutOne"));
30  EXPECT_THROW(result.getResult("cutTwo"), std::out_of_range);
31 
32  // Another first result: a reject result
33  result.clear();
34  result.addResult("cutOne", SoftwareTriggerCutResult::c_reject, SoftwareTriggerCutResult::c_reject);
35 
36  EXPECT_EQ(SoftwareTriggerCutResult::c_reject, result.getResult("cutOne"));
37  EXPECT_EQ(SoftwareTriggerCutResult::c_reject, result.getNonPrescaledResult("cutOne"));
38 
39  // Another first result: a don't know result
40  result.clear();
41  result.addResult("cutOne", SoftwareTriggerCutResult::c_noResult);
42 
43  EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, result.getResult("cutOne"));
44 
45  // The default for non-prescaled should be noResult
46  result.clear();
47  result.addResult("cutOne", SoftwareTriggerCutResult::c_accept);
48 
49  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getResult("cutOne"));
50  EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, result.getNonPrescaledResult("cutOne"));
51 
52  // Three result
53  result.clear();
54 
55  result.addResult("cutOne", SoftwareTriggerCutResult::c_accept, SoftwareTriggerCutResult::c_reject);
56  result.addResult("cutTwo", SoftwareTriggerCutResult::c_noResult, SoftwareTriggerCutResult::c_accept);
57  result.addResult("cutThree", SoftwareTriggerCutResult::c_reject);
58 
59  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getResult("cutOne"));
60  EXPECT_EQ(SoftwareTriggerCutResult::c_reject, result.getNonPrescaledResult("cutOne"));
61  EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, result.getResult("cutTwo"));
62  EXPECT_EQ(SoftwareTriggerCutResult::c_accept, result.getNonPrescaledResult("cutTwo"));
63  EXPECT_EQ(SoftwareTriggerCutResult::c_reject, result.getResult("cutThree"));
64  EXPECT_EQ(SoftwareTriggerCutResult::c_noResult, result.getNonPrescaledResult("cutThree"));
65  }
66  }
68 }
TEST(TestgetDetectorRegion, TestgetDetectorRegion)
Test Constructors.
Abstract base class for different kinds of events.