CMS 3D CMS Logo

DTGeometryESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DetectorDescription/DTGeometryESProducer
4 // Class: DTGeometryESProducer
5 //
13 //
14 // Original Author: Ianna Osborne
15 // Created: Wed, 16 Jan 2019 10:19:37 GMT
16 // Modified by Sergio Lo Meo (sergio.lo.meo@cern.ch) Mon, 31 August 2020
17 //
18 //
50 #include "DTGeometryBuilder.h"
51 
52 #include <memory>
53 #include <iostream>
54 #include <iterator>
55 #include <string>
56 
57 using namespace edm;
58 using namespace std;
59 using namespace cms;
60 
62 public:
64  ~DTGeometryESProducer() override;
65 
66  using ReturnType = shared_ptr<DTGeometry>;
68 
69  ReturnType produce(const MuonGeometryRecord& record);
70 
71 private:
73 
74  void setupGeometry(MuonNumberingRecord const&, shared_ptr<HostType>&);
75  void setupDBGeometry(DTRecoGeometryRcd const&, shared_ptr<HostType>&);
76 
78 
86  const string m_alignmentsLabel;
87  const string m_myLabel;
88  const string m_attribute;
89  const string m_value;
91  bool m_fromDDD;
92 };
93 
95  : m_tag(iConfig.getParameter<ESInputTag>("DDDetector")),
96  m_alignmentsLabel(iConfig.getParameter<string>("alignmentsLabel")),
97  m_myLabel(iConfig.getParameter<string>("appendToDataLabel")),
98  m_attribute(iConfig.getParameter<string>("attribute")),
99  m_value(iConfig.getParameter<string>("value")),
100  m_fromDDD(iConfig.getParameter<bool>("fromDDD")) {
101  m_applyAlignment = iConfig.getParameter<bool>("applyAlignment");
102 
103  auto cc = setWhatProduced(this);
104 
105  if (m_applyAlignment) {
110  }
111 
112  if (m_fromDDD) {
116  }
117 
118  edm::LogInfo("Geometry") << "@SUB=DTGeometryESProducer"
119  << "Label '" << m_myLabel << "' " << (m_applyAlignment ? "looking for" : "IGNORING")
120  << " alignment labels '" << m_alignmentsLabel << "'.";
121 }
122 
124 
125 std::shared_ptr<DTGeometry> DTGeometryESProducer::produce(const MuonGeometryRecord& record) {
126  auto host = m_holder.makeOrGet([]() { return new HostType; });
127 
128  {
129  BenchmarkGrd counter("DTGeometryESProducer");
130 
131  if (m_fromDDD) {
132  host->ifRecordChanges<MuonNumberingRecord>(record, [this, &host](auto const& rec) { setupGeometry(rec, host); });
133  } else {
134  host->ifRecordChanges<DTRecoGeometryRcd>(record, [this, &host](auto const& rec) { setupDBGeometry(rec, host); });
135  }
136  }
137 
138  if (m_applyAlignment) {
139  const auto& globalPosition = record.get(m_globalPositionToken);
140  const auto& alignments = record.get(m_alignmentsToken);
141  const auto& alignmentErrors = record.get(m_alignmentErrorsToken);
142 
143  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
144  edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
145  << "Alignment and global position errors";
146 
147  } else {
148  GeometryAligner aligner;
149  aligner.applyAlignments<DTGeometry>(
150  &(*host), &alignments, &alignmentErrors, align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)));
151  }
152  }
153 
154  return host;
155 }
156 
158  host->clear();
159 
160  const auto& mdc = record.get(m_mdcToken);
161 
162  edm::ESTransientHandle<DDDetector> cpv = record.getTransientHandle(m_cpvToken);
163 
164  ESTransientHandle<DDSpecParRegistry> registry = record.getTransientHandle(m_registryToken);
165 
166  DDSpecParRefs myReg;
167  {
168  BenchmarkGrd b1("DTGeometryESProducer Filter Registry");
169  registry->filter(myReg, m_attribute, m_value);
170  }
171 
172  DTGeometryBuilder builder;
173  builder.build(*host, cpv.product(), mdc, myReg);
174 }
175 
176 void DTGeometryESProducer::setupDBGeometry(const DTRecoGeometryRcd& record, std::shared_ptr<HostType>& host) {
177  // host->clear();
178  // edm::ESHandle<RecoIdealGeometry> rig;
179  // record.get(rig);
180  // DTGeometryBuilderFromCondDB builder;
181  // builder.build(host, *rig);
182 }
183 
AlignmentErrorsExtended.h
DTGeometryESProducer::setupDBGeometry
void setupDBGeometry(DTRecoGeometryRcd const &, shared_ptr< HostType > &)
Definition: DTGeometryESProducer.cc:176
DTGeometry
Definition: DTGeometry.h:28
DDSpecParRegistryRcd
Definition: DDSpecParRegistryRcd.h:8
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
GlobalPositionRcd.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::ESInputTag
Definition: ESInputTag.h:87
DTGeometryESProducer::Detector
dd4hep::Detector Detector
Definition: DTGeometryESProducer.cc:67
ESTransientHandle.h
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
DTGeometryESProducer::setupGeometry
void setupGeometry(MuonNumberingRecord const &, shared_ptr< HostType > &)
Definition: DTGeometryESProducer.cc:157
DTGeometryESProducer::m_cpvToken
edm::ESGetToken< DDDetector, IdealGeometryRecord > m_cpvToken
Definition: DTGeometryESProducer.cc:83
DTGeometryESProducer::m_registryToken
edm::ESGetToken< DDSpecParRegistry, DDSpecParRegistryRcd > m_registryToken
Definition: DTGeometryESProducer.cc:84
DTGeometryESProducer::m_alignmentsLabel
const string m_alignmentsLabel
Definition: DTGeometryESProducer.cc:86
DTRecoGeometryRcd.h
DTGeometryESProducer::m_mdcToken
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > m_mdcToken
Definition: DTGeometryESProducer.cc:82
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
DTGeometryESProducer
Definition: DTGeometryESProducer.cc:61
MuonGeometryConstants.h
cms::DDSpecParRefs
dd4hep::SpecParRefs DDSpecParRefs
Definition: DDCompactView.h:29
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ESProducer.h
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
DTGeometryESProducer::m_alignmentErrorsToken
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > m_alignmentErrorsToken
Definition: DTGeometryESProducer.cc:81
DetectorGlobalPosition.h
MuonGeometryNumbering.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
MuonNumberingRecord.h
DDDetector.h
query.host
string host
Definition: query.py:115
ESGetToken.h
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
cc
edm::ReusableObjectHolder< HostType >
edm::ReusableObjectHolder::makeOrGet
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn't an object already available, creates a new one using iFunc.
Definition: ReusableObjectHolder.h:126
DTGeometryESProducer::HostType
ESProductHost< DTGeometry, MuonNumberingRecord, DTRecoGeometryRcd > HostType
Definition: DTGeometryESProducer.cc:72
DetId
Definition: DetId.h:17
Plane.h
b1
static constexpr float b1
Definition: L1EGammaCrystalsEmulatorProducer.cc:83
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
ReusableObjectHolder.h
DTAlignmentRcd
Definition: DTAlignmentRcd.h:6
RectangularPlaneBounds.h
DTAlignmentErrorExtendedRcd
Definition: DTAlignmentErrorExtendedRcd.h:6
DTGeometryESProducer::m_holder
ReusableObjectHolder< HostType > m_holder
Definition: DTGeometryESProducer.cc:77
DDFilteredView.h
Bounds.h
RecoIdealGeometry.h
EventSetupRecordIntervalFinder.h
DTGeometryESProducer::ReturnType
shared_ptr< DTGeometry > ReturnType
Definition: DTGeometryESProducer.cc:66
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
DDSpecParRegistry.h
DTAlignmentErrorRcd.h
cms::DTGeometryBuilder
Definition: DTGeometryBuilder.h:46
DTRecoGeometryRcd
Definition: DTRecoGeometryRcd.h:5
edm::ParameterSet
Definition: ParameterSet.h:47
DTGeometryESProducer::DTGeometryESProducer
DTGeometryESProducer(const ParameterSet &)
Definition: DTGeometryESProducer.cc:94
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
volumeBasedMagneticField_dd4hep_160812_cfi.DDDetector
DDDetector
Definition: volumeBasedMagneticField_dd4hep_160812_cfi.py:27
DTGeometryESProducer::m_globalPositionToken
edm::ESGetToken< Alignments, GlobalPositionRcd > m_globalPositionToken
Definition: DTGeometryESProducer.cc:79
DTGeometryESProducer::~DTGeometryESProducer
~DTGeometryESProducer() override
Definition: DTGeometryESProducer.cc:123
DTAlignmentRcd.h
IdealGeometryRecord.h
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
DTGeometryESProducer::m_fromDDD
bool m_fromDDD
Definition: DTGeometryESProducer.cc:91
BenchmarkGrd.h
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
edm::ESGetToken< Alignments, GlobalPositionRcd >
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
cms::DTGeometryBuilder::build
void build(DTGeometry &, const DDDetector *, const MuonGeometryConstants &, const dd4hep::SpecParRefs &)
Definition: DTGeometryBuilder.cc:180
DTGeometryESProducer::produce
ReturnType produce(const MuonGeometryRecord &record)
Definition: DTGeometryESProducer.cc:125
align::Detector
Definition: StructureType.h:92
ModuleFactory.h
edm::ESProductHost
Definition: ESProductHost.h:93
DTGeometryESProducer::m_attribute
const string m_attribute
Definition: DTGeometryESProducer.cc:88
std
Definition: JetResolutionObject.h:76
DTGeometryESProducer::m_tag
const ESInputTag m_tag
Definition: DTGeometryESProducer.cc:85
GeometryAligner.h
DDSpecParRegistryRcd.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
DTGeometryESProducer::m_alignmentsToken
edm::ESGetToken< Alignments, DTAlignmentRcd > m_alignmentsToken
Definition: DTGeometryESProducer.cc:80
BenchmarkGrd
Definition: BenchmarkGrd.h:9
DTGeometryESProducer::m_value
const string m_value
Definition: DTGeometryESProducer.cc:89
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DTGeometryESProducer::m_myLabel
const string m_myLabel
Definition: DTGeometryESProducer.cc:87
edm::ESProducer
Definition: ESProducer.h:104
ESProductHost.h
DTGeometryBuilder.h
DetId::Muon
Definition: DetId.h:26
ParameterSet.h
MuonNumberingRecord
Definition: MuonNumberingRecord.h:30
MuonGeometryRecord.h
Alignments
Definition: Alignments.h:10
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
DTGeometryESProducer::m_applyAlignment
bool m_applyAlignment
Definition: DTGeometryESProducer.cc:90
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21