CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
magfieldparam::rz_harm_poly Class Reference

#include <rz_harm_poly.h>

Inheritance diagram for magfieldparam::rz_harm_poly:
magfieldparam::poly2d_base

Public Member Functions

void CheatL (const unsigned newL)
 
double GetCos ()
 
rz_harm_poly GetDecPow (int nvar)
 
rz_harm_poly GetDiff (int nvar)
 
rz_harm_poly GetIncPow (int nvar)
 
rz_harm_poly GetInt (int nvar)
 
unsigned GetL ()
 
int GetM ()
 
double GetSin ()
 
bool IsPhiSet ()
 
rz_harm_poly LadderDwn ()
 
rz_harm_poly LadderUp ()
 
void Print (std::ostream &out=std::cout, const std::streamsize prec=5)
 
 rz_harm_poly ()
 
 rz_harm_poly (const poly2d_base &S)
 
 rz_harm_poly (const rz_harm_poly &S)
 
 rz_harm_poly (const unsigned N)
 
 ~rz_harm_poly () override
 
- Public Member Functions inherited from magfieldparam::poly2d_base
void Collect ()
 
void Compress ()
 
void DecPow (int nvar)
 
void Diff (int nvar)
 
double Eval ()
 
double GetVal ()
 
double GetVal (const double r, const double z)
 
void IncPow (int nvar)
 
void Int (int nvar)
 
bool IsOn ()
 
bool IsRZSet ()
 
 poly2d_base ()
 
 poly2d_base (const poly2d_base &S)
 
void Print (std::ostream &out=std::cout, const std::streamsize prec=5)
 
void Scale (const double C)
 
virtual ~poly2d_base ()
 

Static Public Member Functions

static unsigned Count ()
 
static int GetMaxM ()
 
static unsigned ParentCount ()
 
static void PrintTrigArr (std::ostream &out=std::cout, const std::streamsize prec=5)
 
static void SetPhi (const double phi)
 
static void SetPoint (const double r, const double z, const double phi)
 
- Static Public Member Functions inherited from magfieldparam::poly2d_base
static unsigned Count ()
 
static int GetMaxPow ()
 
static void IncNPwr (const unsigned N)
 
static void PrintTab (std::ostream &out=std::cout, const std::streamsize prec=5)
 
static void SetPoint (const double r, const double z)
 

Private Member Functions

void PrintLM (std::ostream &out=std::cout)
 

Static Private Member Functions

static void FillTrigArr (const double phi)
 
static void SetTrigArrSize (const unsigned N)
 

Private Attributes

unsigned L
 
int M
 

Static Private Attributes

static unsigned Cnt = 0
 
static unsigned MaxM = 0
 
static bool phi_set = false
 
static double phival = -11111.
 
static unsigned TASize = 0
 
static trig_pairTrigArr = nullptr
 

Additional Inherited Members

- Static Protected Member Functions inherited from magfieldparam::poly2d_base
static void AdjustTab ()
 
static void FillTable (const double r, const double z)
 
static void SetTabSize (const unsigned N)
 
- Protected Attributes inherited from magfieldparam::poly2d_base
std::vector< poly2d_termdata
 
unsigned max_pwr
 
- Static Protected Attributes inherited from magfieldparam::poly2d_base
static const double MIN_COEFF = DBL_EPSILON
 
static unsigned NPwr = 0
 
static unsigned NTab = 0
 
static std::set< poly2d_base * > poly2d_base_set
 
static double rval = 0.
 
static double ** rz_pow = nullptr
 
static bool rz_set = false
 
static double zval = 0.
 

Detailed Description

Definition at line 38 of file rz_harm_poly.h.

Constructor & Destructor Documentation

◆ rz_harm_poly() [1/4]

magfieldparam::rz_harm_poly::rz_harm_poly ( )
inline

Definition at line 68 of file rz_harm_poly.h.

68 : poly2d_base(), L(0), M(0) { ++Cnt; }

References Cnt.

◆ rz_harm_poly() [2/4]

magfieldparam::rz_harm_poly::rz_harm_poly ( const poly2d_base S)
inline

Definition at line 69 of file rz_harm_poly.h.

69 : poly2d_base(S), L(0), M(0) { ++Cnt; }

References Cnt.

◆ rz_harm_poly() [3/4]

magfieldparam::rz_harm_poly::rz_harm_poly ( const rz_harm_poly S)
inline

Definition at line 70 of file rz_harm_poly.h.

70 : poly2d_base(S), L(S.L), M(S.M) { ++Cnt; }

References Cnt.

◆ rz_harm_poly() [4/4]

rz_harm_poly::rz_harm_poly ( const unsigned  N)

Definition at line 23 of file rz_harm_poly.cc.

23  {
24  //Constructor for rz_harm_poly of length N. The polynomial P(r,z) is normalized
25  //in such a way that dP/dz(r=0,z)=z^(N-1)
26  //
27  unsigned nz = N, nr = 0, nv = 0;
28  poly2d_term v3(1. / N, nr, nz);
29 
30  data = std::vector<poly2d_term>((N + 2) / 2, v3);
31 
32  while (nz >= 2) {
33  nz -= 2;
34  nr += 2;
35  nv += 1;
36  data[nv].coeff = -data[nv - 1].coeff * (nz + 1) * (nz + 2) / (nr * nr);
37  data[nv].np[0] = nr;
38  data[nv].np[1] = nz;
39  }
40  max_pwr = N;
41  if (max_pwr > NPwr) {
42  NPwr = max_pwr;
43  rz_set = false;
44  phi_set = false;
45  }
46  L = N;
47  M = 0;
48  poly2d_base_set.insert(this);
49  ++Cnt;
50 }

References Cnt, magfieldparam::poly2d_base::data, L, M, magfieldparam::poly2d_base::max_pwr, N, magfieldparam::poly2d_base::NPwr, EgHLTOffHistBins_cfi::nr, phi_set, magfieldparam::poly2d_base::poly2d_base_set, and magfieldparam::poly2d_base::rz_set.

◆ ~rz_harm_poly()

rz_harm_poly::~rz_harm_poly ( )
override

Definition at line 53 of file rz_harm_poly.cc.

53  {
54  if (--Cnt) {
55  if (std::abs(M) >= int(MaxM)) { //a number of objects still left
56  M = 0;
57  MaxM = GetMaxM();
58  }
59  } else { //last instance -> memory cleanup
60  if (TrigArr)
61  delete[] TrigArr;
62  TrigArr = nullptr;
63  TASize = 0;
64  MaxM = 0;
65  phival = -11111.;
66  phi_set = false;
67  }
68 }

References funct::abs(), Cnt, GetMaxM(), M, MaxM, phi_set, phival, TASize, and TrigArr.

Member Function Documentation

◆ CheatL()

void magfieldparam::rz_harm_poly::CheatL ( const unsigned  newL)
inline

Definition at line 109 of file rz_harm_poly.h.

109 { L = newL; }

References L.

◆ Count()

static unsigned magfieldparam::rz_harm_poly::Count ( )
inlinestatic

Definition at line 61 of file rz_harm_poly.h.

61 { return Cnt; }

References Cnt.

◆ FillTrigArr()

void rz_harm_poly::FillTrigArr ( const double  phi)
staticprivate

Definition at line 114 of file rz_harm_poly.cc.

114  {
115  //Fill TrigArr with trig_pair(jp*phi)
116  if (!TrigArr)
117  return;
118  trig_pair tp(phi);
119  TrigArr[1] = tp;
120  for (unsigned jp = 2; jp <= MaxM; ++jp)
121  TrigArr[jp] = TrigArr[jp - 1].Add(tp);
122 }

References MaxM, cmsswSequenceInfo::tp, and TrigArr.

Referenced by SetPhi().

◆ GetCos()

double magfieldparam::rz_harm_poly::GetCos ( )
inline

Definition at line 106 of file rz_harm_poly.h.

106 { return TrigArr[M].CosPhi; }

References magfieldparam::trig_pair::CosPhi, M, and TrigArr.

◆ GetDecPow()

rz_harm_poly magfieldparam::rz_harm_poly::GetDecPow ( int  nvar)
inline

Definition at line 91 of file rz_harm_poly.h.

91  {
92  rz_harm_poly R(*this);
93  R.DecPow(nvar);
94  return R;
95  }

References dttmaxenums::R.

◆ GetDiff()

rz_harm_poly magfieldparam::rz_harm_poly::GetDiff ( int  nvar)
inline

Definition at line 76 of file rz_harm_poly.h.

76  {
77  rz_harm_poly R(*this);
78  R.Diff(nvar);
79  return R;
80  }

References dttmaxenums::R.

◆ GetIncPow()

rz_harm_poly magfieldparam::rz_harm_poly::GetIncPow ( int  nvar)
inline

Definition at line 86 of file rz_harm_poly.h.

86  {
87  rz_harm_poly R(*this);
88  R.IncPow(nvar);
89  return R;
90  }

References dttmaxenums::R.

◆ GetInt()

rz_harm_poly magfieldparam::rz_harm_poly::GetInt ( int  nvar)
inline

Definition at line 81 of file rz_harm_poly.h.

81  {
82  rz_harm_poly R(*this);
83  R.Int(nvar);
84  return R;
85  }

References dttmaxenums::R.

◆ GetL()

unsigned magfieldparam::rz_harm_poly::GetL ( )
inline

Definition at line 100 of file rz_harm_poly.h.

100 { return L; }

References L.

◆ GetM()

int magfieldparam::rz_harm_poly::GetM ( )
inline

Definition at line 101 of file rz_harm_poly.h.

101 { return M; }

References M.

◆ GetMaxM()

int rz_harm_poly::GetMaxM ( )
static

Definition at line 71 of file rz_harm_poly.cc.

71  {
72  //Return max abs(M) for all rz_harm_poly objects created
73  //
74  int M_cur, M_max = 0;
75  for (auto const &poly : poly2d_base_set) {
76  if (typeid(*poly) == typeid(rz_harm_poly)) {
77  M_cur = std::abs(static_cast<rz_harm_poly const *>(poly)->M);
78  if (M_cur > M_max)
79  M_max = M_cur;
80  }
81  }
82  return M_max;
83 }

References funct::abs(), M, and magfieldparam::poly2d_base::poly2d_base_set.

Referenced by ~rz_harm_poly().

◆ GetSin()

double magfieldparam::rz_harm_poly::GetSin ( )
inline

Definition at line 107 of file rz_harm_poly.h.

107 { return TrigArr[M].SinPhi; }

References M, magfieldparam::trig_pair::SinPhi, and TrigArr.

◆ IsPhiSet()

bool magfieldparam::rz_harm_poly::IsPhiSet ( )
inline

Definition at line 74 of file rz_harm_poly.h.

74 { return phi_set; }

References phi_set.

◆ LadderDwn()

rz_harm_poly rz_harm_poly::LadderDwn ( )

Definition at line 194 of file rz_harm_poly.cc.

194  {
195  //Return a polynomial with decreased M
196  //
197  rz_harm_poly p_out;
198  p_out.data.reserve(2 * L);
199  unsigned it;
200  poly2d_term term;
201 
202  //In 2 passes (for-cycles) to get terms in z-descending order
203  for (it = 0; it < data.size(); ++it) {
204  term = data[it];
205  if (term.np[0]) {
206  term.coeff *= -int(term.np[0]) - M;
207  --term.np[0];
208  ++term.np[1];
209  p_out.data.push_back(term);
210  }
211  }
212  for (it = 0; it < data.size(); ++it) {
213  term = data[it];
214  if (term.np[1]) {
215  term.coeff *= term.np[1];
216  --term.np[1];
217  ++term.np[0];
218  p_out.data.push_back(term);
219  }
220  }
221  p_out.Collect();
222  if (!p_out.data.empty()) {
223  p_out.L = L;
224  p_out.M = M - 1;
225  if (std::abs(p_out.M) > int(MaxM))
226  MaxM = std::abs(p_out.M);
227  p_out.Scale(1. / sqrt(double((L + M) * (L - M + 1))));
228  }
229  return p_out;
230 }

References funct::abs(), magfieldparam::poly2d_term::coeff, magfieldparam::poly2d_base::Collect(), magfieldparam::poly2d_base::data, createfilelist::int, L, M, MaxM, magfieldparam::poly2d_term::np, magfieldparam::poly2d_base::Scale(), and mathSSE::sqrt().

◆ LadderUp()

rz_harm_poly rz_harm_poly::LadderUp ( )

Definition at line 155 of file rz_harm_poly.cc.

155  {
156  //Return a polynomial with increased M
157  //
158  rz_harm_poly p_out;
159  p_out.data.reserve(2 * L);
160  unsigned it;
161  poly2d_term term;
162 
163  //In 2 passes (for-cycles) to get terms in z-descending order
164  for (it = 0; it < data.size(); ++it) {
165  term = data[it];
166  if (term.np[0]) {
167  term.coeff *= int(term.np[0]) - M;
168  --term.np[0];
169  ++term.np[1];
170  p_out.data.push_back(term);
171  }
172  }
173  for (it = 0; it < data.size(); ++it) {
174  term = data[it];
175  if (term.np[1]) {
176  term.coeff *= -(int)term.np[1];
177  --term.np[1];
178  ++term.np[0];
179  p_out.data.push_back(term);
180  }
181  }
182  p_out.Collect();
183  if (!p_out.data.empty()) {
184  p_out.L = L;
185  p_out.M = M + 1;
186  if (std::abs(p_out.M) > int(MaxM))
187  MaxM = std::abs(p_out.M);
188  p_out.Scale(1. / sqrt(double((L - M) * (L + M + 1))));
189  }
190  return p_out;
191 }

References funct::abs(), magfieldparam::poly2d_term::coeff, magfieldparam::poly2d_base::Collect(), magfieldparam::poly2d_base::data, createfilelist::int, L, M, MaxM, magfieldparam::poly2d_term::np, magfieldparam::poly2d_base::Scale(), and mathSSE::sqrt().

◆ ParentCount()

static unsigned magfieldparam::rz_harm_poly::ParentCount ( )
inlinestatic

Definition at line 60 of file rz_harm_poly.h.

60 { return poly2d_base::Count(); }

References magfieldparam::poly2d_base::Count().

◆ Print()

void magfieldparam::rz_harm_poly::Print ( std::ostream &  out = std::cout,
const std::streamsize  prec = 5 
)
inline

Definition at line 110 of file rz_harm_poly.h.

110  {
111  PrintLM(out);
112  poly2d_base::Print(out, prec);
113  }

References MillePedeFileConverter_cfg::out, magfieldparam::poly2d_base::Print(), and PrintLM().

◆ PrintLM()

void magfieldparam::rz_harm_poly::PrintLM ( std::ostream &  out = std::cout)
inlineprivate

Definition at line 54 of file rz_harm_poly.h.

54  {
55  out << "L=" << std::setw(3) << std::left << L << ", M=" << std::setw(3) << std::left << M << "; ";
56  }

References L, M, and MillePedeFileConverter_cfg::out.

Referenced by Print().

◆ PrintTrigArr()

void rz_harm_poly::PrintTrigArr ( std::ostream &  out = std::cout,
const std::streamsize  prec = 5 
)
static

Definition at line 125 of file rz_harm_poly.cc.

125  {
126  out << "TrigArr: TASize = " << TASize << "\tMaxM = " << MaxM << std::endl;
127  if (TrigArr) {
128  if (MaxM < TASize) {
129  unsigned jm;
130  std::streamsize old_prec = out.precision(), wdt = prec + 7;
131  out.precision(prec);
132  out << "M: ";
133  for (jm = 0; jm <= MaxM; ++jm) {
134  out << std::setw(wdt) << std::left << jm;
135  }
136  out << "|\nCos_M: ";
137  for (jm = 0; jm <= MaxM; ++jm) {
138  out << std::setw(wdt) << std::left << TrigArr[jm].CosPhi;
139  }
140  out << "|\nSin_M: ";
141  for (jm = 0; jm <= MaxM; ++jm) {
142  out << std::setw(wdt) << std::left << TrigArr[jm].SinPhi;
143  }
144  out << "|" << std::endl;
145  out.precision(old_prec);
146  } else {
147  out << "\tTrigArr size is not adjusted." << std::endl;
148  }
149  } else {
150  out << "\tTrigArr is not allocated." << std::endl;
151  }
152 }

References magfieldparam::trig_pair::CosPhi, MaxM, MillePedeFileConverter_cfg::out, magfieldparam::trig_pair::SinPhi, TASize, and TrigArr.

◆ SetPhi()

void rz_harm_poly::SetPhi ( const double  phi)
static

Definition at line 86 of file rz_harm_poly.cc.

86  {
87  //Set value of the angle argument, adjust the TrigArr size if neccessary
88  //and fill TrigArr if the phi value is changed
89  //
90  if (MaxM >= TASize) {
91  SetTrigArrSize(MaxM + 1);
93  } else if (phi != phival)
95  phival = phi;
96  phi_set = true;
97 }

References FillTrigArr(), MaxM, phi_set, phival, SetTrigArrSize(), and TASize.

Referenced by SetPoint().

◆ SetPoint()

static void magfieldparam::rz_harm_poly::SetPoint ( const double  r,
const double  z,
const double  phi 
)
inlinestatic

Definition at line 63 of file rz_harm_poly.h.

63  {
65  SetPhi(phi);
66  }

References alignCSCRings::r, SetPhi(), and magfieldparam::poly2d_base::SetPoint().

Referenced by magfieldparam::HarmBasis3DCyl::SetPoint().

◆ SetTrigArrSize()

void rz_harm_poly::SetTrigArrSize ( const unsigned  N)
staticprivate

Definition at line 100 of file rz_harm_poly.cc.

100  {
101  //Increase TrigArr size if neccessary
102  //
103  if (N <= TASize)
104  return;
105  if (TrigArr)
106  delete[] TrigArr;
107  TrigArr = new trig_pair[N];
108  (*TrigArr) = trig_pair(1., 0.);
109  TASize = N;
110  phi_set = false;
111 }

References N, phi_set, TASize, and TrigArr.

Referenced by SetPhi().

Member Data Documentation

◆ Cnt

unsigned rz_harm_poly::Cnt = 0
staticprivate

Definition at line 43 of file rz_harm_poly.h.

Referenced by Count(), rz_harm_poly(), and ~rz_harm_poly().

◆ L

unsigned magfieldparam::rz_harm_poly::L
private

Definition at line 40 of file rz_harm_poly.h.

Referenced by CheatL(), GetL(), LadderDwn(), LadderUp(), PrintLM(), and rz_harm_poly().

◆ M

int magfieldparam::rz_harm_poly::M
private

◆ MaxM

unsigned rz_harm_poly::MaxM = 0
staticprivate

Definition at line 46 of file rz_harm_poly.h.

Referenced by FillTrigArr(), LadderDwn(), LadderUp(), PrintTrigArr(), SetPhi(), and ~rz_harm_poly().

◆ phi_set

bool rz_harm_poly::phi_set = false
staticprivate

Definition at line 45 of file rz_harm_poly.h.

Referenced by IsPhiSet(), rz_harm_poly(), SetPhi(), SetTrigArrSize(), and ~rz_harm_poly().

◆ phival

double rz_harm_poly::phival = -11111.
staticprivate

Definition at line 44 of file rz_harm_poly.h.

Referenced by SetPhi(), and ~rz_harm_poly().

◆ TASize

unsigned rz_harm_poly::TASize = 0
staticprivate

Definition at line 48 of file rz_harm_poly.h.

Referenced by PrintTrigArr(), SetPhi(), SetTrigArrSize(), and ~rz_harm_poly().

◆ TrigArr

trig_pair * rz_harm_poly::TrigArr = nullptr
staticprivate

Definition at line 49 of file rz_harm_poly.h.

Referenced by FillTrigArr(), GetCos(), GetSin(), PrintTrigArr(), SetTrigArrSize(), and ~rz_harm_poly().

magfieldparam::poly2d_base::Collect
void Collect()
Definition: poly2d_base.cc:171
magfieldparam::rz_harm_poly::FillTrigArr
static void FillTrigArr(const double phi)
Definition: rz_harm_poly.cc:114
magfieldparam::poly2d_base::Count
static unsigned Count()
Definition: poly2d_base.h:78
magfieldparam::trig_pair
Definition: rz_harm_poly.h:15
magfieldparam::rz_harm_poly::TASize
static unsigned TASize
Definition: rz_harm_poly.h:48
magfieldparam::poly2d_term
Definition: poly2d_base.h:23
magfieldparam::trig_pair::SinPhi
double SinPhi
Definition: rz_harm_poly.h:17
magfieldparam::poly2d_base::rz_set
static bool rz_set
Definition: poly2d_base.h:56
magfieldparam::poly2d_base::max_pwr
unsigned max_pwr
Definition: poly2d_base.h:70
magfieldparam::rz_harm_poly::rz_harm_poly
rz_harm_poly()
Definition: rz_harm_poly.h:68
magfieldparam::rz_harm_poly::phi_set
static bool phi_set
Definition: rz_harm_poly.h:45
magfieldparam::poly2d_base::Scale
void Scale(const double C)
Definition: poly2d_base.cc:307
magfieldparam::poly2d_term::coeff
double coeff
Definition: poly2d_base.h:24
magfieldparam::poly2d_base::Print
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: poly2d_base.cc:214
magfieldparam::rz_harm_poly::TrigArr
static trig_pair * TrigArr
Definition: rz_harm_poly.h:49
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
magfieldparam::rz_harm_poly
Definition: rz_harm_poly.h:38
magfieldparam::poly2d_term::np
unsigned np[2]
Definition: poly2d_base.h:25
N
#define N
Definition: blowfish.cc:9
magfieldparam::rz_harm_poly::phival
static double phival
Definition: rz_harm_poly.h:44
magfieldparam::rz_harm_poly::MaxM
static unsigned MaxM
Definition: rz_harm_poly.h:46
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
magfieldparam::rz_harm_poly::PrintLM
void PrintLM(std::ostream &out=std::cout)
Definition: rz_harm_poly.h:54
magfieldparam::poly2d_base::SetPoint
static void SetPoint(const double r, const double z)
Definition: poly2d_base.cc:151
EgHLTOffHistBins_cfi.nr
nr
Definition: EgHLTOffHistBins_cfi.py:4
magfieldparam::rz_harm_poly::Cnt
static unsigned Cnt
Definition: rz_harm_poly.h:43
createfilelist.int
int
Definition: createfilelist.py:10
magfieldparam::poly2d_base::NPwr
static unsigned NPwr
Definition: poly2d_base.h:55
magfieldparam::poly2d_base::data
std::vector< poly2d_term > data
Definition: poly2d_base.h:69
magfieldparam::rz_harm_poly::M
int M
Definition: rz_harm_poly.h:41
alignCSCRings.r
r
Definition: alignCSCRings.py:93
magfieldparam::poly2d_base::poly2d_base
poly2d_base()
Definition: poly2d_base.h:83
DDAxes::phi
magfieldparam::rz_harm_poly::SetPhi
static void SetPhi(const double phi)
Definition: rz_harm_poly.cc:86
poly
Definition: poly.h:11
magfieldparam::rz_harm_poly::GetMaxM
static int GetMaxM()
Definition: rz_harm_poly.cc:71
magfieldparam::rz_harm_poly::SetTrigArrSize
static void SetTrigArrSize(const unsigned N)
Definition: rz_harm_poly.cc:100
S
Definition: CSCDBL1TPParametersExtended.h:16
magfieldparam::rz_harm_poly::L
unsigned L
Definition: rz_harm_poly.h:40
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
magfieldparam::trig_pair::CosPhi
double CosPhi
Definition: rz_harm_poly.h:16
dttmaxenums::R
Definition: DTTMax.h:29
magfieldparam::poly2d_base::poly2d_base_set
static std::set< poly2d_base * > poly2d_base_set
Definition: poly2d_base.h:60