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