CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

magfieldparam::HarmBasis3DCyl Class Reference

#include <HarmBasis3DCyl.h>

List of all members.

Public Member Functions

void EvalBphi ()
void EvalBr ()
void EvalBz ()
void EvalPtn ()
double GetBphi (double *coeff)
double GetBphi_k (const unsigned k)
double GetBr (double *coeff)
double GetBr_k (const unsigned k)
double GetBz (double *coeff)
double GetBz_k (const unsigned k)
unsigned GetDim ()
unsigned GetLen ()
void GetLM (const unsigned j, int &Lj, int &Mj)
double GetPtn (double *coeff)
double GetPtn_k (const unsigned k)
 HarmBasis3DCyl (const unsigned N=18)
void Print (std::ostream &out=std::cout)
void PrintBphiB (std::ostream &out=std::cout)
void PrintBrB (std::ostream &out=std::cout)
void PrintBzB (std::ostream &out=std::cout)
void PrintPtB (std::ostream &out=std::cout)
void SetPoint (const double r, const double z, const double phi)
virtual ~HarmBasis3DCyl ()

Private Member Functions

void EvalRZ (harm_poly_arr &B, double *val)
double GetVal (double *coeff, double *basis)
void Print (harm_poly_arr &B, std::ostream &out=std::cout)

Private Attributes

double * Bphi_k
harm_poly_arr BphiB
double * Br_k
harm_poly_arr BrB
double * Bz_k
harm_poly_arr BzB
unsigned Dim
int * L_k
unsigned Len
int * M_k
double * P_k
harm_poly_arr PtB

Detailed Description

Definition at line 17 of file HarmBasis3DCyl.h.


Constructor & Destructor Documentation

HarmBasis3DCyl::HarmBasis3DCyl ( const unsigned  N = 18)

Definition at line 13 of file HarmBasis3DCyl.cc.

References Bphi_k, BphiB, Br_k, BrB, Bz_k, BzB, Dim, magfieldparam::poly2d_base::IncNPwr(), gen::k, dttmaxenums::L, L_k, Len, M_k, N, P_k, and PtB.

{
//Construct a basis of dimension N
//
   Dim = N;
   Len = N*(N+2);
   
   L_k = new int [Len];
   M_k = new int [Len];
   
   P_k    = new double [Len];
   Br_k   = new double [Len];
   Bz_k   = new double [Len];
   Bphi_k = new double [Len];
   
   PtB.reserve(N);
   BrB.reserve(N);
   BzB.reserve(N);
   BphiB.reserve(N);
   
   rz_harm_poly::IncNPwr(N); //In order to prevent GetMaxPow() calls
   unsigned M, vLen, k = 0;
   for (unsigned L = 1; L <= N; ++L) {
      vLen = L+1;
      harm_poly_vec Pt_vec;   Pt_vec.reserve(vLen);
      harm_poly_vec Br_vec;   Br_vec.reserve(vLen);
      harm_poly_vec Bz_vec;   Bz_vec.reserve(vLen);
      harm_poly_vec Bphi_vec; Bphi_vec.reserve(vLen);

      Pt_vec.push_back  (rz_harm_poly(L));
      Br_vec.push_back  (Pt_vec[0].GetDiff(0));
      Bz_vec.push_back  (Pt_vec[0].GetDiff(1));
      Bphi_vec.push_back(rz_harm_poly());
      Bphi_vec[0].CheatL(L);
      
      L_k[k] = L; M_k[k] = 0; ++k;

      for (M = 1; M <= L; ++M) {
         Pt_vec.push_back  (Pt_vec[M-1].LadderUp());
         Br_vec.push_back  (Pt_vec[M].GetDiff(0));
         Bz_vec.push_back  (Pt_vec[M].GetDiff(1));
         Bphi_vec.push_back(Pt_vec[M].GetDecPow(0));
         Bphi_vec[M].Scale(M);
         L_k[k] = L; M_k[k] =  M; ++k;
         L_k[k] = L; M_k[k] = -M; ++k;
      }
      PtB.push_back  (Pt_vec);
      BrB.push_back  (Br_vec);
      BzB.push_back  (Bz_vec);
      BphiB.push_back(Bphi_vec);
   }
}
HarmBasis3DCyl::~HarmBasis3DCyl ( ) [virtual]

Definition at line 67 of file HarmBasis3DCyl.cc.

References Bphi_k, Br_k, Bz_k, L_k, M_k, and P_k.

{
   delete [] Bphi_k;
   delete [] Bz_k;
   delete [] Br_k;
   delete [] P_k;
   delete [] M_k;
   delete [] L_k;
}

Member Function Documentation

void HarmBasis3DCyl::EvalBphi ( )

Definition at line 98 of file HarmBasis3DCyl.cc.

References Bphi_k, BphiB, Dim, magfieldparam::poly2d_base::Eval(), magfieldparam::rz_harm_poly::GetCos(), magfieldparam::rz_harm_poly::GetSin(), gen::k, dttmaxenums::L, and P.

Referenced by magfieldparam::BFit3D::GetField().

{
//Fills the array Bphi_k[Len] with values of phi-basis polynomials.
//
   unsigned M;
   double   V;
   double  *val = Bphi_k;
   rz_harm_poly *P;
   for (unsigned L = 1, k = 0; L <= Dim; ++L, ++k) {
      (*val) = 0.; ++val;
      for (M = 1; M <= L; ++M) {
         P = &(BphiB[k][M]);
         V = P->Eval();
         (*val) = -V*P->GetSin(); ++val;
         (*val) =  V*P->GetCos(); ++val;
      }
   }
}
void magfieldparam::HarmBasis3DCyl::EvalBr ( ) [inline]

Definition at line 51 of file HarmBasis3DCyl.h.

References Br_k, BrB, and EvalRZ().

Referenced by magfieldparam::BFit3D::GetField().

{ EvalRZ(BrB, Br_k);}
void magfieldparam::HarmBasis3DCyl::EvalBz ( ) [inline]

Definition at line 52 of file HarmBasis3DCyl.h.

References Bz_k, BzB, and EvalRZ().

Referenced by magfieldparam::BFit3D::GetField().

{ EvalRZ(BzB, Bz_k);}
void magfieldparam::HarmBasis3DCyl::EvalPtn ( ) [inline]

Definition at line 50 of file HarmBasis3DCyl.h.

References EvalRZ(), P_k, and PtB.

{ EvalRZ(PtB, P_k);}
void HarmBasis3DCyl::EvalRZ ( harm_poly_arr B,
double *  val 
) [private]

Definition at line 78 of file HarmBasis3DCyl.cc.

References Dim, magfieldparam::poly2d_base::Eval(), magfieldparam::rz_harm_poly::GetCos(), magfieldparam::rz_harm_poly::GetSin(), gen::k, dttmaxenums::L, and P.

Referenced by EvalBr(), EvalBz(), and EvalPtn().

{
//Fills the linear array val[Len] with values of basis polynomials.
//Private function, intended for internal use only.
//
   unsigned M;
   double   V;
   rz_harm_poly *P;
   for (unsigned L = 1, k = 0; L <= Dim; ++L, ++k) {
      (*val) = B[k][0].Eval(); ++val;
      for (M = 1; M <= L; ++M) {
         P = &(B[k][M]);
         V = P->Eval();
         (*val) = V*P->GetCos(); ++val;
         (*val) = V*P->GetSin(); ++val;
      }
   }
}
double magfieldparam::HarmBasis3DCyl::GetBphi ( double *  coeff) [inline]

Definition at line 68 of file HarmBasis3DCyl.h.

References Bphi_k, and GetVal().

Referenced by magfieldparam::BFit3D::GetField().

{ return GetVal(coeff, Bphi_k);}
double magfieldparam::HarmBasis3DCyl::GetBphi_k ( const unsigned  k) [inline]

Definition at line 60 of file HarmBasis3DCyl.h.

References Bphi_k, and gen::k.

Referenced by magfieldparam::BFit3D::GetBphi_k().

{ return Bphi_k[k];}
double magfieldparam::HarmBasis3DCyl::GetBr ( double *  coeff) [inline]

Definition at line 66 of file HarmBasis3DCyl.h.

References Br_k, and GetVal().

Referenced by magfieldparam::BFit3D::GetField().

{ return GetVal(coeff, Br_k);}
double magfieldparam::HarmBasis3DCyl::GetBr_k ( const unsigned  k) [inline]

Definition at line 58 of file HarmBasis3DCyl.h.

References Br_k, and gen::k.

Referenced by magfieldparam::BFit3D::GetBr_k().

{ return Br_k[k];}
double magfieldparam::HarmBasis3DCyl::GetBz ( double *  coeff) [inline]

Definition at line 67 of file HarmBasis3DCyl.h.

References Bz_k, and GetVal().

Referenced by magfieldparam::BFit3D::GetField().

{ return GetVal(coeff, Bz_k);}
double magfieldparam::HarmBasis3DCyl::GetBz_k ( const unsigned  k) [inline]

Definition at line 59 of file HarmBasis3DCyl.h.

References Bz_k, and gen::k.

Referenced by magfieldparam::BFit3D::GetBz_k().

{ return Bz_k[k];}
unsigned magfieldparam::HarmBasis3DCyl::GetDim ( ) [inline]

Definition at line 40 of file HarmBasis3DCyl.h.

References Dim.

{ return Dim;}
unsigned magfieldparam::HarmBasis3DCyl::GetLen ( ) [inline]

Definition at line 41 of file HarmBasis3DCyl.h.

References Len.

Referenced by magfieldparam::BFit3D::GetLen().

{ return Len;}
void magfieldparam::HarmBasis3DCyl::GetLM ( const unsigned  j,
int &  Lj,
int &  Mj 
) [inline]

Definition at line 42 of file HarmBasis3DCyl.h.

References j, L_k, and M_k.

{ Lj = L_k[j]; Mj = M_k[j];}
double magfieldparam::HarmBasis3DCyl::GetPtn ( double *  coeff) [inline]

Definition at line 65 of file HarmBasis3DCyl.h.

References GetVal(), and P_k.

{ return GetVal(coeff, P_k);}
double magfieldparam::HarmBasis3DCyl::GetPtn_k ( const unsigned  k) [inline]

Definition at line 57 of file HarmBasis3DCyl.h.

References gen::k, and P_k.

{ return P_k[k];}
double HarmBasis3DCyl::GetVal ( double *  coeff,
double *  basis 
) [private]

Definition at line 118 of file HarmBasis3DCyl.cc.

References gen::k, and Len.

Referenced by GetBphi(), GetBr(), GetBz(), and GetPtn().

{
//return value of the expansion with coefficients coeff[Len] for the basis
//Private function, intended for internal use only.
//
   double S = 0.;
   for (unsigned k = 0; k < Len; ++k) S += coeff[k]*basis[k];
   return S;
}
void HarmBasis3DCyl::Print ( std::ostream &  out = std::cout)

Definition at line 145 of file HarmBasis3DCyl.cc.

References PrintBphiB(), PrintBrB(), PrintBzB(), and PrintPtB().

{
   out << "BASIS POLYNOMIALS FOR THE POTENTIAL:\n" << std::endl;
   PrintPtB(out);
   out << "\nBASIS POLYNOMIALS FOR R-COMPONENT   OF THE FIELD:\n" << std::endl;
   PrintBrB(out);
   out << "\nBASIS POLYNOMIALS FOR Z-COMPONENT   OF THE FIELD:\n" << std::endl;
   PrintBzB(out);
   out << "\nBASIS POLYNOMIALS FOR PHI-COMPONENT OF THE FIELD:\n" << std::endl;
   PrintBphiB(out);
}
void HarmBasis3DCyl::Print ( harm_poly_arr B,
std::ostream &  out = std::cout 
) [private]

Definition at line 129 of file HarmBasis3DCyl.cc.

Referenced by PrintBphiB(), PrintBrB(), PrintBzB(), magfieldparam::BFit3D::PrintPoly(), and PrintPtB().

{
   unsigned jL, jM, wdt = 60;
   char fc1 = '-', fc0 = out.fill(fc1);
   for (jL = 0; jL < B.size(); ++jL) {
      out << std::setw(wdt) << fc1 << std::endl;
      out << "Basis subset " << jL+1 << std::endl;
      out << std::setw(wdt) << fc1 << std::endl;
      for (jM = 0; jM < B[jL].size(); ++jM) {
         B[jL][jM].Print(out);
      }
   }
   out.fill(fc0);
}
void magfieldparam::HarmBasis3DCyl::PrintBphiB ( std::ostream &  out = std::cout) [inline]

Definition at line 73 of file HarmBasis3DCyl.h.

References BphiB, dbtoconf::out, and Print().

Referenced by Print(), and magfieldparam::BFit3D::PrintBphiPoly().

{ Print(BphiB, out);}
void magfieldparam::HarmBasis3DCyl::PrintBrB ( std::ostream &  out = std::cout) [inline]

Definition at line 71 of file HarmBasis3DCyl.h.

References BrB, dbtoconf::out, and Print().

Referenced by Print(), and magfieldparam::BFit3D::PrintBrPoly().

{ Print(BrB,   out);}
void magfieldparam::HarmBasis3DCyl::PrintBzB ( std::ostream &  out = std::cout) [inline]

Definition at line 72 of file HarmBasis3DCyl.h.

References BzB, dbtoconf::out, and Print().

Referenced by Print(), and magfieldparam::BFit3D::PrintBzPoly().

{ Print(BzB,   out);}
void magfieldparam::HarmBasis3DCyl::PrintPtB ( std::ostream &  out = std::cout) [inline]

Definition at line 70 of file HarmBasis3DCyl.h.

References dbtoconf::out, Print(), and PtB.

Referenced by Print(), and magfieldparam::BFit3D::PrintPtnPoly().

{ Print(PtB,   out);}
void magfieldparam::HarmBasis3DCyl::SetPoint ( const double  r,
const double  z,
const double  phi 
) [inline]

Definition at line 45 of file HarmBasis3DCyl.h.

Referenced by magfieldparam::BFit3D::GetField().


Member Data Documentation

Definition at line 24 of file HarmBasis3DCyl.h.

Referenced by EvalBphi(), GetBphi(), GetBphi_k(), HarmBasis3DCyl(), and ~HarmBasis3DCyl().

Definition at line 29 of file HarmBasis3DCyl.h.

Referenced by EvalBphi(), HarmBasis3DCyl(), and PrintBphiB().

Definition at line 24 of file HarmBasis3DCyl.h.

Referenced by EvalBr(), GetBr(), GetBr_k(), HarmBasis3DCyl(), and ~HarmBasis3DCyl().

Definition at line 27 of file HarmBasis3DCyl.h.

Referenced by EvalBr(), HarmBasis3DCyl(), and PrintBrB().

Definition at line 24 of file HarmBasis3DCyl.h.

Referenced by EvalBz(), GetBz(), GetBz_k(), HarmBasis3DCyl(), and ~HarmBasis3DCyl().

Definition at line 28 of file HarmBasis3DCyl.h.

Referenced by EvalBz(), HarmBasis3DCyl(), and PrintBzB().

Definition at line 20 of file HarmBasis3DCyl.h.

Referenced by EvalBphi(), EvalRZ(), GetDim(), and HarmBasis3DCyl().

Definition at line 23 of file HarmBasis3DCyl.h.

Referenced by GetLM(), HarmBasis3DCyl(), and ~HarmBasis3DCyl().

Definition at line 21 of file HarmBasis3DCyl.h.

Referenced by GetLen(), GetVal(), and HarmBasis3DCyl().

Definition at line 23 of file HarmBasis3DCyl.h.

Referenced by GetLM(), HarmBasis3DCyl(), and ~HarmBasis3DCyl().

Definition at line 24 of file HarmBasis3DCyl.h.

Referenced by EvalPtn(), GetPtn(), GetPtn_k(), HarmBasis3DCyl(), and ~HarmBasis3DCyl().

Definition at line 26 of file HarmBasis3DCyl.h.

Referenced by EvalPtn(), HarmBasis3DCyl(), and PrintPtB().