CMS 3D CMS Logo

VolumeBasedMagneticFieldESProducer.cc
Go to the documentation of this file.
1 
12 
16 
20 
21 #include <string>
22 #include <vector>
23 #include <iostream>
24 
25 namespace magneticfield {
27  public:
29 
30  std::unique_ptr<MagneticField> produce(const IdealMagneticFieldRecord& iRecord);
31 
32  // forbid copy ctor and assignment op.
35 
36  private:
37  const bool debug_;
43  };
44 } // namespace magneticfield
45 
46 using namespace std;
47 using namespace magneticfield;
48 
50  : debug_{iConfig.getUntrackedParameter<bool>("debugBuilder", false)},
51  useParametrizedTrackerField_{iConfig.getParameter<bool>("useParametrizedTrackerField")},
52  conf_{iConfig, debug_},
53  version_{iConfig.getParameter<std::string>("version")} {
54  auto cc = setWhatProduced(this, iConfig.getUntrackedParameter<std::string>("label", ""));
55  cc.setConsumes(cpvToken_, edm::ESInputTag{"", "magfield"});
56  if (useParametrizedTrackerField_) {
57  cc.setConsumes(paramFieldToken_, edm::ESInputTag{"", iConfig.getParameter<string>("paramLabel")});
58  }
59 }
60 
61 // ------------ method called to produce the data ------------
62 std::unique_ptr<MagneticField> VolumeBasedMagneticFieldESProducer::produce(const IdealMagneticFieldRecord& iRecord) {
63  LogTrace("MagGeoBuilder") << "VolumeBasedMagneticFieldESProducer::produce() " << version_;
64 
65  auto cpv = iRecord.getTransientHandle(cpvToken_);
67 
68  // Set scaling factors
69  if (!conf_.keys.empty()) {
70  builder.setScaling(conf_.keys, conf_.values);
71  }
72 
73  // Set specification for the grid tables to be used.
74  if (!conf_.gridFiles.empty()) {
75  builder.setGridFiles(conf_.gridFiles);
76  }
77 
78  builder.build(*cpv);
79 
80  // Get slave field (from ES)
81  const MagneticField* paramField = nullptr;
83  paramField = &iRecord.get(paramFieldToken_);
84  }
85  return std::make_unique<VolumeBasedMagneticField>(conf_.geometryVersion,
86  builder.barrelLayers(),
87  builder.endcapSectors(),
88  builder.barrelVolumes(),
89  builder.endcapVolumes(),
90  builder.maxR(),
91  builder.maxZ(),
92  paramField,
93  false);
94 }
95 
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
magneticfield::VolumeBasedMagneticFieldESProducer::operator=
const VolumeBasedMagneticFieldESProducer & operator=(const VolumeBasedMagneticFieldESProducer &)=delete
MagGeoBuilderFromDDD
Definition: MagGeoBuilderFromDDD.h:32
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
MagFieldConfig::geometryVersion
int geometryVersion
Version of the geometry to be used.
Definition: MagFieldConfig.h:38
magneticfield::VolumeBasedMagneticFieldESProducer::conf_
const MagFieldConfig conf_
Definition: VolumeBasedMagneticFieldESProducer.cc:39
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
MagGeoBuilderFromDDD::barrelLayers
std::vector< MagBLayer * > barrelLayers() const
Get barrel layers.
Definition: MagGeoBuilderFromDDD.cc:621
DDCompactView.h
magneticfield::VolumeBasedMagneticFieldESProducer::debug_
const bool debug_
Definition: VolumeBasedMagneticFieldESProducer.cc:37
cc
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
MagGeoBuilderFromDDD::setScaling
void setScaling(const std::vector< int > &keys, const std::vector< double > &values)
Definition: MagGeoBuilderFromDDD.cc:658
magneticfield::VolumeBasedMagneticFieldESProducer::cpvToken_
edm::ESGetToken< DDCompactView, IdealMagneticFieldRecord > cpvToken_
Definition: VolumeBasedMagneticFieldESProducer.cc:41
MagGeoBuilderFromDDD::maxZ
float maxZ() const
Definition: MagGeoBuilderFromDDD.cc:648
MagGeoBuilderFromDDD::maxR
float maxR() const
Definition: MagGeoBuilderFromDDD.cc:643
magneticfield::VolumeBasedMagneticFieldESProducer::VolumeBasedMagneticFieldESProducer
VolumeBasedMagneticFieldESProducer(const edm::ParameterSet &iConfig)
Definition: VolumeBasedMagneticFieldESProducer.cc:49
MagGeoBuilderFromDDD::setGridFiles
void setGridFiles(const magneticfield::TableFileMap &gridFiles)
Definition: MagGeoBuilderFromDDD.cc:668
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:99
VolumeBasedMagneticField.h
IdealMagneticFieldRecord.h
VolumeBasedMagneticFieldESProducer_cfi.VolumeBasedMagneticFieldESProducer
VolumeBasedMagneticFieldESProducer
Definition: VolumeBasedMagneticFieldESProducer_cfi.py:3
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:112
EventSetupRecordIntervalFinder.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MagGeoBuilderFromDDD::build
virtual void build(const DDCompactView &cpv)
Definition: MagGeoBuilderFromDDD.cc:117
MagGeoBuilderFromDDD::endcapSectors
std::vector< MagESector * > endcapSectors() const
Get endcap layers.
Definition: MagGeoBuilderFromDDD.cc:623
edm::ParameterSet
Definition: ParameterSet.h:36
MagFieldConfig
Definition: MagFieldConfig.h:26
MagFieldConfig.h
MagGeoBuilderFromDDD.h
MagGeoBuilderFromDDD::endcapVolumes
std::vector< MagVolume6Faces * > endcapVolumes() const
Definition: MagGeoBuilderFromDDD.cc:634
MagneticField.h
magneticfield::VolumeBasedMagneticFieldESProducer::produce
std::unique_ptr< MagneticField > produce(const IdealMagneticFieldRecord &iRecord)
Definition: VolumeBasedMagneticFieldESProducer.cc:62
magneticfield::VolumeBasedMagneticFieldESProducer
Definition: VolumeBasedMagneticFieldESProducer.cc:26
magneticfield::VolumeBasedMagneticFieldESProducer::version_
const std::string version_
Definition: VolumeBasedMagneticFieldESProducer.cc:40
edm::ESGetToken< DDCompactView, IdealMagneticFieldRecord >
ModuleFactory.h
std
Definition: JetResolutionObject.h:76
MagFieldConfig::keys
std::vector< int > keys
Scaling factors for the field in specific volumes.
Definition: MagFieldConfig.h:47
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
magneticfield::VolumeBasedMagneticFieldESProducer::useParametrizedTrackerField_
const bool useParametrizedTrackerField_
Definition: VolumeBasedMagneticFieldESProducer.cc:38
MagFieldConfig::values
std::vector< double > values
Definition: MagFieldConfig.h:48
magneticfield::VolumeBasedMagneticFieldESProducer::paramFieldToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > paramFieldToken_
Definition: VolumeBasedMagneticFieldESProducer.cc:42
edm::ESProducer
Definition: ESProducer.h:101
MagGeoBuilderFromDDD::barrelVolumes
std::vector< MagVolume6Faces * > barrelVolumes() const
Definition: MagGeoBuilderFromDDD.cc:625
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
ParameterSet.h
MagneticField
Definition: MagneticField.h:19