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  edm::ESHandle<Alignments> globalPosition;
140  record.getRecord<GlobalPositionRcd>().get(m_alignmentsLabel, globalPosition);
141  edm::ESHandle<Alignments> alignments;
142  record.getRecord<DTAlignmentRcd>().get(m_alignmentsLabel, alignments);
144  record.getRecord<DTAlignmentErrorExtendedRcd>().get(m_alignmentsLabel, alignmentErrors);
145 
146  if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
147  edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
148  << "Alignment(Error)s and global position (label '" << m_alignmentsLabel
149  << "') empty: Geometry producer (label "
150  << "'" << m_myLabel << "') assumes fake and does not apply.";
151  } else {
152  GeometryAligner aligner;
153  aligner.applyAlignments<DTGeometry>(&(*host),
154  &(*alignments),
155  &(*alignmentErrors),
156  align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)));
157  }
158  }
159 
160  return host;
161 }
162 
164  host->clear();
165 
166  const auto& mdc = record.get(m_mdcToken);
167 
168  edm::ESTransientHandle<DDDetector> cpv = record.getTransientHandle(m_cpvToken);
169 
170  ESTransientHandle<DDSpecParRegistry> registry = record.getTransientHandle(m_registryToken);
171 
172  DDSpecParRefs myReg;
173  {
174  BenchmarkGrd b1("DTGeometryESProducer Filter Registry");
175  registry->filter(myReg, m_attribute, m_value);
176  }
177 
178  DTGeometryBuilder builder;
179  builder.build(*host, cpv.product(), mdc, myReg);
180 }
181 
182 void DTGeometryESProducer::setupDBGeometry(const DTRecoGeometryRcd& record, std::shared_ptr<HostType>& host) {
183  // host->clear();
184  // edm::ESHandle<RecoIdealGeometry> rig;
185  // record.get(rig);
186  // DTGeometryBuilderFromCondDB builder;
187  // builder.build(host, *rig);
188 }
189 
AlignmentErrorsExtended.h
DTGeometryESProducer::setupDBGeometry
void setupDBGeometry(DTRecoGeometryRcd const &, shared_ptr< HostType > &)
Definition: DTGeometryESProducer.cc:182
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:393
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:163
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:82
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
ReusableObjectHolder.h
DTAlignmentRcd
Definition: DTAlignmentRcd.h:6
edm::ESHandle< Alignments >
RectangularPlaneBounds.h
AlignmentErrorsExtended::empty
bool empty() const
Test of empty vector without having to look into internals:
Definition: AlignmentErrorsExtended.h:15
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:17
DTGeometryESProducer::m_fromDDD
bool m_fromDDD
Definition: DTGeometryESProducer.cc:91
BenchmarkGrd.h
get
#define get
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:162
DTGeometryESProducer::produce
ReturnType produce(const MuonGeometryRecord &record)
Definition: DTGeometryESProducer.cc:125
align::Detector
Definition: StructureType.h:86
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
Alignments::empty
bool empty() const
Test of empty vector without having to look into internals:
Definition: Alignments.h:15
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