File indexing completed on 2024-04-06 12:14:23
0001
0002
0003
0004 #include "FWCore/Utilities/interface/Exception.h"
0005
0006 #include "Geometry/CommonTopologies/interface/SurfaceDeformationFactory.h"
0007 #include "Geometry/CommonTopologies/interface/BowedSurfaceDeformation.h"
0008 #include "Geometry/CommonTopologies/interface/TwoBowedSurfacesDeformation.h"
0009
0010
0011
0012
0013
0014 SurfaceDeformationFactory::Type SurfaceDeformationFactory::surfaceDeformationType(const std::string &typeString) {
0015 if (typeString == "BowedSurface")
0016 return kBowedSurface;
0017 else if (typeString == "TwoBowedSurfaces")
0018 return kTwoBowedSurfaces;
0019 else {
0020 throw cms::Exception("BadInput") << "SurfaceDeformationFactory::surfaceDeformationType: "
0021 << "Unknown SurfaceDeformation type " << typeString
0022 << " (must be 'BowedSurface' or 'TwoBowedSurfaces'.\n";
0023 return kNoDeformations;
0024 }
0025 }
0026 std::string SurfaceDeformationFactory::surfaceDeformationTypeName(const SurfaceDeformationFactory::Type &type) {
0027 switch (type) {
0028 case kBowedSurface:
0029 return std::string("BowedSurface");
0030 case kTwoBowedSurfaces:
0031 return std::string("TwoBowedSurfaces");
0032 default:
0033 throw cms::Exception("BadInput") << "SurfaceDeformationFactory::surfaceDeformationTypeName: "
0034 << "Unknown SurfaceDeformation type " << type
0035 << " (must be 'kBowedSurface' or 'kTwoBowedSurfaces'.\n";
0036 return std::string("NoDeformations");
0037 }
0038 }
0039
0040 SurfaceDeformation *SurfaceDeformationFactory::create(int type, const std::vector<double> ¶ms) {
0041 switch (type) {
0042 case kBowedSurface:
0043 case kTwoBowedSurfaces:
0044 return SurfaceDeformationFactory::create(params);
0045 default:
0046 throw cms::Exception("BadInput") << "SurfaceDeformationFactory::create: "
0047 << "Unknown SurfaceDeformation type " << type << " (need " << kBowedSurface
0048 << " or " << kTwoBowedSurfaces << ")\n";
0049 return nullptr;
0050 }
0051 }
0052
0053 SurfaceDeformation *SurfaceDeformationFactory::create(const std::vector<double> ¶ms) {
0054 if (params.size() <= BowedSurfaceDeformation::maxParameterSize() &&
0055 params.size() >= BowedSurfaceDeformation::minParameterSize())
0056 return new BowedSurfaceDeformation(params);
0057 else if (params.size() <= TwoBowedSurfacesDeformation::maxParameterSize() &&
0058 params.size() >= TwoBowedSurfacesDeformation::minParameterSize())
0059 return new TwoBowedSurfacesDeformation(params);
0060
0061 throw cms::Exception("BadInput") << "SurfaceDeformationFactory::create: "
0062 << "Params.size() (" << params.size() << ") does not match.\n";
0063
0064 return nullptr;
0065 }