CMS 3D CMS Logo

DTGeometryESModule.cc
Go to the documentation of this file.
1 
41 
42 #include <memory>
43 #include <iostream>
44 #include <iterator>
45 #include <string>
46 
47 using namespace edm;
48 using namespace std;
49 
51 public:
54 
57 
59  std::shared_ptr<DTGeometry> produce(const MuonGeometryRecord& record);
60 
61 private:
63 
64  void setupDDDGeometry(MuonNumberingRecord const&, std::shared_ptr<HostType>&);
65  void setupDD4hepGeometry(MuonNumberingRecord const&, std::shared_ptr<HostType>&);
66  void setupDBGeometry(DTRecoGeometryRcd const&, std::shared_ptr<HostType>&);
67 
69 
78 
84  bool fromDDD_;
86  bool applyAlignment_; // Switch to apply alignment corrections
87 };
88 
90  : m_tag(p.getParameter<edm::ESInputTag>("DDDetector")),
91  alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
92  myLabel_(p.getParameter<std::string>("appendToDataLabel")),
93  m_attribute(p.getParameter<std::string>("attribute")),
94  m_value(p.getParameter<std::string>("value")),
95  fromDDD_(p.getParameter<bool>("fromDDD")),
96  fromDD4hep_(p.getParameter<bool>("fromDD4hep")) {
97  applyAlignment_ = p.getParameter<bool>("applyAlignment");
98 
99  auto cc = setWhatProduced(this);
100  if (applyAlignment_) {
105  }
106  if (fromDDD_) {
109  } else if (fromDD4hep_) {
113  } else {
115  }
116 
117  edm::LogVerbatim("Geometry") << "@SUB=DTGeometryESModule Label '" << myLabel_ << "' "
118  << (applyAlignment_ ? "looking for" : "IGNORING") << " alignment labels '"
119  << alignmentsLabel_ << "'.";
120 }
121 
123  //
124  // This cfi should be included to build the DT geometry model.
125  //
127  desc.add<bool>("fromDDD", true);
128  desc.add<bool>("fromDD4hep", false);
129  desc.add<edm::ESInputTag>("DDDetector", edm::ESInputTag("", ""));
130  desc.add<std::string>("alignmentsLabel", "");
131  desc.add<std::string>("appendToDataLabel", "");
132  desc.add<std::string>("attribute", "MuStructure");
133  desc.add<std::string>("value", "MuonBarrelDT");
134  desc.add<bool>("applyAlignment", true);
135  descriptions.add("DTGeometryESModule", desc);
136 }
137 
138 std::shared_ptr<DTGeometry> DTGeometryESModule::produce(const MuonGeometryRecord& record) {
139  auto host = holder_.makeOrGet([]() { return new HostType; });
140 
141  if (fromDDD_) {
142  host->ifRecordChanges<MuonNumberingRecord>(record, [this, &host](auto const& rec) { setupDDDGeometry(rec, host); });
143  } else if (fromDD4hep_) {
144  host->ifRecordChanges<MuonNumberingRecord>(record,
145  [this, &host](auto const& rec) { setupDD4hepGeometry(rec, host); });
146  } else {
147  host->ifRecordChanges<DTRecoGeometryRcd>(record, [this, &host](auto const& rec) { setupDBGeometry(rec, host); });
148  }
149  //
150  // Called whenever the alignments or alignment errors change
151  //
152  if (applyAlignment_) {
153  // applyAlignment_ is scheduled for removal.
154  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
155  const auto& globalPosition = record.get(globalPositionToken_);
156  const auto& alignments = record.get(alignmentsToken_);
157  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
158  // Only apply alignment if values exist
159  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
160  edm::LogVerbatim("Geometry") << "@SUB=DTGeometryRecord::produce Alignment(Error)s and global position (label '"
161  << alignmentsLabel_ << "') empty: Geometry producer (label '" << myLabel_
162  << "') assumes fake and does not apply.";
163  } else {
164  GeometryAligner aligner;
165  aligner.applyAlignments<DTGeometry>(
166  &(*host), &alignments, &alignmentErrors, align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)));
167  }
168  }
169 
170  return host; // automatically converts to std::shared_ptr<DTGeometry>
171 }
172 
173 void DTGeometryESModule::setupDDDGeometry(const MuonNumberingRecord& record, std::shared_ptr<HostType>& host) {
174  //
175  // Called whenever the muon numbering (or ideal geometry) changes
176  //
177 
178  host->clear();
179 
180  const auto& mdc = record.get(mdcToken_);
181  edm::ESTransientHandle<DDCompactView> cpv = record.getTransientHandle(cpvToken_);
182 
183  DTGeometryBuilderFromDDD builder;
184  builder.build(*host, cpv.product(), mdc);
185 }
186 
187 void DTGeometryESModule::setupDD4hepGeometry(const MuonNumberingRecord& record, std::shared_ptr<HostType>& host) {
188  host->clear();
189 
190  const auto& mdc = record.get(mdcToken_);
191  edm::ESTransientHandle<cms::DDDetector> cpv = record.getTransientHandle(m_cpvToken);
192  ESTransientHandle<cms::DDSpecParRegistry> registry = record.getTransientHandle(m_registryToken);
193 
194  cms::DDSpecParRefs myReg;
195  registry->filter(myReg, m_attribute, m_value);
196 
198  builder.build(*host, cpv.product(), mdc, myReg);
199 }
200 
201 void DTGeometryESModule::setupDBGeometry(const DTRecoGeometryRcd& record, std::shared_ptr<HostType>& host) {
202  //
203  // Called whenever the muon numbering (or ideal geometry) changes
204  //
205 
206  host->clear();
207 
208  const auto& rig = record.get(rigToken_);
209 
211  builder.build(host, rig);
212 }
213 
ConfigurationDescriptions.h
AlignmentErrorsExtended.h
DTGeometry
Definition: DTGeometry.h:28
DDSpecParRegistryRcd
Definition: DDSpecParRegistryRcd.h:8
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
DTGeometryESModule::DTGeometryESModule
DTGeometryESModule(const edm::ParameterSet &p)
Constructor.
Definition: DTGeometryESModule.cc:89
GlobalPositionRcd.h
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
DTRecoGeometryRcd.h
DTAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
DTGeometryBuilderFromDDD
Definition: DTGeometryBuilderFromDDD.h:31
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
DTGeometryESModule::rigToken_
edm::ESGetToken< RecoIdealGeometry, DTRecoGeometryRcd > rigToken_
Definition: DTGeometryESModule.cc:77
DetectorGlobalPosition.h
MuonGeometryNumbering.h
DTGeometryBuilderFromCondDB.h
MuonNumberingRecord.h
DDDetector.h
DTGeometryESModule::m_tag
const edm::ESInputTag m_tag
Definition: DTGeometryESModule.cc:79
DTGeometryESModule::fromDDD_
bool fromDDD_
Definition: DTGeometryESModule.cc:84
query.host
string host
Definition: query.py:115
ESGetToken.h
DDCompactView.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 >
DTGeometryBuilderFromDDD.h
DetId
Definition: DetId.h:17
DTGeometryESModule::applyAlignment_
bool applyAlignment_
Definition: DTGeometryESModule.cc:86
Plane.h
dtGeometry_cfi.DTGeometryESModule
DTGeometryESModule
Definition: dtGeometry_cfi.py:16
DTGeometryESModule::myLabel_
const std::string myLabel_
Definition: DTGeometryESModule.cc:81
cms::DDSpecParRegistry
dd4hep::SpecParRegistry DDSpecParRegistry
Definition: DDCompactView.h:28
ReusableObjectHolder.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
DTAlignmentRcd
Definition: DTAlignmentRcd.h:6
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
DTGeometryESModule::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition: DTGeometryESModule.cc:68
DTGeometryBuilderFromDDD::build
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
Definition: DTGeometryBuilderFromDDD.cc:37
RectangularPlaneBounds.h
DTGeometryESModule::setupDBGeometry
void setupDBGeometry(DTRecoGeometryRcd const &, std::shared_ptr< HostType > &)
Definition: DTGeometryESModule.cc:201
DTAlignmentErrorExtendedRcd
Definition: DTAlignmentErrorExtendedRcd.h:6
DTGeometryBuilderFromCondDB
Definition: DTGeometryBuilderFromCondDB.h:40
DDFilteredView.h
DTGeometryESModule::m_registryToken
edm::ESGetToken< cms::DDSpecParRegistry, DDSpecParRegistryRcd > m_registryToken
Definition: DTGeometryESModule.cc:76
Bounds.h
DTGeometryESModule::globalPositionToken_
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
Definition: DTGeometryESModule.cc:70
RecoIdealGeometry.h
EventSetupRecordIntervalFinder.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTGeometry.h
DTGeometryESModule::fromDD4hep_
bool fromDD4hep_
Definition: DTGeometryESModule.cc:85
DDSpecParRegistry.h
DTAlignmentErrorRcd.h
DTRecoGeometryRcd
Definition: DTRecoGeometryRcd.h:5
edm::ParameterSet
Definition: ParameterSet.h:47
DTGeometryBuilderFromDD4Hep.h
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
DTGeometryESModule::alignmentsToken_
edm::ESGetToken< Alignments, DTAlignmentRcd > alignmentsToken_
Definition: DTGeometryESModule.cc:71
DTGeometryESModule::alignmentsLabel_
const std::string alignmentsLabel_
Definition: DTGeometryESModule.cc:80
DTAlignmentRcd.h
IdealGeometryRecord.h
DTGeometryESModule::m_cpvToken
edm::ESGetToken< cms::DDDetector, IdealGeometryRecord > m_cpvToken
Definition: DTGeometryESModule.cc:75
BenchmarkGrd.h
DTGeometryESModule::m_attribute
const std::string m_attribute
Definition: DTGeometryESModule.cc:82
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
DTGeometryBuilderFromCondDB::build
void build(const std::shared_ptr< DTGeometry > &theGeometry, const RecoIdealGeometry &rig)
Definition: DTGeometryBuilderFromCondDB.cc:41
edm::ESGetToken< Alignments, GlobalPositionRcd >
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
DTGeometryBuilderFromDD4Hep
Definition: DTGeometryBuilderFromDD4Hep.h:42
ModuleFactory.h
edm::ESProductHost
Definition: ESProductHost.h:93
DTGeometryBuilderFromDD4Hep::build
void build(DTGeometry &, const cms::DDDetector *, const MuonGeometryConstants &, const dd4hep::SpecParRefs &)
Definition: DTGeometryBuilderFromDD4Hep.cc:163
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
GeometryAligner.h
DDSpecParRegistryRcd.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
DTGeometryESModule::alignmentErrorsToken_
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > alignmentErrorsToken_
Definition: DTGeometryESModule.cc:72
DTGeometryESModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Creation of configuration file.
Definition: DTGeometryESModule.cc:122
DTGeometryESModule::setupDDDGeometry
void setupDDDGeometry(MuonNumberingRecord const &, std::shared_ptr< HostType > &)
Definition: DTGeometryESModule.cc:173
DTGeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: DTGeometryESModule.cc:73
DTGeometryESModule::produce
std::shared_ptr< DTGeometry > produce(const MuonGeometryRecord &record)
Produce DTGeometry.
Definition: DTGeometryESModule.cc:138
edm::ESProducer
Definition: ESProducer.h:104
ESProductHost.h
DetId::Muon
Definition: DetId.h:26
DTGeometryESModule::m_value
const std::string m_value
Definition: DTGeometryESModule.cc:83
ParameterSet.h
MuonNumberingRecord
Definition: MuonNumberingRecord.h:30
MuonGeometryRecord.h
DTGeometryESModule::setupDD4hepGeometry
void setupDD4hepGeometry(MuonNumberingRecord const &, std::shared_ptr< HostType > &)
Definition: DTGeometryESModule.cc:187
Alignments
Definition: Alignments.h:10
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
RecoIdealGeometry
Definition: RecoIdealGeometry.h:28
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33
DTGeometryESModule::cpvToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: DTGeometryESModule.cc:74