CMS 3D CMS Logo

ParametrizedMagneticFieldFactory.cc
Go to the documentation of this file.
1 
8 
13 
15 
16 using namespace std;
17 using namespace edm;
18 
20 
21 // Legacy interface, deprecated
22 std::unique_ptr<MagneticField> ParametrizedMagneticFieldFactory::get(string version, const ParameterSet& parameters) {
23  if (version == "OAE_1103l_071212") {
24  // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation
25  std::unique_ptr<MagneticField> result(new OAEParametrizedMagneticField(parameters));
26  return result;
27  } else if (version == "PolyFit2D") {
28  // V. Maroussov polynomial fit to mapping data
29  std::unique_ptr<MagneticField> result(new PolyFit2DParametrizedMagneticField(parameters));
30  return result;
31  } else if (version == "PolyFit3D") {
32  // V. Maroussov polynomial fit to mapping data
33  throw cms::Exception("InvalidParameter") << "PolyFit3D is not supported anymore";
34  } else if (version == "Parabolic") {
35  // FIXME implement configurable parameters to be passed to ctor
36  // vector<double> params = parameters.getParameter<vdouble>("parameters");
37  // std::unique_ptr<MagneticField> result( new ParabolicParametrizedMagneticField(params));
38  std::unique_ptr<MagneticField> result(new ParabolicParametrizedMagneticField());
39  return result;
40  } else {
41  throw cms::Exception("InvalidParameter") << "Invalid parametrization version " << version;
42  }
43  return std::unique_ptr<MagneticField>(nullptr); //make compiler happy
44 }
45 
46 // New interface
47 std::unique_ptr<MagneticField> ParametrizedMagneticFieldFactory::get(string version, vector<double> parameters) {
48  if (version == "Uniform") {
49  if (parameters.size() != 1)
50  throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size() << ")`for " << version;
51  std::unique_ptr<MagneticField> result(new UniformMagneticField(parameters[0]));
52  return result;
53  } else if (version == "OAE_1103l_071212") {
54  // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation
55  if (parameters.size() != 1)
56  throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size() << ")`for " << version;
57  std::unique_ptr<MagneticField> result(new OAEParametrizedMagneticField(parameters[0]));
58  return result;
59  } else if (version == "PolyFit2D") {
60  // V. Maroussov polynomial fit to mapping data
61  if (parameters.size() != 1)
62  throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size() << ")`for " << version;
63  std::unique_ptr<MagneticField> result(new PolyFit2DParametrizedMagneticField(parameters[0]));
64  return result;
65  } else if (version == "PolyFit3D") {
66  // V. Maroussov polynomial fit to mapping data
67  throw cms::Exception("InvalidParameter") << "PolyFit3D is not supported anymore";
68  } else if (version == "Parabolic") {
69  if (parameters.size() != 4)
70  throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size() << ")`for " << version;
71  std::unique_ptr<MagneticField> result(new ParabolicParametrizedMagneticField(parameters));
72  return result;
73  } else {
74  throw cms::Exception("InvalidParameter") << "Invalid parametrization version " << version;
75  }
76  return std::unique_ptr<MagneticField>(nullptr); //make compiler happy
77 }
OAEParametrizedMagneticField
Definition: OAEParametrizedMagneticField.h:25
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
ParametrizedMagneticFieldFactory::get
static std::unique_ptr< MagneticField > get(std::string version, const edm::ParameterSet &parameters)
ParametrizedMagneticFieldFactory::ParametrizedMagneticFieldFactory
ParametrizedMagneticFieldFactory()
Constructor.
Definition: ParametrizedMagneticFieldFactory.cc:19
edm
HLT enums.
Definition: AlignableModifier.h:19
ParabolicParametrizedMagneticField
Definition: ParabolicParametrizedMagneticField.h:19
PolyFit2DParametrizedMagneticField
Definition: PolyFit2DParametrizedMagneticField.h:21
edm::ParameterSet
Definition: ParameterSet.h:47
ParabolicParametrizedMagneticField.h
UniformMagneticField.h
std
Definition: JetResolutionObject.h:76
OAEParametrizedMagneticField.h
PolyFit2DParametrizedMagneticField.h
Exception
Definition: hltDiff.cc:245
Exception.h
mps_fire.result
result
Definition: mps_fire.py:311
cms::Exception
Definition: Exception.h:70
ParameterSet.h
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
ParametrizedMagneticFieldFactory.h
UniformMagneticField
Definition: UniformMagneticField.h:13