9 #include <alignment/dbobjects/VXDAlignment.h>
10 #include <alignment/GlobalParam.h>
11 #include <alignment/Manager.h>
12 #include <cdc/dbobjects/CDCTimeZeros.h>
13 #include <cdc/dbobjects/CDCTimeWalks.h>
14 #include <cdc/dbobjects/CDCAlignment.h>
15 #include <cdc/dbobjects/CDCXtRelations.h>
16 #include <framework/dataobjects/EventMetaData.h>
17 #include <klm/dbobjects/bklm/BKLMAlignment.h>
18 #include <klm/dbobjects/eklm/EKLMAlignment.h>
20 #include <gtest/gtest.h>
27 using namespace alignment;
56 class MockDetectorInterface :
public IGlobalParamInterface {
58 explicit MockDetectorInterface(
int id) : m_id(id) {}
59 int hasBeenCalled() {
return m_called; }
60 virtual void readFromResult(std::vector<std::tuple<unsigned short, unsigned short, unsigned short, double>>&,
61 GlobalParamVector&)
override final
63 std::cout <<
" Interface " << m_id <<
": called readFromResult()" << std::endl;
72 class GlobalParamTest :
public ::testing::Test {
82 virtual void TearDown()
92 TEST_F(GlobalParamTest, GlobalParamComponentsInterfaces)
95 GlobalParamVector gpv;
97 GlobalParamVector gpvComp({
"BeamSpot"});
100 auto interface1 =
new MockDetectorInterface(1);
101 auto interface2 =
new MockDetectorInterface(2);
102 auto interface3 =
new MockDetectorInterface(3);
104 auto iptr1 = std::shared_ptr<IGlobalParamInterface>(interface1);
105 auto iptr2 = std::shared_ptr<IGlobalParamInterface>(interface2);
106 auto iptr3 = std::shared_ptr<IGlobalParamInterface>(interface3);
109 for (
auto vect : std::vector<GlobalParamVector*>({&gpv, &gpvComp})) {
119 vect->addSubDetectorInterface(iptr3);
120 vect->addSubDetectorInterface(iptr3);
121 vect->addSubDetectorInterface(iptr3);
125 EXPECT_EQ(interface1->hasBeenCalled(), 0);
126 EXPECT_EQ(interface2->hasBeenCalled(), 0);
127 EXPECT_EQ(interface3->hasBeenCalled(), 0);
129 std::vector<std::tuple<unsigned short, unsigned short, unsigned short, double>> emptyResult;
132 gpv.postReadFromResult(emptyResult);
133 EXPECT_EQ(interface1->hasBeenCalled(), 1);
134 EXPECT_EQ(interface2->hasBeenCalled(), 1);
135 EXPECT_EQ(interface3->hasBeenCalled(), 1);
139 gpvComp.postReadFromResult(emptyResult);
140 EXPECT_EQ(interface1->hasBeenCalled(), 2);
141 EXPECT_EQ(interface2->hasBeenCalled(), 1);
142 EXPECT_EQ(interface3->hasBeenCalled(), 2);
144 EXPECT_EQ(gpv.getGlobalParamSet<
VXDAlignment>().isConstructed(),
false);
145 EXPECT_EQ(gpvComp.getGlobalParamSet<
VXDAlignment>().isConstructed(),
false);
152 EXPECT_EQ(!!gpv.getDBObj<
BeamSpot>(),
true);
155 EXPECT_EQ(!!gpvComp.getDBObj<
BeamSpot>(),
true);
158 EXPECT_EQ(gpv.getGlobalParamSet<
VXDAlignment>().isConstructed(),
true);
159 EXPECT_EQ(gpv.getGlobalParamSet<
BeamSpot>().isConstructed(),
true);
161 EXPECT_EQ(gpvComp.getGlobalParamSet<
VXDAlignment>().isConstructed(),
false);
162 EXPECT_EQ(gpvComp.getGlobalParamSet<
BeamSpot>().isConstructed(),
true);
166 EXPECT_EQ(gpvComp.getGlobalParamSet<
VXDAlignment>().is<EmptyGlobalParamSet>(),
true);
167 EXPECT_EQ(gpvComp.getGlobalParamSet<
VXDAlignment>().empty(),
true);
168 EXPECT_EQ(gpvComp.getGlobalParamSet<
VXDAlignment>().isConstructed(),
false);
169 EXPECT_EQ((
bool) gpvComp.getGlobalParamSet<
VXDAlignment>(),
false);
172 EXPECT_EQ(gpv.getGlobalParamSet<
BeamSpot>().is<EmptyGlobalParamSet>(),
false);
173 EXPECT_EQ(gpv.getGlobalParamSet<
BeamSpot>().empty(),
false);
174 EXPECT_EQ(gpv.getGlobalParamSet<
BeamSpot>().isConstructed(),
true);
175 EXPECT_EQ((
bool) gpv.getGlobalParamSet<
BeamSpot>(),
true);
178 EXPECT_EQ(gpvComp.getGlobalParamSet<EmptyGlobalParamSet>().is<EmptyGlobalParamSet>(),
true);
203 GlobalParamVector newgpv({
"VXDAlignment",
"CDCAlignment"});
204 GlobalCalibrationManager::initGlobalVector(newgpv);
206 EXPECT_EQ(newgpv.getGlobalParamSet<
VXDAlignment>().isConstructed(),
false);
208 EXPECT_EQ(newgpv.getGlobalParamSet<
VXDAlignment>().isConstructed(),
true);
210 newgpv.setGlobalParam(42., VXDAlignment::getGlobalUniqueID(), 0, 1);
211 EXPECT_EQ(newgpv.getGlobalParam(VXDAlignment::getGlobalUniqueID(), 0, 1), 42.);
213 EXPECT_EQ(newgpv.getGlobalParam(VXDAlignment::getGlobalUniqueID(), 0, 1), 0.);
215 newgpv.updateGlobalParam(42., VXDAlignment::getGlobalUniqueID(), 0, 1);
216 EXPECT_EQ(newgpv.getGlobalParam(VXDAlignment::getGlobalUniqueID(), 0, 1), 42.);
218 newgpv.setGlobalParam(42., CDCAlignment::getGlobalUniqueID(), 0, 1);
219 EXPECT_EQ(newgpv.getGlobalParam(CDCAlignment::getGlobalUniqueID(), 0, 1), 42.);
Class to store BKLM alignment data in the database.
This class contains the beam spot position and size modeled as a gaussian distribution in space.
Database object for time-walk.
Database object for timing offset (t0).
Database object for xt-relations.
Class to store EKLM alignment data in the database.
VXD alignment (and maybe some calibration) parameters.
TEST_F(GlobalLabelTest, LargeNumberOfTimeDependentParameters)
Test large number of time-dep params for registration and retrieval.
Abstract base class for different kinds of events.