CMS 3D CMS Logo

ME0GeometryESModule.cc
Go to the documentation of this file.
1 /*
2 //\class ME0GeometryESModule
3 
4  Description: ME0 GeometryESModule 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 Osborne made for DTs (DD4HEP migration)
8 // Created: 29 Apr 2020
9 */
10 
13 
17 
20 
25 
32 
33 #include <memory>
34 
35 using namespace edm;
36 
38 public:
40  ~ME0GeometryESModule() override;
41 
42  std::unique_ptr<ME0Geometry> produce(const MuonGeometryRecord& record);
43 
44 private:
50  // use the DDD or DD4hep as Geometry source
51  bool useDDD_;
52  bool useDD4hep_;
53 };
54 
56  useDDD_ = p.getParameter<bool>("useDDD");
57  useDD4hep_ = p.getUntrackedParameter<bool>("useDD4hep", false);
58  auto cc = setWhatProduced(this);
59  if (useDDD_) {
60  cc.setConsumes(cpvToken_).setConsumes(mdcToken_);
61  } else if (useDD4hep_) {
62  cc.setConsumes(dd4hepcpvToken_).setConsumes(dd4hepmdcToken_);
63  } else {
64  cc.setConsumes(rigme0Token_);
65  }
66 }
67 
69 
70 std::unique_ptr<ME0Geometry> ME0GeometryESModule::produce(const MuonGeometryRecord& record) {
71  LogTrace("ME0GeometryESModule") << "ME0GeometryESModule::produce with useDDD = " << useDDD_;
72  if (useDDD_) {
73  LogTrace("ME0GeometryESModule") << "ME0GeometryESModule::produce :: ME0GeometryBuilder builder";
74  auto cpv = record.getTransientHandle(cpvToken_);
75  const auto& mdc = record.get(mdcToken_);
76  ME0GeometryBuilder builder;
77  return std::unique_ptr<ME0Geometry>(builder.build(cpv.product(), mdc));
78  } else if (useDD4hep_) {
79  LogTrace("ME0GeometryESModule") << "ME0GeometryESModule::produce :: ME0GeometryBuilder builder DD4hep";
80  auto cpv = record.getTransientHandle(dd4hepcpvToken_);
81  const auto& mdc = record.get(dd4hepmdcToken_);
82  ME0GeometryBuilder builder;
83  return std::unique_ptr<ME0Geometry>(builder.build(cpv.product(), mdc));
84  } else {
85  LogTrace("ME0GeometryESModule") << "ME0GeometryESModule::produce :: ME0GeometryBuilderFromCondDB builder";
86  const auto& rigme0 = record.get(rigme0Token_);
88  return std::unique_ptr<ME0Geometry>(builder.build(rigme0));
89  }
90 }
91 
ME0GeometryESModule::rigme0Token_
edm::ESGetToken< RecoIdealGeometry, ME0RecoGeometryRcd > rigme0Token_
Definition: ME0GeometryESModule.cc:49
ESTransientHandle.h
ESHandle.h
ME0GeometryESModule
Definition: ME0GeometryESModule.cc:37
edm
HLT enums.
Definition: AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
MuonGeometryConstants.h
ESProducer.h
GlobalPosition_Frontier_DevDB_cff.record
record
Definition: GlobalPosition_Frontier_DevDB_cff.py:10
ME0GeometryBuilderFromCondDB::build
ME0Geometry * build(const RecoIdealGeometry &rgeo)
Definition: ME0GeometryBuilderFromCondDB.cc:31
DDCompactView.h
cc
me0Geometry_cfi.ME0GeometryESModule
ME0GeometryESModule
Definition: me0Geometry_cfi.py:6
ME0GeometryESModule::useDD4hep_
bool useDD4hep_
Definition: ME0GeometryESModule.cc:52
ME0GeometryESModule::mdcToken_
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_
Definition: ME0GeometryESModule.cc:46
ME0GeometryESModule::ME0GeometryESModule
ME0GeometryESModule(const edm::ParameterSet &p)
Definition: ME0GeometryESModule.cc:55
ME0GeometryBuilderFromCondDB
Definition: ME0GeometryBuilderFromCondDB.h:20
ME0GeometryESModule::~ME0GeometryESModule
~ME0GeometryESModule() override
Definition: ME0GeometryESModule.cc:68
DDCompactView.h
RecoIdealGeometry.h
ME0GeometryESModule::cpvToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
Definition: ME0GeometryESModule.cc:45
edm::ParameterSet
Definition: ParameterSet.h:36
ME0GeometryESModule::produce
std::unique_ptr< ME0Geometry > produce(const MuonGeometryRecord &record)
Definition: ME0GeometryESModule.cc:70
IdealGeometryRecord.h
ME0GeometryBuilder
Definition: ME0GeometryBuilder.h:34
ME0GeometryBuilder::build
ME0Geometry * build(const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
Definition: ME0GeometryBuilder.cc:42
edm::ESGetToken< DDCompactView, IdealGeometryRecord >
DD4hep_MuonNumbering.h
ME0Geometry.h
ModuleFactory.h
ME0GeometryBuilderFromCondDB.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
ME0RecoGeometryRcd.h
EventSetup.h
ME0GeometryESModule::dd4hepcpvToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepcpvToken_
Definition: ME0GeometryESModule.cc:47
edm::ESProducer
Definition: ESProducer.h:101
ME0GeometryESModule::useDDD_
bool useDDD_
Definition: ME0GeometryESModule.cc:51
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
ParameterSet.h
MuonGeometryRecord.h
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
ME0GeometryESModule::dd4hepmdcToken_
edm::ESGetToken< cms::MuonNumbering, MuonNumberingRecord > dd4hepmdcToken_
Definition: ME0GeometryESModule.cc:48
ME0GeometryBuilder.h