CMS 3D CMS Logo

VolumeBasedMagneticField.cc
Go to the documentation of this file.
3 
5  const std::vector<MagBLayer*>& theBLayers,
6  const std::vector<MagESector*>& theESectors,
7  const std::vector<MagVolume6Faces*>& theBVolumes,
8  const std::vector<MagVolume6Faces*>& theEVolumes,
9  float rMax,
10  float zMax,
11  const MagneticField* param,
12  bool isParamFieldOwned)
13  : field(new MagGeometry(geomVersion, theBLayers, theESectors, theBVolumes, theEVolumes)),
14  maxR(rMax),
15  maxZ(zMax),
16  paramField(param),
17  magGeomOwned(true),
18  paramFieldOwned(isParamFieldOwned) {}
19 
22  field(vbf.field),
23  maxR(vbf.maxR),
24  maxZ(vbf.maxZ),
28  // std::cout << "VolumeBasedMagneticField::clone() (shallow copy)" << std::endl;
29 }
30 
32 
34  if (magGeomOwned)
35  delete field;
36  if (paramFieldOwned)
37  delete paramField;
38 }
39 
41  // If parametrization of the inner region is available, use it.
42  if (paramField && paramField->isDefined(gp))
43  return paramField->inTeslaUnchecked(gp);
44 
45  // If point is outside magfield map, return 0 field (not an error)
46  if (!isDefined(gp))
47  return GlobalVector();
48 
49  return field->fieldInTesla(gp);
50 }
51 
53  //same as above, but do not check range
54  if (paramField && paramField->isDefined(gp))
55  return paramField->inTeslaUnchecked(gp);
56  return field->fieldInTesla(gp);
57 }
58 
60 
62  return (fabs(gp.z()) < maxZ && gp.perp() < maxR);
63 }
64 
bool isZSymmetric() const
Definition: MagGeometry.h:50
virtual GlobalVector inTeslaUnchecked(const GlobalPoint &gp) const
Definition: MagneticField.h:44
T perp() const
Definition: PV3DBase.h:69
GlobalVector inTesla(const GlobalPoint &g) const override
Field value ad specified global point, in Tesla.
const MagVolume * findVolume(const GlobalPoint &gp) const
VolumeBasedMagneticField(int geomVersion, const std::vector< MagBLayer * > &theBLayers, const std::vector< MagESector * > &theESectors, const std::vector< MagVolume6Faces * > &theBVolumes, const std::vector< MagVolume6Faces * > &theEVolumes, float rMax, float zMax, const MagneticField *param=0, bool isParamFieldOwned=false)
MagVolume const * findVolume(const GlobalPoint &gp, double tolerance=0.) const
Find a volume.
Definition: MagGeometry.cc:150
T z() const
Definition: PV3DBase.h:61
virtual bool isDefined(const GlobalPoint &) const
True if the point is within the region where the concrete field.
Definition: MagneticField.h:40
GlobalVector inTeslaUnchecked(const GlobalPoint &g) const override
bool isDefined(const GlobalPoint &gp) const override
True if the point is within the region where the concrete field.
const MagneticField * paramField
MagneticField * clone() const override
Returns a shallow copy.
GlobalVector fieldInTesla(const GlobalPoint &gp) const
Return field vector at the specified global point.
Definition: MagGeometry.cc:89
Global3DVector GlobalVector
Definition: GlobalVector.h:10