Belle II Software development
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
17using namespace std;
18
19namespace Belle2 {
24 namespace SoftwareTrigger {
25
27 class DBRepresentationOfSoftwareTriggerCutTest : public ::testing::Test {
28
31
33 void SetUp()
34 {
37 evtPtr.registerInDataStore();
39 evtPtr.construct(0, 0, 0);
40 }
41
43 void TearDown()
44 {
45 std::filesystem::remove_all("testPayloads");
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.
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition: DataStore.cc:94
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition: DataStore.cc:86
void SetUp()
Setup the local DB and the datastore with the event meta data.
TestHelpers::TempDirCreator tmp_dir
Do everything in a temporary dir.
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...
static std::unique_ptr< SoftwareTriggerCut > createCutFromDB(const DBRepresentationOfSoftwareTriggerCut &dbCut)
Helper factory function to generate a unique cut pointer from its representation in the database.
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
Abstract base class for different kinds of events.
STL namespace.