CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PolyFit3DParametrizedMagneticField.cc
Go to the documentation of this file.
1 
11 
12 #include "BFit3D.h"
13 
14 
15 using namespace std;
16 using namespace magfieldparam;
17 
19  theParam(new BFit3D())
20 {
21  theParam->SetField(bVal);
22 }
23 
24 
26  theParam->SetField(parameters.getParameter<double>("BValue"));
27 
28  // Additional options (documentation by Vassili):
29 
30  // By default, the package accepts signed value of "r". That means,
31  // one can cross r=0 and orientation of the coordinate "orts"
32  // e_r and e_phi will not be flipped over.
33  // In other words for an r<0 the e_r points inward, in the direction r=0.
34  // This is a "natural" mode. However, the default behavior may be
35  // changed by the call
36 
37  // theParam->UseSignedRad(false);
38 
39  // In that case with crossing of r=0 e_r and e_phi will be flipped in
40  // such a way that e_r always points outward. In other words instead of
41  // (r<0, phi) the (abs(r), phi+PI) will be used in this mode.
42 
43  // The expansion coefficients for a nominal field in between measurement
44  // field values (2.0T, 3.5T, 3.8T and 4.0T) by default are calculated by
45  // means of a linear piecewise interpolation. Another provided
46  // interpolation mode is cubic spline. This mode can be switched
47  // on by the call:
48 
49  // theParam->UseSpline(true);
50 
51  // From practical point of view the use of spline interpolation doesn't
52  // change much, but it makes the coefficients' behavior a bit more
53  // physical at very low/high field values.
54 }
55 
56 
58  delete theParam;
59 }
60 
61 
64 
65  if (isDefined(gp)) {
66  return inTeslaUnchecked(gp);
67  } else {
68  edm::LogWarning("MagneticField|FieldOutsideValidity") << " Point " << gp << " is outside the validity region of PolyFit3DParametrizedMagneticField";
69  return GlobalVector();
70  }
71 }
72 
75  double Br, Bz, Bphi;
76  theParam->GetField(gp.perp()/100., gp.z()/100., gp.phi(),
77  Br, Bz, Bphi);
78 
79  double cosphi = cos(gp.phi());
80  double sinphi = sin(gp.phi());
81 
82  return GlobalVector(Br*cosphi - Bphi*sinphi,
83  Br*sinphi + Bphi*cosphi,
84  Bz);
85 }
86 
87 bool
89  double z = fabs(gp.z());
90  double r = gp.perp();
91  //"rectangle" |z|<3.5, r<1.9 _except_ the "corners" |z|+2.5*r>6.7, everything in meters
92  if (z>350. || r>190 || z+2.5*r>670.) return false;
93  return true;
94 }
T getParameter(std::string const &) const
dictionary parameters
Definition: Parameters.py:2
bool isDefined(const GlobalPoint &gp) const
True if the point is within the region where the concrete field.
T perp() const
Definition: PV3DBase.h:71
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
void SetField(const double B)
Definition: BFit3D.h:47
GlobalVector inTeslaUnchecked(const GlobalPoint &gp) const
double double double z
void GetField(const double r, const double z, const double phi, double &Br, double &Bz, double &Bphi)
Definition: BFit3D.cc:70
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
GlobalVector inTesla(const GlobalPoint &gp) const
Field value ad specified global point, in Tesla.
Global3DVector GlobalVector
Definition: GlobalVector.h:10