CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SurfaceDeformationFactory.cc
Go to the documentation of this file.
1 
5 
9 
10 // included by header:
11 // #include <vector>
12 // #include <string>
13 
16 {
17  if (typeString == "BowedSurface") return kBowedSurface;
18  else if (typeString == "TwoBowedSurfaces") return kTwoBowedSurfaces;
19  else {
20  throw cms::Exception("BadInput") << "SurfaceDeformationFactory::surfaceDeformationType: "
21  << "Unknown SurfaceDeformation type " << typeString
22  << " (must be 'BowedSurface' or 'TwoBowedSurfaces'.\n";
23  return kBowedSurface; // not reached, to please the compiler
24  }
25 }
26 
27 SurfaceDeformation* SurfaceDeformationFactory::create(int type, const std::vector<double> &params)
28 {
29  switch(type) {
30  case kBowedSurface:
31  {
32  if (params.size() <= BowedSurfaceDeformation::maxParameterSize() &&
33  params.size() >= BowedSurfaceDeformation::minParameterSize()) {
34  return new BowedSurfaceDeformation(params);
35  } else {
36  break;
37  }
38  }
39  case kTwoBowedSurfaces:
40  {
41  if (params.size() <= TwoBowedSurfacesDeformation::maxParameterSize() &&
43  return new TwoBowedSurfacesDeformation(params);
44  } else {
45  break;
46  }
47  }
48  }
49 
50  throw cms::Exception("BadInput") << "SurfaceDeformationFactory::create: "
51  << "Unknown SurfaceDeformation type " << type << " (need "
52  << kBowedSurface << " or " << kTwoBowedSurfaces
53  << ") or params.size() (" << params.size()
54  << ") does not match.\n";
55 
56  return 0;
57 }
type
Definition: HCALResponse.h:21
static constexpr unsigned int minParameterSize()
minimum size of vector that is accepted by constructor from vector
static constexpr unsigned int maxParameterSize()
maximum size of vector that is accepted by constructor from vector
static unsigned int minParameterSize()
minimum size of vector that is accepted by constructor from vector
static unsigned int maxParameterSize()
maximum size of vector that is accepted by constructor from vector
Type surfaceDeformationType(const std::string &typeString)
convert string to &#39;Type&#39; - exception if string is not known
SurfaceDeformation * create(int type, const std::vector< double > &params)