Belle II Software  release-08-01-10
dbRepresentationOfSoftwareTriggerCut.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/dbobjects/DBRepresentationOfSoftwareTriggerCut.h>
10 #include <hlt/softwaretrigger/core/SoftwareTriggerCut.h>
11 #include <hlt/softwaretrigger/core/SoftwareTriggerDBHandler.h>
12 #include <filesystem>
13 
14 #include <framework/utilities/TestHelpers.h>
15 #include <gtest/gtest.h>
16 
17 using namespace std;
18 
19 namespace Belle2 {
24  namespace SoftwareTrigger {
25 
27  class DBRepresentationOfSoftwareTriggerCutTest : public ::testing::Test {
28 
31 
33  void SetUp()
34  {
36  DataStore::Instance().setInitializeActive(true);
37  evtPtr.registerInDataStore();
38  DataStore::Instance().setInitializeActive(false);
39  evtPtr.construct(0, 0, 0);
40  }
41 
43  void TearDown()
44  {
45  std::filesystem::remove_all("testPayloads");
46  DataStore::Instance().reset();
47  }
48  };
49 
51  TEST_F(DBRepresentationOfSoftwareTriggerCutTest, basic)
52  {
53  auto cut = SoftwareTriggerCut::compile("1 == 2", 10, true);
54  DBRepresentationOfSoftwareTriggerCut representation(cut->getPreScaleFactor(), cut->isRejectCut(), cut->decompile());
55  auto returnedCut = SoftwareTriggerDBHandler::createCutFromDB(representation);
56 
57  EXPECT_EQ(cut->decompile(), returnedCut->decompile());
58  EXPECT_EQ(cut->getPreScaleFactor(), returnedCut->getPreScaleFactor());
59  EXPECT_EQ(cut->isRejectCut(), returnedCut->isRejectCut());
60 
61  auto cut2 = SoftwareTriggerCut::compile("1 == 2", 10, false);
62  DBRepresentationOfSoftwareTriggerCut representation2(cut2->getPreScaleFactor(), cut2->isRejectCut(), cut2->decompile());
63  auto returnedCut2 = SoftwareTriggerDBHandler::createCutFromDB(representation2);
64 
65  EXPECT_EQ(cut2->decompile(), returnedCut2->decompile());
66  EXPECT_EQ(cut2->getPreScaleFactor(), returnedCut2->getPreScaleFactor());
67  EXPECT_EQ(cut2->isRejectCut(), returnedCut2->isRejectCut());
68  }
69  }
71 }
Class to handle storing SoftwareTriggerCuts in the database.
void SetUp()
Setup the local DB and the datastore with the event meta data.
TestHelpers::TempDirCreator tmp_dir
Do everything in a temporary dir.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
bool construct(Args &&... params)
Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
Definition: StoreObjPtr.h:119
changes working directory into a newly created directory, and removes it (and contents) on destructio...
Definition: TestHelpers.h:66
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Definition: globalLabel.cc:72
Abstract base class for different kinds of events.