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 
DDDetectorESProducer::appendToDataLabel_
const string appendToDataLabel_
Definition: DDDetectorESProducer.cc:57
electrons_cff.bool
bool
Definition: electrons_cff.py:372
DDDetectorESProducer::geomToken_
edm::ESGetToken< FileBlob, GeometryFileRcd > geomToken_
Definition: DDDetectorESProducer.cc:62
edm::ESInputTag
Definition: ESInputTag.h:87
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
MFGeometryFileRcd.h
ESHandle.h
DDDetectorESProducer::setIntervalFor
void setIntervalFor(const eventsetup::EventSetupRecordKey &, const IOVSyncValue &, ValidityInterval &) override
Definition: DDDetectorESProducer.cc:107
DDDetectorESProducer::produceGeom
ReturnType produceGeom(const IdealGeometryRecord &)
Definition: DDDetectorESProducer.cc:125
DDDetectorESProducer::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &)
Definition: DDDetectorESProducer.cc:91
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm
HLT enums.
Definition: AlignableModifier.h:19
DDDetectorESProducer::Detector
dd4hep::Detector Detector
Definition: DDDetectorESProducer.cc:45
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
DDDetectorESProducer::ReturnType
unique_ptr< DDDetector > ReturnType
Definition: DDDetectorESProducer.cc:44
volumeBasedMagneticField_dd4hep_160812_cfi.DDDetectorESProducer
DDDetectorESProducer
Definition: volumeBasedMagneticField_dd4hep_160812_cfi.py:13
edm::ParameterSetDescription::addOptional
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:105
DDDetector.h
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
FileBlob.h
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
DDDetectorESProducer::DDDetectorESProducer
DDDetectorESProducer(const ParameterSet &)
Definition: DDDetectorESProducer.cc:65
DDDetectorESProducer::produce
ReturnType produce()
Definition: DDDetectorESProducer.cc:137
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
edm::FileInPath
Definition: FileInPath.h:64
GeometryFileRcd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:99
IdealMagneticFieldRecord.h
edm::es::Label
Definition: es_Label.h:54
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SourceFactory.h
edm::ParameterSet
Definition: ParameterSet.h:36
DDDetectorESProducer::label_
const string label_
Definition: DDDetectorESProducer.cc:60
DDDetectorESProducer::rootDDName_
const string rootDDName_
Definition: DDDetectorESProducer.cc:59
DDDetectorESProducer::fromDB_
const bool fromDB_
Definition: DDDetectorESProducer.cc:56
edm::LogVerbatim
Definition: MessageLogger.h:297
DDDetectorESProducer::~DDDetectorESProducer
~DDDetectorESProducer() override
Definition: DDDetectorESProducer.cc:89
IdealGeometryRecord.h
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DDDetectorESProducer::produceMagField
ReturnType produceMagField(const IdealMagneticFieldRecord &)
Definition: DDDetectorESProducer.cc:113
edm::ESGetToken< FileBlob, MFGeometryFileRcd >
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
align::Detector
Definition: StructureType.h:86
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
std
Definition: JetResolutionObject.h:76
DDDetectorESProducer::confGeomXMLFiles_
const string confGeomXMLFiles_
Definition: DDDetectorESProducer.cc:58
DDDetectorESProducer::mfToken_
edm::ESGetToken< FileBlob, MFGeometryFileRcd > mfToken_
Definition: DDDetectorESProducer.cc:61
DDDetectorESProducer
Definition: DDDetectorESProducer.cc:39
edm::ESProducer
Definition: ESProducer.h:101
IdealGeometryRecord
Definition: IdealGeometryRecord.h:27
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21