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_);
91  edm::ESTransientHandle<DDCompactView> cpv = record.getTransientHandle(cpvToken_);
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 
DTGeometry
Definition: DTGeometry.h:28
MuonGeometryConstants
Definition: MuonGeometryConstants.h:20
DTGeometryESModule::DTGeometryESModule
DTGeometryESModule(const edm::ParameterSet &p)
Constructor.
Definition: DTGeometryESModule.cc:23
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
edm
HLT enums.
Definition: AlignableModifier.h:19
DTGeometryBuilderFromDDD
Definition: DTGeometryBuilderFromDDD.h:31
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::LogInfo
Definition: MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
DTGeometryESModule::rigToken_
edm::ESGetToken< RecoIdealGeometry, DTRecoGeometryRcd > rigToken_
Definition: DTGeometryESModule.h:64
DetectorGlobalPosition.h
DTGeometryBuilderFromCondDB.h
DTGeometryESModule::fromDDD_
bool fromDDD_
Definition: DTGeometryESModule.h:69
GlobalPositionRcd
Definition: GlobalPositionRcd.h:6
DTGeometryESModule::~DTGeometryESModule
~DTGeometryESModule() override
Destructor.
Definition: DTGeometryESModule.cc:48
cc
query.host
host
Definition: query.py:115
DTGeometryBuilderFromDDD.h
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
DetId
Definition: DetId.h:17
DTGeometryESModule::applyAlignment_
bool applyAlignment_
Definition: DTGeometryESModule.h:66
DTGeometryESModule::myLabel_
const std::string myLabel_
Definition: DTGeometryESModule.h:68
DTAlignmentRcd
Definition: DTAlignmentRcd.h:6
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
DTGeometryESModule::holder_
edm::ReusableObjectHolder< HostType > holder_
Definition: DTGeometryESModule.h:57
DTGeometryBuilderFromDDD::build
void build(DTGeometry &theGeometry, const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
Definition: DTGeometryBuilderFromDDD.cc:37
DTGeometryESModule::setupDBGeometry
void setupDBGeometry(DTRecoGeometryRcd const &, std::shared_ptr< HostType > &)
Definition: DTGeometryESModule.cc:97
DTAlignmentErrorExtendedRcd
Definition: DTAlignmentErrorExtendedRcd.h:6
DTGeometryBuilderFromCondDB
Definition: DTGeometryBuilderFromCondDB.h:40
DTGeometryESModule::globalPositionToken_
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
Definition: DTGeometryESModule.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTRecoGeometryRcd
Definition: DTRecoGeometryRcd.h:5
edm::ParameterSet
Definition: ParameterSet.h:36
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
DTGeometryESModule::alignmentsToken_
edm::ESGetToken< Alignments, DTAlignmentRcd > alignmentsToken_
Definition: DTGeometryESModule.h:60
DTGeometryESModule::alignmentsLabel_
const std::string alignmentsLabel_
Definition: DTGeometryESModule.h:67
AlignmentErrorsExtended
Definition: AlignmentErrorsExtended.h:10
DTGeometryBuilderFromCondDB::build
void build(const std::shared_ptr< DTGeometry > &theGeometry, const RecoIdealGeometry &rig)
Definition: DTGeometryBuilderFromCondDB.cc:41
DTGeometryESModule::HostType
edm::ESProductHost< DTGeometry, MuonNumberingRecord, DTRecoGeometryRcd > HostType
Definition: DTGeometryESModule.h:52
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
ModuleFactory.h
std
Definition: JetResolutionObject.h:76
DTGeometryESModule.h
GeometryAligner.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
DTGeometryESModule::alignmentErrorsToken_
edm::ESGetToken< AlignmentErrorsExtended, DTAlignmentErrorExtendedRcd > alignmentErrorsToken_
Definition: DTGeometryESModule.h:61
DTGeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: DTGeometryESModule.h:62
DTGeometryESModule::produce
std::shared_ptr< DTGeometry > produce(const MuonGeometryRecord &record)
Produce DTGeometry.
Definition: DTGeometryESModule.cc:50
DTGeometryESModule::setupGeometry
void setupGeometry(MuonNumberingRecord const &, std::shared_ptr< HostType > &)
Definition: DTGeometryESModule.cc:83
DTGeometryESModule
Definition: DTGeometryESModule.h:40
DetId::Muon
Definition: DetId.h:26
MuonNumberingRecord
Definition: MuonNumberingRecord.h:30
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
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.h:63