CMS 3D CMS Logo

DD4hep_VolumeBasedMagneticFieldESProducer.cc
Go to the documentation of this file.
1 
13 
17 
23 
24 #include <string>
25 
26 namespace magneticfield {
27 
29  public:
31 
32  // forbid copy ctor and assignment op.
35  delete;
36 
37  std::unique_ptr<MagneticField> produce(const IdealMagneticFieldRecord& iRecord);
38 
39  private:
41  const bool debug_;
47  };
48 } // namespace magneticfield
49 
50 using namespace magneticfield;
51 
53  : pset_{iConfig},
54  debug_{iConfig.getUntrackedParameter<bool>("debugBuilder", false)},
55  useParametrizedTrackerField_{iConfig.getParameter<bool>("useParametrizedTrackerField")},
56  conf_{iConfig, debug_},
57  version_{iConfig.getParameter<std::string>("version")} {
58  LogTrace("MagGeoBuilder") << "info:Constructing a DD4hep_VolumeBasedMagneticFieldESProducer";
59 
60  auto cc = setWhatProduced(this, iConfig.getUntrackedParameter<std::string>("label", ""));
61  cpvToken_ = cc.consumes(edm::ESInputTag{"", "magfield"});
62  if (useParametrizedTrackerField_) {
63  paramFieldToken_ = cc.consumes(edm::ESInputTag{"", iConfig.getParameter<std::string>("paramLabel")});
64  }
65 }
66 
67 // ------------ method called to produce the data ------------
69  const IdealMagneticFieldRecord& iRecord) {
70  if (debug_) {
71  LogTrace("MagGeoBuilder") << "DD4hep_VolumeBasedMagneticFieldESProducer::produce() " << version_;
72  }
73 
75 
76  // Set scaling factors
77  if (!conf_.keys.empty()) {
78  builder.setScaling(conf_.keys, conf_.values);
79  }
80 
81  // Set specification for the grid tables to be used.
82  if (!conf_.gridFiles.empty()) {
83  builder.setGridFiles(conf_.gridFiles);
84  }
85 
86  auto cpv = iRecord.getTransientHandle(cpvToken_);
87  const cms::DDCompactView* cpvPtr = cpv.product();
88  const cms::DDDetector* det = cpvPtr->detector();
89  builder.build(det);
90  LogTrace("MagGeoBuilder") << "produce() finished build";
91 
92  // Get slave field (from ES)
93  const MagneticField* paramField = nullptr;
95  LogTrace("MagGeoBuilder") << "Getting MF for parametrized field";
96  paramField = &iRecord.get(paramFieldToken_);
97  }
98  return std::make_unique<VolumeBasedMagneticField>(conf_.geometryVersion,
99  builder.barrelLayers(),
100  builder.endcapSectors(),
101  builder.barrelVolumes(),
102  builder.endcapVolumes(),
103  builder.maxR(),
104  builder.maxZ(),
105  paramField,
106  false);
107 }
108 
magneticfield::MagGeoBuilder::build
void build(const cms::DDDetector *det)
Definition: DD4hep_MagGeoBuilder.cc:104
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
MessageLogger.h
MagFieldConfig::gridFiles
magneticfield::TableFileMap gridFiles
Specification of which data table is to be used for each volume.
Definition: MagFieldConfig.h:44
magneticfield
Definition: MagFieldConfig.h:22
MagFieldConfig::version
std::string version
Version of the data tables to be used.
Definition: MagFieldConfig.h:41
ESProducer.h
magneticfield::MagGeoBuilder
Definition: DD4hep_MagGeoBuilder.h:35
MagFieldConfig::geometryVersion
int geometryVersion
Version of the geometry to be used.
Definition: MagFieldConfig.h:38
DD4hep_MagGeoBuilder.h
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::pset_
edm::ParameterSet pset_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:40
magneticfield::MagGeoBuilder::endcapSectors
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
Definition: DD4hep_MagGeoBuilder.cc:557
DDDetector.h
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::version_
const std::string version_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:44
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::paramFieldToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > paramFieldToken_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:45
cc
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
magneticfield::MagGeoBuilder::barrelLayers
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
Definition: DD4hep_MagGeoBuilder.cc:555
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::debug_
const bool debug_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:41
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:98
VolumeBasedMagneticField.h
IdealMagneticFieldRecord.h
magneticfield::MagGeoBuilder::maxZ
float maxZ() const
Definition: DD4hep_MagGeoBuilder.cc:582
DDCompactView.h
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::conf_
const MagFieldConfig conf_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:43
edm::ParameterSet
Definition: ParameterSet.h:47
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::cpvToken_
edm::ESGetToken< cms::DDCompactView, IdealMagneticFieldRecord > cpvToken_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:46
magneticfield::MagGeoBuilder::maxR
float maxR() const
Definition: DD4hep_MagGeoBuilder.cc:577
MagFieldConfig
Definition: MagFieldConfig.h:26
MagFieldConfig.h
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::produce
std::unique_ptr< MagneticField > produce(const IdealMagneticFieldRecord &iRecord)
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:68
MagneticField.h
BenchmarkGrd.h
magneticfield::MagGeoBuilder::barrelVolumes
std::vector< MagVolume6Faces * > barrelVolumes() const
Definition: DD4hep_MagGeoBuilder.cc:559
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::DD4hep_VolumeBasedMagneticFieldESProducer
DD4hep_VolumeBasedMagneticFieldESProducer(const edm::ParameterSet &iConfig)
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:52
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:28
ModuleFactory.h
MagFieldConfig::keys
std::vector< int > keys
Scaling factors for the field in specific volumes.
Definition: MagFieldConfig.h:47
magneticfield::MagGeoBuilder::endcapVolumes
std::vector< MagVolume6Faces * > endcapVolumes() const
Definition: DD4hep_MagGeoBuilder.cc:568
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::useParametrizedTrackerField_
const bool useParametrizedTrackerField_
Definition: DD4hep_VolumeBasedMagneticFieldESProducer.cc:42
cms::DDDetector
Definition: DDDetector.h:12
cms::DDCompactView
Definition: DDCompactView.h:31
MagFieldConfig::values
std::vector< double > values
Definition: MagFieldConfig.h:48
edm::ESProducer
Definition: ESProducer.h:104
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:234
ParameterSet.h
magneticfield::MagGeoBuilder::setScaling
void setScaling(const std::vector< int > &keys, const std::vector< double > &values)
Definition: DD4hep_MagGeoBuilder.cc:592
MagneticField
Definition: MagneticField.h:19
magneticfield::MagGeoBuilder::setGridFiles
void setGridFiles(const TableFileMap &gridFiles)
Definition: DD4hep_MagGeoBuilder.cc:602
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:34
magneticfield::DD4hep_VolumeBasedMagneticFieldESProducer::operator=
const DD4hep_VolumeBasedMagneticFieldESProducer & operator=(const DD4hep_VolumeBasedMagneticFieldESProducer &)=delete