CMS 3D CMS Logo

GEMGeometryESModule.cc
Go to the documentation of this file.
1 /*
2 //\class GEMGeometryESModule
3 
4  Description: GEM Geometry ES Module from DD & DD4HEP
5  DD4hep part added to the original old file (DD version) made by M. Maggi (INFN Bari)
6 //
7 // Author: Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration)
8 // Created: 27 Jan 2020
9 */
12 
16 
19 
26 
29 
30 // Alignments
37 
38 #include <memory>
39 
40 //dd4hep
44 
45 using namespace edm;
46 
48 public:
51 
53  ~GEMGeometryESModule() override;
54 
56  std::unique_ptr<GEMGeometry> produce(const MuonGeometryRecord& record);
57 
58 private:
59  // use the DDD as Geometry source
60  const bool useDDD_;
61  const bool useDD4hep_;
71 };
72 
74  : useDDD_{p.getParameter<bool>("useDDD")},
75  useDD4hep_{p.getUntrackedParameter<bool>("useDD4hep", false)},
76  applyAlignment_(p.getParameter<bool>("applyAlignment")),
77  alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")) {
78  auto cc = setWhatProduced(this);
79  if (useDDD_ || useDD4hep_) {
80  cc.setConsumes(cpvToken_).setConsumes(mdcToken_);
81  } else {
82  cc.setConsumes(riggemToken_);
83  }
84  if (applyAlignment_) {
85  cc.setConsumes(globalPositionToken_, edm::ESInputTag{"", alignmentsLabel_})
86  .setConsumes(alignmentsToken_, edm::ESInputTag{"", alignmentsLabel_})
87  .setConsumes(alignmentErrorsToken_, edm::ESInputTag{"", alignmentsLabel_});
88  }
89 }
90 
92 
93 std::unique_ptr<GEMGeometry> GEMGeometryESModule::produce(const MuonGeometryRecord& record) {
94  auto gemGeometry = std::make_unique<GEMGeometry>();
95 
96  if (useDDD_) {
97  auto cpv = record.getTransientHandle(cpvToken_);
98  const auto& mdc = record.get(mdcToken_);
100  builder.build(*gemGeometry, cpv.product(), mdc);
101  } else if (useDD4hep_) {
103  const auto& mdc = record.get(mdcToken_);
105  builder.build(*gemGeometry, cpv.product(), mdc);
106  } else {
107  const auto& riggem = record.get(riggemToken_);
109  builder.build(*gemGeometry, riggem);
110  }
111 
112  if (applyAlignment_) {
113  const auto& globalPosition = record.get(globalPositionToken_);
114  const auto& alignments = record.get(alignmentsToken_);
115  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
116 
117  // No alignment records, assume ideal geometry is wanted
118  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
119  edm::LogInfo("Config") << "@SUB=GEMGeometryRecord::produce"
120  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
121  << "') empty: it is assumed fake and will not apply.";
122  } else {
123  GeometryAligner aligner;
124  aligner.applyAlignments<GEMGeometry>(gemGeometry.get(),
125  &alignments,
126  &alignmentErrors,
128  }
129  }
130 
131  return gemGeometry;
132 }
133 
AlignmentErrorsExtended.h
GlobalPositionRcd.h
GEMGeometryESModule::produce
std::unique_ptr< GEMGeometry > produce(const MuonGeometryRecord &record)
Produce GEMGeometry.
Definition: GEMGeometryESModule.cc:93
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
GEMGeometryESModule::alignmentsLabel_
const std::string alignmentsLabel_
Definition: GEMGeometryESModule.cc:63
ESHandle.h
GEMGeometryESModule::useDDD_
const bool useDDD_
Definition: GEMGeometryESModule.cc:60
GEMAlignmentErrorExtendedRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
GEMGeometryESModule::~GEMGeometryESModule
~GEMGeometryESModule() override
Destructor.
Definition: GEMGeometryESModule.cc:91
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MuonGeometryConstants.h
edm::LogInfo
Definition: MessageLogger.h:254
ESProducer.h
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
DetectorGlobalPosition.h
GEMGeometryBuilderFromDDD.h
GEMGeometryBuilderFromDDD
Definition: GEMGeometryBuilderFromDDD.h:34
DDCompactView.h
GEMGeometryBuilderFromDDD::build
void build(GEMGeometry &theGeometry, const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
Definition: GEMGeometryBuilderFromDDD.cc:45
cc
DetId
Definition: DetId.h:17
GEMAlignmentRcd.h
GEMGeometryESModule
Definition: GEMGeometryESModule.cc:47
DDCompactView.h
GEMGeometryBuilderFromCondDB
Definition: GEMGeometryBuilderFromCondDB.h:14
RecoIdealGeometry.h
GEMGeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: GEMGeometryESModule.cc:65
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
gemGeometry_cfi.GEMGeometryESModule
GEMGeometryESModule
Definition: gemGeometry_cfi.py:6
align::DetectorGlobalPosition
const AlignTransform & DetectorGlobalPosition(const Alignments &allGlobals, const DetId &id)
Definition: DetectorGlobalPosition.cc:10
GEMGeometryESModule::globalPositionToken_
edm::ESGetToken< Alignments, GlobalPositionRcd > globalPositionToken_
Definition: GEMGeometryESModule.cc:68
MuonBaseNumber.h
GEMGeometryESModule::cpvToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: GEMGeometryESModule.cc:64
IdealGeometryRecord.h
GEMGeometryESModule::riggemToken_
edm::ESGetToken< RecoIdealGeometry, GEMRecoGeometryRcd > riggemToken_
Definition: GEMGeometryESModule.cc:67
edm::ESGetToken< DDCompactView, IdealGeometryRecord >
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
GEMGeometryESModule::alignmentsToken_
edm::ESGetToken< Alignments, GEMAlignmentRcd > alignmentsToken_
Definition: GEMGeometryESModule.cc:69
ModuleFactory.h
GEMGeometry.h
GeometryAligner.h
GEMGeometryESModule::GEMGeometryESModule
GEMGeometryESModule(const edm::ParameterSet &p)
Constructor.
Definition: GEMGeometryESModule.cc:73
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
GEMGeometryESModule::dd4hepcpvToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepcpvToken_
Definition: GEMGeometryESModule.cc:66
EventSetup.h
GEMGeometryBuilderFromCondDB::build
void build(GEMGeometry &theGeometry, const RecoIdealGeometry &rgeo)
Definition: GEMGeometryBuilderFromCondDB.cc:20
GEMGeometryBuilderFromCondDB.h
edm::ESProducer
Definition: ESProducer.h:101
GEMGeometry
Definition: GEMGeometry.h:24
GEMRecoGeometryRcd.h
DetId::Muon
Definition: DetId.h:26
ParameterSet.h
MuonGeometryRecord.h
MuonDDDNumbering.h
GEMGeometryESModule::applyAlignment_
bool applyAlignment_
Definition: GEMGeometryESModule.cc:62
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
GEMGeometryESModule::alignmentErrorsToken_
edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > alignmentErrorsToken_
Definition: GEMGeometryESModule.cc:70
GeometryAligner::applyAlignments
void applyAlignments(C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
GEMGeometryESModule::useDD4hep_
const bool useDD4hep_
Definition: GEMGeometryESModule.cc:61
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33