CMS 3D CMS Logo

XMLIdealGeometryESSource.cc
Go to the documentation of this file.
2 
4 
8 
13 
18 
20 
21 #include <memory>
22 
24  : rootNodeName_(p.getParameter<std::string>("rootNodeName")),
25  userNS_(p.getUntrackedParameter<bool>("userControlledNamespace", false)),
26  geoConfig_(p) {
28 
29  if (rootNodeName_.empty() || rootNodeName_ == "\\") {
30  throw cms::Exception("DDException") << "XMLIdealGeometryESSource must have a root node name.";
31  }
32 
33  if (rootNodeName_ == "MagneticFieldVolumes:MAGF" || rootNodeName_ == "cmsMagneticField:MAGF") {
35  this, &XMLIdealGeometryESSource::produceMagField, edm::es::Label(p.getParameter<std::string>("@module_label")));
36  findingRecord<IdealMagneticFieldRecord>();
37  } else {
39  this, &XMLIdealGeometryESSource::produceGeom, edm::es::Label(p.getParameter<std::string>("@module_label")));
40  findingRecord<IdealGeometryRecord>();
41  }
42 }
43 
45 
46 std::unique_ptr<DDCompactView> XMLIdealGeometryESSource::produceGeom(const IdealGeometryRecord &) { return produce(); }
47 
49  return produce();
50 }
51 
52 std::unique_ptr<DDCompactView> XMLIdealGeometryESSource::produce() {
53  DDName ddName(rootNodeName_);
54  DDLogicalPart rootNode(ddName);
55  DDRootDef::instance().set(rootNode);
56  std::unique_ptr<DDCompactView> returnValue(new DDCompactView(rootNode));
57  DDLParser parser(*returnValue); //* parser = DDLParser::instance();
58  parser.getDDLSAX2FileHandler()->setUserNS(userNS_);
59  int result2 = parser.parse(geoConfig_);
60  if (result2 != 0)
61  throw cms::Exception("DDException") << "DDD-Parser: parsing failed!";
62 
63  // after parsing the root node should be valid!
64 
65  if (!rootNode.isValid()) {
66  throw cms::Exception("Geometry") << "There is no valid node named \"" << rootNodeName_ << "\"";
67  }
68  returnValue->lockdown();
69  return returnValue;
70 }
71 
73  const edm::IOVSyncValue &iosv,
74  edm::ValidityInterval &oValidity) {
76  oValidity = infinity;
77 }
78 
80 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
XMLIdealGeometryESSource(const edm::ParameterSet &p)
std::unique_ptr< DDCompactView > produce()
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
void usesResources(std::vector< std::string > const &)
Definition: ESProducer.cc:86
bool isValid() const
true, if the wrapped pointer is valid
Definition: DDBase.h:95
static value_type & instance()
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
static const std::string kDDGeometry
const double infinity
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
GeometryConfiguration geoConfig_
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
std::unique_ptr< DDCompactView > produceGeom(const IdealGeometryRecord &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
std::unique_ptr< DDCompactView > produceMagField(const IdealMagneticFieldRecord &)