Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:43

0001 ///  $Date: 2010/09/10 11:19:37 $
0002 ///  $Revision: 1.3 $
0003 /// (last update by $Author: mussgill $)
0004 
0005 #include "Alignment/CommonAlignmentParametrization/interface/AlignmentParametersFactory.h"
0006 #include "Alignment/CommonAlignmentParametrization/interface/BeamSpotAlignmentParameters.h"
0007 #include "Alignment/CommonAlignmentParametrization/interface/BowedSurfaceAlignmentParameters.h"
0008 #include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters.h"
0009 #include "Alignment/CommonAlignmentParametrization/interface/RigidBodyAlignmentParameters4D.h"
0010 #include "Alignment/CommonAlignmentParametrization/interface/TwoBowedSurfacesAlignmentParameters.h"
0011 //#include "Alignment/SurveyAnalysis/interface/SurveyParameters.h"
0012 #include "DataFormats/CLHEP/interface/AlgebraicObjects.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014 #include "FWCore/Utilities/interface/Exception.h"
0015 
0016 #include <string>
0017 #include <vector>
0018 
0019 namespace AlignmentParametersFactory {
0020 
0021   //_______________________________________________________________________________________
0022   ParametersType parametersType(const std::string &typeString) {
0023     if (typeString == "RigidBody")
0024       return kRigidBody;
0025     else if (typeString == "Survey")
0026       return kSurvey;  // GF: do not belong here, so remove in the long term...
0027     else if (typeString == "RigidBody4D")
0028       return kRigidBody4D;
0029     else if (typeString == "BeamSpot")
0030       return kBeamSpot;
0031     else if (typeString == "BowedSurface")
0032       return kBowedSurface;
0033     else if (typeString == "TwoBowedSurfaces")
0034       return kTwoBowedSurfaces;
0035     throw cms::Exception("BadConfig") << "AlignmentParametersFactory"
0036                                       << " No AlignmentParameters with name '" << typeString << "'.";
0037 
0038     return kRigidBody;  // to please compiler...
0039   }
0040 
0041   //_______________________________________________________________________________________
0042   ParametersType parametersType(int typeInt) {
0043     if (typeInt == kRigidBody)
0044       return kRigidBody;
0045     if (typeInt == kSurvey)
0046       return kSurvey;  // GF: do not belong here, so remove in the long term...
0047     if (typeInt == kRigidBody4D)
0048       return kRigidBody4D;
0049     if (typeInt == kBeamSpot)
0050       return kBeamSpot;
0051     if (typeInt == kBowedSurface)
0052       return kBowedSurface;
0053     if (typeInt == kTwoBowedSurfaces)
0054       return kTwoBowedSurfaces;
0055 
0056     throw cms::Exception("BadConfig") << "AlignmentParametersFactory"
0057                                       << " No AlignmentParameters with number " << typeInt << ".";
0058 
0059     return kRigidBody;  // to please compiler...
0060   }
0061 
0062   //_______________________________________________________________________________________
0063   std::string parametersTypeName(ParametersType parType) {
0064     switch (parType) {
0065       case kRigidBody:
0066         return "RigiBody";
0067       case kSurvey:  // GF: do not belong here, so remove in the long term...
0068         return "Survey";
0069       case kRigidBody4D:
0070         return "RigiBody4D";
0071       case kBeamSpot:
0072         return "BeamSpot";
0073       case kBowedSurface:
0074         return "BowedSurface";
0075       case kTwoBowedSurfaces:
0076         return "TwoBowedSurfaces";
0077     }
0078 
0079     return "unknown_should_never_reach";  // to please the compiler
0080   }
0081 
0082   //_______________________________________________________________________________________
0083   AlignmentParameters *createParameters(Alignable *ali, ParametersType parType, const std::vector<bool> &sel) {
0084     switch (parType) {
0085       case kRigidBody: {
0086         const AlgebraicVector par(RigidBodyAlignmentParameters::N_PARAM, 0);
0087         const AlgebraicSymMatrix cov(RigidBodyAlignmentParameters::N_PARAM, 0);
0088         return new RigidBodyAlignmentParameters(ali, par, cov, sel);
0089       } break;
0090       case kSurvey:
0091         // creates some unwanted dependencies - and does not fit into
0092         // AlignmentParameters anyway!
0093         throw cms::Exception("BadConfig") << "AlignmentParametersFactory cannot create SurveyParameters.";
0094         //       edm::LogWarning("Alignment") << "@SUB=createParameters"
0095         //                 << "Creating SurveyParameters of length 0!";
0096         //       return new SurveyParameters(ali, AlgebraicVector(),
0097         //       AlgebraicSymMatrix());
0098         break;
0099       case kRigidBody4D: {
0100         const AlgebraicVector par(RigidBodyAlignmentParameters4D::N_PARAM, 0);
0101         const AlgebraicSymMatrix cov(RigidBodyAlignmentParameters4D::N_PARAM, 0);
0102         return new RigidBodyAlignmentParameters4D(ali, par, cov, sel);
0103       } break;
0104       case kBeamSpot: {
0105         const AlgebraicVector par(BeamSpotAlignmentParameters::N_PARAM, 0);
0106         const AlgebraicSymMatrix cov(BeamSpotAlignmentParameters::N_PARAM, 0);
0107         return new BeamSpotAlignmentParameters(ali, par, cov, sel);
0108       } break;
0109       case kBowedSurface: {
0110         const AlgebraicVector par(BowedSurfaceAlignmentParameters::N_PARAM, 0);
0111         const AlgebraicSymMatrix cov(BowedSurfaceAlignmentParameters::N_PARAM, 0);
0112         return new BowedSurfaceAlignmentParameters(ali, par, cov, sel);
0113       } break;
0114       case kTwoBowedSurfaces: {
0115         const AlgebraicVector par(TwoBowedSurfacesAlignmentParameters::N_PARAM, 0);
0116         const AlgebraicSymMatrix cov(TwoBowedSurfacesAlignmentParameters::N_PARAM, 0);
0117         return new TwoBowedSurfacesAlignmentParameters(ali, par, cov, sel);
0118       } break;
0119     }
0120 
0121     return nullptr;  // unreached (all ParametersType appear in switch), to please
0122                      // the compiler
0123   }
0124 }  // namespace AlignmentParametersFactory