1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <cppunit/extensions/HelperMacros.h>
#include "DataFormats/Luminosity/interface/BeamCurrentInfo.h"
#include <string>
#include <vector>
#include <iostream>
#include <cmath>
class TestBeamCurrentInfo : public CppUnit::TestFixture {
static const float tol;
CPPUNIT_TEST_SUITE(TestBeamCurrentInfo);
CPPUNIT_TEST(testFill);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void testFill();
};
// tolerance (relative)
const float TestBeamCurrentInfo::tol = 1e-3;
///registration of the test so that the runner can find it
CPPUNIT_TEST_SUITE_REGISTRATION(TestBeamCurrentInfo);
void TestBeamCurrentInfo::testFill() {
BeamCurrentInfo beamCurrentInfo;
// Use somewhat realistic data so that we don't end up out-of-range.
std::vector<float> beam1;
beam1.push_back(0.042e10f);
beam1.push_back(14.481e10f);
beam1.push_back(0.422e10f);
std::vector<float> beam2;
beam2.push_back(0.081e10f);
beam2.push_back(14.662e10f);
beam2.push_back(0.135e10f);
beamCurrentInfo.fill(beam1, beam2);
std::cout << beamCurrentInfo;
CPPUNIT_ASSERT(std::abs(beamCurrentInfo.getBeam1IntensityBX(0) - beam1[0]) <
beamCurrentInfo.getBeam1IntensityBX(0) * tol);
CPPUNIT_ASSERT(std::abs(beamCurrentInfo.getBeam1IntensityBX(1) - beam1[1]) <
beamCurrentInfo.getBeam1IntensityBX(1) * tol);
CPPUNIT_ASSERT(std::abs(beamCurrentInfo.getBeam1IntensityBX(2) - beam1[2]) <
beamCurrentInfo.getBeam1IntensityBX(2) * tol);
CPPUNIT_ASSERT(std::abs(beamCurrentInfo.getBeam2IntensityBX(0) - beam2[0]) <
beamCurrentInfo.getBeam2IntensityBX(0) * tol);
CPPUNIT_ASSERT(std::abs(beamCurrentInfo.getBeam2IntensityBX(1) - beam2[1]) <
beamCurrentInfo.getBeam2IntensityBX(1) * tol);
CPPUNIT_ASSERT(std::abs(beamCurrentInfo.getBeam2IntensityBX(2) - beam2[2]) <
beamCurrentInfo.getBeam2IntensityBX(2) * tol);
CPPUNIT_ASSERT(beamCurrentInfo.isProductEqual(beamCurrentInfo));
BeamCurrentInfo beamCurrentInfo2;
CPPUNIT_ASSERT(!beamCurrentInfo.isProductEqual(beamCurrentInfo2));
}
|