CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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::auto_ptr<MagneticField>
24 
25  if (version=="OAE_1103l_071212") {
26  // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation
27  std::auto_ptr<MagneticField> result( new OAEParametrizedMagneticField(parameters));
28  return result;
29  } else if (version=="PolyFit2D") {
30  // V. Maroussov polynomial fit to mapping data
31  std::auto_ptr<MagneticField> result( new PolyFit2DParametrizedMagneticField(parameters));
32  return result;
33  } else if (version=="PolyFit3D") {
34  // V. Maroussov polynomial fit to mapping data
35  throw cms::Exception("InvalidParameter")<<"PolyFit3D is not supported anymore";
36  } else if (version=="Parabolic"){
37  // FIXME implement configurable parameters to be passed to ctor
38 // vector<double> params = parameters.getParameter<vdouble>("parameters");
39 // std::auto_ptr<MagneticField> result( new ParabolicParametrizedMagneticField(params));
40  std::auto_ptr<MagneticField> result( new ParabolicParametrizedMagneticField());
41  return result;
42  } else {
43  throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << version;
44  }
45  return std::auto_ptr<MagneticField>(0); //make compiler happy
46 }
47 
48 
49 // New interface
50 std::auto_ptr<MagneticField>
51 ParametrizedMagneticFieldFactory::get(string version, vector<double> parameters) {
52 
53  if (version=="Uniform") {
54  if (parameters.size()!=1) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ;
55  std::auto_ptr<MagneticField> result(new UniformMagneticField(parameters[0]));
56  return result;
57  } else if (version=="OAE_1103l_071212") {
58  // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation
59  if (parameters.size()!=1) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ;
60  std::auto_ptr<MagneticField> result( new OAEParametrizedMagneticField(parameters[0]));
61  return result;
62  } else if (version=="PolyFit2D") {
63  // V. Maroussov polynomial fit to mapping data
64  if (parameters.size()!=1) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ;
65  std::auto_ptr<MagneticField> result( new PolyFit2DParametrizedMagneticField(parameters[0]));
66  return result;
67  } else if (version=="PolyFit3D") {
68  // V. Maroussov polynomial fit to mapping data
69  throw cms::Exception("InvalidParameter")<<"PolyFit3D is not supported anymore";
70  } else if (version=="Parabolic"){
71  if (parameters.size()!=4) throw cms::Exception("InvalidParameter") << "Incorrect parameters (" << parameters.size()<< ")`for " << version ;
72  std::auto_ptr<MagneticField> result( new ParabolicParametrizedMagneticField(parameters));
73  return result;
74  } else {
75  throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << version;
76  }
77  return std::auto_ptr<MagneticField>(0); //make compiler happy
78 }
static std::auto_ptr< MagneticField > get(std::string version, const edm::ParameterSet &parameters)
tuple result
Definition: mps_fire.py:84