CMS 3D CMS Logo

DDDetectorESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DetectorDescription/DDDetectorESProducer
4 // Class: DDDetectorESProducer
5 //
13 //
14 // Original Author: Ianna Osborne
15 // Created: Fri, 07 Dec 2018 11:20:52 GMT
16 //
17 //
18 
19 #include <memory>
20 
28 
33 #include "DD4hep/Detector.h"
34 
35 using namespace std;
36 using namespace cms;
37 using namespace edm;
38 
40 public:
42  ~DDDetectorESProducer() override;
43 
44  using ReturnType = unique_ptr<DDDetector>;
46 
47  ReturnType produceGeom(const IdealGeometryRecord&);
48  ReturnType produceMagField(const IdealMagneticFieldRecord&);
49  ReturnType produce();
51 
52 protected:
53  void setIntervalFor(const eventsetup::EventSetupRecordKey&, const IOVSyncValue&, ValidityInterval&) override;
54 
55 private:
56  const bool fromDB_;
57  const string appendToDataLabel_;
58  const string confGeomXMLFiles_;
59  const string rootDDName_;
60  const string label_;
63 };
64 
66  : fromDB_(iConfig.getParameter<bool>("fromDB")),
67  appendToDataLabel_(iConfig.getParameter<string>("appendToDataLabel")),
68  confGeomXMLFiles_(iConfig.getParameter<FileInPath>("confGeomXMLFiles").fullPath()),
69  rootDDName_(iConfig.getParameter<string>("rootDDName")),
70  label_(iConfig.getParameter<string>("label")) {
71  if (rootDDName_ == "MagneticFieldVolumes:MAGF" || rootDDName_ == "cmsMagneticField:MAGF") {
72  auto c = setWhatProduced(this,
74  edm::es::Label(iConfig.getParameter<std::string>("@module_label")));
75  if (fromDB_) {
76  c.setConsumes(mfToken_, edm::ESInputTag("", label_));
77  }
78  findingRecord<IdealMagneticFieldRecord>();
79  } else {
80  auto c = setWhatProduced(
82  if (fromDB_) {
83  c.setConsumes(geomToken_, edm::ESInputTag("", label_));
84  }
85  findingRecord<IdealGeometryRecord>();
86  }
87 }
88 
90 
93 
94  desc.addOptional<FileInPath>("confGeomXMLFiles");
95  desc.add<string>("rootDDName", "cms:OCMS");
96  desc.add<string>("label", "");
97  desc.add<bool>("fromDB", false);
98  descriptions.add("DDDetectorESProducer", desc);
99 
101  descDB.add<string>("rootDDName", "cms:OCMS");
102  descDB.add<string>("label", "Extended");
103  descDB.add<bool>("fromDB", true);
104  descriptions.add("DDDetectorESProducerFromDB", descDB);
105 }
106 
108  const IOVSyncValue& iTime,
109  ValidityInterval& oInterval) {
110  oInterval = ValidityInterval(IOVSyncValue::beginOfTime(), IOVSyncValue::endOfTime()); //infinite
111 }
112 
114  LogVerbatim("Geometry") << "DDDetectorESProducer::Produce MF " << appendToDataLabel_;
115  if (fromDB_) {
117  unique_ptr<vector<unsigned char> > tb = (*gdd).getUncompressedBlob();
118 
119  return make_unique<cms::DDDetector>(label_, string(tb->begin(), tb->end()), true);
120  } else {
121  return make_unique<DDDetector>(appendToDataLabel_, confGeomXMLFiles_);
122  }
123 }
124 
126  LogVerbatim("Geometry") << "DDDetectorESProducer::Produce " << appendToDataLabel_;
127  if (fromDB_) {
129  unique_ptr<vector<unsigned char> > tb = (*gdd).getUncompressedBlob();
130 
131  return make_unique<cms::DDDetector>(label_, string(tb->begin(), tb->end()), true);
132  } else {
133  return make_unique<DDDetector>(appendToDataLabel_, confGeomXMLFiles_);
134  }
135 }
136 
138  LogVerbatim("Geometry") << "DDDetectorESProducer::Produce " << appendToDataLabel_;
139  return make_unique<DDDetector>(appendToDataLabel_, confGeomXMLFiles_);
140 }
141 
edm::ESGetToken< FileBlob, GeometryFileRcd > geomToken_
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
unique_ptr< DDDetector > ReturnType
edm::ESGetToken< FileBlob, MFGeometryFileRcd > mfToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setIntervalFor(const eventsetup::EventSetupRecordKey &, const IOVSyncValue &, ValidityInterval &) override
Namespace of DDCMS conversion namespace.
ReturnType produceMagField(const IdealMagneticFieldRecord &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(ConfigurationDescriptions &)
DDDetectorESProducer(const ParameterSet &)
HLT enums.
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
ReturnType produceGeom(const IdealGeometryRecord &)