1 #include <generators/particlegun/ParticleGun.h>
2 #include <gtest/gtest.h>
17 parameters.momentumParams = {1, 1};
18 parameters.xVertexParams = {1, 1};
19 parameters.yVertexParams = {1, 1};
20 parameters.zVertexParams = {1, 1};
21 parameters.thetaParams = {1, 1};
22 parameters.phiParams = {1, 1};
31 std::vector<double>& pars);
35 std::vector<double>& pars)
38 parameters.pdgCodes = {11};
39 for (
auto item : allowed) {
44 ASSERT_EQ(item.second, pgun.setParameters(parameters)) << name <<
": " << item.first <<
", " << item.second;
47 for (
int i = 0; i < 10; ++i) {
49 int minpar = (item.first == ParticleGun::c_fixedValue) ? 1 : 2;
51 if (dist == ParticleGun::c_polylineDistribution || dist == ParticleGun::c_polylinePtDistribution
52 || dist == ParticleGun::c_polylineCosDistribution) minpar = 4;
53 bool valid = i >= minpar;
55 if (dist == ParticleGun::c_discreteSpectrum || dist == ParticleGun::c_polylineDistribution ||
56 dist == ParticleGun::c_polylinePtDistribution || dist == ParticleGun::c_polylineCosDistribution) {
60 ASSERT_EQ(valid, pgun.setParameters(parameters)) << name <<
" " << pars.size();
64 if (item.first == ParticleGun::c_inversePtDistribution && item.second) {
66 ASSERT_TRUE(pgun.setParameters(parameters));
68 ASSERT_FALSE(pgun.setParameters(parameters)) << name <<
": " << parameters.momentumParams[0] <<
", " <<
69 parameters.momentumParams[1];
71 ASSERT_FALSE(pgun.setParameters(parameters)) << name <<
": " << parameters.momentumParams[0] <<
", " <<
72 parameters.momentumParams[1];
75 if ((dist == ParticleGun::c_polylineDistribution || dist == ParticleGun::c_polylinePtDistribution
76 || dist == ParticleGun::c_polylineCosDistribution) && item.second) {
78 ASSERT_TRUE(pgun.setParameters(parameters));
81 ASSERT_FALSE(pgun.setParameters(parameters));
84 ASSERT_FALSE(pgun.setParameters(parameters));
87 ASSERT_FALSE(pgun.setParameters(parameters));
90 if (dist == ParticleGun::c_discreteSpectrum) {
92 ASSERT_TRUE(pgun.setParameters(parameters));
95 ASSERT_FALSE(pgun.setParameters(parameters));
98 ASSERT_FALSE(pgun.setParameters(parameters));
101 std::cout << std::endl;
107 std::map<int, bool> distributions = {
108 {ParticleGun::c_fixedValue,
true},
109 {ParticleGun::c_uniformDistribution,
true},
110 {ParticleGun::c_uniformPtDistribution,
true},
111 {ParticleGun::c_uniformCosDistribution,
false},
112 {ParticleGun::c_normalDistribution,
true},
113 {ParticleGun::c_normalPtDistribution,
true},
114 {ParticleGun::c_normalCosDistribution,
false},
115 {ParticleGun::c_discreteSpectrum,
true},
116 {ParticleGun::c_inversePtDistribution,
true},
117 {ParticleGun::c_polylineDistribution,
true},
118 {ParticleGun::c_polylinePtDistribution,
true},
119 {ParticleGun::c_polylineCosDistribution,
false}
121 checkVariable(
"momentum", distributions, parameters.momentumDist, parameters.momentumParams);
127 std::map<int, bool> distributions = {
128 {ParticleGun::c_fixedValue,
true},
129 {ParticleGun::c_uniformDistribution,
true},
130 {ParticleGun::c_uniformPtDistribution,
false},
131 {ParticleGun::c_uniformCosDistribution,
false},
132 {ParticleGun::c_normalDistribution,
true},
133 {ParticleGun::c_normalPtDistribution,
false},
134 {ParticleGun::c_normalCosDistribution,
false},
135 {ParticleGun::c_discreteSpectrum,
true},
136 {ParticleGun::c_inversePtDistribution,
false},
137 {ParticleGun::c_polylineDistribution,
true},
138 {ParticleGun::c_polylinePtDistribution,
false},
139 {ParticleGun::c_polylineCosDistribution,
false}
141 checkVariable(
"xvertex", distributions, parameters.xVertexDist, parameters.xVertexParams);
142 checkVariable(
"yvertex", distributions, parameters.yVertexDist, parameters.yVertexParams);
143 checkVariable(
"zvertex", distributions, parameters.zVertexDist, parameters.zVertexParams);
149 std::map<int, bool> distributions = {
150 {ParticleGun::c_fixedValue,
true},
151 {ParticleGun::c_uniformDistribution,
true},
152 {ParticleGun::c_uniformPtDistribution,
false},
153 {ParticleGun::c_uniformCosDistribution,
true},
154 {ParticleGun::c_normalDistribution,
true},
155 {ParticleGun::c_normalPtDistribution,
false},
156 {ParticleGun::c_normalCosDistribution,
true},
157 {ParticleGun::c_discreteSpectrum,
true},
158 {ParticleGun::c_inversePtDistribution,
false},
159 {ParticleGun::c_polylineDistribution,
true},
160 {ParticleGun::c_polylinePtDistribution,
false},
161 {ParticleGun::c_polylineCosDistribution,
true}
163 checkVariable(
"theta", distributions, parameters.thetaDist, parameters.thetaParams);
164 checkVariable(
"phi", distributions, parameters.phiDist, parameters.phiParams);
The fixture for testing the Particlegun.
ParticleGun::Parameters parameters
Variable parameters.
virtual void SetUp()
Set up parameters which work for all distributions.
ParticleGun pgun
Variable of pgun.
Class to generate tracks in the particle gun and store them in a MCParticle graph.
EDistribution
enum containing all known distributions available for generation of values
TEST_F(ParticleGunTest, AngularDistributions)
Tests angular generation parameters.
Abstract base class for different kinds of events.
Struct to keep all necessary parameters for the particle gun.