From 49297324e87f9eec692e04fceef7e1db934b349d Mon Sep 17 00:00:00 2001 From: Nicola Amapane Date: Thu, 19 Mar 2009 10:51:40 +0000 Subject: [PATCH] Implement correct delete of slave field. Serve B=0 field correctly to SHP. --- .../plugins/AutoMagneticFieldESProducer.cc | 121 +++++++++--------- .../VolumeBasedMagneticFieldESProducer.cc | 8 +- 2 files changed, 60 insertions(+), 69 deletions(-) diff --git a/MagneticField/GeomBuilder/plugins/AutoMagneticFieldESProducer.cc b/MagneticField/GeomBuilder/plugins/AutoMagneticFieldESProducer.cc index d57128284e8f8..46186192032e2 100644 --- a/MagneticField/GeomBuilder/plugins/AutoMagneticFieldESProducer.cc +++ b/MagneticField/GeomBuilder/plugins/AutoMagneticFieldESProducer.cc @@ -1,7 +1,7 @@ /** \file * - * $Date: 2009/01/16 16:43:46 $ - * $Revision: 1.3 $ + * $Date: 2009/03/03 12:58:02 $ + * $Revision: 1.4 $ * \author Nicola Amapane 11/08 */ @@ -65,31 +65,25 @@ AutoMagneticFieldESProducer::produce(const IdealMagneticFieldRecord& iRecord) } else { edm::LogInfo("MagneticField|AutoMagneticField") << "Ignoring DB current readings; using map for " << value/10. << " T"; } + + MagneticField * paramField=0; + + string version; - - string sValue; - if (value == 0) { // B=0, uniform field map - // result = new UniformMagneticField(0.); - - ParameterSet VBFPset; - VBFPset.addUntrackedParameter("debugBuilder",false); - VBFPset.addUntrackedParameter("cacheLastVolume",true); - VBFPset.addParameter("version","fake"); - - MagGeoBuilderFromDDD builder(VBFPset.getParameter("version"), - VBFPset.getUntrackedParameter("debugBuilder", false)); - result = new VolumeBasedMagneticField(VBFPset, - builder.barrelLayers(), - builder.endcapSectors(), - builder.barrelVolumes(), - builder.endcapVolumes(), - builder.maxR(), - builder.maxZ(), - new UniformMagneticField(0.)); - - } else { // Use VolumeBasedMagneticField - - // different conventions... + if (value == 0) { + // Use UniformMagneticField instead of the inner region parametrization. + // This trick allows to keep a VBF field to be used by propagators to check the geometry. + paramField = new UniformMagneticField(0.); + + // Temporary hack: set 3.8T underlying VBF map so that SHP can decide if volume is iron + // version = "fake"; + stringstream str; + string model = pset.getParameter("model"); + str << model << "_" << "3_8t"; + version = str.str(); + + } else { + // Handle different labelling conventions string VBFValue; string OAEValue; @@ -112,9 +106,12 @@ AutoMagneticFieldESProducer::produce(const IdealMagneticFieldRecord& iRecord) throw cms::Exception("InvalidParameter")<<"Invalid field value: requested : " << value << " kGauss"; } - // Build slave field - MagneticField * paramField=0; + stringstream str; + string model = pset.getParameter("model"); + str << model << "_" << VBFValue; + version = str.str(); + // Build slave field if (pset.getParameter("useParametrizedTrackerField")) { string parVersion = pset.getParameter("subModel"); @@ -124,52 +121,48 @@ AutoMagneticFieldESProducer::produce(const IdealMagneticFieldRecord& iRecord) ParameterSet ppar; ppar.addParameter("BValue", OAEValue); paramField = new OAEParametrizedMagneticField(ppar); -// } else if (parVersion=="PolyFit2D") { -// // V. Maroussov polynomial fit to mapping data -// ParameterSet ppar; -// ppar.addParameter("BValue", 4.01242188708911); //FIXME -// paramField = new PolyFit2DParametrizedMagneticField(ppar); -// } + // } else if (parVersion=="PolyFit2D") { + // V. Maroussov polynomial fit to mapping data + // ParameterSet ppar; + // ppar.addParameter("BValue", 4.01242188708911); //FIXME + // paramField = new PolyFit2DParametrizedMagneticField(ppar); + // } } else { throw cms::Exception("InvalidParameter")<<"Invalid parametrization version " << parVersion; } } - - string model = pset.getParameter("model"); - - stringstream str; - str << model << "_" << VBFValue; - - ParameterSet VBFPset; - VBFPset.addUntrackedParameter("debugBuilder",false); - VBFPset.addUntrackedParameter("cacheLastVolume",true); - VBFPset.addParameter("version",str.str()); + } + + ParameterSet VBFPset; + VBFPset.addUntrackedParameter("debugBuilder",false); + VBFPset.addUntrackedParameter("cacheLastVolume",true); + VBFPset.addParameter("version",version); - edm::ESHandle cpv; - iRecord.get("magfield",cpv ); - MagGeoBuilderFromDDD builder(VBFPset.getParameter("version"), - VBFPset.getUntrackedParameter("debugBuilder", false)); + edm::ESHandle cpv; + iRecord.get("magfield",cpv ); + MagGeoBuilderFromDDD builder(VBFPset.getParameter("version"), + VBFPset.getUntrackedParameter("debugBuilder", false)); - // Get scaling factors - vector keys = pset.getParameter >("scalingVolumes"); - vector values = pset.getParameter >("scalingFactors"); + // Get scaling factors + vector keys = pset.getParameter >("scalingVolumes"); + vector values = pset.getParameter >("scalingFactors"); - if (keys.size() != 0) { - builder.setScaling(keys, values); - } + if (keys.size() != 0) { + builder.setScaling(keys, values); + } - builder.build(*cpv); + builder.build(*cpv); + + result = new VolumeBasedMagneticField(VBFPset, + builder.barrelLayers(), + builder.endcapSectors(), + builder.barrelVolumes(), + builder.endcapVolumes(), + builder.maxR(), + builder.maxZ(), + paramField, true); - result = new VolumeBasedMagneticField(VBFPset, - builder.barrelLayers(), - builder.endcapSectors(), - builder.barrelVolumes(), - builder.endcapVolumes(), - builder.maxR(), - builder.maxZ(), - paramField); - } std::auto_ptr s(result); return s; diff --git a/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.cc b/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.cc index 109a509f0460b..6d37d6508bb8a 100644 --- a/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.cc +++ b/MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.cc @@ -1,7 +1,7 @@ /** \file * - * $Date: 2008/11/14 10:42:41 $ - * $Revision: 1.1 $ + * $Date: 2009/01/16 16:43:46 $ + * $Revision: 1.2 $ */ #include "MagneticField/GeomBuilder/plugins/VolumeBasedMagneticFieldESProducer.h" @@ -55,9 +55,7 @@ std::auto_ptr VolumeBasedMagneticFieldESProducer::produce(const I if (pset.getParameter("useParametrizedTrackerField")) {; iRecord.get("parametrizedField",paramField); } - - - std::auto_ptr s(new VolumeBasedMagneticField(pset,builder.barrelLayers(), builder.endcapSectors(), builder.barrelVolumes(), builder.endcapVolumes(), builder.maxR(), builder.maxZ(), paramField.product())); + std::auto_ptr s(new VolumeBasedMagneticField(pset,builder.barrelLayers(), builder.endcapSectors(), builder.barrelVolumes(), builder.endcapVolumes(), builder.maxR(), builder.maxZ(), paramField.product(), false)); return s; }