CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
tuple result
Definition: mps_fire.py:311
static std::unique_ptr< MagneticField > get(std::string version, const edm::ParameterSet &parameters)