CMS 3D CMS Logo

TotemGeometryESModule.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Author:
5 * Laurent Forthomme
6 *
7 ****************************************************************************/
8 
9 #include <memory>
10 
14 
17 
22 
24 public:
26 
27  std::unique_ptr<TotemGeometry> produce(const TotemGeometryRcd&);
28 
30 
31 private:
34 
35  const bool useDDL_;
36  const bool useDD4hep_;
37 };
38 
40  : useDDL_(iConfig.getParameter<bool>("useDDL")), useDD4hep_(iConfig.getParameter<bool>("useDD4hep")) {
41  auto cc = setWhatProduced(this);
42  if (useDDL_)
43  ddlToken_ = cc.consumes();
44  else if (useDD4hep_)
45  dd4hepToken_ = cc.consumes();
46  else
47  throw cms::Exception("TotemGeometryESModule") << "Geometry must either be retrieved from a DDL or DD4hep payload!";
48 }
49 
50 std::unique_ptr<TotemGeometry> TotemGeometryESModule::produce(const TotemGeometryRcd& iRecord) {
51  if (useDDL_) {
53  return std::make_unique<TotemGeometry>(detgeomdescbuilder::buildDetGeomDescFromCompactView(*hnd, false).get());
54  } else {
56  return std::make_unique<TotemGeometry>(detgeomdescbuilder::buildDetGeomDescFromCompactView(*hnd, false).get());
57  }
58 }
59 
62  desc.add<bool>("useDDL", true);
63  desc.add<bool>("useDD4hep", false);
64  descriptions.addWithDefaultLabel(desc);
65 }
66 
67 //define this as a plug-in
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
static void fillDescriptions(edm::ConfigurationDescriptions &)
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::unique_ptr< TotemGeometry > produce(const TotemGeometryRcd &)
TotemGeometryESModule(const edm::ParameterSet &)
std::unique_ptr< DetGeomDesc > buildDetGeomDescFromCompactView(const DDCompactView &myCompactView, const bool isRun2)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
Event setup record containing the real (actual) geometry information.
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > dd4hepToken_
edm::ESGetToken< DDCompactView, IdealGeometryRecord > ddlToken_