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