CMS 3D CMS Logo

rz_harm_poly.h
Go to the documentation of this file.
1 #ifndef rz_harm_poly_h
2 #define rz_harm_poly_h
3 
4 #include <cmath>
5 #include "poly2d_base.h"
6 
8 // //
9 // Pair (Cos(phi),Sin(Phi)). Intended for internal use by rz_harm_poly. //
10 // //
12 
13 //_______________________________________________________________________________
14 namespace magfieldparam {
15 struct trig_pair {
16  double CosPhi;
17  double SinPhi;
18 
19  trig_pair() : CosPhi(1.), SinPhi(0.) {}
20  trig_pair(const trig_pair &tp) : CosPhi(tp.CosPhi), SinPhi(tp.SinPhi) {}
21  trig_pair(const double C, const double S) : CosPhi(C), SinPhi(S) {}
22  trig_pair(const double phi) : CosPhi(cos(phi)), SinPhi(sin(phi)) {}
23 
24  //Return trig_pair fo angle increased by angle of tp.
25  trig_pair Add(const trig_pair &tp) {
26  return trig_pair(this->CosPhi*tp.CosPhi - this->SinPhi*tp.SinPhi,
27  this->SinPhi*tp.CosPhi + this->CosPhi*tp.SinPhi);
28  }
29 };
30 
32 // //
33 // Harmonic homogeneous polynomial in cylindrical system. //
34 // //
36 
37 //_______________________________________________________________________________
38 class rz_harm_poly : public poly2d_base {
39 
40 private:
41  unsigned L;
42  int M;
43 
44  static unsigned Cnt; //Number of the "rz_harm_poly" objects
45  static double phival; //Last phi value used
46  static bool phi_set; //TRUE if phi value is set
47  static unsigned MaxM; //Max. M among "rz_harm_poly" objects
48 
49  static unsigned TASize; //TrigArr size
50  static trig_pair *TrigArr; //Array with angular data
51 
52  static void SetTrigArrSize(const unsigned N);
53  static void FillTrigArr (const double phi);
54 
55  void PrintLM(std::ostream &out = std::cout)
56  {
57  out << "L=" << std::setw(3) << std::left << L
58  <<", M=" << std::setw(3) << std::left << M << "; ";
59  }
60 
61 public:
62 
63  static int GetMaxM(); //return Max. M for the class
64  static unsigned ParentCount() { return poly2d_base::Count();}
65  static unsigned Count() { return Cnt;}
66  static void SetPhi(const double phi);
67  static void SetPoint(const double r, const double z, const double phi)
68  {
69  poly2d_base::SetPoint(r, z); SetPhi(phi);
70  }
71 
72  rz_harm_poly() : poly2d_base(), L(0), M(0) {++Cnt;}
73  rz_harm_poly(const poly2d_base &S) : poly2d_base(S), L(0), M(0) {++Cnt;}
74  rz_harm_poly(const rz_harm_poly &S) : poly2d_base(S), L(S.L), M(S.M) {++Cnt;}
75  rz_harm_poly(const unsigned N);
76  ~rz_harm_poly();
77 
78  bool IsPhiSet() { return phi_set;}
79 
80  rz_harm_poly GetDiff (int nvar) { rz_harm_poly R(*this); R.Diff (nvar); return R;}
81  rz_harm_poly GetInt (int nvar) { rz_harm_poly R(*this); R.Int (nvar); return R;}
82  rz_harm_poly GetIncPow(int nvar) { rz_harm_poly R(*this); R.IncPow(nvar); return R;}
83  rz_harm_poly GetDecPow(int nvar) { rz_harm_poly R(*this); R.DecPow(nvar); return R;}
84 
85  rz_harm_poly LadderUp();
86  rz_harm_poly LadderDwn();
87 
88  unsigned GetL() { return L;}
89  int GetM() { return M;}
90 
91  //Next functions return value of angular terms.
92  //No check is made, wheither the TrigArr is initialized.
93  //User can check if IsPhiSet() == true
94  double GetCos() { return TrigArr[M].CosPhi;}
95  double GetSin() { return TrigArr[M].SinPhi;}
96 
97  void CheatL(const unsigned newL) { L = newL;}
98  void Print(std::ostream &out = std::cout, const std::streamsize prec = 5)
99  { PrintLM(out); poly2d_base::Print(out, prec);}
100 
101 
102  static void PrintTrigArr(std::ostream &out = std::cout, const std::streamsize prec = 5);
103 
104 }; //class rz_harm_poly
105 }
106 
107 #endif
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: poly2d_base.cc:204
trig_pair Add(const trig_pair &tp)
Definition: rz_harm_poly.h:25
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static unsigned Count()
Definition: rz_harm_poly.h:65
static trig_pair * TrigArr
Definition: rz_harm_poly.h:50
static void SetPoint(const double r, const double z)
Definition: poly2d_base.cc:148
rz_harm_poly GetInt(int nvar)
Definition: rz_harm_poly.h:81
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static void SetPoint(const double r, const double z, const double phi)
Definition: rz_harm_poly.h:67
rz_harm_poly GetIncPow(int nvar)
Definition: rz_harm_poly.h:82
trig_pair(const double phi)
Definition: rz_harm_poly.h:22
rz_harm_poly GetDecPow(int nvar)
Definition: rz_harm_poly.h:83
#define N
Definition: blowfish.cc:9
rz_harm_poly GetDiff(int nvar)
Definition: rz_harm_poly.h:80
trig_pair(const double C, const double S)
Definition: rz_harm_poly.h:21
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:99
rz_harm_poly(const rz_harm_poly &S)
Definition: rz_harm_poly.h:74
void PrintLM(std::ostream &out=std::cout)
Definition: rz_harm_poly.h:55
rz_harm_poly(const poly2d_base &S)
Definition: rz_harm_poly.h:73
void CheatL(const unsigned newL)
Definition: rz_harm_poly.h:97
static unsigned ParentCount()
Definition: rz_harm_poly.h:64
void Print(std::ostream &out=std::cout, const std::streamsize prec=5)
Definition: rz_harm_poly.h:98
trig_pair(const trig_pair &tp)
Definition: rz_harm_poly.h:20
static unsigned Count()
Definition: poly2d_base.h:74