CMS 3D CMS Logo

GEMGeometryESModule.cc
Go to the documentation of this file.
1 
8 
12 
15 
22 
25 
26 // Alignments
33 
34 #include <memory>
35 
36 using namespace edm;
37 
39 public:
42 
44  ~GEMGeometryESModule() override;
45 
47  std::unique_ptr<GEMGeometry> produce(const MuonGeometryRecord& record);
48 
49 private:
50  // use the DDD as Geometry source
51  bool useDDD_;
60 };
61 
63  : useDDD_(p.getParameter<bool>("useDDD")),
64  applyAlignment_(p.getParameter<bool>("applyAlignment")),
65  alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")) {
66  auto cc = setWhatProduced(this);
67  if (useDDD_) {
68  cc.setConsumes(cpvToken_).setConsumes(mdcToken_);
69  } else {
70  cc.setConsumes(riggemToken_);
71  }
72  if (applyAlignment_) {
76  }
77 }
78 
80 
81 std::unique_ptr<GEMGeometry> GEMGeometryESModule::produce(const MuonGeometryRecord& record) {
82  auto gemGeometry = std::make_unique<GEMGeometry>();
83 
84  if (useDDD_) {
85  auto cpv = record.getTransientHandle(cpvToken_);
86  const auto& mdc = record.get(mdcToken_);
88  builder.build(*gemGeometry, cpv.product(), mdc);
89  } else {
90  const auto& riggem = record.get(riggemToken_);
92  builder.build(*gemGeometry, riggem);
93  }
94 
95  if (applyAlignment_) {
96  const auto& globalPosition = record.get(globalPositionToken_);
97  const auto& alignments = record.get(alignmentsToken_);
98  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
99 
100  // No alignment records, assume ideal geometry is wanted
101  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
102  edm::LogInfo("Config") << "@SUB=GEMGeometryRecord::produce"
103  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
104  << "') empty: it is assumed fake and will not apply.";
105  } else {
106  GeometryAligner aligner;
107  aligner.applyAlignments<GEMGeometry>(gemGeometry.get(),
108  &alignments,
109  &alignmentErrors,
111  }
112  }
113 
114  return gemGeometry;
115 }
116 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > alignmentErrorsToken_
Class to update a given geometry with a set of alignments.
JetCorrectorParameters::Record record
Definition: classes.h:7
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::unique_ptr< GEMGeometry > produce(const MuonGeometryRecord &record)
Produce GEMGeometry.
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
void build(GEMGeometry &theGeometry, const DDCompactView *cview, const MuonDDDConstants &muonConstants)
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
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)
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
GEMGeometryESModule(const edm::ParameterSet &p)
Constructor.
edm::ESGetToken< RecoIdealGeometry, GEMRecoGeometryRcd > riggemToken_
edm::ESGetToken< MuonDDDConstants, MuonNumberingRecord > mdcToken_
HLT enums.
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
edm::ESGetToken< Alignments, GEMAlignmentRcd > alignmentsToken_
~GEMGeometryESModule() override
Destructor.
const std::string alignmentsLabel_
void build(GEMGeometry &theGeometry, const RecoIdealGeometry &rgeo)