Belle II Software  release-05-01-25
KlIdTest.cc
1 #include <mdst/dataobjects/KlId.h>
2 #include <mdst/dataobjects/ECLCluster.h>
3 #include <mdst/dataobjects/KLMCluster.h>
4 #include <framework/datastore/StoreArray.h>
5 #include <gtest/gtest.h>
6 
7 using namespace std;
8 
9 namespace Belle2 {
18  class KlIdTest : public ::testing::Test {
19  protected:
20  };
21 
23  TEST_F(KlIdTest, SettersAndGetters)
24  {
25 
26  DataStore::Instance().setInitializeActive(true);
27  StoreArray<ECLCluster> eclClusters;
28  eclClusters.registerInDataStore();
29  StoreArray<KLMCluster> klmClusters;
30  klmClusters.registerInDataStore();
31  StoreArray<KlId> klids;
32  klids.registerInDataStore();
33  klmClusters.registerRelationTo(klids);
34  eclClusters.registerRelationTo(klids);
35 
36 
37  const KlId* klid = klids.appendNew();
38  const KLMCluster* klmCluster = klmClusters.appendNew();
39  const ECLCluster* eclCluster = eclClusters.appendNew();
40 
41  EXPECT_FALSE(klid->isECL());
42  EXPECT_FALSE(klid->isKLM());
43  EXPECT_TRUE(std::isnan(klid->getKlId()));
44 
45  klmCluster->addRelationTo(klid, 0.5);
46  eclCluster->addRelationTo(klid, 0.5);
47 
48  EXPECT_TRUE(klid->isECL());
49  EXPECT_TRUE(klid->isKLM());
50  EXPECT_EQ(0.5, klid->getKlId());
51 
52  }
54 } // namespace
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::StoreArray::registerRelationTo
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:150
Belle2::ECLCluster
ECL cluster data.
Definition: ECLCluster.h:39
KlId
Helper functions for all klid modules to improve readability of the code.
Definition: KlId.h:28
Belle2::RelationsInterface::addRelationTo
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).
Definition: RelationsObject.h:144
Belle2::TEST_F
TEST_F(KlIdTest, SettersAndGetters)
Test setter and getter.
Definition: KlIdTest.cc:23
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::KlId::getKlId
double getKlId() const
get the klong classifier output
Belle2::KlIdTest
Test class for the KlId object.
Definition: KlIdTest.cc:18
Belle2::KLMCluster
KLM cluster data.
Definition: KLMCluster.h:38
Belle2::KlId::isKLM
bool isKLM() const
is this ID originally a KLM Cluster ?
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::KlId::isECL
bool isECL() const
is this ID originally a ECL Cluster ?