CMS 3D CMS Logo

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

◆ BFit3D()

magfieldparam::BFit3D::BFit3D ( )
inline

Definition at line 32 of file BFit3D.h.

32 : use_spline(false), signed_rad(true), B_set(0.), HB(new HarmBasis3DCyl(18)) {}

◆ ~BFit3D()

virtual magfieldparam::BFit3D::~BFit3D ( )
inlinevirtual

Definition at line 34 of file BFit3D.h.

34 { delete HB; }

References HB.

Member Function Documentation

◆ GetBnom()

double magfieldparam::BFit3D::GetBnom ( )
inline

Definition at line 57 of file BFit3D.h.

57 { return B_set; } //Ret. nominal field

References B_set.

◆ GetBphi_k()

double magfieldparam::BFit3D::GetBphi_k ( const unsigned  k)
inline

Definition at line 64 of file BFit3D.h.

64 { return HB->GetBphi_k(k); }

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

◆ GetBr_k()

double magfieldparam::BFit3D::GetBr_k ( const unsigned  k)
inline

Definition at line 62 of file BFit3D.h.

62 { return HB->GetBr_k(k); }

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

◆ GetBz_k()

double magfieldparam::BFit3D::GetBz_k ( const unsigned  k)
inline

Definition at line 63 of file BFit3D.h.

63 { return HB->GetBz_k(k); }

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

◆ GetC()

double magfieldparam::BFit3D::GetC ( const int  k)
inline

Definition at line 58 of file BFit3D.h.

58 { return C[k]; } //Ret. k-th expansion coefficient

References C, and dqmdumpme::k.

◆ GetField()

void BFit3D::GetField ( const double  r,
const double  z,
const double  phi,
double &  Br,
double &  Bz,
double &  Bphi 
)

Definition at line 73 of file BFit3D.cc.

73  {
74  //Return field components in Br, Bz, Bphi. SetField must be called before use.
75  //
76  if (signed_rad || (r >= 0.))
77  HB->SetPoint(r, z, phi);
78  else
79  HB->SetPoint(-r, z, phi + M_PI);
80  HB->EvalBr();
81  HB->EvalBz();
82  HB->EvalBphi();
83  Br = HB->GetBr(C);
84  Bz = HB->GetBz(C);
85  Bphi = HB->GetBphi(C);
86 }

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

◆ GetLen()

unsigned magfieldparam::BFit3D::GetLen ( )
inline

Definition at line 56 of file BFit3D.h.

56 { return HB->GetLen(); } //Ret. the basis length

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

◆ PrintBphiPoly()

void magfieldparam::BFit3D::PrintBphiPoly ( std::ostream &  out = std::cout)
inline

◆ PrintBrPoly()

void magfieldparam::BFit3D::PrintBrPoly ( std::ostream &  out = std::cout)
inline

Definition at line 69 of file BFit3D.h.

69 { HB->PrintBrB(out); }

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

◆ PrintBzPoly()

void magfieldparam::BFit3D::PrintBzPoly ( std::ostream &  out = std::cout)
inline

Definition at line 70 of file BFit3D.h.

70 { HB->PrintBzB(out); }

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

◆ PrintPoly()

void magfieldparam::BFit3D::PrintPoly ( std::ostream &  out = std::cout)
inline

Definition at line 72 of file BFit3D.h.

72 { HB->Print(out); }

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

◆ PrintPtnPoly()

void magfieldparam::BFit3D::PrintPtnPoly ( std::ostream &  out = std::cout)
inline

Definition at line 68 of file BFit3D.h.

68 { HB->PrintPtB(out); }

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

◆ SetCoeff_Linear()

void BFit3D::SetCoeff_Linear ( const double  B)
private

Definition at line 11 of file BFit3D.cc.

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

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

Referenced by SetField().

◆ SetCoeff_Spline()

void BFit3D::SetCoeff_Spline ( const double  B)
private

Definition at line 40 of file BFit3D.cc.

40  {
41  int jc, k0 = 0, k1 = 1;
42  double dB2, dB = fabs(B);
43  if (dB >= B_nom[3]) { //Linear extrapolation for a large field
44  dB -= B_nom[3];
45  for (jc = 0; jc < 360; ++jc)
46  C[jc] = C0[jc][3] + C1[jc][4] * dB;
47  } else {
48  if (dB < B_nom[0]) {
49  dB2 = dB * dB / (3. * B_nom[0]);
50  for (jc = 0; jc < 360; ++jc)
51  C[jc] = (C2[jc][0] * dB2 + C1[jc][0]) * dB;
52  } else {
53  while (B_nom[k1] < dB)
54  ++k1; //Simple linear search
55  k0 = k1 - 1;
56  dB2 = (dB -= B_nom[k0]) / (3. * (B_nom[k1] - B_nom[k0]));
57  if (k1 < 3) { //"Regular" interval
58  for (jc = 0; jc < 360; ++jc)
59  C[jc] = (((C2[jc][k1] - C2[jc][k0]) * dB2 + C2[jc][k0]) * dB + C1[jc][k1]) * dB + C0[jc][k0];
60  } else { //The last interval
61  dB2 = (1. - dB2) * dB;
62  for (jc = 0; jc < 360; ++jc)
63  C[jc] = (C2[jc][k0] * dB2 + C1[jc][k1]) * dB + C0[jc][k0];
64  }
65  }
66  }
67  if (B < 0)
68  for (jc = 0; jc < 360; ++jc)
69  C[jc] = -C[jc];
70 }

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

Referenced by SetField().

◆ SetField()

void magfieldparam::BFit3D::SetField ( const double  B)
inline

Definition at line 43 of file BFit3D.h.

43  {
44  if (use_spline)
46  else
48  B_set = B;
49  }

References TtFullHadDaughter::B, B_set, SetCoeff_Linear(), SetCoeff_Spline(), and use_spline.

◆ UseSignedRad()

void magfieldparam::BFit3D::UseSignedRad ( const bool  flag = true)
inline

Definition at line 40 of file BFit3D.h.

40 { signed_rad = flag; }

References RemoveAddSevLevel::flag, and signed_rad.

◆ UseSpline()

void magfieldparam::BFit3D::UseSpline ( const bool  flag = true)
inline

Definition at line 37 of file BFit3D.h.

37 { use_spline = flag; }

References RemoveAddSevLevel::flag, and use_spline.

Member Data Documentation

◆ B_nom

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

Definition at line 12 of file BFit3D.h.

Referenced by SetCoeff_Linear(), and SetCoeff_Spline().

◆ B_set

double magfieldparam::BFit3D::B_set
private

Definition at line 21 of file BFit3D.h.

Referenced by GetBnom(), and SetField().

◆ C

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

Definition at line 17 of file BFit3D.h.

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

◆ C0

const double magfieldparam::BFit3D::C0
staticprivate

Definition at line 13 of file BFit3D.h.

Referenced by SetCoeff_Linear(), and SetCoeff_Spline().

◆ C1

const double magfieldparam::BFit3D::C1
staticprivate

Definition at line 14 of file BFit3D.h.

Referenced by SetCoeff_Spline().

◆ C2

const double magfieldparam::BFit3D::C2
staticprivate

Definition at line 15 of file BFit3D.h.

Referenced by SetCoeff_Spline().

◆ HB

HarmBasis3DCyl* magfieldparam::BFit3D::HB
private

◆ signed_rad

bool magfieldparam::BFit3D::signed_rad
private

Definition at line 20 of file BFit3D.h.

Referenced by GetField(), and UseSignedRad().

◆ use_spline

bool magfieldparam::BFit3D::use_spline
private

Definition at line 19 of file BFit3D.h.

Referenced by SetField(), and UseSpline().

magfieldparam::HarmBasis3DCyl::PrintBzB
void PrintBzB(std::ostream &out=std::cout)
Definition: HarmBasis3DCyl.h:73
magfieldparam::BFit3D::C2
static const double C2[360][3]
Definition: BFit3D.h:15
magfieldparam::BFit3D::C0
static const double C0[360][4]
Definition: BFit3D.h:13
magfieldparam::BFit3D::HB
HarmBasis3DCyl * HB
Definition: BFit3D.h:23
reco::ParticleMasses::k0
const double k0
Definition: ParticleMasses.h:7
magfieldparam::HarmBasis3DCyl::Print
void Print(harm_poly_arr &B, std::ostream &out=std::cout)
Definition: HarmBasis3DCyl.cc:140
magfieldparam::HarmBasis3DCyl::GetBz
double GetBz(double *coeff)
Definition: HarmBasis3DCyl.h:68
magfieldparam::HarmBasis3DCyl::GetLen
unsigned GetLen()
Definition: HarmBasis3DCyl.h:40
magfieldparam::HarmBasis3DCyl::EvalBphi
void EvalBphi()
Definition: HarmBasis3DCyl.cc:107
magfieldparam::HarmBasis3DCyl::GetBz_k
double GetBz_k(const unsigned k)
Definition: HarmBasis3DCyl.h:60
magfieldparam::HarmBasis3DCyl::GetBphi_k
double GetBphi_k(const unsigned k)
Definition: HarmBasis3DCyl.h:61
DDAxes::z
GetRecoTauVFromDQM_MC_cff.kk
kk
Definition: GetRecoTauVFromDQM_MC_cff.py:84
magfieldparam::HarmBasis3DCyl::PrintPtB
void PrintPtB(std::ostream &out=std::cout)
Definition: HarmBasis3DCyl.h:71
dqmdumpme.k
k
Definition: dqmdumpme.py:60
magfieldparam::HarmBasis3DCyl::PrintBrB
void PrintBrB(std::ostream &out=std::cout)
Definition: HarmBasis3DCyl.h:72
magfieldparam::BFit3D::SetCoeff_Spline
void SetCoeff_Spline(const double B)
Definition: BFit3D.cc:40
M_PI
#define M_PI
Definition: BFit3D.cc:3
magfieldparam::HarmBasis3DCyl::GetBr_k
double GetBr_k(const unsigned k)
Definition: HarmBasis3DCyl.h:59
magfieldparam::BFit3D::C1
static const double C1[360][5]
Definition: BFit3D.h:14
magfieldparam::HarmBasis3DCyl::EvalBr
void EvalBr()
Definition: HarmBasis3DCyl.h:52
alignCSCRings.r
r
Definition: alignCSCRings.py:93
magfieldparam::BFit3D::B_set
double B_set
Definition: BFit3D.h:21
DDAxes::phi
magfieldparam::HarmBasis3DCyl::PrintBphiB
void PrintBphiB(std::ostream &out=std::cout)
Definition: HarmBasis3DCyl.h:74
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
magfieldparam::HarmBasis3DCyl::SetPoint
void SetPoint(const double r, const double z, const double phi)
Definition: HarmBasis3DCyl.h:47
magfieldparam::HarmBasis3DCyl::GetBphi
double GetBphi(double *coeff)
Definition: HarmBasis3DCyl.h:69
magfieldparam::BFit3D::signed_rad
bool signed_rad
Definition: BFit3D.h:20
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
magfieldparam::BFit3D::B_nom
static const double B_nom[4]
Definition: BFit3D.h:12
magfieldparam::BFit3D::SetCoeff_Linear
void SetCoeff_Linear(const double B)
Definition: BFit3D.cc:11
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
magfieldparam::BFit3D::C
double C[360]
Definition: BFit3D.h:17
magfieldparam::HarmBasis3DCyl::EvalBz
void EvalBz()
Definition: HarmBasis3DCyl.h:53
magfieldparam::BFit3D::use_spline
bool use_spline
Definition: BFit3D.h:19
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116
magfieldparam::HarmBasis3DCyl::GetBr
double GetBr(double *coeff)
Definition: HarmBasis3DCyl.h:67