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 {
28 
29  applyAlignment_ = p.getParameter<bool>("applyAlignment");
30 
31  auto cc = setWhatProduced(this);
32  if(applyAlignment_) {
36  }
37  if(fromDDD_) {
40  }
41  else {
43  }
44 
45  edm::LogInfo("Geometry") << "@SUB=DTGeometryESModule"
46  << "Label '" << myLabel_ << "' "
47  << (applyAlignment_ ? "looking for" : "IGNORING")
48  << " alignment labels '" << alignmentsLabel_ << "'.";
49 }
50 
52 
53 std::shared_ptr<DTGeometry>
55 
56  auto host = holder_.makeOrGet([]() {
57  return new HostType;
58  });
59 
60  if(fromDDD_) {
61  host->ifRecordChanges<MuonNumberingRecord>(record,
62  [this, &host](auto const& rec) {
63  setupGeometry(rec, host);
64  });
65  } else {
66  host->ifRecordChanges<DTRecoGeometryRcd>(record,
67  [this, &host](auto const& rec) {
68  setupDBGeometry(rec, host);
69  });
70  }
71  //
72  // Called whenever the alignments or alignment errors change
73  //
74  if ( applyAlignment_ ) {
75  // applyAlignment_ is scheduled for removal.
76  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
77  const auto& globalPosition = record.get(globalPositionToken_);
78  const auto& alignments = record.get(alignmentsToken_);
79  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
80  // Only apply alignment if values exist
81  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
82  edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
83  << "Alignment(Error)s and global position (label '"
84  << alignmentsLabel_ << "') empty: Geometry producer (label "
85  << "'" << myLabel_ << "') assumes fake and does not apply.";
86  } else {
87  GeometryAligner aligner;
88  aligner.applyAlignments<DTGeometry>( &(*host),
89  &alignments, &alignmentErrors,
91  }
92  }
93 
94  return host; // automatically converts to std::shared_ptr<DTGeometry>
95 
96 }
97 
99  std::shared_ptr<HostType>& host) {
100  //
101  // Called whenever the muon numbering (or ideal geometry) changes
102  //
103 
104  host->clear();
105 
106  const auto& mdc = record.get(mdcToken_);
108 
109  DTGeometryBuilderFromDDD builder;
110  builder.build(*host, cpv.product(), mdc);
111 }
112 
114  std::shared_ptr<HostType>& host ) {
115  //
116  // Called whenever the muon numbering (or ideal geometry) changes
117  //
118 
119  host->clear();
120 
121  const auto& rig = record.get(rigToken_);
122 
124  builder.build(host, rig);
125 }
126 
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
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
std::shared_ptr< T > makeOrGet(F iFunc)
If there isn&#39;t an object already available, creates a new one using iFunc.
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_
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:18
#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_