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