CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/MagneticField/ParametrizedEngine/plugins/ParametrizedMagneticFieldProducer.cc

Go to the documentation of this file.
00001 
00008 #include "MagneticField/ParametrizedEngine/plugins/ParametrizedMagneticFieldProducer.h"
00009 #include "OAEParametrizedMagneticField.h"
00010 #include "OAE85lParametrizedMagneticField.h"
00011 #include "PolyFit2DParametrizedMagneticField.h"
00012 #include "PolyFit3DParametrizedMagneticField.h"
00013 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00014 
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/Utilities/interface/Exception.h"
00018 
00019 #include <string>
00020 #include <iostream>
00021 
00022 using namespace std;
00023 using namespace edm;
00024 using namespace magneticfield;
00025 
00026 
00027 ParametrizedMagneticFieldProducer::ParametrizedMagneticFieldProducer(const edm::ParameterSet& iConfig) : pset(iConfig) {
00028   setWhatProduced(this, pset.getUntrackedParameter<std::string>("label",""));
00029 }
00030 
00031 
00032 ParametrizedMagneticFieldProducer::~ParametrizedMagneticFieldProducer()
00033 {
00034 }
00035 
00036 
00037 std::auto_ptr<MagneticField>
00038 ParametrizedMagneticFieldProducer::produce(const IdealMagneticFieldRecord& iRecord)
00039 {
00040   string version = pset.getParameter<string>("version");
00041   ParameterSet parameters = pset.getParameter<ParameterSet>("parameters");
00042 
00043   if (version=="OAE_85l_030919") {
00044     // V. Karimaki's off-axis expansion fitted to v85l TOSCA computation
00045     std::auto_ptr<MagneticField> result(new OAE85lParametrizedMagneticField(parameters));
00046     return result;
00047   } else if (version=="OAE_1103l_071212") {
00048     // V. Karimaki's off-axis expansion fitted to v1103l TOSCA computation
00049     std::auto_ptr<MagneticField> result( new OAEParametrizedMagneticField(parameters));
00050     return result;
00051   } else if (version=="PolyFit2D") {
00052     // V. Maroussov polynomial fit to mapping data
00053     std::auto_ptr<MagneticField> result( new PolyFit2DParametrizedMagneticField(parameters));
00054     return result;
00055   } else if (version=="PolyFit3D") {
00056     // V. Maroussov polynomial fit to mapping data
00057     std::auto_ptr<MagneticField> result( new PolyFit3DParametrizedMagneticField(parameters));
00058     return result;
00059   } else {
00060     throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << version;
00061   }
00062   return std::auto_ptr<MagneticField>(0); //make compiler happy
00063 }
00064 
00065 #include "FWCore/Framework/interface/ModuleFactory.h"
00066 DEFINE_FWK_EVENTSETUP_MODULE(ParametrizedMagneticFieldProducer);