Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
cortes_c
src
Commits
1a5bff88
Commit
1a5bff88
authored
Jul 22, 2017
by
Christof Metzger-Kraus
Browse files
fixing few issues binomial distribution and cleaning up
parent
acaf84b7
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
467 additions
and
318 deletions
+467
-318
src/Distribution/Distribution.cpp
src/Distribution/Distribution.cpp
+196
-259
src/Distribution/Distribution.h
src/Distribution/Distribution.h
+179
-3
tests/opal_src/Distribution/BinomialTest.cpp
tests/opal_src/Distribution/BinomialTest.cpp
+46
-30
tests/opal_src/Distribution/GaussTest.cpp
tests/opal_src/Distribution/GaussTest.cpp
+46
-26
No files found.
src/Distribution/Distribution.cpp
View file @
1a5bff88
This diff is collapsed.
Click to expand it.
src/Distribution/Distribution.h
View file @
1a5bff88
...
...
@@ -28,6 +28,7 @@
#include "Algorithms/Vektor.h"
#include "Beamlines/Beamline.h"
#include "Attributes/Attributes.h"
#include "Ippl.h"
...
...
@@ -85,7 +86,6 @@ namespace Attrib
{
enum
AttributesT
{
TYPE
,
DISTRIBUTION
,
FNAME
,
WRITETOFILE
,
WEIGHT
,
...
...
@@ -207,7 +207,8 @@ namespace Attrib
{
enum
LegacyAttributesT
{
// DESCRIPTION OF THE DISTRIBUTION:
DEBIN
=
Attrib
::
Distribution
::
SIZE
,
DISTRIBUTION
=
Attrib
::
Distribution
::
SIZE
,
DEBIN
,
SBIN
,
SIGMAPT
,
CUTOFF
,
...
...
@@ -383,6 +384,34 @@ private:
double
converteVToBetaGamma
(
double
valueIneV
,
double
massIneV
);
double
convertMeVPerCToBetaGamma
(
double
valueInMeVPerC
,
double
massIneV
);
size_t
getNumberOfParticlesInFile
(
std
::
ifstream
&
inputFile
);
class
BinomialBehaviorSplitter
{
public:
virtual
~
BinomialBehaviorSplitter
()
{
}
virtual
double
get
(
double
rand
)
=
0
;
};
class
MDependentBehavior
:
public
BinomialBehaviorSplitter
{
public:
MDependentBehavior
(
const
MDependentBehavior
&
rhs
)
:
ami_m
(
rhs
.
ami_m
)
{}
MDependentBehavior
(
double
a
)
{
ami_m
=
1.0
/
a
;
}
virtual
double
get
(
double
rand
);
private:
double
ami_m
;
};
class
GaussianLikeBehavior
:
public
BinomialBehaviorSplitter
{
public:
virtual
double
get
(
double
rand
);
};
void
createDistributionBinomial
(
size_t
numberOfParticles
,
double
massIneV
);
void
createDistributionFlattop
(
size_t
numberOfParticles
,
double
massIneV
);
void
createDistributionFromFile
(
size_t
numberOfParticles
,
double
massIneV
);
...
...
@@ -619,8 +648,155 @@ DistrTypeT::DistrTypeT Distribution::getType() const {
return
distrTypeT_m
;
}
inline
double
Distribution
::
getPercentageEmitted
()
const
{
inline
double
Distribution
::
getPercentageEmitted
()
const
{
return
(
double
)
totalNumberEmittedParticles_m
/
(
double
)
totalNumberParticles_m
;
}
inline
double
Distribution
::
getEkin
()
const
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
EKIN
]);
}
inline
double
Distribution
::
getLaserEnergy
()
const
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
ELASER
]);
}
inline
double
Distribution
::
getWorkFunctionRf
()
const
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
W
]);
}
inline
size_t
Distribution
::
getNumberOfDarkCurrentParticles
()
{
return
(
size_t
)
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
NPDARKCUR
]);
}
inline
double
Distribution
::
getDarkCurrentParticlesInwardMargin
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
INWARDMARGIN
]);
}
inline
double
Distribution
::
getEInitThreshold
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
EINITHR
]);
}
inline
double
Distribution
::
getWorkFunction
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNPHIW
]);
}
inline
double
Distribution
::
getFieldEnhancement
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNBETA
]);
}
inline
size_t
Distribution
::
getMaxFNemissionPartPerTri
()
{
return
(
size_t
)
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNMAXEMI
]);
}
inline
double
Distribution
::
getFieldFNThreshold
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNFIELDTHR
]);
}
inline
double
Distribution
::
getFNParameterA
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNA
]);
}
inline
double
Distribution
::
getFNParameterB
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNB
]);
}
inline
double
Distribution
::
getFNParameterY
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNY
]);
}
inline
double
Distribution
::
getFNParameterVYZero
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNVYZERO
]);
}
inline
double
Distribution
::
getFNParameterVYSecond
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
FNVYSECOND
]);
}
inline
int
Distribution
::
getSecondaryEmissionFlag
()
{
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
SECONDARYFLAG
]);
}
inline
bool
Distribution
::
getEmissionMode
()
{
return
Attributes
::
getBool
(
itsAttr
[
Attrib
::
Distribution
::
NEMISSIONMODE
]);
}
inline
std
::
string
Distribution
::
getTypeofDistribution
()
{
return
(
std
::
string
)
Attributes
::
getString
(
itsAttr
[
Attrib
::
Distribution
::
TYPE
]);
}
inline
double
Distribution
::
getvSeyZero
()
{
// return sey_0 in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VSEYZERO
]);
}
inline
double
Distribution
::
getvEZero
()
{
// return the energy related to sey_0 in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VEZERO
]);
}
inline
double
Distribution
::
getvSeyMax
()
{
// return sey max in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VSEYMAX
]);
}
inline
double
Distribution
::
getvEmax
()
{
// return Emax in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VEMAX
]);
}
inline
double
Distribution
::
getvKenergy
()
{
// return fitting parameter denotes the roughness of surface for
// impact energy in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VKENERGY
]);
}
inline
double
Distribution
::
getvKtheta
()
{
// return fitting parameter denotes the roughness of surface for
// impact angle in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VKTHETA
]);
}
inline
double
Distribution
::
getvVThermal
()
{
// thermal velocity of Maxwellian distribution of secondaries in Vaughan's model
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VVTHERMAL
]);
}
inline
double
Distribution
::
getVw
()
{
// velocity scalar for parallel plate benchmark;
return
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
VW
]);
}
inline
int
Distribution
::
getSurfMaterial
()
{
// Surface material number for Furman-Pivi's Model;
return
(
int
)
Attributes
::
getReal
(
itsAttr
[
Attrib
::
Distribution
::
SURFMATERIAL
]);
}
#endif // OPAL_Distribution_HH
\ No newline at end of file
tests/opal_src/Distribution/BinomialTest.cpp
View file @
1a5bff88
...
...
@@ -15,7 +15,7 @@ TEST(BinomialTest, FullSigmaTest1) {
const
double
expectedR22
=
0.7998
;
const
double
expectedR33
=
2.498
;
const
double
expectedR44
=
0.6212
;
const
double
expectedR55
=
1.537
;
const
double
expectedR55
=
1.537
;
const
double
expectedR66
=
0.9457
;
const
double
expectedR21
=
-
0.40993
;
...
...
@@ -35,16 +35,22 @@ TEST(BinomialTest, FullSigmaTest1) {
Distribution
dist
;
Attributes
::
setString
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
TYPE
],
"BINOMIAL"
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MX
],
999999999.9
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MY
],
999999999.9
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MZ
],
999999999.9
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAX
],
expectedR11
*
1e-3
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAPX
],
expectedR22
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAY
],
expectedR33
*
1e-3
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAPY
],
expectedR44
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAZ
],
expectedR55
*
1e-3
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAPZ
],
expectedR66
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MX
],
999999999.9
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MY
],
999999999.9
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MZ
],
999999999.9
);
Attributes
::
setRealArray
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R
],
expectedR
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CORRX
],
expectedR21
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CORRY
],
expectedR43
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CORRZ
],
expectedR65
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R51
],
expectedR51
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R61
],
expectedR61
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R52
],
expectedR52
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R62
],
expectedR62
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
EMITTED
],
false
);
dist
.
setDistType
();
...
...
@@ -61,6 +67,8 @@ TEST(BinomialTest, FullSigmaTest1) {
double
R21
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
pxDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e3
/
(
expectedR11
*
expectedR22
));
double
R43
=
(
gsl_stats_covariance
(
&
(
dist
.
yDist_m
[
0
]),
1
,
&
(
dist
.
pyDist_m
[
0
]),
1
,
dist
.
yDist_m
.
size
())
*
1e3
/
(
expectedR33
*
expectedR44
));
double
R51
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e6
/
(
expectedR11
*
expectedR55
));
double
R52
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
*
1e3
/
...
...
@@ -70,18 +78,19 @@ TEST(BinomialTest, FullSigmaTest1) {
double
R62
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
pzDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
/
(
expectedR22
*
expectedR66
));
EXPECT_NEAR
(
expectedR11
,
R11
,
0.05
*
std
::
abs
(
expectedR11
));
EXPECT_NEAR
(
expectedR22
,
R22
,
0.05
*
std
::
abs
(
expectedR22
));
EXPECT_NEAR
(
expectedR33
,
R33
,
0.05
*
std
::
abs
(
expectedR33
));
EXPECT_NEAR
(
expectedR44
,
R44
,
0.05
*
std
::
abs
(
expectedR44
));
EXPECT_NEAR
(
expectedR55
,
R55
,
0.05
*
std
::
abs
(
expectedR55
));
EXPECT_NEAR
(
expectedR66
,
R66
,
0.05
*
std
::
abs
(
expectedR66
));
EXPECT_NEAR
(
expectedR21
,
R21
,
0.1
*
std
::
abs
(
expectedR21
));
EXPECT_NEAR
(
expectedR51
,
R51
,
0.1
*
std
::
abs
(
expectedR51
));
EXPECT_NEAR
(
expectedR52
,
R52
,
0.1
*
std
::
abs
(
expectedR52
));
EXPECT_NEAR
(
expectedR61
,
R61
,
0.1
*
std
::
abs
(
expectedR61
));
EXPECT_NEAR
(
expectedR62
,
R62
,
0.1
*
std
::
abs
(
expectedR62
));
EXPECT_NEAR
(
R11
/
expectedR11
,
1.0
,
0.002
);
EXPECT_NEAR
(
R22
/
expectedR22
,
1.0
,
0.002
);
EXPECT_NEAR
(
R33
/
expectedR33
,
1.0
,
0.002
);
EXPECT_NEAR
(
R44
/
expectedR44
,
1.0
,
0.002
);
EXPECT_NEAR
(
R55
/
expectedR55
,
1.0
,
0.002
);
EXPECT_NEAR
(
R66
/
expectedR66
,
1.0
,
0.002
);
EXPECT_NEAR
(
R21
/
expectedR21
,
1.0
,
0.01
);
EXPECT_NEAR
(
R43
/
expectedR43
,
1.0
,
0.01
);
EXPECT_NEAR
(
R51
/
expectedR51
,
1.0
,
0.01
);
EXPECT_NEAR
(
R52
/
expectedR52
,
1.0
,
0.01
);
EXPECT_NEAR
(
R61
/
expectedR61
,
1.0
,
0.01
);
EXPECT_NEAR
(
R62
/
expectedR62
,
1.0
,
0.01
);
}
TEST
(
BinomialTest
,
FullSigmaTest2
)
{
...
...
@@ -104,7 +113,10 @@ TEST(BinomialTest, FullSigmaTest2) {
Distribution
dist
;
Attributes
::
setString
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
TYPE
],
"GAUSS"
);
Attributes
::
setString
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
TYPE
],
"BINOMIAL"
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MX
],
1.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MY
],
1.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
MZ
],
1.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAX
],
expectedR11
*
1e-3
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAPX
],
expectedR22
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAY
],
expectedR33
*
1e-3
);
...
...
@@ -119,6 +131,7 @@ TEST(BinomialTest, FullSigmaTest2) {
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R52
],
expectedR52
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R62
],
expectedR62
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
EMITTED
],
false
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
WRITETOFILE
],
true
);
dist
.
setDistType
();
dist
.
checkIfEmitted
();
...
...
@@ -135,6 +148,8 @@ TEST(BinomialTest, FullSigmaTest2) {
double
R21
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
pxDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e3
/
(
expectedR11
*
expectedR22
));
double
R43
=
(
gsl_stats_covariance
(
&
(
dist
.
yDist_m
[
0
]),
1
,
&
(
dist
.
pyDist_m
[
0
]),
1
,
dist
.
yDist_m
.
size
())
*
1e3
/
(
expectedR33
*
expectedR44
));
double
R51
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e6
/
(
expectedR11
*
expectedR55
));
double
R52
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
*
1e3
/
...
...
@@ -144,16 +159,17 @@ TEST(BinomialTest, FullSigmaTest2) {
double
R62
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
pzDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
/
(
expectedR22
*
expectedR66
));
EXPECT_NEAR
(
expectedR11
,
R11
,
0.05
*
std
::
abs
(
expectedR11
));
EXPECT_NEAR
(
expectedR22
,
R22
,
0.05
*
std
::
abs
(
expectedR22
));
EXPECT_NEAR
(
expectedR33
,
R33
,
0.05
*
std
::
abs
(
expectedR33
));
EXPECT_NEAR
(
expectedR44
,
R44
,
0.05
*
std
::
abs
(
expectedR44
));
EXPECT_NEAR
(
expectedR55
,
R55
,
0.05
*
std
::
abs
(
expectedR55
));
EXPECT_NEAR
(
expectedR66
,
R66
,
0.05
*
std
::
abs
(
expectedR66
));
EXPECT_NEAR
(
expectedR21
,
R21
,
0.1
*
std
::
abs
(
expectedR21
));
EXPECT_NEAR
(
expectedR51
,
R51
,
0.1
*
std
::
abs
(
expectedR51
));
EXPECT_NEAR
(
expectedR52
,
R52
,
0.1
*
std
::
abs
(
expectedR52
));
EXPECT_NEAR
(
expectedR61
,
R61
,
0.1
*
std
::
abs
(
expectedR61
));
EXPECT_NEAR
(
expectedR62
,
R62
,
0.1
*
std
::
abs
(
expectedR62
));
EXPECT_NEAR
(
R11
/
expectedR11
,
1.0
,
0.002
);
EXPECT_NEAR
(
R22
/
expectedR22
,
1.0
,
0.002
);
EXPECT_NEAR
(
R33
/
expectedR33
,
1.0
,
0.002
);
EXPECT_NEAR
(
R44
/
expectedR44
,
1.0
,
0.002
);
EXPECT_NEAR
(
R55
/
expectedR55
,
1.0
,
0.002
);
EXPECT_NEAR
(
R66
/
expectedR66
,
1.0
,
0.002
);
EXPECT_NEAR
(
R21
/
expectedR21
,
1.0
,
0.01
);
EXPECT_NEAR
(
R43
/
expectedR43
,
1.0
,
0.01
);
EXPECT_NEAR
(
R51
/
expectedR51
,
1.0
,
0.01
);
EXPECT_NEAR
(
R52
/
expectedR52
,
1.0
,
0.01
);
EXPECT_NEAR
(
R61
/
expectedR61
,
1.0
,
0.01
);
EXPECT_NEAR
(
R62
/
expectedR62
,
1.0
,
0.01
);
}
\ No newline at end of file
tests/opal_src/Distribution/GaussTest.cpp
View file @
1a5bff88
...
...
@@ -9,7 +9,7 @@
#include "gsl/gsl_statistics_double.h"
TEST
(
GaussTest
,
FullSigmaTest1
)
{
OpalTestUtilities
::
SilenceTest
silencer
(
fals
e
);
OpalTestUtilities
::
SilenceTest
silencer
(
tru
e
);
const
double
expectedR11
=
1.978
;
const
double
expectedR22
=
0.7998
;
...
...
@@ -41,8 +41,15 @@ TEST(GaussTest, FullSigmaTest1) {
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAPY
],
expectedR44
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAZ
],
expectedR55
*
1e-3
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
SIGMAPZ
],
expectedR66
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFX
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFY
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFLONG
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFPX
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFPY
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFPZ
],
5.0
);
Attributes
::
setRealArray
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R
],
expectedR
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
EMITTED
],
false
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
WRITETOFILE
],
true
);
dist
.
setDistType
();
dist
.
checkIfEmitted
();
...
...
@@ -58,6 +65,8 @@ TEST(GaussTest, FullSigmaTest1) {
double
R21
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
pxDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e3
/
(
expectedR11
*
expectedR22
));
double
R43
=
(
gsl_stats_covariance
(
&
(
dist
.
yDist_m
[
0
]),
1
,
&
(
dist
.
pyDist_m
[
0
]),
1
,
dist
.
yDist_m
.
size
())
*
1e3
/
(
expectedR33
*
expectedR44
));
double
R51
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e6
/
(
expectedR11
*
expectedR55
));
double
R52
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
*
1e3
/
...
...
@@ -67,22 +76,23 @@ TEST(GaussTest, FullSigmaTest1) {
double
R62
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
pzDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
/
(
expectedR22
*
expectedR66
));
EXPECT_NEAR
(
expectedR11
,
R11
,
0.05
*
std
::
abs
(
expectedR11
));
EXPECT_NEAR
(
expectedR22
,
R22
,
0.05
*
std
::
abs
(
expectedR22
));
EXPECT_NEAR
(
expectedR33
,
R33
,
0.05
*
std
::
abs
(
expectedR33
));
EXPECT_NEAR
(
expectedR44
,
R44
,
0.05
*
std
::
abs
(
expectedR44
));
EXPECT_NEAR
(
expectedR55
,
R55
,
0.05
*
std
::
abs
(
expectedR55
));
EXPECT_NEAR
(
expectedR66
,
R66
,
0.05
*
std
::
abs
(
expectedR66
));
EXPECT_NEAR
(
expectedR21
,
R21
,
0.1
*
std
::
abs
(
expectedR21
));
EXPECT_NEAR
(
expectedR51
,
R51
,
0.1
*
std
::
abs
(
expectedR51
));
EXPECT_NEAR
(
expectedR52
,
R52
,
0.1
*
std
::
abs
(
expectedR52
));
EXPECT_NEAR
(
expectedR61
,
R61
,
0.1
*
std
::
abs
(
expectedR61
));
EXPECT_NEAR
(
expectedR62
,
R62
,
0.1
*
std
::
abs
(
expectedR62
));
EXPECT_NEAR
(
R11
/
expectedR11
,
1.0
,
0.002
);
EXPECT_NEAR
(
R22
/
expectedR22
,
1.0
,
0.002
);
EXPECT_NEAR
(
R33
/
expectedR33
,
1.0
,
0.002
);
EXPECT_NEAR
(
R44
/
expectedR44
,
1.0
,
0.002
);
EXPECT_NEAR
(
R55
/
expectedR55
,
1.0
,
0.002
);
EXPECT_NEAR
(
R66
/
expectedR66
,
1.0
,
0.002
);
EXPECT_NEAR
(
R21
/
expectedR21
,
1.0
,
0.02
);
EXPECT_NEAR
(
R43
/
expectedR43
,
1.0
,
0.02
);
EXPECT_NEAR
(
R51
/
expectedR51
,
1.0
,
0.05
);
EXPECT_NEAR
(
R52
/
expectedR52
,
1.0
,
0.02
);
EXPECT_NEAR
(
R61
/
expectedR61
,
1.0
,
0.02
);
EXPECT_NEAR
(
R62
/
expectedR62
,
1.0
,
0.02
);
}
TEST
(
GaussTest
,
FullSigmaTest2
)
{
OpalTestUtilities
::
SilenceTest
silencer
(
fals
e
);
OpalTestUtilities
::
SilenceTest
silencer
(
tru
e
);
const
double
expectedR11
=
1.978
;
const
double
expectedR22
=
0.7998
;
...
...
@@ -115,7 +125,14 @@ TEST(GaussTest, FullSigmaTest2) {
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R61
],
expectedR61
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R52
],
expectedR52
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
R62
],
expectedR62
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFX
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFY
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFLONG
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFPX
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFPY
],
5.0
);
Attributes
::
setReal
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
CUTOFFPZ
],
5.0
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
EMITTED
],
false
);
Attributes
::
setBool
(
dist
.
itsAttr
[
Attrib
::
Distribution
::
WRITETOFILE
],
true
);
dist
.
setDistType
();
dist
.
checkIfEmitted
();
...
...
@@ -132,6 +149,8 @@ TEST(GaussTest, FullSigmaTest2) {
double
R21
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
pxDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e3
/
(
expectedR11
*
expectedR22
));
double
R43
=
(
gsl_stats_covariance
(
&
(
dist
.
yDist_m
[
0
]),
1
,
&
(
dist
.
pyDist_m
[
0
]),
1
,
dist
.
yDist_m
.
size
())
*
1e3
/
(
expectedR33
*
expectedR44
));
double
R51
=
(
gsl_stats_covariance
(
&
(
dist
.
xDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
xDist_m
.
size
())
*
1e6
/
(
expectedR11
*
expectedR55
));
double
R52
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
tOrZDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
*
1e3
/
...
...
@@ -141,16 +160,17 @@ TEST(GaussTest, FullSigmaTest2) {
double
R62
=
(
gsl_stats_covariance
(
&
(
dist
.
pxDist_m
[
0
]),
1
,
&
(
dist
.
pzDist_m
[
0
]),
1
,
dist
.
pxDist_m
.
size
())
/
(
expectedR22
*
expectedR66
));
EXPECT_NEAR
(
expectedR11
,
R11
,
0.05
*
std
::
abs
(
expectedR11
));
EXPECT_NEAR
(
expectedR22
,
R22
,
0.05
*
std
::
abs
(
expectedR22
));
EXPECT_NEAR
(
expectedR33
,
R33
,
0.05
*
std
::
abs
(
expectedR33
));
EXPECT_NEAR
(
expectedR44
,
R44
,
0.05
*
std
::
abs
(
expectedR44
));
EXPECT_NEAR
(
expectedR55
,
R55
,
0.05
*
std
::
abs
(
expectedR55
));
EXPECT_NEAR
(
expectedR66
,
R66
,
0.05
*
std
::
abs
(
expectedR66
));
EXPECT_NEAR
(
expectedR21
,
R21
,
0.1
*
std
::
abs
(
expectedR21
));
EXPECT_NEAR
(
expectedR51
,
R51
,
0.1
*
std
::
abs
(
expectedR51
));
EXPECT_NEAR
(
expectedR52
,
R52
,
0.1
*
std
::
abs
(
expectedR52
));
EXPECT_NEAR
(
expectedR61
,
R61
,
0.1
*
std
::
abs
(
expectedR61
));
EXPECT_NEAR
(
expectedR62
,
R62
,
0.1
*
std
::
abs
(
expectedR62
));
EXPECT_NEAR
(
R11
/
expectedR11
,
1.0
,
0.002
);
EXPECT_NEAR
(
R22
/
expectedR22
,
1.0
,
0.002
);
EXPECT_NEAR
(
R33
/
expectedR33
,
1.0
,
0.002
);
EXPECT_NEAR
(
R44
/
expectedR44
,
1.0
,
0.002
);
EXPECT_NEAR
(
R55
/
expectedR55
,
1.0
,
0.002
);
EXPECT_NEAR
(
R66
/
expectedR66
,
1.0
,
0.002
);
EXPECT_NEAR
(
R21
/
expectedR21
,
1.0
,
0.02
);
EXPECT_NEAR
(
R43
/
expectedR43
,
1.0
,
0.02
);
EXPECT_NEAR
(
R51
/
expectedR51
,
1.0
,
0.05
);
EXPECT_NEAR
(
R52
/
expectedR52
,
1.0
,
0.02
);
EXPECT_NEAR
(
R61
/
expectedR61
,
1.0
,
0.02
);
EXPECT_NEAR
(
R62
/
expectedR62
,
1.0
,
0.02
);
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment