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

magfieldparam::rz_harm_poly::rz_harm_poly ( )
inline

Definition at line 72 of file rz_harm_poly.h.

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

Definition at line 74 of file rz_harm_poly.h.

References N.

rz_harm_poly::rz_harm_poly ( const unsigned  N)

Definition at line 23 of file rz_harm_poly.cc.

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

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

Definition at line 54 of file rz_harm_poly.cc.

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

55 {
56  if (--Cnt) {
57  if (std::abs(M) >= int(MaxM)) { //a number of objects still left
58  M = 0;
59  MaxM = GetMaxM();
60  }
61  } else { //last instance -> memory cleanup
62  if (TrigArr) delete [] TrigArr;
63  TrigArr = nullptr;
64  TASize = 0;
65  MaxM = 0;
66  phival = -11111.;
67  phi_set = false;
68  }
69 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

Member Function Documentation

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

Definition at line 97 of file rz_harm_poly.h.

97 { L = newL;}
static unsigned magfieldparam::rz_harm_poly::Count ( )
inlinestatic

Definition at line 65 of file rz_harm_poly.h.

65 { return Cnt;}
void rz_harm_poly::FillTrigArr ( const double  phi)
staticprivate

Definition at line 112 of file rz_harm_poly.cc.

References MaxM, and TrigArr.

Referenced by SetPhi().

113 {
114 //Fill TrigArr with trig_pair(jp*phi)
115  if (!TrigArr) return;
116  trig_pair tp(phi);
117  TrigArr[1] = tp;
118  for (unsigned jp = 2; jp <= MaxM; ++jp) TrigArr[jp] = TrigArr[jp-1].Add(tp);
119 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50
double magfieldparam::rz_harm_poly::GetCos ( )
inline
rz_harm_poly magfieldparam::rz_harm_poly::GetDecPow ( int  nvar)
inline

Definition at line 83 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::DecPow(), and dttmaxenums::R.

83 { rz_harm_poly R(*this); R.DecPow(nvar); return R;}
rz_harm_poly magfieldparam::rz_harm_poly::GetDiff ( int  nvar)
inline

Definition at line 80 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::Diff(), and dttmaxenums::R.

80 { rz_harm_poly R(*this); R.Diff (nvar); return R;}
rz_harm_poly magfieldparam::rz_harm_poly::GetIncPow ( int  nvar)
inline

Definition at line 82 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::IncPow(), and dttmaxenums::R.

82 { rz_harm_poly R(*this); R.IncPow(nvar); return R;}
rz_harm_poly magfieldparam::rz_harm_poly::GetInt ( int  nvar)
inline

Definition at line 81 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::Int(), and dttmaxenums::R.

81 { rz_harm_poly R(*this); R.Int (nvar); return R;}
unsigned magfieldparam::rz_harm_poly::GetL ( )
inline

Definition at line 88 of file rz_harm_poly.h.

References dttmaxenums::L.

88 { return L;}
int magfieldparam::rz_harm_poly::GetM ( )
inline

Definition at line 89 of file rz_harm_poly.h.

89 { return M;}
int rz_harm_poly::GetMaxM ( )
static

Definition at line 72 of file rz_harm_poly.cc.

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

Referenced by ~rz_harm_poly().

73 {
74 //Return max abs(M) for all rz_harm_poly objects created
75 //
76  int M_cur, M_max = 0;
77  for (auto const& poly: poly2d_base_set) {
78  if (typeid(*poly) == typeid(rz_harm_poly)) {
79  M_cur = std::abs(static_cast<rz_harm_poly const*>(poly)->M);
80  if (M_cur > M_max) M_max = M_cur;
81  }
82  }
83  return M_max;
84 }
static std::set< poly2d_base * > poly2d_base_set
Definition: poly2d_base.h:59
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: poly.h:10
double magfieldparam::rz_harm_poly::GetSin ( )
inline
bool magfieldparam::rz_harm_poly::IsPhiSet ( )
inline

Definition at line 78 of file rz_harm_poly.h.

78 { return phi_set;}
rz_harm_poly rz_harm_poly::LadderDwn ( )

Definition at line 192 of file rz_harm_poly.cc.

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().

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

Definition at line 154 of file rz_harm_poly.cc.

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().

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

Definition at line 64 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::Count().

64 { return poly2d_base::Count();}
static unsigned Count()
Definition: poly2d_base.h:74
void magfieldparam::rz_harm_poly::Print ( std::ostream &  out = std::cout,
const std::streamsize  prec = 5 
)
inline

Definition at line 98 of file rz_harm_poly.h.

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

99  { PrintLM(out); poly2d_base::Print(out, prec);}
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: poly2d_base.cc:204
void PrintLM(std::ostream &out=std::cout)
Definition: rz_harm_poly.h:55
void magfieldparam::rz_harm_poly::PrintLM ( std::ostream &  out = std::cout)
inlineprivate

Definition at line 55 of file rz_harm_poly.h.

References MillePedeFileConverter_cfg::out.

56  {
57  out << "L=" << std::setw(3) << std::left << L
58  <<", M=" << std::setw(3) << std::left << M << "; ";
59  }
void rz_harm_poly::PrintTrigArr ( std::ostream &  out = std::cout,
const std::streamsize  prec = 5 
)
static

Definition at line 122 of file rz_harm_poly.cc.

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

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

Definition at line 87 of file rz_harm_poly.cc.

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

88 {
89 //Set value of the angle argument, adjust the TrigArr size if neccessary
90 //and fill TrigArr if the phi value is changed
91 //
92  if (MaxM >= TASize) { SetTrigArrSize(MaxM+1); FillTrigArr(phi);}
93  else if (phi != phival) FillTrigArr(phi);
94  phival = phi;
95  phi_set = true;
96 }
static void FillTrigArr(const double phi)
static void SetTrigArrSize(const unsigned N)
Definition: rz_harm_poly.cc:99
static void magfieldparam::rz_harm_poly::SetPoint ( const double  r,
const double  z,
const double  phi 
)
inlinestatic

Definition at line 67 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::SetPoint().

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

68  {
70  }
static void SetPhi(const double phi)
Definition: rz_harm_poly.cc:87
static void SetPoint(const double r, const double z)
Definition: poly2d_base.cc:148
void rz_harm_poly::SetTrigArrSize ( const unsigned  N)
staticprivate

Definition at line 99 of file rz_harm_poly.cc.

References N, phi_set, TASize, and TrigArr.

Referenced by SetPhi().

100 {
101 //Increase TrigArr size if neccessary
102 //
103  if (N <= TASize) return;
104  if (TrigArr) delete [] TrigArr;
105  TrigArr = new trig_pair [N];
106  (*TrigArr) = trig_pair(1., 0.);
107  TASize = N;
108  phi_set = false;
109 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50
#define N
Definition: blowfish.cc:9

Member Data Documentation

unsigned rz_harm_poly::Cnt = 0
staticprivate

Definition at line 44 of file rz_harm_poly.h.

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

unsigned magfieldparam::rz_harm_poly::L
private

Definition at line 41 of file rz_harm_poly.h.

Referenced by LadderDwn(), LadderUp(), and rz_harm_poly().

int magfieldparam::rz_harm_poly::M
private

Definition at line 42 of file rz_harm_poly.h.

Referenced by GetMaxM(), LadderDwn(), LadderUp(), rz_harm_poly(), and ~rz_harm_poly().

unsigned rz_harm_poly::MaxM = 0
staticprivate

Definition at line 47 of file rz_harm_poly.h.

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

bool rz_harm_poly::phi_set = false
staticprivate

Definition at line 46 of file rz_harm_poly.h.

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

double rz_harm_poly::phival = -11111.
staticprivate

Definition at line 45 of file rz_harm_poly.h.

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

unsigned rz_harm_poly::TASize = 0
staticprivate

Definition at line 49 of file rz_harm_poly.h.

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

trig_pair * rz_harm_poly::TrigArr = nullptr
staticprivate

Definition at line 50 of file rz_harm_poly.h.

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