8#include <generators/particlegun/ParticleGun.h>
9#include <gtest/gtest.h>
38 std::vector<double>& pars);
42 std::vector<double>& pars)
46 for (
auto item : allowed) {
54 for (
int i = 0; i < 10; ++i) {
60 bool valid = i >= minpar;
104 pars = {0, 1, 1, -1};
108 std::cout << std::endl;
114 std::map<int, bool> distributions = {
115 {ParticleGun::c_fixedValue,
true},
116 {ParticleGun::c_uniformDistribution,
true},
117 {ParticleGun::c_uniformPtDistribution,
true},
118 {ParticleGun::c_uniformCosDistribution,
false},
119 {ParticleGun::c_normalDistribution,
true},
120 {ParticleGun::c_normalPtDistribution,
true},
121 {ParticleGun::c_normalCosDistribution,
false},
122 {ParticleGun::c_discreteSpectrum,
true},
123 {ParticleGun::c_inversePtDistribution,
true},
124 {ParticleGun::c_polylineDistribution,
true},
125 {ParticleGun::c_polylinePtDistribution,
true},
126 {ParticleGun::c_polylineCosDistribution,
false}
128 checkVariable(
"momentum", distributions, parameters.momentumDist, parameters.momentumParams);
134 std::map<int, bool> distributions = {
135 {ParticleGun::c_fixedValue,
true},
136 {ParticleGun::c_uniformDistribution,
true},
137 {ParticleGun::c_uniformPtDistribution,
false},
138 {ParticleGun::c_uniformCosDistribution,
false},
139 {ParticleGun::c_normalDistribution,
true},
140 {ParticleGun::c_normalPtDistribution,
false},
141 {ParticleGun::c_normalCosDistribution,
false},
142 {ParticleGun::c_discreteSpectrum,
true},
143 {ParticleGun::c_inversePtDistribution,
false},
144 {ParticleGun::c_polylineDistribution,
true},
145 {ParticleGun::c_polylinePtDistribution,
false},
146 {ParticleGun::c_polylineCosDistribution,
false}
148 checkVariable(
"xvertex", distributions, parameters.xVertexDist, parameters.xVertexParams);
149 checkVariable(
"yvertex", distributions, parameters.yVertexDist, parameters.yVertexParams);
150 checkVariable(
"zvertex", distributions, parameters.zVertexDist, parameters.zVertexParams);
156 std::map<int, bool> distributions = {
157 {ParticleGun::c_fixedValue,
true},
158 {ParticleGun::c_uniformDistribution,
true},
159 {ParticleGun::c_uniformPtDistribution,
false},
160 {ParticleGun::c_uniformCosDistribution,
true},
161 {ParticleGun::c_normalDistribution,
true},
162 {ParticleGun::c_normalPtDistribution,
false},
163 {ParticleGun::c_normalCosDistribution,
true},
164 {ParticleGun::c_discreteSpectrum,
true},
165 {ParticleGun::c_inversePtDistribution,
false},
166 {ParticleGun::c_polylineDistribution,
true},
167 {ParticleGun::c_polylinePtDistribution,
false},
168 {ParticleGun::c_polylineCosDistribution,
true}
170 checkVariable(
"theta", distributions, parameters.thetaDist, parameters.thetaParams);
171 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
@ c_polylineDistribution
Distribution given as list of (x,y) points.
@ c_polylinePtDistribution
Same as polylineDistribution but for the transverse momentum.
@ c_discreteSpectrum
Discrete spectrum, parameters are first the values and then the weights (non-negative) for each value...
@ c_fixedValue
Fixed value, no random generation at all, 1 parameter.
@ c_inversePtDistribution
Distribution uniform in the inverse pt distribution, that is uniform in track curvature.
@ c_polylineCosDistribution
Same as polylineDistribution but for the cosine of the angle.
bool setParameters(const Parameters ¶meters)
Set the parameters for generating the Particles.
void checkVariable(const std::string &name, const std::map< int, bool > &allowed, ParticleGun::EDistribution &dist, std::vector< double > &pars)
check one of the variables given a list of allowed and excluded distributions
Abstract base class for different kinds of events.
Struct to keep all necessary parameters for the particle gun.
std::vector< int > pdgCodes
List of PDG particle codes to pick from when generating particles.
std::vector< double > thetaParams
Parameters for the polar angle generation, meaning depends on chosen distribution.
std::vector< double > momentumParams
Parameters for the momentum generation, meaning depends on chosen distribution.
std::vector< double > xVertexParams
Parameters for the x vertex generation, meaning depends on chosen distribution.
std::vector< double > zVertexParams
Parameters for the z vertex generation, meaning depends on chosen distribution.
std::vector< double > phiParams
Parameters for the azimuth angle generation, meaning depends on chosen distribution.
std::vector< double > yVertexParams
Parameters for the y vertex generation, meaning depends on chosen distribution.