CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/MagneticField/ParametrizedEngine/plugins/HarmBasis3DCyl.h

Go to the documentation of this file.
00001 #ifndef HarmBasis3DCyl_h
00002 #define HarmBasis3DCyl_h
00003 
00004 #include "rz_harm_poly.h"
00005 
00006 namespace magfieldparam {
00007 
00008 typedef std::vector<rz_harm_poly>  harm_poly_vec;
00009 typedef std::vector<harm_poly_vec> harm_poly_arr;
00010 
00012 //                                                                             //
00013 //  HarmBasis3DCyl: set of basis harmonic polynomials in cylindrical CS        //
00014 //                                                                             //
00016 
00017 class HarmBasis3DCyl {
00018 
00019 private:
00020    unsigned Dim;   //Dimension of the basis
00021    unsigned Len;   //Length of the basis, accounting negative M's
00022    
00023    int *L_k, *M_k; //Translation arrays from linear to (L,M) address;
00024    double *P_k, *Br_k, *Bz_k, *Bphi_k; //Calculated values for (r,z) terms
00025 
00026    harm_poly_arr PtB;   //Potential basis
00027    harm_poly_arr BrB;   //Br basis
00028    harm_poly_arr BzB;   //Bz basis
00029    harm_poly_arr BphiB; //phi basis
00030 
00031    void   EvalRZ(harm_poly_arr &B, double *val);
00032    double GetVal(double *coeff, double *basis);
00033 
00034    void Print(harm_poly_arr &B,std::ostream &out = std::cout);
00035    
00036 public:
00037    HarmBasis3DCyl(const unsigned N = 18); //The only legal constructor
00038    virtual ~HarmBasis3DCyl();
00039 
00040    unsigned GetDim() { return Dim;}
00041    unsigned GetLen() { return Len;}
00042    void     GetLM(const unsigned j, int &Lj, int &Mj) { Lj = L_k[j]; Mj = M_k[j];}
00043    
00044    //Sets point for the basis components evaluation
00045    void SetPoint(const double r, const double z, const double phi)
00046    { rz_harm_poly::SetPoint(r, z, phi);}
00047    
00048    //Fill tables with the basis component values. SetPoint(r,z,phi)
00049    //must be called before EvalXXX() calls.
00050    void EvalPtn() { EvalRZ(PtB, P_k);}
00051    void EvalBr()  { EvalRZ(BrB, Br_k);}
00052    void EvalBz()  { EvalRZ(BzB, Bz_k);}
00053    void EvalBphi();
00054    
00055    //Return the basis component value for the linear address k.
00056    //EvalXXX() must be called before GetXXX_k() call
00057    double GetPtn_k (const unsigned k) { return P_k[k];}
00058    double GetBr_k  (const unsigned k) { return Br_k[k];}
00059    double GetBz_k  (const unsigned k) { return Bz_k[k];}
00060    double GetBphi_k(const unsigned k) { return Bphi_k[k];}
00061    
00062    //Return the the potential and the field component values
00063    //resulted by the basis expansion with coefficients in <coeff>
00064    //EvalXXX() must be called before GetXXX() call
00065    double GetPtn (double *coeff) { return GetVal(coeff, P_k);}
00066    double GetBr  (double *coeff) { return GetVal(coeff, Br_k);}
00067    double GetBz  (double *coeff) { return GetVal(coeff, Bz_k);}
00068    double GetBphi(double *coeff) { return GetVal(coeff, Bphi_k);}
00069 
00070    void PrintPtB  (std::ostream &out = std::cout) { Print(PtB,   out);}
00071    void PrintBrB  (std::ostream &out = std::cout) { Print(BrB,   out);}
00072    void PrintBzB  (std::ostream &out = std::cout) { Print(BzB,   out);}
00073    void PrintBphiB(std::ostream &out = std::cout) { Print(BphiB, out);}
00074    void Print     (std::ostream &out = std::cout);
00075 
00076 }; //class HarmBasis3DCyl
00077 }
00078 
00079 #endif