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 //
17 //
30 
49 #include "DTGeometryBuilder.h"
50 
51 #include <memory>
52 #include <iostream>
53 #include <iterator>
54 #include <string>
55 
56 using namespace edm;
57 using namespace std;
58 using namespace cms;
59 
61 public:
63  ~DTGeometryESProducer() override;
64 
65  using ReturnType = shared_ptr<DTGeometry>;
67 
68  ReturnType produce(const MuonGeometryRecord& record);
69 
70 private:
72 
73  void setupGeometry(MuonNumberingRecord const&, shared_ptr<HostType>&);
74  void setupDBGeometry(DTRecoGeometryRcd const&, shared_ptr<HostType>&);
75 
77 
85  const string m_alignmentsLabel;
86  const string m_myLabel;
87  const string m_attribute;
88  const string m_value;
90  bool m_fromDDD;
91 };
92 
94  : m_tag(iConfig.getParameter<ESInputTag>("DDDetector")),
95  m_alignmentsLabel(iConfig.getParameter<string>("alignmentsLabel")),
96  m_myLabel(iConfig.getParameter<string>("appendToDataLabel")),
97  m_attribute(iConfig.getParameter<string>("attribute")),
98  m_value(iConfig.getParameter<string>("value")),
99  m_fromDDD(iConfig.getParameter<bool>("fromDDD")) {
100  m_applyAlignment = iConfig.getParameter<bool>("applyAlignment");
101 
102  auto cc = setWhatProduced(this);
103 
104  if (m_applyAlignment) {
109  }
110 
111  if (m_fromDDD) {
115  }
116 
117  edm::LogInfo("Geometry") << "@SUB=DTGeometryESProducer"
118  << "Label '" << m_myLabel << "' " << (m_applyAlignment ? "looking for" : "IGNORING")
119  << " alignment labels '" << m_alignmentsLabel << "'.";
120 }
121 
123 
124 std::shared_ptr<DTGeometry> DTGeometryESProducer::produce(const MuonGeometryRecord& record) {
125  auto host = m_holder.makeOrGet([]() { return new HostType; });
126 
127  {
128  BenchmarkGrd counter("DTGeometryESProducer");
129 
130  if (m_fromDDD) {
131  host->ifRecordChanges<MuonNumberingRecord>(record, [this, &host](auto const& rec) { setupGeometry(rec, host); });
132  } else {
133  host->ifRecordChanges<DTRecoGeometryRcd>(record, [this, &host](auto const& rec) { setupDBGeometry(rec, host); });
134  }
135  }
136  //
137  // Called whenever the alignments or alignment errors change
138  //
139  if (m_applyAlignment) {
140  // m_applyAlignment is scheduled for removal.
141  // Ideal geometry obtained by using 'fake alignment' (with m_applyAlignment = true)
142  edm::ESHandle<Alignments> globalPosition;
143  record.getRecord<GlobalPositionRcd>().get(m_alignmentsLabel, globalPosition);
144  edm::ESHandle<Alignments> alignments;
145  record.getRecord<DTAlignmentRcd>().get(m_alignmentsLabel, alignments);
147  record.getRecord<DTAlignmentErrorExtendedRcd>().get(m_alignmentsLabel, alignmentErrors);
148  // Only apply alignment if values exist
149  if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
150  edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
151  << "Alignment(Error)s and global position (label '" << m_alignmentsLabel
152  << "') empty: Geometry producer (label "
153  << "'" << m_myLabel << "') assumes fake and does not apply.";
154  } else {
155  GeometryAligner aligner;
156  aligner.applyAlignments<DTGeometry>(&(*host),
157  &(*alignments),
158  &(*alignmentErrors),
159  align::DetectorGlobalPosition(*globalPosition, DetId(DetId::Muon)));
160  }
161  }
162 
163  return host; // automatically converts to std::shared_ptr<DTGeometry>
164 }
165 
167  host->clear();
168 
169  const auto& mdc = record.get(m_mdcToken);
170 
171  edm::ESTransientHandle<DDDetector> cpv = record.getTransientHandle(m_cpvToken);
172 
173  ESTransientHandle<DDSpecParRegistry> registry = record.getTransientHandle(m_registryToken);
174 
175  DDSpecParRefs myReg;
176  {
177  BenchmarkGrd b1("DTGeometryESProducer Filter Registry");
178  registry->filter(myReg, m_attribute, m_value);
179  }
180 
181  DTGeometryBuilder builder;
182  builder.build(*host, cpv.product(), mdc, myReg);
183 }
184 
185 void DTGeometryESProducer::setupDBGeometry(const DTRecoGeometryRcd& record, std::shared_ptr<HostType>& host) {
186  // host->clear();
187 
188  // edm::ESHandle<RecoIdealGeometry> rig;
189  // record.get(rig);
190 
191  // DTGeometryBuilderFromCondDB builder;
192  // builder.build(host, *rig);
193 }
194 
AlignmentErrorsExtended.h
DTGeometryESProducer::setupDBGeometry
void setupDBGeometry(DTRecoGeometryRcd const &, shared_ptr< HostType > &)
Definition: DTGeometryESProducer.cc:185
DTGeometry
Definition: DTGeometry.h:28
DDSpecParRegistryRcd
Definition: DDSpecParRegistryRcd.h:8
GlobalPositionRcd.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ESInputTag
Definition: ESInputTag.h:87
DTGeometryESProducer::Detector
dd4hep::Detector Detector
Definition: DTGeometryESProducer.cc:66
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:166
DTGeometryESProducer::m_cpvToken
edm::ESGetToken< DDDetector, IdealGeometryRecord > m_cpvToken
Definition: DTGeometryESProducer.cc:82
DTGeometryESProducer::m_registryToken
edm::ESGetToken< DDSpecParRegistry, DDSpecParRegistryRcd > m_registryToken
Definition: DTGeometryESProducer.cc:83
DTGeometryESProducer::m_alignmentsLabel
const string m_alignmentsLabel
Definition: DTGeometryESProducer.cc:85
DTRecoGeometryRcd.h
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
DTGeometryESProducer
Definition: DTGeometryESProducer.cc:60
edm::LogInfo
Definition: MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
ESProducer.h
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
cms::DDSpecParRegistry
Definition: DDSpecParRegistry.h:32
DTGeometryESProducer::m_alignmentErrorsToken
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > m_alignmentErrorsToken
Definition: DTGeometryESProducer.cc:80
DetectorGlobalPosition.h
MuonNumberingRecord.h
DDDetector.h
ESGetToken.h
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
cc
query.host
host
Definition: query.py:115
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:71
DetId
Definition: DetId.h:17
Plane.h
b1
static constexpr float b1
Definition: L1EGammaCrystalsEmulatorProducer.cc:82
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:76
DDFilteredView.h
Bounds.h
cms::DDSpecParRefs
std::vector< const DDSpecPar * > DDSpecParRefs
Definition: DDSpecParRegistry.h:30
RecoIdealGeometry.h
EventSetupRecordIntervalFinder.h
DTGeometryESProducer::ReturnType
shared_ptr< DTGeometry > ReturnType
Definition: DTGeometryESProducer.cc:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
DDSpecParRegistry.h
DTAlignmentErrorRcd.h
cms::DTGeometryBuilder
Definition: DTGeometryBuilder.h:25
DTRecoGeometryRcd
Definition: DTRecoGeometryRcd.h:5
edm::ParameterSet
Definition: ParameterSet.h:36
DTGeometryESProducer::DTGeometryESProducer
DTGeometryESProducer(const ParameterSet &)
Definition: DTGeometryESProducer.cc:93
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:78
cms::MuonNumbering
Definition: DD4hep_MuonNumbering.h:37
DTGeometryESProducer::~DTGeometryESProducer
~DTGeometryESProducer() override
Definition: DTGeometryESProducer.cc:122
DTAlignmentRcd.h
IdealGeometryRecord.h
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:15
DTGeometryESProducer::m_fromDDD
bool m_fromDDD
Definition: DTGeometryESProducer.cc:90
BenchmarkGrd.h
get
#define get
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
edm::ESGetToken< Alignments, GlobalPositionRcd >
DD4hep_MuonNumbering.h
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
DTGeometryESProducer::produce
ReturnType produce(const MuonGeometryRecord &record)
Definition: DTGeometryESProducer.cc:124
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
align::Detector
Definition: StructureType.h:86
ModuleFactory.h
edm::ESProductHost
Definition: ESProductHost.h:93
DTGeometryESProducer::m_attribute
const string m_attribute
Definition: DTGeometryESProducer.cc:87
std
Definition: JetResolutionObject.h:76
DTGeometryESProducer::m_tag
const ESInputTag m_tag
Definition: DTGeometryESProducer.cc:84
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:79
cms::DDSpecParRegistry::filter
void filter(DDSpecParRefs &, const std::string &, const std::string &="") const
Definition: DDSpecparRegistry.cc:98
BenchmarkGrd
Definition: BenchmarkGrd.h:9
DTGeometryESProducer::m_value
const string m_value
Definition: DTGeometryESProducer.cc:88
cms::DTGeometryBuilder::build
void build(DTGeometry &, const DDDetector *, const MuonNumbering &, const DDSpecParRefs &)
Definition: DTGeometryBuilder.cc:167
DTGeometryESProducer::m_myLabel
const string m_myLabel
Definition: DTGeometryESProducer.cc:86
edm::ESProducer
Definition: ESProducer.h:101
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
GeometryAligner::applyAlignments
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
DTGeometryESProducer::m_mdcToken
edm::ESGetToken< MuonNumbering, MuonNumberingRecord > m_mdcToken
Definition: DTGeometryESProducer.cc:81
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:89
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21