File indexing completed on 2024-04-06 12:11:19
0001 #include "FastSimulation/ParticlePropagator/plugins/MagneticFieldMapESProducer.h"
0002 #include "FWCore/Framework/interface/ConsumesCollector.h"
0003 #include "FWCore/Framework/interface/ModuleFactory.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include <memory>
0006
0007 MagneticFieldMapESProducer::MagneticFieldMapESProducer(const edm::ParameterSet& p)
0008 : label_(p.getUntrackedParameter<std::string>("trackerGeometryLabel", "")) {
0009 auto cc = setWhatProduced(this);
0010 tokenGeom_ = cc.consumes(edm::ESInputTag("", label_));
0011 tokenBField_ = cc.consumes();
0012 }
0013
0014 std::unique_ptr<MagneticFieldMap> MagneticFieldMapESProducer::produce(const MagneticFieldMapRecord& iRecord) {
0015 auto theInteractionGeometry = &(iRecord.getRecord<TrackerInteractionGeometryRecord>().get(tokenGeom_));
0016 auto theMagneticField = &(iRecord.getRecord<IdealMagneticFieldRecord>().get(tokenBField_));
0017
0018 return std::make_unique<MagneticFieldMap>(theMagneticField, theInteractionGeometry);
0019 }
0020
0021 DEFINE_FWK_EVENTSETUP_MODULE(MagneticFieldMapESProducer);