CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.cc

Go to the documentation of this file.
00001 
00007 #include "MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.h"
00008 #include "MagneticField/VolumeBasedEngine/interface/VolumeBasedMagneticField.h"
00009 
00010 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00011 
00012 #include "FWCore/Framework/interface/ESTransientHandle.h"
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 
00015 #include "DetectorDescription/Core/interface/DDCompactView.h"
00016 #include "FWCore/Framework/interface/ModuleFactory.h"
00017 #include "MagneticField/GeomBuilder/src/MagGeoBuilderFromDDD.h"
00018 
00019 #include <string>
00020 #include <vector>
00021 #include <iostream>
00022 
00023 using namespace std;
00024 using namespace magneticfield;
00025 
00026 VolumeBasedMagneticFieldESProducer::VolumeBasedMagneticFieldESProducer(const edm::ParameterSet& iConfig) : pset(iConfig)
00027 {
00028   setWhatProduced(this, pset.getUntrackedParameter<std::string>("label",""));
00029 }
00030 
00031 
00032 
00033 
00034 // ------------ method called to produce the data  ------------
00035 std::auto_ptr<MagneticField> VolumeBasedMagneticFieldESProducer::produce(const IdealMagneticFieldRecord & iRecord)
00036 {
00037   bool debug = pset.getUntrackedParameter<bool>("debugBuilder", false);
00038   if (debug) {
00039     cout << "VolumeBasedMagneticFieldESProducer::produce() " << pset.getParameter<std::string>("version") << endl;
00040   }
00041   
00042   edm::ESTransientHandle<DDCompactView> cpv;
00043   iRecord.get("magfield",cpv );
00044   MagGeoBuilderFromDDD builder(pset.getParameter<std::string>("version"),
00045                                debug, 
00046                                pset.getParameter<bool>("overrideMasterSector"));
00047 
00048   // Get scaling factors
00049   vector<int> keys = pset.getParameter<vector<int> >("scalingVolumes");
00050   vector<double> values = pset.getParameter<vector<double> >("scalingFactors");
00051 
00052   if (keys.size() != 0) {
00053     builder.setScaling(keys, values);
00054   }
00055 
00056   builder.build(*cpv);
00057 
00058 
00059   // Get slave field
00060   edm::ESHandle<MagneticField> paramField;
00061   if (pset.getParameter<bool>("useParametrizedTrackerField")) {;
00062     iRecord.get(pset.getParameter<string>("paramLabel"),paramField);
00063   }
00064   std::auto_ptr<MagneticField> s(new VolumeBasedMagneticField(pset,builder.barrelLayers(), builder.endcapSectors(), builder.barrelVolumes(), builder.endcapVolumes(), builder.maxR(), builder.maxZ(), paramField.product(), false));
00065   return s;
00066 }
00067 
00068 DEFINE_FWK_EVENTSETUP_MODULE(VolumeBasedMagneticFieldESProducer);