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.

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.

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.

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.

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.

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 }
std::vector< poly2d_term > data
Definition: poly2d_base.h:69
static std::set< poly2d_base * > poly2d_base_set
Definition: poly2d_base.h:60
#define N
Definition: blowfish.cc:9
static unsigned NPwr
Definition: poly2d_base.h:55

◆ ~rz_harm_poly()

rz_harm_poly::~rz_harm_poly ( )
override

Definition at line 53 of file rz_harm_poly.cc.

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

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 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

Member Function Documentation

◆ CheatL()

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

Definition at line 109 of file rz_harm_poly.h.

References L.

109 { L = newL; }

◆ Count()

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

Definition at line 61 of file rz_harm_poly.h.

References Cnt.

61 { return Cnt; }

◆ FillTrigArr()

void rz_harm_poly::FillTrigArr ( const double  phi)
staticprivate

Definition at line 114 of file rz_harm_poly.cc.

References SiStripClientConfig_Tier0_cff::Add, MaxM, cmsswSequenceInfo::tp, and TrigArr.

Referenced by SetPhi().

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 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:49

◆ GetCos()

double magfieldparam::rz_harm_poly::GetCos ( )
inline

Definition at line 106 of file rz_harm_poly.h.

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.

References dttmaxenums::R.

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

◆ GetDiff()

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

Definition at line 76 of file rz_harm_poly.h.

References dttmaxenums::R.

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

◆ GetIncPow()

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

Definition at line 86 of file rz_harm_poly.h.

References dttmaxenums::R.

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

◆ GetInt()

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

Definition at line 81 of file rz_harm_poly.h.

References dttmaxenums::R.

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

◆ GetL()

unsigned magfieldparam::rz_harm_poly::GetL ( )
inline

Definition at line 100 of file rz_harm_poly.h.

References L.

100 { return L; }

◆ GetM()

int magfieldparam::rz_harm_poly::GetM ( )
inline

Definition at line 101 of file rz_harm_poly.h.

References M.

101 { return M; }

◆ GetMaxM()

int rz_harm_poly::GetMaxM ( )
static

Definition at line 71 of file rz_harm_poly.cc.

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

Referenced by ~rz_harm_poly().

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 }
static std::set< poly2d_base * > poly2d_base_set
Definition: poly2d_base.h:60
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: poly.h:11

◆ GetSin()

double magfieldparam::rz_harm_poly::GetSin ( )
inline

Definition at line 107 of file rz_harm_poly.h.

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.

References phi_set.

74 { return phi_set; }

◆ LadderDwn()

rz_harm_poly rz_harm_poly::LadderDwn ( )

Definition at line 194 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().

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 }
std::vector< poly2d_term > data
Definition: poly2d_base.h:69
void Scale(const double C)
Definition: poly2d_base.cc:307
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ LadderUp()

rz_harm_poly rz_harm_poly::LadderUp ( )

Definition at line 155 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;
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 }
std::vector< poly2d_term > data
Definition: poly2d_base.h:69
void Scale(const double C)
Definition: poly2d_base.cc:307
T sqrt(T t)
Definition: SSEVec.h:19
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ ParentCount()

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

Definition at line 60 of file rz_harm_poly.h.

References magfieldparam::poly2d_base::Count().

60 { return poly2d_base::Count(); }
static unsigned Count()
Definition: poly2d_base.h:78

◆ 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.

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

110  {
111  PrintLM(out);
112  poly2d_base::Print(out, prec);
113  }
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: poly2d_base.cc:214
void PrintLM(std::ostream &out=std::cout)
Definition: rz_harm_poly.h:54

◆ PrintLM()

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

Definition at line 54 of file rz_harm_poly.h.

References L, M, and MillePedeFileConverter_cfg::out.

Referenced by Print().

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

◆ 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.

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

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 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:49

◆ SetPhi()

void rz_harm_poly::SetPhi ( const double  phi)
static

Definition at line 86 of file rz_harm_poly.cc.

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

Referenced by SetPoint().

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 }
static void FillTrigArr(const double phi)
static void SetTrigArrSize(const unsigned N)

◆ 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.

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

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

63  {
65  SetPhi(phi);
66  }
static void SetPhi(const double phi)
Definition: rz_harm_poly.cc:86
static void SetPoint(const double r, const double z)
Definition: poly2d_base.cc:151

◆ SetTrigArrSize()

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

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 }
static trig_pair * TrigArr
Definition: rz_harm_poly.h:49
#define N
Definition: blowfish.cc:9

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