4 #include <framework/dataobjects/RelationElement.h>
5 #include <svd/simulation/SVDSignal.h>
6 #include <gtest/gtest.h>
25 vector<double> charges;
26 charges.push_back(10);
27 charges.push_back(11);
28 charges.push_back(30);
30 for (
int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
31 vector<RelationElement::index_type> mcParticles;
32 for (
int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
33 vector<RelationElement::index_type> trueHits;
34 for (
int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
35 const float tau = 25.0e-9;
37 for (
int i = 0; i < 3; ++i) signal.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
39 double totalcharge = 0;
40 for (
int i = 0; i < 3; ++i) totalcharge += charges.at(i);
41 EXPECT_EQ(signal.getCharge(), totalcharge);
44 for (
int i = 0; i < 3; ++i) {
45 EXPECT_EQ(functions.at(i).m_initTime, times.at(i));
46 EXPECT_EQ(functions.at(i).m_charge, charges.at(i));
47 EXPECT_EQ(functions.at(i).m_tau, tau);
48 EXPECT_EQ(functions.at(i).m_particle, mcParticles.at(i));
49 EXPECT_EQ(functions.at(i).m_truehit, trueHits.at(i));
57 vector<double> charges;
58 charges.push_back(10);
59 charges.push_back(11);
60 charges.push_back(30);
62 for (
int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
63 vector<RelationElement::index_type> mcParticles;
64 for (
int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
65 vector<RelationElement::index_type> trueHits;
66 for (
int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
67 const float tau = 25.0e-9;
69 for (
int i = 0; i < 3; ++i) signal.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
72 double totalcharge = 0;
73 for (
int i = 0; i < 3; ++i) totalcharge += charges.at(i);
74 EXPECT_EQ(signal2.
getCharge(), totalcharge);
77 size_t n = functions.size();
79 for (
int i = 0; i < 3; ++i) {
80 EXPECT_EQ(functions.at(i).m_initTime, times.at(i));
81 EXPECT_EQ(functions.at(i).m_charge, charges.at(i));
82 EXPECT_EQ(functions.at(i).m_tau, tau);
83 EXPECT_EQ(functions.at(i).m_particle, mcParticles.at(i));
84 EXPECT_EQ(functions.at(i).m_truehit, trueHits.at(i));
92 vector<double> charges;
93 charges.push_back(10);
94 charges.push_back(11);
95 charges.push_back(30);
97 for (
int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
98 vector<RelationElement::index_type> mcParticles;
99 for (
int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
100 vector<RelationElement::index_type> trueHits;
101 for (
int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
102 const float tau = 25.0e-9;
104 for (
int i = 0; i < 3; ++i) signal.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
107 double totalcharge = 0;
108 for (
int i = 0; i < 3; ++i) totalcharge += charges.at(i);
109 EXPECT_EQ(signal2.
getCharge(), totalcharge);
112 for (
int i = 0; i < 3; ++i) {
113 EXPECT_EQ(functions.at(i).m_initTime, times.at(i));
114 EXPECT_EQ(functions.at(i).m_charge, charges.at(i));
115 EXPECT_EQ(functions.at(i).m_tau, tau);
116 EXPECT_EQ(functions.at(i).m_particle, mcParticles.at(i));
117 EXPECT_EQ(functions.at(i).m_truehit, trueHits.at(i));
125 vector<double> charges;
126 charges.push_back(10);
127 charges.push_back(11);
128 charges.push_back(30);
129 vector<double> times;
130 for (
int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
131 vector<RelationElement::index_type> mcParticles;
132 for (
int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
133 vector<RelationElement::index_type> trueHits;
134 for (
int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
135 const float tau = 25.0e-9;
137 for (
int i = 0; i < 3; ++i) signal.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
139 double time = 40.0e-9;
141 double expected_value = 0;
146 double value = signal.waveform(time, wave);
147 expected_value += value;
148 expected_particles_map[mcParticles.at(i)] += wave.m_charge;
149 expected_truehits_map[trueHits.at(i)] += wave.m_charge;
152 double function_value = signal(time);
153 EXPECT_EQ(function_value, expected_value);
160 vector<double> charges;
161 charges.push_back(10);
162 charges.push_back(11);
163 charges.push_back(30);
164 vector<double> times;
165 for (
int i = 0; i < 3; ++i) times.push_back(i * 15.0e-9);
166 vector<RelationElement::index_type> mcParticles;
167 for (
int i = 0; i < 3; ++i) mcParticles.push_back(3 * i);
168 vector<RelationElement::index_type> trueHits;
169 for (
int i = 0; i < 3; ++i) trueHits.push_back(7 * i);
170 const float tau = 50.0e-9;
172 for (
int i = 0; i < 3; ++i) signal.add(times.at(i), charges.at(i), tau, mcParticles.at(i), trueHits.at(i));
173 std::ostringstream os;
174 for (
int i = 0; i < 3; ++i)
175 os << i + 1 <<
'\t' << times.at(i) <<
'\t' << charges.at(i) <<
'\t' << tau << std::endl;
176 EXPECT_EQ(signal.toString(), os.str());