5 using namespace magfieldparam;
8 rz_poly::rz_poly(
int N)
10 int nz, nr = 0, nv,
nt;
22 for (
int m = 2;
m <=
N; ++
m) {
37 v3x[nv].coeff = -v3x[nv-1].coeff*(nz+1)*(nz+2)/(nr*nr);
45 r_pow =
new double [max_nr];
46 z_pow =
new double [max_nz];
47 fill(r_pow, r_pow+max_nr, 1.);
48 fill(z_pow, z_pow+max_nz, 1.);
50 n_active =
data.size();
51 is_off =
new bool [n_active];
52 fill(is_off, is_off+n_active,
false);
64 r_pow =
new double [max_nr];
69 z_pow =
new double [max_nz];
74 is_off =
new bool [
data.size()];
82 if (is_off)
delete [] is_off;
83 if (r_pow)
delete [] r_pow;
84 if (z_pow)
delete [] z_pow;
88 void rz_poly::SetOFF(
int npoly)
90 if ((npoly < 0) || (npoly >= (
int)
data.size()))
return;
91 if (is_off[npoly])
return;
97 void rz_poly::SetON(
int npoly)
99 if ((npoly < 0) || (npoly >= (
int)
data.size()))
return;
101 is_off[npoly] =
false;
110 cout <<
"The \"rz_poly\" object is NOT initialized!" << endl;
114 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
115 cout <<
"Polynomial " << ip <<
" (size=" <<
data[ip].size() <<
", status=";
116 if (is_off[ip])
cout <<
"OFF):" << endl;
117 else cout <<
"ON):" << endl;
118 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
119 cout <<
"\tnr=" <<
data[ip][it].np[0]
120 <<
"\tnz=" <<
data[ip][it].np[1]
121 <<
"\tcoeff=" <<
data[ip][it].coeff
128 rz_poly rz_poly::Diff(
int nvar,
bool keep_empty)
139 bool *tmp_mask =
new bool [
data.size()];
140 unsigned int ind_tmp = 0;
143 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
146 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
150 v3.
np[nvar] =
data[ip][it].np[nvar] - 1;
154 if (v3x.size() || keep_empty) {
155 v3x.resize(v3x.size());
156 p_out.
data.push_back(v3x);
157 tmp_mask[ind_tmp] = is_off[ip];
159 if (! is_off[ip]) ++tmp_act;
163 p_out.
data.resize(p_out.
data.size());
190 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
191 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
192 p_out.
data[ip][it].coeff /= ++p_out.
data[ip][it].np[nvar];
206 if (nvar == 0) p_out.
r_pow[max_nr] = p_out.
r_pow[max_nr-1] * r_pow[1];
207 else p_out.
z_pow[max_nz] = p_out.
z_pow[max_nz-1] * z_pow[1];
221 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
222 if (is_off[ip])
continue;
223 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
224 data[ip][it].coeff *=
C;
235 for (
unsigned int ip = 0; ip <
data.size(); ++ip) {
236 if (is_off[ip])
continue;
237 for (
unsigned int it = 0; it <
data[ip].size(); ++it) {
238 data[ip][it].coeff *= *
C;
246 double rz_poly::GetSVal(
double r,
double z,
const double *
C)
const
250 if (r_pow == 0)
return 0.;
252 double term, rez = 0.;
255 if (r != r_pow[1])
for (ip = 1; ip < max_nr; ++ip) r_pow[ip] = r*r_pow[ip-1];
256 if (z != z_pow[1])
for (ip = 1; ip < max_nz; ++ip) z_pow[ip] = z*z_pow[ip-1];
258 for (ip = 0; ip < (int)
data.size(); ++ip) {
259 if (is_off[ip])
continue;
261 for (it = 0; it < (int)
data[ip].
size(); ++it) {
262 term +=
data[ip][it].coeff
263 * r_pow[
data[ip][it].np[0]]
264 * z_pow[
data[ip][it].np[1]];
274 double *rz_poly::GetVVal(
double r,
double z,
double *rez_out)
281 if (r_pow == 0)
return 0;
287 if (rez_out) rez = rez_out;
288 else rez =
new double [n_active];
292 if (r != r_pow[1])
for (ip = 1; ip < max_nr; ++ip) r_pow[ip] = r*r_pow[ip-1];
293 if (z != z_pow[1])
for (ip = 1; ip < max_nz; ++ip) z_pow[ip] = z*z_pow[ip-1];
295 for (ip = 0; ip < (int)
data.size(); ++ip) {
296 if (is_off[ip])
continue;
298 for (it = 0; it < (int)
data[ip].
size(); ++it) {
299 term +=
data[ip][it].coeff
300 * r_pow[
data[ip][it].np[0]]
301 * z_pow[
data[ip][it].np[1]];
311 double *rz_poly::Expand(
double *
C)
317 double *rez =
new double [
data.size()];
318 for (
int ip = 0; ip < (int)
data.size(); ++ip) {
319 if (is_off[ip]) rez[ip] = 0.;
Basic3DVector & operator*=(T t)
Scaling by a scalar value (multiplication)
std::vector< poly_term > poly_vect
double S(const TLorentzVector &, const TLorentzVector &)
tuple size
Write out results.