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 */
13 
20 
22 
30 
31 // Alignments
38 
39 #include <memory>
40 
42 public:
45 
48 
50  std::unique_ptr<GEMGeometry> produce(const MuonGeometryRecord& record);
51 
52 private:
53  // use the DDD as Geometry source
54  const bool fromDDD_;
55  const bool fromDD4hep_;
65 };
66 
68  : fromDDD_{p.getParameter<bool>("fromDDD")},
69  fromDD4hep_{p.getParameter<bool>("fromDD4Hep")},
70  applyAlignment_(p.getParameter<bool>("applyAlignment")),
71  alignmentsLabel_(p.getParameter<std::string>("alignmentsLabel")) {
72  auto cc = setWhatProduced(this);
73  if (fromDDD_) {
74  cpvToken_ = cc.consumes();
75  mdcToken_ = cc.consumes();
76  } else if (fromDD4hep_) {
77  dd4hepcpvToken_ = cc.consumes();
78  mdcToken_ = cc.consumes();
79  } else {
80  riggemToken_ = cc.consumes();
81  }
82  if (applyAlignment_) {
83  globalPositionToken_ = cc.consumes(edm::ESInputTag{"", alignmentsLabel_});
84  alignmentsToken_ = cc.consumes(edm::ESInputTag{"", alignmentsLabel_});
85  alignmentErrorsToken_ = cc.consumes(edm::ESInputTag{"", alignmentsLabel_});
86  }
87  edm::LogVerbatim("GEMGeometry") << "GEMGeometryESModule::initailized with flags " << fromDDD_ << ":" << fromDD4hep_;
88 }
89 
92  desc.add<bool>("fromDDD", true);
93  desc.add<bool>("fromDD4Hep", false);
94  desc.add<bool>("applyAlignment", false);
95  desc.add<std::string>("alignmentsLabel", "");
96  descriptions.add("gemGeometry", desc);
97 }
98 
99 std::unique_ptr<GEMGeometry> GEMGeometryESModule::produce(const MuonGeometryRecord& record) {
100  auto gemGeometry = std::make_unique<GEMGeometry>();
101 
102  if (fromDDD_) {
103  edm::LogVerbatim("GEMGeometry") << "GEMGeometryESModule::produce :: GEMGeometryBuilder builder ddd";
104  auto cpv = record.getTransientHandle(cpvToken_);
105  const auto& mdc = record.get(mdcToken_);
106  GEMGeometryBuilder builder;
107  builder.build(*gemGeometry, cpv.product(), mdc);
108  } else if (fromDD4hep_) {
109  edm::LogVerbatim("GEMGeometry") << "GEMGeometryESModule::produce :: GEMGeometryBuilder builder dd4hep";
111  const auto& mdc = record.get(mdcToken_);
112  GEMGeometryBuilder builder;
113  builder.build(*gemGeometry, cpv.product(), mdc);
114  } else {
115  edm::LogVerbatim("GEMGeometry") << "GEMGeometryESModule::produce :: GEMGeometryBuilder builder db";
116  const auto& riggem = record.get(riggemToken_);
118  builder.build(*gemGeometry, riggem);
119  }
120 
121  if (applyAlignment_) {
122  const auto& globalPosition = record.get(globalPositionToken_);
123  const auto& alignments = record.get(alignmentsToken_);
124  const auto& alignmentErrors = record.get(alignmentErrorsToken_);
125 
126  // No alignment records, assume ideal geometry is wanted
127  if (alignments.empty() && alignmentErrors.empty() && globalPosition.empty()) {
128  edm::LogInfo("Config") << "@SUB=GEMGeometryRecord::produce"
129  << "Alignment(Error)s and global position (label '" << alignmentsLabel_
130  << "') empty: it is assumed fake and will not apply.";
131  } else {
132  GeometryAligner aligner;
133  aligner.applyAlignments<GEMGeometry>(gemGeometry.get(),
134  &alignments,
135  &alignmentErrors,
137  }
138  }
139 
140  return gemGeometry;
141 }
142 
ConfigurationDescriptions.h
GEMGeometryESModule::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Define the cfi file.
Definition: GEMGeometryESModule.cc:90
AlignmentErrorsExtended.h
GlobalPositionRcd.h
GEMGeometryESModule::produce
std::unique_ptr< GEMGeometry > produce(const MuonGeometryRecord &record)
Produce GEMGeometry.
Definition: GEMGeometryESModule.cc:99
edm::ESInputTag
Definition: ESInputTag.h:87
ESTransientHandle.h
GEMGeometryESModule::fromDDD_
const bool fromDDD_
Definition: GEMGeometryESModule.cc:54
edm::ESTransientHandle::product
T const * product() const
Definition: ESTransientHandle.h:51
GEMGeometryESModule::alignmentsLabel_
const std::string alignmentsLabel_
Definition: GEMGeometryESModule.cc:57
ESHandle.h
GEMAlignmentErrorExtendedRcd.h
GEMGeometryESModule::fromDD4hep_
const bool fromDD4hep_
Definition: GEMGeometryESModule.cc:55
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MuonGeometryConstants.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ESProducer.h
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
DetectorGlobalPosition.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DDCompactView.h
GeometryAligner::applyAlignments
void applyAlignments(const C *geometry, const Alignments *alignments, const AlignmentErrorsExtended *alignmentErrors, const AlignTransform &globalCoordinates)
Definition: GeometryAligner.h:52
DetId
Definition: DetId.h:17
GEMAlignmentRcd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
GEMGeometryESModule
Definition: GEMGeometryESModule.cc:41
DDCompactView.h
GEMGeometryBuilderFromCondDB
Definition: GEMGeometryBuilderFromCondDB.h:14
RecoIdealGeometry.h
GEMGeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: GEMGeometryESModule.cc:59
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
GEMGeometryBuilder
Definition: GEMGeometryBuilder.h:32
edm::ParameterSet
Definition: ParameterSet.h:47
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:62
GEMGeometryESModule::cpvToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: GEMGeometryESModule.cc:58
IdealGeometryRecord.h
GEMGeometryESModule::riggemToken_
edm::ESGetToken< RecoIdealGeometry, GEMRecoGeometryRcd > riggemToken_
Definition: GEMGeometryESModule.cc:61
cc
edm::ESGetToken< DDCompactView, IdealGeometryRecord >
GEMGeometryBuilder::build
void build(GEMGeometry &theGeometry, const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
Definition: GEMGeometryBuilder.cc:48
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
GEMGeometryESModule::alignmentsToken_
edm::ESGetToken< Alignments, GEMAlignmentRcd > alignmentsToken_
Definition: GEMGeometryESModule.cc:63
ModuleFactory.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
GEMGeometry.h
GeometryAligner.h
GEMGeometryESModule::GEMGeometryESModule
GEMGeometryESModule(const edm::ParameterSet &p)
Constructor.
Definition: GEMGeometryESModule.cc:67
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
GEMGeometryBuilder.h
GEMGeometryESModule::dd4hepcpvToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepcpvToken_
Definition: GEMGeometryESModule.cc:60
EventSetup.h
gemGeometry_cff.gemGeometry
gemGeometry
Definition: gemGeometry_cff.py:5
GEMGeometryBuilderFromCondDB::build
void build(GEMGeometry &theGeometry, const RecoIdealGeometry &rgeo)
Definition: GEMGeometryBuilderFromCondDB.cc:21
GEMGeometryBuilderFromCondDB.h
edm::ESProducer
Definition: ESProducer.h:104
GEMGeometry
Definition: GEMGeometry.h:24
GEMRecoGeometryRcd.h
DetId::Muon
Definition: DetId.h:26
ParameterSet.h
MuonGeometryRecord.h
GEMGeometryESModule::applyAlignment_
bool applyAlignment_
Definition: GEMGeometryESModule.cc:56
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
GEMGeometryESModule::alignmentErrorsToken_
edm::ESGetToken< AlignmentErrorsExtended, GEMAlignmentErrorExtendedRcd > alignmentErrorsToken_
Definition: GEMGeometryESModule.cc:64
GeometryAligner
Class to update a given geometry with a set of alignments.
Definition: GeometryAligner.h:33