Main Page
Namespaces
Classes
Package Documentation
MagneticField
ParametrizedEngine
src
poly2d_base.h
Go to the documentation of this file.
1
#ifndef poly2d_base_h
2
#define poly2d_base_h
3
4
#include <iostream>
5
#include <fstream>
6
#include <iomanip>
7
#include <vector>
8
#include <set>
9
#include <cstring>
10
11
#include <cmath>
12
#include <cfloat>
//in order to use DBL_EPSILON (1+DBL_EPSILON > 1)
13
15
// //
16
// The "poly2d_term" represent a term of a polynomial of 2 variables. //
17
// //
19
20
//_______________________________________________________________________________
21
namespace
magfieldparam
{
22
23
struct
poly2d_term
{
24
double
coeff
;
//Coefficient of the term
25
unsigned
np
[2];
//Powers of variables
26
27
poly2d_term
() {memset(
this
, 0,
sizeof
(*
this
));}
28
poly2d_term
(
double
C
,
unsigned
nr,
unsigned
nz)
29
{
30
coeff =
C
; np[0] = nr; np[1] = nz;
31
}
32
void
Print
(std::ostream &
out
=
std::cout
,
bool
first_term =
true
);
33
};
34
36
// //
37
// Base class that represent a polynomial of 2 variables. It isn't supposed //
38
// to be used directly and provides no way of setting coefficients directly. //
39
// Such methods must be defined in derived classes. //
40
// //
42
43
//_______________________________________________________________________________
44
class
poly2d_base
{
// a general polynomial of 2 variables
45
46
protected
:
47
//Group of static members for the class memory management
48
//----------------------------------------------------------------------------
49
static
double
rval
;
//last r-value used in calculation
50
static
double
zval
;
//last z-value used in calculation
51
52
static
double
**
rz_pow
;
//table with calculated r^n*z^m values
53
static
unsigned
NTab
;
//rz_pow table size
54
static
unsigned
NPwr
;
//max power in use by CLASS
55
static
bool
rz_set
;
56
57
static
const
double
MIN_COEFF
;
//Threshold for assigning a coeff. to 0
58
59
static
std::set<poly2d_base*>
poly2d_base_set
;
//Set of all poly2d_base objects
60
// static std::set<poly2d_base*, less<poly2d_base*> > poly2d_base_set; //Set of all poly2d_base objects
61
62
static
void
SetTabSize(
const
unsigned
N
);
//Set rz-table size
63
static
void
FillTable (
const
double
r
,
const
double
z);
64
65
static
void
AdjustTab();
66
//----------------------------------------------------------------------------
67
68
std::vector<poly2d_term>
data
;
//polynomial terms
69
unsigned
max_pwr
;
//max power in use by INSTANCE
70
71
public
:
72
static
void
IncNPwr
(
const
unsigned
N
) {
if
(N > NPwr) NPwr =
N
;}
73
static
int
GetMaxPow();
74
static
unsigned
Count
() {
return
poly2d_base_set.size();}
75
static
void
PrintTab(std::ostream &
out
=
std::cout
,
const
std::streamsize prec = 5);
76
77
static
void
SetPoint(
const
double
r
,
const
double
z);
78
79
poly2d_base
() {
80
max_pwr = 0;
81
poly2d_base_set.insert(
this
);
82
}
83
poly2d_base
(
const
poly2d_base
&
S
) {
84
data = S.
data
;
85
max_pwr = S.
max_pwr
;
86
poly2d_base_set.insert(
this
);
87
}
88
89
virtual
~
poly2d_base
();
90
91
bool
IsOn
() {
return
bool
(!data.empty());}
92
bool
IsRZSet
() {
return
rz_set;}
93
94
void
Collect();
//Collect terms and remove zero terms
95
void
Compress
() { Collect();}
96
97
void
Diff (
int
nvar);
//differentiate the polynomial by variable# nvar
98
void
Int
(
int
nvar);
//Integrate the polynomial by variable# nvar
99
void
IncPow(
int
nvar);
//Multiply the polynomial by variable# nvar
100
void
DecPow(
int
nvar);
//Divide the polynomial by variable# nvar
101
102
void
Scale(
const
double
C
);
103
// poly2d_base& operator*=(const double C) { Scale(C); return *this;}
104
105
double
Eval();
//Evaluation with no check that rz_pow table exist
106
double
GetVal
() {
if
(rz_set)
return
Eval();
else
return
0.;}
107
double
GetVal
(
const
double
r,
const
double
z) { SetPoint(r,z);
return
Eval();}
108
109
void
Print
(std::ostream &
out
=
std::cout
,
const
std::streamsize prec = 5);
110
111
};
//Class poly2d_base
112
}
113
114
#endif
magfieldparam::poly2d_base
Definition:
poly2d_base.h:44
magfieldparam::poly2d_base::NTab
static unsigned NTab
Definition:
poly2d_base.h:53
magfieldparam::poly2d_base::data
std::vector< poly2d_term > data
Definition:
poly2d_base.h:68
magfieldparam::poly2d_base::poly2d_base
poly2d_base(const poly2d_base &S)
Definition:
poly2d_base.h:83
magfieldparam::poly2d_base::GetVal
double GetVal(const double r, const double z)
Definition:
poly2d_base.h:107
magfieldparam::poly2d_base::IsRZSet
bool IsRZSet()
Definition:
poly2d_base.h:92
magfieldparam::poly2d_base::rz_pow
static double ** rz_pow
Definition:
poly2d_base.h:52
magfieldparam::poly2d_base::poly2d_base
poly2d_base()
Definition:
poly2d_base.h:79
magfieldparam::poly2d_term::poly2d_term
poly2d_term(double C, unsigned nr, unsigned nz)
Definition:
poly2d_base.h:28
magfieldparam::poly2d_base::poly2d_base_set
static std::set< poly2d_base * > poly2d_base_set
Definition:
poly2d_base.h:59
magfieldparam::poly2d_base::rz_set
static bool rz_set
Definition:
poly2d_base.h:55
magfieldparam::poly2d_term::coeff
double coeff
Definition:
poly2d_base.h:24
magfieldparam
Definition:
BCyl.h:23
magfieldparam::poly2d_term
Definition:
poly2d_base.h:23
magfieldparam::poly2d_base::zval
static double zval
Definition:
poly2d_base.h:50
magfieldparam::poly2d_base::max_pwr
unsigned max_pwr
Definition:
poly2d_base.h:69
patCaloMETCorrections_cff.C
C
Definition:
patCaloMETCorrections_cff.py:45
magfieldparam::poly2d_term::Print
void Print(std::ostream &out=std::cout, bool first_term=true)
Definition:
poly2d_base.cc:12
magfieldparam::poly2d_base::IncNPwr
static void IncNPwr(const unsigned N)
Definition:
poly2d_base.h:72
magfieldparam::poly2d_base::Compress
void Compress()
Definition:
poly2d_base.h:95
electrons_cff.bool
bool
Definition:
electrons_cff.py:154
alignCSCRings.r
r
Definition:
alignCSCRings.py:92
Json::Int
int Int
Definition:
forwards.h:16
MillePedeFileConverter_cfg.out
out
Definition:
MillePedeFileConverter_cfg.py:31
N
#define N
Definition:
blowfish.cc:9
magfieldparam::poly2d_base::GetVal
double GetVal()
Definition:
poly2d_base.h:106
magfieldparam::poly2d_base::IsOn
bool IsOn()
Definition:
poly2d_base.h:91
magfieldparam::poly2d_term::np
unsigned np[2]
Definition:
poly2d_base.h:25
S
double S(const TLorentzVector &, const TLorentzVector &)
Definition:
Particle.cc:99
magfieldparam::poly2d_base::rval
static double rval
Definition:
poly2d_base.h:49
magfieldparam::poly2d_base::NPwr
static unsigned NPwr
Definition:
poly2d_base.h:54
gather_cfg.cout
cout
Definition:
gather_cfg.py:145
magfieldparam::poly2d_base::MIN_COEFF
static const double MIN_COEFF
Definition:
poly2d_base.h:57
magfieldparam::poly2d_term::poly2d_term
poly2d_term()
Definition:
poly2d_base.h:27
magfieldparam::poly2d_base::Count
static unsigned Count()
Definition:
poly2d_base.h:74
Generated for CMSSW Reference Manual by
1.8.11