Garfield++ v1r0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
linexi2.cpp
Go to the documentation of this file.
1#include <cfloat>
5/*
6Copyright (c) 2000 I. B. Smirnov
7
8Permission to use, copy, modify, distribute and sell this file for any purpose
9is hereby granted without fee, provided that the above copyright notice,
10this permission notice, and notices about any modifications of the original
11text appear in all copies and in supporting documentation.
12The file is provided "as is" without express or implied warranty.
13*/
14
15linexi2_coor::linexi2_coor(const long fqlr, const double* fax)
16 : qlr(fqlr), ax(fax) {
17 long n;
18 x_mean = 0;
19 Dx = 0;
20 for (n = 0; n < qlr; n++) {
21 x_mean += ax[n];
22 Dx += ax[n] * ax[n];
23 }
24 x_mean /= qlr;
25 Dx /= qlr;
26 Dx = Dx - x_mean * x_mean;
27}
28std::ostream& operator<<(std::ostream& file, const linexi2_coor& l) {
29 Ifile << "linexi2_coor: qlr=" << l.qlr << " x_mean=" << l.x_mean
30 << " Dx=" << l.Dx << '\n';
31 int n;
32 for (n = 0; n < l.qlr; n++)
33 Ifile << "n=" << n << " x=" << l.ax[n] << '\n';
34 return file;
35}
36linexi2::linexi2(const linexi2_coor& lc, const double* fay)
37 : linexi2_coor(lc), ay(fay) {
38 long n;
39 y_mean = 0;
40 xy_mean = 0;
41 for (n = 0; n < qlr; n++) {
42 y_mean += ay[n];
43 xy_mean += ax[n] * ay[n];
44 }
45 y_mean /= qlr;
46 xy_mean /= qlr;
47 if (Dx > 0)
48 a = (xy_mean - x_mean * y_mean) / Dx;
49 else
50 a = DBL_MAX;
51 b = y_mean - a * x_mean;
52}
53linexi2::linexi2(const long fqlr, const double* fax, const double* fay)
54 : linexi2_coor(fqlr, fax), ay(fay) {
55 long n;
56 y_mean = 0;
57 xy_mean = 0;
58 for (n = 0; n < qlr; n++) {
59 y_mean += ay[n];
60 xy_mean += ax[n] * ay[n];
61 }
62 y_mean /= qlr;
63 xy_mean /= qlr;
64 if (Dx > 0)
65 a = (xy_mean - x_mean * y_mean) / Dx;
66 else
67 a = DBL_MAX;
68 b = y_mean - a * x_mean;
69}
70std::ostream& operator<<(std::ostream& file, const linexi2& l) {
71 Ifile << "linexi2_coor: qlr=" << l.qlr << '\n';
72 Ifile << "x_mean=" << l.x_mean << " Dx=" << l.Dx << '\n';
73 Ifile << "y_mean=" << l.y_mean << " xy_mean=" << l.xy_mean << '\n';
74 Ifile << "a=" << l.a << " b=" << l.b << '\n';
75 int n;
76 for (n = 0; n < l.qlr; n++)
77 Ifile << "n=" << n << " x=" << l.ax[n] << " y=" << l.ay[n] << '\n';
78 return file;
79}
81 mfunname("linexi2B::linexi2B(linexi2& lx)");
82 B = (double**)new double[lx.qlr * lx.qlr];
83 long i, m;
84 for (i = 0; i < qlr; i++)
85 for (m = 0; m < qlr; m++)
86 B[i][m] = (ax[i] - x_mean) * (ax[m] - x_mean) / Dx + 1;
87}
88void linexi2B::copy(const linexi2B& lxB) {
89 *this = (linexi2&)lxB; // '=' redefined
90 long i, m;
91 for (i = 0; i < qlr; i++)
92 for (m = 0; m < qlr; m++)
93 B[i][m] = lxB.B[i][m];
94}
96 mfunname("linexi2B::linexi2B(const linexi2B& lxB)");
97 B = (double**)new double[lxB.qlr * lxB.qlr];
98 long i, m;
99 for (i = 0; i < qlr; i++)
100 for (m = 0; m < qlr; m++)
101 B[i][m] = lxB.B[i][m];
102}
#define mfunname(string)
Definition: FunNameStack.h:67
double ** B
Definition: linexi2.h:72
linexi2B(linexi2 &lx)
Definition: linexi2.cpp:80
void copy(const linexi2B &lxB)
Definition: linexi2.cpp:88
double x_mean
Definition: linexi2.h:22
const double * ax
Definition: linexi2.h:21
linexi2_coor(const long fqlr, const double *fax)
Definition: linexi2.cpp:15
double Dx
Definition: linexi2.h:23
long qlr
Definition: linexi2.h:20
double y_mean
Definition: linexi2.h:42
const double * ay
Definition: linexi2.h:41
double a
Definition: linexi2.h:44
linexi2(const linexi2_coor &lc, const double *fay)
Definition: linexi2.cpp:36
double xy_mean
Definition: linexi2.h:43
double b
Definition: linexi2.h:45
std::ostream & operator<<(std::ostream &file, const linexi2_coor &l)
Definition: linexi2.cpp:28
#define Ifile
Definition: prstream.h:207