CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OAE85lParametrizedMagneticField.cc
Go to the documentation of this file.
1 
9 
10 #include "TkBfield.h"
11 
12 using namespace std;
13 using namespace magfieldparam;
14 
15 
17  float a_,
18  float l_)
19  : b0(b0_),
20  l(l_),
21  a(a_)
22 {
23  init();
24 }
25 
26 
28  b0 = parameters.getParameter<double>("b0");
29  l = parameters.getParameter<double>("l");
30  a = parameters.getParameter<double>("a");
31  init();
32 }
33 
35  ap2=4.0*a*a/(l*l);
36  hb0=0.5*b0*sqrt(1.0+ap2);
37  hlova=1.0/sqrt(ap2);
38  ainv=2.0*hlova/l;
39 }
40 
41 
42 
44 
45 
48 
49  if (isDefined(gp)) {
50  return inTeslaUnchecked(gp);
51  } else {
52  edm::LogWarning("MagneticField|FieldOutsideValidity") << " Point " << gp << " is outside the validity region of OAE85lParametrizedMagneticField";
53  return GlobalVector();
54  }
55 }
56 
57 
60 
61 // Method formerly named "trackerField"
62 
63 //
64 // B-field in Tracker volume
65 //
66 // In: xyz[3]: coordinates (m)
67 // Out: bxyz[3]: Bx,By,Bz (kG)
68 //
69 // Valid for r<1.2 and |z|<3.0 V.Karimäki 040301
70 // Updated for CMSSW field 070424
71 //
72 
73 // b0=field at centre, l=solenoid length, a=radius (m) (phenomen. parameters)
74 
75  // FIXME: beware of statics...
76 // static float ap2=4.0*a*a/(l*l);
77 // static float hb0=0.5*b0*sqrt(1.0+ap2);
78 // static float hlova=1.0/sqrt(ap2);
79 // static float ainv=2.0*hlova/l;
80  float xyz[3];//, bxyz[3];
81  // convert to m (CMSSW)
82  xyz[0]=0.01*gp.x();
83  xyz[1]=0.01*gp.y();
84  xyz[2]=0.01*gp.z();
85 
86  float r=sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
87  float z=xyz[2];
88  float az = fabs(z);
89  // if (r<1.2&&az<3.0) // NOTE: check omitted, is done already by inTesla (NA)
90  {
91  float zainv=z*ainv;
92  float rinv=(r>0.0) ? 1.0/r : 0.0;
93  float u=hlova-zainv;
94  float v=hlova+zainv;
95  float fu[5],gv[5];
96  ffunkti(u,fu);
97  ffunkti(v,gv);
98  float rat=r*ainv;
99  float corrr=0.00894*r*z*(az-2.2221)*(az-2.2221);
100  float corrz=-0.02996*exp(-0.5*(az-1.9820)*(az-1.9820)/(0.78915*0.78915));
101  float br=hb0*0.5*rat*(fu[1]-gv[1]-0.125*(fu[3]-gv[3])*rat*rat)+corrr;
102  float bz=hb0*(fu[0]+gv[0]-(fu[2]+gv[2])*0.25*rat*rat)+corrz;
103  //bxyz[0]=br*xyz[0]*rinv;
104  //bxyz[1]=br*xyz[1]*rinv;
105  //bxyz[2]=bz;
107  // bvec.x()=0.1*br*xyz[0]*rinv;
108  //bvec.y()=0.1*br*xyz[1]*rinv;
109  //bvec.z()=0.1*bz;
110  return 0.1*GlobalVector(br*xyz[0]*rinv, br*xyz[1]*rinv, bz);
111  }
112  // else {
113  // cout <<"The point is outside the region r<1.2m && |z|<3.0m"<<endl;
114  //}
115  // return GlobalVector();
116 }
117 
118 void OAE85lParametrizedMagneticField::ffunkti(float u, float* ff) const {
119 // Function and its 3 derivatives
120  float a,b;
121  a=1.0/(1.0+u*u);
122  b=sqrt(a);
123  ff[0]=u*b;
124  ff[1]=a*b;
125  ff[2]=-3.0*u*a*ff[1];
126  ff[3]=a*ff[2]*((1.0/u)-4.0*u);
127  return;
128 }
129 
130 
131 bool
133  return (gp.perp()<120. && fabs(gp.z())<300.);
134 }
135 
T getParameter(std::string const &) const
dictionary parameters
Definition: Parameters.py:2
T perp() const
Definition: PV3DBase.h:72
T y() const
Definition: PV3DBase.h:63
float float float z
OAE85lParametrizedMagneticField(float b0_=40.681, float a_=4.6430, float l_=15.284)
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
GlobalVector inTeslaUnchecked(const GlobalPoint &gp) const
GlobalVector inTesla(const GlobalPoint &gp) const
Field value ad specified global point, in Tesla.
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10
bool isDefined(const GlobalPoint &gp) const
True if the point is within the region where the concrete field.