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 
14 
21 
23 
30 
31 #include <memory>
32 
34 public:
36 
38 
39  std::unique_ptr<ME0Geometry> produce(const MuonGeometryRecord& record);
40 
41 private:
46  // use the DDD or DD4hep as Geometry source
47  bool fromDDD_;
49 };
50 
52  fromDDD_ = p.getParameter<bool>("fromDDD");
53  fromDD4hep_ = p.getParameter<bool>("fromDD4hep");
54  auto cc = setWhatProduced(this);
55  if (fromDDD_) {
56  cpvToken_ = cc.consumes();
57  mdcToken_ = cc.consumes();
58  } else if (fromDD4hep_) {
59  dd4hepcpvToken_ = cc.consumes();
60  mdcToken_ = cc.consumes();
61  } else {
62  rigme0Token_ = cc.consumes();
63  }
64  edm::LogVerbatim("GEMGeometry") << "ME0GeometryESModule::initailized with flags " << fromDDD_ << ":" << fromDD4hep_;
65 }
66 
69  desc.add<bool>("fromDDD", true);
70  desc.add<bool>("fromDD4hep", false);
71  descriptions.add("me0Geometry", desc);
72 }
73 
74 std::unique_ptr<ME0Geometry> ME0GeometryESModule::produce(const MuonGeometryRecord& record) {
75  edm::LogVerbatim("GEMGeometry") << "ME0GeometryESModule::produce with fromDDD = " << fromDDD_ << " fromDD4hep "
76  << fromDD4hep_;
77  if (fromDDD_) {
78  edm::LogVerbatim("ME0GeometryESModule") << "(0) ME0GeometryESModule - DDD ";
79  edm::LogVerbatim("GEMGeometry") << "ME0GeometryESModule::produce :: ME0GeometryBuilder builder";
80  auto cpv = record.getTransientHandle(cpvToken_);
81  const auto& mdc = record.get(mdcToken_);
82  ME0GeometryBuilder builder;
83  return std::unique_ptr<ME0Geometry>(builder.build(cpv.product(), mdc));
84  } else if (fromDD4hep_) {
85  edm::LogVerbatim("ME0GeometryESModule") << "(0) ME0GeometryESModule - DD4hep ";
86  edm::LogVerbatim("GEMGeometry") << "ME0GeometryESModule::produce :: ME0GeometryBuilder builder DD4hep";
87  auto cpv = record.getTransientHandle(dd4hepcpvToken_);
88  const auto& mdc = record.get(mdcToken_);
89  ME0GeometryBuilder builder;
90  return std::unique_ptr<ME0Geometry>(builder.build(cpv.product(), mdc));
91  } else {
92  edm::LogVerbatim("ME0GeometryESModule") << "(0) ME0GeometryESModule - DB ";
93  edm::LogVerbatim("GEMGeometry") << "ME0GeometryESModule::produce :: ME0GeometryBuilderFromCondDB builder";
94  const auto& rigme0 = record.get(rigme0Token_);
96  return std::unique_ptr<ME0Geometry>(builder.build(rigme0));
97  }
98 }
99 
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
ME0GeometryESModule(const edm::ParameterSet &p)
ME0Geometry * build(const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
edm::ESGetToken< DDCompactView, IdealGeometryRecord > cpvToken_
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepcpvToken_
std::unique_ptr< ME0Geometry > produce(const MuonGeometryRecord &record)
static void fillDescriptions(edm::ConfigurationDescriptions &)
edm::ESGetToken< RecoIdealGeometry, ME0RecoGeometryRcd > rigme0Token_
ME0Geometry * build(const RecoIdealGeometry &rgeo)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > mdcToken_