CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
magfieldparam::BFit3D Class Reference

#include <BFit3D.h>

Public Member Functions

 BFit3D ()
 
double GetBnom ()
 
double GetBphi_k (const unsigned k)
 
double GetBr_k (const unsigned k)
 
double GetBz_k (const unsigned k)
 
double GetC (const int k)
 
void GetField (const double r, const double z, const double phi, double &Br, double &Bz, double &Bphi)
 
unsigned GetLen ()
 
void PrintBphiPoly (std::ostream &out=std::cout)
 
void PrintBrPoly (std::ostream &out=std::cout)
 
void PrintBzPoly (std::ostream &out=std::cout)
 
void PrintPoly (std::ostream &out=std::cout)
 
void PrintPtnPoly (std::ostream &out=std::cout)
 
void SetField (const double B)
 
void UseSignedRad (const bool flag=true)
 
void UseSpline (const bool flag=true)
 
virtual ~BFit3D ()
 

Private Member Functions

void SetCoeff_Linear (const double B)
 
void SetCoeff_Spline (const double B)
 

Private Attributes

double B_set
 
double C [360]
 
HarmBasis3DCylHB
 
bool signed_rad
 
bool use_spline
 

Static Private Attributes

static const double B_nom [4]
 
static const double C0 [360][4]
 
static const double C1 [360][5]
 
static const double C2 [360][3]
 

Detailed Description

Definition at line 9 of file BFit3D.h.

Constructor & Destructor Documentation

magfieldparam::BFit3D::BFit3D ( )
inline

Definition at line 35 of file BFit3D.h.

35  : use_spline(false), signed_rad(true), B_set(0.),
36  HB(new HarmBasis3DCyl(18)) {}
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
virtual magfieldparam::BFit3D::~BFit3D ( )
inlinevirtual

Definition at line 38 of file BFit3D.h.

References HB.

38 { delete HB;}
HarmBasis3DCyl * HB
Definition: BFit3D.h:25

Member Function Documentation

double magfieldparam::BFit3D::GetBnom ( )
inline

Definition at line 59 of file BFit3D.h.

References B_set.

59 { return B_set;} //Ret. nominal field
double magfieldparam::BFit3D::GetBphi_k ( const unsigned  k)
inline

Definition at line 66 of file BFit3D.h.

References magfieldparam::HarmBasis3DCyl::GetBphi_k(), and HB.

66 { return HB->GetBphi_k(k);}
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
double GetBphi_k(const unsigned k)
int k[5][pyjets_maxn]
double magfieldparam::BFit3D::GetBr_k ( const unsigned  k)
inline

Definition at line 64 of file BFit3D.h.

References magfieldparam::HarmBasis3DCyl::GetBr_k(), and HB.

64 { return HB->GetBr_k (k);}
double GetBr_k(const unsigned k)
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
int k[5][pyjets_maxn]
double magfieldparam::BFit3D::GetBz_k ( const unsigned  k)
inline

Definition at line 65 of file BFit3D.h.

References magfieldparam::HarmBasis3DCyl::GetBz_k(), and HB.

65 { return HB->GetBz_k (k);}
double GetBz_k(const unsigned k)
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
int k[5][pyjets_maxn]
double magfieldparam::BFit3D::GetC ( const int  k)
inline

Definition at line 60 of file BFit3D.h.

References C, and gen::k.

60 { return C[k];} //Ret. k-th expansion coefficient
int k[5][pyjets_maxn]
double C[360]
Definition: BFit3D.h:19
void BFit3D::GetField ( const double  r,
const double  z,
const double  phi,
double &  Br,
double &  Bz,
double &  Bphi 
)

Definition at line 70 of file BFit3D.cc.

References C, magfieldparam::HarmBasis3DCyl::EvalBphi(), magfieldparam::HarmBasis3DCyl::EvalBr(), magfieldparam::HarmBasis3DCyl::EvalBz(), magfieldparam::HarmBasis3DCyl::GetBphi(), magfieldparam::HarmBasis3DCyl::GetBr(), magfieldparam::HarmBasis3DCyl::GetBz(), HB, M_PI, magfieldparam::HarmBasis3DCyl::SetPoint(), and signed_rad.

Referenced by PolyFit3DParametrizedMagneticField::inTeslaUnchecked().

72 {
73 //Return field components in Br, Bz, Bphi. SetField must be called before use.
74 //
75  if (signed_rad || (r >= 0.)) HB->SetPoint(r, z, phi);
76  else HB->SetPoint(-r, z, phi+M_PI);
77  HB->EvalBr();
78  HB->EvalBz();
79  HB->EvalBphi();
80  Br = HB->GetBr (C);
81  Bz = HB->GetBz (C);
82  Bphi = HB->GetBphi(C);
83 }
double GetBphi(double *coeff)
double GetBr(double *coeff)
double double double z
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
#define M_PI
Definition: BFit3D.cc:3
double C[360]
Definition: BFit3D.h:19
void SetPoint(const double r, const double z, const double phi)
double GetBz(double *coeff)
Definition: DDAxes.h:10
unsigned magfieldparam::BFit3D::GetLen ( )
inline

Definition at line 58 of file BFit3D.h.

References magfieldparam::HarmBasis3DCyl::GetLen(), and HB.

58 { return HB->GetLen();} //Ret. the basis length
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
void magfieldparam::BFit3D::PrintBphiPoly ( std::ostream &  out = std::cout)
inline

Definition at line 73 of file BFit3D.h.

References HB, dbtoconf::out, and magfieldparam::HarmBasis3DCyl::PrintBphiB().

73 { HB->PrintBphiB(out);}
void PrintBphiB(std::ostream &out=std::cout)
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
tuple out
Definition: dbtoconf.py:99
void magfieldparam::BFit3D::PrintBrPoly ( std::ostream &  out = std::cout)
inline

Definition at line 71 of file BFit3D.h.

References HB, dbtoconf::out, and magfieldparam::HarmBasis3DCyl::PrintBrB().

71 { HB->PrintBrB (out);}
void PrintBrB(std::ostream &out=std::cout)
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
tuple out
Definition: dbtoconf.py:99
void magfieldparam::BFit3D::PrintBzPoly ( std::ostream &  out = std::cout)
inline

Definition at line 72 of file BFit3D.h.

References HB, dbtoconf::out, and magfieldparam::HarmBasis3DCyl::PrintBzB().

72 { HB->PrintBzB (out);}
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
tuple out
Definition: dbtoconf.py:99
void PrintBzB(std::ostream &out=std::cout)
void magfieldparam::BFit3D::PrintPoly ( std::ostream &  out = std::cout)
inline

Definition at line 74 of file BFit3D.h.

References HB, dbtoconf::out, and magfieldparam::HarmBasis3DCyl::Print().

74 { HB->Print (out);}
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
tuple out
Definition: dbtoconf.py:99
void Print(harm_poly_arr &B, std::ostream &out=std::cout)
void magfieldparam::BFit3D::PrintPtnPoly ( std::ostream &  out = std::cout)
inline

Definition at line 70 of file BFit3D.h.

References HB, dbtoconf::out, and magfieldparam::HarmBasis3DCyl::PrintPtB().

70 { HB->PrintPtB (out);}
HarmBasis3DCyl * HB
Definition: BFit3D.h:25
tuple out
Definition: dbtoconf.py:99
void PrintPtB(std::ostream &out=std::cout)
void BFit3D::SetCoeff_Linear ( const double  B)
private

Definition at line 12 of file BFit3D.cc.

References B_nom, C, C0, findQualityFiles::jj, and GetRecoTauVFromDQM_MC_cff::kk.

Referenced by SetField().

13 {
14  unsigned jj, kk = 1;
15  double w_0, w_1, B_mod = fabs(B);
16  if (B_mod <= B_nom[0]) {
17  w_0 = B / B_nom[0];
18  for (jj = 0; jj < 360; ++jj) {
19  C[jj] = w_0*C0[jj][0];
20  }
21  } else if (B_mod >= B_nom[3]) {
22  w_0 = B / B_nom[3];
23  for (jj = 0; jj < 360; ++jj) {
24  C[jj] = w_0*C0[jj][3];
25  }
26  } else {
27  while (B_nom[kk] < B_mod) ++kk; //Simple linear search
28  w_1 = (B_mod - B_nom[kk-1])/(B_nom[kk] - B_nom[kk-1]);
29  w_0 = 1.0 - w_1;
30  if (B < 0.) {
31  w_0 = -w_0;
32  w_1 = -w_1;
33  }
34  for (jj = 0; jj < 360; ++jj) {
35  C[jj] = w_0*C0[jj][kk-1] + w_1*C0[jj][kk];
36  }
37  }
38 }
static const double B_nom[4]
Definition: BFit3D.h:14
static const double C0[360][4]
Definition: BFit3D.h:15
double C[360]
Definition: BFit3D.h:19
void BFit3D::SetCoeff_Spline ( const double  B)
private

Definition at line 41 of file BFit3D.cc.

References B_nom, C, C0, C1, C2, and reco::ParticleMasses::k0.

Referenced by SetField().

42 {
43  int jc, k0 = 0, k1 = 1;
44  double dB2, dB = fabs(B);
45  if (dB >= B_nom[3]) { //Linear extrapolation for a large field
46  dB -= B_nom[3];
47  for (jc = 0; jc < 360; ++jc) C[jc] = C0[jc][3] + C1[jc][4]*dB;
48  } else {
49  if (dB < B_nom[0]) {
50  dB2 = dB*dB / (3.*B_nom[0]);
51  for (jc = 0; jc < 360; ++jc) C[jc] = (C2[jc][0]*dB2 + C1[jc][0])*dB;
52  } else {
53  while (B_nom[k1] < dB) ++k1; //Simple linear search
54  k0 = k1-1;
55  dB2 = (dB -= B_nom[k0]) / (3.*(B_nom[k1] - B_nom[k0]));
56  if (k1 < 3) { //"Regular" interval
57  for (jc = 0; jc < 360; ++jc)
58  C[jc] = (((C2[jc][k1] - C2[jc][k0])*dB2+C2[jc][k0])*dB + C1[jc][k1])*dB + C0[jc][k0];
59  } else { //The last interval
60  dB2 = (1.- dB2)*dB;
61  for (jc = 0; jc < 360; ++jc)
62  C[jc] = (C2[jc][k0]*dB2 + C1[jc][k1])*dB + C0[jc][k0];
63  }
64  }
65  }
66  if (B < 0) for (jc = 0; jc < 360; ++jc) C[jc] = -C[jc];
67 }
static const double B_nom[4]
Definition: BFit3D.h:14
static const double C0[360][4]
Definition: BFit3D.h:15
static const double C1[360][5]
Definition: BFit3D.h:16
double C[360]
Definition: BFit3D.h:19
static const double C2[360][3]
Definition: BFit3D.h:17
void magfieldparam::BFit3D::SetField ( const double  B)
inline

Definition at line 47 of file BFit3D.h.

References B_set, SetCoeff_Linear(), SetCoeff_Spline(), and use_spline.

Referenced by PolyFit3DParametrizedMagneticField::PolyFit3DParametrizedMagneticField().

47  {
49  B_set = B;
50  }
double_binary B
Definition: DDStreamer.cc:234
void SetCoeff_Linear(const double B)
Definition: BFit3D.cc:12
void SetCoeff_Spline(const double B)
Definition: BFit3D.cc:41
void magfieldparam::BFit3D::UseSignedRad ( const bool  flag = true)
inline

Definition at line 44 of file BFit3D.h.

References signed_rad.

44 { signed_rad = flag;}
long int flag
Definition: mlp_lapack.h:47
void magfieldparam::BFit3D::UseSpline ( const bool  flag = true)
inline

Definition at line 41 of file BFit3D.h.

References use_spline.

41 { use_spline = flag;}
long int flag
Definition: mlp_lapack.h:47

Member Data Documentation

const double magfieldparam::BFit3D::B_nom
staticprivate
Initial value:
=
{ 2.02156567013928,
3.51622117206486,
3.81143026675623,
4.01242188708911
}

Definition at line 14 of file BFit3D.h.

Referenced by SetCoeff_Linear(), and SetCoeff_Spline().

double magfieldparam::BFit3D::B_set
private

Definition at line 23 of file BFit3D.h.

Referenced by GetBnom(), and SetField().

double magfieldparam::BFit3D::C[360]
private

Definition at line 19 of file BFit3D.h.

Referenced by GetC(), GetField(), SetCoeff_Linear(), and SetCoeff_Spline().

const double magfieldparam::BFit3D::C0
staticprivate

Definition at line 15 of file BFit3D.h.

Referenced by SetCoeff_Linear(), and SetCoeff_Spline().

const double magfieldparam::BFit3D::C1
staticprivate

Definition at line 16 of file BFit3D.h.

Referenced by SetCoeff_Spline().

const double magfieldparam::BFit3D::C2
staticprivate

Definition at line 17 of file BFit3D.h.

Referenced by SetCoeff_Spline().

HarmBasis3DCyl* magfieldparam::BFit3D::HB
private
bool magfieldparam::BFit3D::signed_rad
private

Definition at line 22 of file BFit3D.h.

Referenced by GetField(), and UseSignedRad().

bool magfieldparam::BFit3D::use_spline
private

Definition at line 21 of file BFit3D.h.

Referenced by SetField(), and UseSpline().