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 
29 
34 #include "DD4hep/Detector.h"
35 
36 using namespace std;
37 using namespace cms;
38 using namespace edm;
39 
41 public:
43  ~DDDetectorESProducer() override;
44 
45  using ReturnType = unique_ptr<DDDetector>;
47 
48  ReturnType produceGeom(const IdealGeometryRecord&);
49  ReturnType produceMagField(const IdealMagneticFieldRecord&);
50  ReturnType produce();
52 
53 protected:
54  void setIntervalFor(const eventsetup::EventSetupRecordKey&, const IOVSyncValue&, ValidityInterval&) override;
55 
56 private:
57  const bool fromDB_;
58  const string appendToDataLabel_;
59  const string confGeomXMLFiles_;
60  const string rootDDName_;
61  const string label_;
64 };
65 
67  : fromDB_(iConfig.getParameter<bool>("fromDB")),
68  appendToDataLabel_(iConfig.getParameter<string>("appendToDataLabel")),
69  confGeomXMLFiles_(fromDB_ ? "none" : iConfig.getParameter<FileInPath>("confGeomXMLFiles").fullPath()),
70  rootDDName_(iConfig.getParameter<string>("rootDDName")),
71  label_(iConfig.getParameter<string>("label")) {
73  if (rootDDName_ == "MagneticFieldVolumes:MAGF" || rootDDName_ == "cmsMagneticField:MAGF") {
74  auto c = setWhatProduced(this,
76  edm::es::Label(iConfig.getParameter<std::string>("@module_label")));
77  if (fromDB_) {
78  mfToken_ = c.consumes(edm::ESInputTag("", label_));
79  }
80  findingRecord<IdealMagneticFieldRecord>();
81  } else {
83  if (fromDB_) {
84  geomToken_ = c.consumes(edm::ESInputTag("", label_));
85  }
86  findingRecord<IdealGeometryRecord>();
87  }
88 }
89 
91 
94 
95  desc.addOptional<FileInPath>("confGeomXMLFiles");
96  desc.add<string>("rootDDName", "cms:OCMS");
97  desc.add<string>("label", "");
98  desc.add<bool>("fromDB", false);
99  descriptions.add("DDDetectorESProducer", desc);
100 
102  descDB.add<string>("rootDDName", "cms:OCMS");
103  descDB.add<string>("label", "Extended");
104  descDB.add<bool>("fromDB", true);
105  descriptions.add("DDDetectorESProducerFromDB", descDB);
106 }
107 
109  const IOVSyncValue& iTime,
110  ValidityInterval& oInterval) {
111  oInterval = ValidityInterval(IOVSyncValue::beginOfTime(), IOVSyncValue::endOfTime()); //infinite
112 }
113 
115  LogVerbatim("Geometry") << "DDDetectorESProducer::Produce MF " << appendToDataLabel_;
116  if (fromDB_) {
118  unique_ptr<vector<unsigned char> > tb = (*gdd).getUncompressedBlob();
119 
120  return make_unique<cms::DDDetector>(label_, string(tb->begin(), tb->end()), true);
121  } else {
122  return make_unique<DDDetector>(appendToDataLabel_, confGeomXMLFiles_);
123  }
124 }
125 
127  LogVerbatim("Geometry") << "DDDetectorESProducer::Produce " << appendToDataLabel_;
128  if (fromDB_) {
130  unique_ptr<vector<unsigned char> > tb = (*gdd).getUncompressedBlob();
131 
132  return make_unique<cms::DDDetector>(label_, string(tb->begin(), tb->end()), true);
133  } else {
134  return make_unique<DDDetector>(appendToDataLabel_, confGeomXMLFiles_, false);
135  }
136 }
137 
139  LogVerbatim("Geometry") << "DDDetectorESProducer::Produce " << appendToDataLabel_;
140  return make_unique<DDDetector>(appendToDataLabel_, confGeomXMLFiles_, false);
141 }
142 
DDDetectorESProducer::appendToDataLabel_
const string appendToDataLabel_
Definition: DDDetectorESProducer.cc:58
electrons_cff.bool
bool
Definition: electrons_cff.py:366
DDDetectorESProducer::geomToken_
edm::ESGetToken< FileBlob, GeometryFileRcd > geomToken_
Definition: DDDetectorESProducer.cc:63
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:108
DDDetectorESProducer::produceGeom
ReturnType produceGeom(const IdealGeometryRecord &)
Definition: DDDetectorESProducer.cc:126
DDDetectorESProducer::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &)
Definition: DDDetectorESProducer.cc:92
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm
HLT enums.
Definition: AlignableModifier.h:19
DDDetectorESProducer::Detector
dd4hep::Detector Detector
Definition: DDDetectorESProducer.cc:46
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
DDDetectorESProducer::ReturnType
unique_ptr< DDDetector > ReturnType
Definition: DDDetectorESProducer.cc:45
DDDetector.h
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::ESSharedResourceNames::kDD4Hep
static const std::string kDD4Hep
Definition: SharedResourceNames.h:38
FileBlob.h
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
DDDetectorESProducer::DDDetectorESProducer
DDDetectorESProducer(const ParameterSet &)
Definition: DDDetectorESProducer.cc:66
DDDetectorESProducer::produce
ReturnType produce()
Definition: DDDetectorESProducer.cc:138
IdealMagneticFieldRecord
Definition: IdealMagneticFieldRecord.h:11
edm::FileInPath
Definition: FileInPath.h:61
GeometryFileRcd.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
geometryPPS_CMSxz_fromDD_2016_cfi.DDDetectorESProducer
DDDetectorESProducer
Definition: geometryPPS_CMSxz_fromDD_2016_cfi.py:3
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::eventsetup::DependentRecordImplementation::getTransientHandle
ESTransientHandle< ProductT > getTransientHandle(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:98
edm::ESProducer::usesResources
void usesResources(std::vector< std::string > const &)
Definition: ESProducer.cc:117
IdealMagneticFieldRecord.h
edm::es::Label
Definition: es_Label.h:56
SharedResourceNames.h
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
SourceFactory.h
edm::ParameterSet
Definition: ParameterSet.h:47
DDDetectorESProducer::label_
const string label_
Definition: DDDetectorESProducer.cc:61
DDDetectorESProducer::rootDDName_
const string rootDDName_
Definition: DDDetectorESProducer.cc:60
DDDetectorESProducer::fromDB_
const bool fromDB_
Definition: DDDetectorESProducer.cc:57
DDDetectorESProducer::~DDDetectorESProducer
~DDDetectorESProducer() override
Definition: DDDetectorESProducer.cc:90
IdealGeometryRecord.h
DDDetectorESProducer::produceMagField
ReturnType produceMagField(const IdealMagneticFieldRecord &)
Definition: DDDetectorESProducer.cc:114
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< FileBlob, MFGeometryFileRcd >
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
align::Detector
Definition: StructureType.h:92
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition: Time.h:17
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
DDDetectorESProducer::confGeomXMLFiles_
const string confGeomXMLFiles_
Definition: DDDetectorESProducer.cc:59
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
DDDetectorESProducer::mfToken_
edm::ESGetToken< FileBlob, MFGeometryFileRcd > mfToken_
Definition: DDDetectorESProducer.cc:62
DDDetectorESProducer
Definition: DDDetectorESProducer.cc:40
edm::ESProducer
Definition: ESProducer.h:104
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21