CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Geometry/CommonTopologies/src/SurfaceDeformationFactory.cc

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 #include "FWCore/Utilities/interface/Exception.h"
00008 
00009 #include "Geometry/CommonTopologies/interface/SurfaceDeformationFactory.h"
00010 #include "Geometry/CommonTopologies/interface/BowedSurfaceDeformation.h"
00011 #include "Geometry/CommonTopologies/interface/TwoBowedSurfacesDeformation.h"
00012 
00013 // included by header:
00014 // #include <vector>
00015 // #include <string>
00016 
00017 SurfaceDeformationFactory::Type
00018 SurfaceDeformationFactory::surfaceDeformationType(const std::string &typeString)
00019 {
00020   if      (typeString == "BowedSurface")     return kBowedSurface;
00021   else if (typeString == "TwoBowedSurfaces") return kTwoBowedSurfaces;
00022   else {
00023     throw cms::Exception("BadInput") << "SurfaceDeformationFactory::surfaceDeformationType: "
00024                                      << "Unknown SurfaceDeformation type " << typeString
00025                                      << " (must be 'BowedSurface' or 'TwoBowedSurfaces'.\n";
00026     return kBowedSurface; // not reached, to please the compiler
00027   }
00028 }
00029 
00030 SurfaceDeformation* SurfaceDeformationFactory::create(int type, const std::vector<double> &params)
00031 {
00032   switch(type) {
00033   case kBowedSurface:
00034     {
00035       if (params.size() <= BowedSurfaceDeformation::maxParameterSize() &&
00036           params.size() >= BowedSurfaceDeformation::minParameterSize()) {
00037         return new BowedSurfaceDeformation(params);
00038       } else {
00039         break;
00040       }
00041     }
00042   case kTwoBowedSurfaces:
00043     {
00044       if (params.size() <= TwoBowedSurfacesDeformation::maxParameterSize() &&
00045           params.size() >= TwoBowedSurfacesDeformation::minParameterSize()) {
00046         return new TwoBowedSurfacesDeformation(params);
00047       } else {
00048         break;
00049       }
00050     }
00051   }
00052 
00053   throw cms::Exception("BadInput") << "SurfaceDeformationFactory::create: "
00054                                    << "Unknown SurfaceDeformation type " << type << " (need "
00055                                    << kBowedSurface << " or " << kTwoBowedSurfaces 
00056                                    << ") or params.size() (" << params.size()
00057                                    << ") does not match.\n";
00058   
00059   return 0;
00060 }