CMS 3D CMS Logo

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