CMS 3D CMS Logo

DTGeometryESModule.cc
Go to the documentation of this file.
1 
6 #include "DTGeometryESModule.h"
9 
14 
15 // Alignments
23 
27 
28 #include <memory>
29 #include <iostream>
30 
31 using namespace edm;
32 using namespace std;
33 
35  : alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")),
36  myLabel_(p.getParameter<std::string>("appendToDataLabel")),
37  fromDDD_(p.getParameter<bool>("fromDDD"))
38 {
39 
40  applyAlignment_ = p.getParameter<bool>("applyAlignment");
41 
42  setWhatProduced(this);
43 
44  edm::LogInfo("Geometry") << "@SUB=DTGeometryESModule"
45  << "Label '" << myLabel_ << "' "
46  << (applyAlignment_ ? "looking for" : "IGNORING")
47  << " alignment labels '" << alignmentsLabel_ << "'.";
48 }
49 
51 
52 std::shared_ptr<DTGeometry>
54 
55  auto host = holder_.makeOrGet([]() {
56  return new HostType;
57  });
58 
59  if(fromDDD_) {
60  host->ifRecordChanges<MuonNumberingRecord>(record,
61  [this, &host](auto const& rec) {
62  setupGeometry(rec, host);
63  });
64  } else {
65  host->ifRecordChanges<DTRecoGeometryRcd>(record,
66  [this, &host](auto const& rec) {
67  setupDBGeometry(rec, host);
68  });
69  }
70  //
71  // Called whenever the alignments or alignment errors change
72  //
73  if ( applyAlignment_ ) {
74  // applyAlignment_ is scheduled for removal.
75  // Ideal geometry obtained by using 'fake alignment' (with applyAlignment_ = true)
76  edm::ESHandle<Alignments> globalPosition;
77  record.getRecord<GlobalPositionRcd>().get(alignmentsLabel_, globalPosition);
78  edm::ESHandle<Alignments> alignments;
79  record.getRecord<DTAlignmentRcd>().get(alignmentsLabel_, alignments);
81  record.getRecord<DTAlignmentErrorExtendedRcd>().get(alignmentsLabel_, alignmentErrors);
82  // Only apply alignment if values exist
83  if (alignments->empty() && alignmentErrors->empty() && globalPosition->empty()) {
84  edm::LogInfo("Config") << "@SUB=DTGeometryRecord::produce"
85  << "Alignment(Error)s and global position (label '"
86  << alignmentsLabel_ << "') empty: Geometry producer (label "
87  << "'" << myLabel_ << "') assumes fake and does not apply.";
88  } else {
89  GeometryAligner aligner;
90  aligner.applyAlignments<DTGeometry>( &(*host),
91  &(*alignments), &(*alignmentErrors),
93  }
94  }
95 
96  return host; // automatically converts to std::shared_ptr<DTGeometry>
97 
98 }
99 
101  std::shared_ptr<HostType>& host) {
102  //
103  // Called whenever the muon numbering (or ideal geometry) changes
104  //
105 
106  host->clear();
107 
109  record.get( mdc );
110 
112  record.getRecord<IdealGeometryRecord>().get(cpv);
113 
114  DTGeometryBuilderFromDDD builder;
115  builder.build(host, &(*cpv), *mdc);
116 }
117 
119  std::shared_ptr<HostType>& host ) {
120  //
121  // Called whenever the muon numbering (or ideal geometry) changes
122  //
123 
124  host->clear();
125 
127  record.get(rig);
128 
130  builder.build(host, *rig);
131 }
132 
T getParameter(std::string const &) const
host
Definition: query.py:115
std::shared_ptr< DTGeometry > produce(const MuonGeometryRecord &record)
Produce DTGeometry.
bool empty() const
Test of empty vector without having to look into internals:
Definition: Alignments.h:15
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
edm::ReusableObjectHolder< HostType > holder_
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
~DTGeometryESModule() override
Destructor.
const std::string myLabel_
void get(HolderT &iHolder) const
const std::string alignmentsLabel_
edm::ESProductHost< DTGeometry, MuonNumberingRecord, DTRecoGeometryRcd > HostType
void setupDBGeometry(DTRecoGeometryRcd const &, std::shared_ptr< HostType > &)
Definition: DetId.h:18
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
void setupGeometry(MuonNumberingRecord const &, std::shared_ptr< HostType > &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
bool empty() const
Test of empty vector without having to look into internals:
HLT enums.
void build(std::shared_ptr< DTGeometry > theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
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)