CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/GeometryReaders/XMLIdealGeometryESSource/src/XMLIdealGeometryESSource.cc

Go to the documentation of this file.
00001 #include "GeometryReaders/XMLIdealGeometryESSource/interface/XMLIdealGeometryESSource.h"
00002 
00003 #include "DetectorDescription/Base/interface/DDdebug.h"
00004 #include "DetectorDescription/Parser/interface/DDLParser.h"
00005 #include "DetectorDescription/Core/interface/DDCompactView.h"
00006 #include "DetectorDescription/Core/interface/DDRoot.h"
00007 
00008 #include "DetectorDescription/Core/interface/DDMaterial.h"
00009 #include "DetectorDescription/Core/interface/DDSolid.h"
00010 #include "DetectorDescription/Core/interface/DDSpecifics.h"
00011 #include "DetectorDescription/Base/interface/DDRotationMatrix.h"
00012 
00013 #include "DetectorDescription/Core/src/Material.h"
00014 #include "DetectorDescription/Core/src/Solid.h"
00015 #include "DetectorDescription/Core/src/LogicalPart.h"
00016 #include "DetectorDescription/Core/src/Specific.h"
00017 
00018 #include "FWCore/ParameterSet/interface/FileInPath.h"
00019 
00020 #include <memory>
00021 
00022 
00023 XMLIdealGeometryESSource::XMLIdealGeometryESSource(const edm::ParameterSet & p): rootNodeName_(p.getParameter<std::string>("rootNodeName")),
00024                                                                                  userNS_(p.getUntrackedParameter<bool>("userControlledNamespace", false)),
00025                                                                                  geoConfig_(p)
00026 {
00027   if ( rootNodeName_ == "" || rootNodeName_ == "\\" ) {
00028     throw cms::Exception("DDException") << "XMLIdealGeometryESSource must have a root node name.";
00029   }
00030   
00031   if ( rootNodeName_ == "MagneticFieldVolumes:MAGF" ||  rootNodeName_ == "cmsMagneticField:MAGF") {
00032     setWhatProduced(this, &XMLIdealGeometryESSource::produceMagField, 
00033                     edm::es::Label(p.getParameter<std::string>("@module_label")));
00034     findingRecord<IdealMagneticFieldRecord>();
00035   } else {
00036     setWhatProduced(this, &XMLIdealGeometryESSource::produceGeom, 
00037                     edm::es::Label(p.getParameter<std::string>("@module_label")));
00038     findingRecord<IdealGeometryRecord>();
00039   }
00040 }
00041 
00042 XMLIdealGeometryESSource::~XMLIdealGeometryESSource() { }
00043 
00044 std::auto_ptr<DDCompactView>
00045 XMLIdealGeometryESSource::produceGeom(const IdealGeometryRecord &)
00046 {
00047   return produce();
00048 }
00049 
00050 std::auto_ptr<DDCompactView>
00051 XMLIdealGeometryESSource::produceMagField(const IdealMagneticFieldRecord &)
00052 { 
00053   return produce();
00054 }
00055 
00056 
00057 std::auto_ptr<DDCompactView>
00058 XMLIdealGeometryESSource::produce() {
00059   
00060   DDName ddName(rootNodeName_);
00061   DDLogicalPart rootNode(ddName);
00062   DDRootDef::instance().set(rootNode);
00063   std::auto_ptr<DDCompactView> returnValue(new DDCompactView(rootNode));
00064   DDLParser parser(*returnValue); //* parser = DDLParser::instance();
00065   parser.getDDLSAX2FileHandler()->setUserNS(userNS_);
00066   int result2 = parser.parse(geoConfig_);
00067   if (result2 != 0) throw cms::Exception("DDException") << "DDD-Parser: parsing failed!";
00068 
00069   // after parsing the root node should be valid!
00070 
00071   if( !rootNode.isValid() ){
00072     throw cms::Exception("Geometry")<<"There is no valid node named \""
00073                                     <<rootNodeName_<<"\"";
00074   }
00075   returnValue->lockdown();  
00076   return returnValue;
00077 }
00078 
00079 void XMLIdealGeometryESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
00080                                               const edm::IOVSyncValue & iosv, 
00081                                               edm::ValidityInterval & oValidity)
00082 {
00083   edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
00084   oValidity = infinity;
00085 }
00086 
00087 
00088 #include "FWCore/Framework/interface/SourceFactory.h"
00089 
00090 
00091 DEFINE_FWK_EVENTSETUP_SOURCE(XMLIdealGeometryESSource);
00092 
00093