CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
- 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 = 0
 

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 = 0
 
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.

References Cnt.

Referenced by GetMaxM().

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

Definition at line 73 of file rz_harm_poly.h.

References Cnt.

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

Definition at line 74 of file rz_harm_poly.h.

References Cnt.

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

Definition at line 54 of file rz_harm_poly.cc.

References 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 = 0;
64  TASize = 0;
65  MaxM = 0;
66  phival = -11111.;
67  phi_set = false;
68  }
69 }
#define abs(x)
Definition: mlp_lapack.h:159
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50

Member Function Documentation

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

Definition at line 97 of file rz_harm_poly.h.

References L.

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

Definition at line 65 of file rz_harm_poly.h.

References Cnt.

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

Definition at line 113 of file rz_harm_poly.cc.

References MaxM, and TrigArr.

Referenced by SetPhi().

114 {
115 //Fill TrigArr with trig_pair(jp*phi)
116  if (!TrigArr) return;
117  trig_pair tp(phi);
118  TrigArr[1] = tp;
119  for (unsigned jp = 2; jp <= MaxM; ++jp) TrigArr[jp] = TrigArr[jp-1].Add(tp);
120 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50
Definition: DDAxes.h:10
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 L.

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

Definition at line 89 of file rz_harm_poly.h.

References M.

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

Definition at line 72 of file rz_harm_poly.cc.

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

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  std::set<poly2d_base*>::iterator it;
78  for (it = poly2d_base_set.begin(); it != poly2d_base_set.end(); ++it) {
79  if (typeid(**it) == typeid(rz_harm_poly)) {
80  M_cur = std::abs(((rz_harm_poly*)(*it))->M);
81  if (M_cur > M_max) M_max = M_cur;
82  }
83  }
84  return M_max;
85 }
#define abs(x)
Definition: mlp_lapack.h:159
static std::set< poly2d_base * > poly2d_base_set
Definition: poly2d_base.h:59
double magfieldparam::rz_harm_poly::GetSin ( )
inline
bool magfieldparam::rz_harm_poly::IsPhiSet ( )
inline

Definition at line 78 of file rz_harm_poly.h.

References phi_set.

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

Definition at line 193 of file rz_harm_poly.cc.

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

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

Definition at line 155 of file rz_harm_poly.cc.

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

156 {
157 //Return a polynomial with increased M
158 //
159  rz_harm_poly p_out; 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.size()) {
184  p_out.L = L;
185  p_out.M = M+1;
186  if (std::abs(p_out.M) > int(MaxM)) MaxM = std::abs(p_out.M);
187  p_out.Scale(1./sqrt(double((L-M)*(L+M+1))));
188  }
189  return p_out;
190 }
std::vector< poly2d_term > data
Definition: poly2d_base.h:68
#define abs(x)
Definition: mlp_lapack.h:159
void Scale(const double C)
Definition: poly2d_base.cc:296
T sqrt(T t)
Definition: SSEVec.h:48
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 dbtoconf::out, magfieldparam::poly2d_base::Print(), and PrintLM().

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
tuple out
Definition: dbtoconf.py:99
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 L, M, and dbtoconf::out.

Referenced by Print().

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

Definition at line 123 of file rz_harm_poly.cc.

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

124 {
125  out << "TrigArr: TASize = " << TASize
126  << "\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 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50
tuple out
Definition: dbtoconf.py:99
void rz_harm_poly::SetPhi ( const double  phi)
static

Definition at line 88 of file rz_harm_poly.cc.

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

Referenced by SetPoint().

89 {
90 //Set value of the angle argument, adjust the TrigArr size if neccessary
91 //and fill TrigArr if the phi value is changed
92 //
93  if (MaxM >= TASize) { SetTrigArrSize(MaxM+1); FillTrigArr(phi);}
94  else if (phi != phival) FillTrigArr(phi);
95  phival = phi;
96  phi_set = true;
97 }
static void FillTrigArr(const double phi)
static void SetTrigArrSize(const unsigned N)
Definition: DDAxes.h:10
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 SetPhi(), and magfieldparam::poly2d_base::SetPoint().

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

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

Definition at line 100 of file rz_harm_poly.cc.

References N, phi_set, TASize, and TrigArr.

Referenced by SetPhi().

101 {
102 //Increase TrigArr size if neccessary
103 //
104  if (N <= TASize) return;
105  if (TrigArr) delete [] TrigArr;
106  TrigArr = new trig_pair [N];
107  (*TrigArr) = trig_pair(1., 0.);
108  TASize = N;
109  phi_set = false;
110 }
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 Count(), 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 CheatL(), GetL(), LadderDwn(), LadderUp(), PrintLM(), and rz_harm_poly().

int magfieldparam::rz_harm_poly::M
private
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 IsPhiSet(), 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 = 0
staticprivate

Definition at line 50 of file rz_harm_poly.h.

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