CMS 3D CMS Logo

PolyFit2DParametrizedMagneticField.cc
Go to the documentation of this file.
1 
9 
10 #include "BFit.h"
11 
12 using namespace std;
13 using namespace magfieldparam;
14 
16  theParam->SetField(bVal);
17 }
18 
20  : theParam(new BFit()) {
21  theParam->SetField(parameters.getParameter<double>("BValue"));
22 }
23 
25 
27  if (isDefined(gp)) {
28  return inTeslaUnchecked(gp);
29  } else {
30  edm::LogWarning("MagneticField|FieldOutsideValidity")
31  << " Point " << gp << " is outside the validity region of PolyFit2DParametrizedMagneticField";
32  return GlobalVector();
33  }
34 }
35 
37  double Br, Bz, Bphi;
38  theParam->GetField(gp.perp() / 100., gp.z() / 100., gp.phi(), Br, Bz, Bphi);
39 
40  double cosphi = cos(gp.phi());
41  double sinphi = sin(gp.phi());
42 
43  return GlobalVector(Br * cosphi - Bphi * sinphi, Br * sinphi + Bphi * cosphi, Bz);
44 }
45 
47  double z = fabs(gp.z());
48  double r = gp.perp();
49  //"rectangle" |z|<3.5, r<1.9 _except_ the "corners" |z|+2.5*r>6.7, everything in meters
50  if (z > 350. || r > 190 || z + 2.5 * r > 670.)
51  return false;
52  return true;
53 }
T getParameter(std::string const &) const
T perp() const
Definition: PV3DBase.h:69
bool isDefined(const GlobalPoint &gp) const override
True if the point is within the region where the concrete field.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void GetField(double r, double z, double phi, double &Br, double &Bz, double &Bphi) const
Definition: BFit.cc:190
GlobalVector inTesla(const GlobalPoint &gp) const override
Field value ad specified global point, in Tesla.
T z() const
Definition: PV3DBase.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
GlobalVector inTeslaUnchecked(const GlobalPoint &gp) const override
void SetField(double B)
Definition: BFit.cc:152
Global3DVector GlobalVector
Definition: GlobalVector.h:10