Garfield++ 4.0
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>
4/*
5Copyright (c) 2000 I. B. Smirnov
6
7Permission to use, copy, modify, distribute and sell this file for any purpose
8is hereby granted without fee, provided that the above copyright notice,
9this permission notice, and notices about any modifications of the original
10text appear in all copies and in supporting documentation.
11The file is provided "as is" without express or implied warranty.
12*/
13
14namespace Heed {
15
16linexi2_coor::linexi2_coor(const long fqlr, const double* fax)
17 : qlr(fqlr), ax(fax) {
18 x_mean = 0;
19 Dx = 0;
20 for (long 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 for (int n = 0; n < l.qlr; n++) Ifile << "n=" << n << " x=" << l.ax[n] << '\n';
32 return file;
33}
34linexi2::linexi2(const linexi2_coor& lc, const double* fay)
35 : linexi2_coor(lc), ay(fay) {
36 y_mean = 0;
37 xy_mean = 0;
38 for (long n = 0; n < qlr; n++) {
39 y_mean += ay[n];
40 xy_mean += ax[n] * ay[n];
41 }
42 y_mean /= qlr;
43 xy_mean /= qlr;
44 if (Dx > 0)
45 a = (xy_mean - x_mean * y_mean) / Dx;
46 else
47 a = DBL_MAX;
48 b = y_mean - a * x_mean;
49}
50linexi2::linexi2(const long fqlr, const double* fax, const double* fay)
51 : linexi2_coor(fqlr, fax), ay(fay) {
52 y_mean = 0;
53 xy_mean = 0;
54 for (long n = 0; n < qlr; n++) {
55 y_mean += ay[n];
56 xy_mean += ax[n] * ay[n];
57 }
58 y_mean /= qlr;
59 xy_mean /= qlr;
60 if (Dx > 0)
61 a = (xy_mean - x_mean * y_mean) / Dx;
62 else
63 a = DBL_MAX;
64 b = y_mean - a * x_mean;
65}
66std::ostream& operator<<(std::ostream& file, const linexi2& l) {
67 Ifile << "linexi2_coor: qlr=" << l.qlr << '\n';
68 Ifile << "x_mean=" << l.x_mean << " Dx=" << l.Dx << '\n';
69 Ifile << "y_mean=" << l.y_mean << " xy_mean=" << l.xy_mean << '\n';
70 Ifile << "a=" << l.a << " b=" << l.b << '\n';
71 for (int n = 0; n < l.qlr; n++)
72 Ifile << "n=" << n << " x=" << l.ax[n] << " y=" << l.ay[n] << '\n';
73 return file;
74}
75}
const double * ax
Definition: linexi2.h:23
linexi2_coor(const long fqlr, const double *fax)
Definition: linexi2.cpp:16
double xy_mean
Definition: linexi2.h:45
double b
Definition: linexi2.h:47
double y_mean
Definition: linexi2.h:44
const double * ay
Definition: linexi2.h:43
linexi2(const linexi2_coor &lc, const double *fay)
Definition: linexi2.cpp:34
double a
Definition: linexi2.h:46
Definition: BGMesh.cpp:6
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
#define Ifile
Definition: prstream.h:195