30 double bz0 = fld->solenoidField();
31 LOG(info) <<
"Created default magnetic field for " << bz0 <<
"kG";
32 const double nomBz = 5.00685;
33 BOOST_CHECK_CLOSE(bz0, nomBz, 0.1);
35 const int ntst = 10000;
37 double xyz[ntst][3] = {}, bxyz[ntst][3] = {}, dummyAcc = 0.;
39 for (
int it = ntst; it--;) {
40 gRandom->RndmArray(3, rnd);
41 xyz[it][0] = rnd[0] * 400. * TMath::Cos(rnd[1] * TMath::Pi() * 2);
42 xyz[it][1] = rnd[1] * 400. * TMath::Sin(rnd[1] * TMath::Pi() * 2);
43 xyz[it][2] = (rnd[0] - 0.5) * 250;
46 const int repFactor = 50;
50 for (
int ii = repFactor; ii--;) {
51 for (
int it = ntst; it--;) {
52 fld->Field(xyz[it], bxyz[it]);
58 fld->AllowFastField(
true);
64 for (
int ii = repFactor; ii--;) {
65 for (
int it = ntst; it--;) {
66 fld->Field(xyz[it], bfast);
71 double sS = swSlow.CpuTime() / (ntst * repFactor);
72 double sF = swFast.CpuTime() / (ntst * repFactor);
73 double rat = sF > 0. ? sS / sF : -1;
74 LOG(info) <<
"Timing: Exact param: " << sS <<
" Fast param: " << sF
75 <<
"s/call -> factor " << rat;
78 double mean[3] = {0.}, rms[3] = {0.};
79 const char comp[] =
"XYZ";
80 LOG(info) <<
"Relative precision of fast field wrt exact field";
81 for (
int it = ntst; it--;) {
82 fld->Field(xyz[it], bfast);
83 for (
int i = 0;
i < 3;
i++) {
84 double df = bxyz[it][
i] - bfast[
i];
89 for (
int i = 0;
i < 3;
i++) {
92 rms[
i] -= mean[
i] * mean[
i];
93 rms[
i] = TMath::Sqrt(rms[
i]);
94 LOG(info) <<
"deltaB" << comp[
i] <<
": "
95 <<
" mean=" << mean[
i] <<
"(" << mean[
i] / nomBz * 100. <<
"%)"
96 <<
" RMS =" << rms[
i] <<
"(" << rms[
i] / nomBz * 100. <<
"%)";