CMS 3D CMS Logo

DTGeometryESModule.cc
Go to the documentation of this file.
1 
6 #include "DTGeometryESModule.h"
9 
10 // Alignments
13 
16 
17 #include <memory>
18 #include <iostream>
19 
20 using namespace edm;
21 using namespace std;
22 
24  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
25  myLabel_(p.getParameter<std::string>("appendToDataLabel")),
26  fromDDD_(p.getParameter<bool>("fromDDD")) {
27  applyAlignment_ = p.getParameter<bool>("applyAlignment");
28 
29  auto cc = setWhatProduced(this);
30  if (applyAlignment_) {
35  }
36  if (fromDDD_) {
39  } else {
41  }
42 
43  edm::LogInfo("Geometry") << "@SUB=DTGeometryESModule"
44  << "Label '" << myLabel_ << "' " << (applyAlignment_ ? "looking for" : "IGNORING")
45  << " alignment labels '" << alignmentsLabel_ << "'.";
46 }
47 
49 
50 std::shared_ptr<DTGeometry> DTGeometryESModule::produce(const MuonGeometryRecord& record) {
51  auto host = holder_.makeOrGet([]() { return new HostType; });
52 
53  if (fromDDD_) {
54  host->ifRecordChanges<MuonNumberingRecord>(record, [this, &host](auto const& rec) { setupGeometry(rec, host); });
55  } else {
56  host->ifRecordChanges<DTRecoGeometryRcd>(record, [this, &host](auto const& rec) { setupDBGeometry(rec, host); });
57  }
58  //
59  // Called whenever the alignments or alignment errors change
60  //
61  if (applyAlignment_) {
62  // applyAlignment_ is scheduled for removal.
63  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
64  const auto& globalPosition = record.get(globalPositionToken_);
65  const auto& alignments = record.get(alignmentsToken_);
66  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
67  // Only apply alignment if values exist
68  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
69  edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
70  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
71  << "') empty: Geometry producer (label "
72  << "'" << myLabel_ << "') assumes fake and does not apply.";
73  } else {
74  GeometryAligner aligner;
75  aligner.applyAlignments<DTGeometry>(
76  &(*host), &alignments, &alignmentErrors, align::DetectorGlobalPosition(globalPosition, DetId(DetId::Muon)));
77  }
78  }
79 
80  return host; // automatically converts to std::shared_ptr<DTGeometry>
81 }
82 
83 void DTGeometryESModule::setupGeometry(const MuonNumberingRecord& record, std::shared_ptr<HostType>& host) {
84  //
85  // Called whenever the muon numbering (or ideal geometry) changes
86  //
87 
88  host->clear();
89 
90  const auto& mdc = record.get(mdcToken_);
92 
94  builder.build(*host, cpv.product(), mdc);
95 }
96 
97 void DTGeometryESModule::setupDBGeometry(const DTRecoGeometryRcd& record, std::shared_ptr<HostType>& host) {
98  //
99  // Called whenever the muon numbering (or ideal geometry) changes
100  //
101 
102  host->clear();
103 
104  const auto& rig = record.get(rigToken_);
105 
107  builder.build(host, rig);
108 }
109 
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
host
Definition: query.py:115
std::shared_ptr< DTGeometry > produce(const MuonGeometryRecord &record)
Produce DTGeometry.
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
edm::ReusableObjectHolder< HostType > holder_
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
~DTGeometryESModule() override
Destructor.
const std::string myLabel_
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
const std::string alignmentsLabel_
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
edm::ESProductHost< DTGeometry, MuonNumberingRecord, DTRecoGeometryRcd > HostType
void setupDBGeometry(DTRecoGeometryRcd const &, std::shared_ptr< HostType > &)
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
edm::ESGetToken< MuonDDDConstants, MuonNumberingRecord > mdcToken_
Definition: DetId.h:17
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
void setupGeometry(MuonNumberingRecord const &, std::shared_ptr< HostType > &)
T const * product() const
HLT enums.
edm::ESGetToken< Alignments, DTAlignmentRcd > alignmentsToken_
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
DTGeometryESModule(const edm::ParameterSet &p)
Constructor.
void build(const std::shared_ptr< DTGeometry > &theGeometry, const RecoIdealGeometry &rig)
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > alignmentErrorsToken_
edm::ESGetToken< RecoIdealGeometry, DTRecoGeometryRcd > rigToken_