Belle II Software light-2406-ragdoll
KlIdTest.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#include <mdst/dataobjects/KlId.h>
9#include <mdst/dataobjects/ECLCluster.h>
10#include <mdst/dataobjects/KLMCluster.h>
11#include <framework/datastore/StoreArray.h>
12#include <gtest/gtest.h>
13
14using namespace std;
15
16namespace Belle2 {
25 class KlIdTest : public ::testing::Test {
26 protected:
27 };
28
30 TEST_F(KlIdTest, SettersAndGetters)
31 {
32
34 StoreArray<ECLCluster> eclClusters;
35 eclClusters.registerInDataStore();
36 StoreArray<KLMCluster> klmClusters;
37 klmClusters.registerInDataStore();
38 StoreArray<KlId> klids;
39 klids.registerInDataStore();
40 klmClusters.registerRelationTo(klids);
41 eclClusters.registerRelationTo(klids);
42
43
44 const KlId* klid = klids.appendNew();
45 const KLMCluster* klmCluster = klmClusters.appendNew();
46 const ECLCluster* eclCluster = eclClusters.appendNew();
47
48 EXPECT_FALSE(klid->isECL());
49 EXPECT_FALSE(klid->isKLM());
50 EXPECT_TRUE(std::isnan(klid->getKlId()));
51
52 klmCluster->addRelationTo(klid, 0.5);
53 eclCluster->addRelationTo(klid, 0.5);
54
55 EXPECT_TRUE(klid->isECL());
56 EXPECT_TRUE(klid->isKLM());
57 EXPECT_EQ(0.5, klid->getKlId());
58
59 }
61} // namespace
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition: DataStore.cc:94
ECL cluster data.
Definition: ECLCluster.h:27
KLM cluster data.
Definition: KLMCluster.h:28
Test class for the KlId object.
Definition: KlIdTest.cc:25
Klong identifcation (KlId) datastore object to store results from KlId calculations.
Definition: KlId.h:23
double getKlId() const
get the klong classifier output
Definition: KlId.cc:29
bool isECL() const
is this ID originally a ECL Cluster ?
Definition: KlId.cc:24
bool isKLM() const
is this ID originally a KLM Cluster ?
Definition: KlId.cc:19
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
Definition: StoreArray.h:140
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24
STL namespace.