CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/MagneticField/ParametrizedEngine/plugins/rz_harm_poly.h

Go to the documentation of this file.
00001 #ifndef rz_harm_poly_h
00002 #define rz_harm_poly_h
00003 
00004 #include <cmath>
00005 #include "poly2d_base.h"
00006 
00008 //                                                                             //
00009 //  Pair (Cos(phi),Sin(Phi)). Intended for internal use by rz_harm_poly.       //
00010 //                                                                             //
00012 
00013 //_______________________________________________________________________________
00014 namespace magfieldparam {
00015 struct trig_pair {
00016    double CosPhi;
00017    double SinPhi;
00018 
00019    trig_pair() : CosPhi(1.), SinPhi(0.) {}
00020    trig_pair(const trig_pair &tp) : CosPhi(tp.CosPhi), SinPhi(tp.SinPhi) {}
00021    trig_pair(const double C, const double S) : CosPhi(C), SinPhi(S) {}
00022    trig_pair(const double phi) : CosPhi(cos(phi)), SinPhi(sin(phi)) {}
00023    
00024    //Return trig_pair fo angle increased by angle of tp.
00025    trig_pair Add(const trig_pair &tp) {
00026       return trig_pair(this->CosPhi*tp.CosPhi - this->SinPhi*tp.SinPhi,
00027                        this->SinPhi*tp.CosPhi + this->CosPhi*tp.SinPhi);
00028    }
00029 };
00030 
00032 //                                                                             //
00033 //  Harmonic homogeneous polynomial in cylindrical system.                     //
00034 //                                                                             //
00036 
00037 //_______________________________________________________________________________
00038 class rz_harm_poly : public poly2d_base {
00039 
00040 private:
00041    unsigned L;
00042    int      M;
00043    
00044    static unsigned   Cnt;      //Number of the "rz_harm_poly" objects
00045    static double     phival;   //Last phi value used
00046    static bool       phi_set;  //TRUE if phi value is set
00047    static unsigned   MaxM;     //Max. M among "rz_harm_poly" objects
00048 
00049    static unsigned   TASize;   //TrigArr size
00050    static trig_pair *TrigArr;  //Array with angular data
00051 
00052    static void SetTrigArrSize(const unsigned N);
00053    static void FillTrigArr   (const double phi);
00054    
00055    void PrintLM(std::ostream &out = std::cout)
00056    {
00057       out <<  "L=" << std::setw(3)  << std::left << L
00058           <<", M=" << std::setw(3)  << std::left << M << "; ";
00059    }
00060 
00061 public:
00062 
00063    static int      GetMaxM(); //return Max. M for the class
00064    static unsigned ParentCount() { return poly2d_base::Count();}
00065    static unsigned Count() { return Cnt;}
00066    static void     SetPhi(const double phi);
00067    static void     SetPoint(const double r, const double z, const double phi)
00068    {
00069       poly2d_base::SetPoint(r, z); SetPhi(phi);
00070    }
00071    
00072    rz_harm_poly() : poly2d_base(), L(0), M(0) {++Cnt;} 
00073    rz_harm_poly(const poly2d_base &S) : poly2d_base(S), L(0), M(0) {++Cnt;}
00074    rz_harm_poly(const rz_harm_poly &S) : poly2d_base(S), L(S.L), M(S.M) {++Cnt;}
00075    rz_harm_poly(const unsigned N);
00076    ~rz_harm_poly();
00077    
00078    bool IsPhiSet() { return phi_set;}
00079    
00080    rz_harm_poly GetDiff  (int nvar) { rz_harm_poly R(*this); R.Diff  (nvar); return R;}
00081    rz_harm_poly GetInt   (int nvar) { rz_harm_poly R(*this); R.Int   (nvar); return R;}
00082    rz_harm_poly GetIncPow(int nvar) { rz_harm_poly R(*this); R.IncPow(nvar); return R;}
00083    rz_harm_poly GetDecPow(int nvar) { rz_harm_poly R(*this); R.DecPow(nvar); return R;}
00084 
00085    rz_harm_poly LadderUp();
00086    rz_harm_poly LadderDwn();
00087    
00088    unsigned GetL() { return L;}
00089    int      GetM() { return M;}
00090    
00091    //Next functions return value of angular terms. 
00092    //No check is made, wheither the TrigArr is initialized.
00093    //User can check if IsPhiSet() == true
00094    double GetCos() { return TrigArr[M].CosPhi;}
00095    double GetSin() { return TrigArr[M].SinPhi;}
00096    
00097    void CheatL(const unsigned newL) { L = newL;}
00098    void Print(std::ostream &out = std::cout, const std::streamsize prec = 5)
00099    { PrintLM(out); poly2d_base::Print(out, prec);}
00100  
00101 
00102    static void PrintTrigArr(std::ostream &out = std::cout, const std::streamsize prec = 5);
00103 
00104 }; //class rz_harm_poly
00105 }
00106 
00107 #endif