CMS 3D CMS Logo

RPCGeometryESModule.cc
Go to the documentation of this file.
1 /*
2 //\class RPCGeometryESModule
3 
4 Description: RPC 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: Fri, 20 Sep 2019
9 // Modified: Fri, 29 May 2020, following what Sunanda Banerjee made in PR #29842 PR #29943 and Ianna Osborne in PR #29954
10 */
27 #include <unordered_map>
28 #include <memory>
29 
31 public:
33 
35 
36  std::unique_ptr<RPCGeometry> produce(const MuonGeometryRecord& record);
37 
38 private:
39  //DDD
42  // dd4hep
44  // Reco
46 
47  const bool fromDDD_;
48  const bool fromDD4hep_;
49 };
50 
52  : fromDDD_{p.getUntrackedParameter<bool>("fromDDD", true)},
53  fromDD4hep_{p.getUntrackedParameter<bool>("fromDD4hep", false)} {
54  auto cc = setWhatProduced(this);
55 
56  if (fromDDD_) {
57  idealGeomToken_ = cc.consumes();
58  dddConstantsToken_ = cc.consumes();
59  } else if (fromDD4hep_) {
60  idealDD4hepGeomToken_ = cc.consumes();
61  dddConstantsToken_ = cc.consumes();
62  } else {
63  recoIdealToken_ = cc.consumes();
64  }
65 }
66 
69  desc.addUntracked<bool>("fromDDD", true);
70  desc.addUntracked<bool>("fromDD4hep", false);
71  descriptions.add("RPCGeometryESModule", desc);
72 }
73 
74 std::unique_ptr<RPCGeometry> RPCGeometryESModule::produce(const MuonGeometryRecord& record) {
75  if (fromDDD_) {
76  edm::LogVerbatim("RPCGeoemtryESModule") << "(0) RPCGeometryESModule - DDD ";
78  auto const& mdc = record.get(dddConstantsToken_);
79  RPCGeometryBuilder builder;
80  return std::unique_ptr<RPCGeometry>(builder.build(&(*cpv), mdc));
81  } else if (fromDD4hep_) {
82  edm::LogVerbatim("RPCGeoemtryESModule") << "(0) RPCGeometryESModule - DD4hep ";
84  auto const& mdc = record.get(dddConstantsToken_);
85  RPCGeometryBuilder builder;
86  return std::unique_ptr<RPCGeometry>(builder.build(&(*cpv), mdc));
87  } else {
88  edm::LogVerbatim("RPCGeoemtryESModule") << "(0) RPCGeometryESModule - DB ";
89  auto const& rigrpc = record.get(recoIdealToken_);
91  return std::unique_ptr<RPCGeometry>(builder.build(rigrpc));
92  }
93 }
94 
Log< level::Info, true > LogVerbatim
RPCGeometry * build(const RecoIdealGeometry &rgeo)
edm::ESGetToken< DDCompactView, IdealGeometryRecord > idealGeomToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::ESGetToken< MuonGeometryConstants, IdealGeometryRecord > dddConstantsToken_
RPCGeometryESModule(const edm::ParameterSet &p)
edm::ESGetToken< RecoIdealGeometry, RPCRecoGeometryRcd > recoIdealToken_
std::unique_ptr< RPCGeometry > produce(const MuonGeometryRecord &record)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
std::unique_ptr< RPCGeometry > build(const DDCompactView *cview, const MuonGeometryConstants &muonConstants)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > idealDD4hepGeomToken_