CMS 3D CMS Logo

XMLIdealGeometryESSource.cc

Go to the documentation of this file.
00001 #include "GeometryReaders/XMLIdealGeometryESSource/interface/XMLIdealGeometryESSource.h"
00002 #include "GeometryReaders/XMLIdealGeometryESSource/interface/GeometryConfiguration.h"
00003 
00004 #include "DetectorDescription/Base/interface/DDException.h"
00005 #include "DetectorDescription/Base/interface/DDdebug.h"
00006 #include "DetectorDescription/Parser/interface/DDLParser.h"
00007 #include "DetectorDescription/Core/interface/DDCompactView.h"
00008 #include "DetectorDescription/Core/interface/DDRoot.h"
00009 
00010 #include "FWCore/ParameterSet/interface/FileInPath.h"
00011 
00012 #include <memory>
00013 
00014 
00015 XMLIdealGeometryESSource::XMLIdealGeometryESSource(const edm::ParameterSet & p): rootNodeName_(p.getParameter<std::string>("rootNodeName"))
00016 {
00017     DDLParser * parser = DDLParser::instance();
00018     GeometryConfiguration cf(p);
00019     if ( rootNodeName_ == "" || rootNodeName_ == "\\" ) {
00020       throw DDException ("XMLIdealGeometryESSource must have a root node name.");
00021     }
00022 
00023     DDRootDef::instance().set(DDName(rootNodeName_));
00024 
00025     int result2 = parser->parse(cf);
00026 
00027     if (result2 != 0) throw DDException("DDD-Parser: parsing failed!");
00028 
00029     if ( !bool(DDLogicalPart( DDName(rootNodeName_) )) ) {
00030       throw DDException ("XMLIdealGeometryESSource was given a non-existent node name for the root. " + rootNodeName_ );
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       findingRecord<IdealGeometryRecord>();
00039     }
00040       //use the label specified in the configuration file as the 
00041       // label client code must use to get the DDCompactView
00042       //      if(""==p.getParameter<std::string>("@module_label")){
00043       //        setWhatProduced(this);
00044       //      }else {
00045       //        setWhatProduced(this,p.getParameter<std::string>("@module_label"));
00046       //      }
00047       //    findingRecord<IdealGeometryRecord>();
00048 }
00049 
00050 XMLIdealGeometryESSource::~XMLIdealGeometryESSource() {
00051   DDCompactView cpv;
00052   cpv.clear();
00053 }
00054 
00055 std::auto_ptr<DDCompactView>
00056 XMLIdealGeometryESSource::produceGeom(const IdealGeometryRecord &)
00057 {
00058   return produce();
00059 }
00060 
00061 std::auto_ptr<DDCompactView>
00062 XMLIdealGeometryESSource::produceMagField(const IdealMagneticFieldRecord &)
00063 { 
00064   return produce();
00065 }
00066 
00067 
00068 std::auto_ptr<DDCompactView>
00069 XMLIdealGeometryESSource::produce() {
00070    //std::cout <<"got in produce"<<std::endl;
00071    DDName ddName(rootNodeName_);
00072    //std::cout <<"ddName \""<<ddName<<"\""<<std::endl;
00073    DDLogicalPart rootNode(ddName);
00074    //std::cout <<"made the DDLogicalPart"<<std::endl;
00075    if(! rootNode.isValid()){
00076       throw cms::Exception("Geometry")<<"There is no valid node named \""
00077                                       <<rootNodeName_<<"\"";
00078    }
00079    std::auto_ptr<DDCompactView> returnValue(new DDCompactView(rootNode));
00080 
00081 // NOTE TO SELF:  Mike, DO NOT try to fix the memory leak here by going global again!!!
00082    //copy the graph from the global one
00083    DDCompactView globalOne;
00084    returnValue->writeableGraph() = globalOne.graph();
00085    //std::cout <<"made the view"<<std::endl;
00086    return returnValue;
00087 }
00088 
00089 void XMLIdealGeometryESSource::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
00090                                                const edm::IOVSyncValue & iosv, 
00091                                                edm::ValidityInterval & oValidity)
00092 {
00093    edm::ValidityInterval infinity(iosv.beginOfTime(), iosv.endOfTime());
00094    oValidity = infinity;
00095 }
00096 
00097 
00098 #include "FWCore/Framework/interface/SourceFactory.h"
00099 
00100 
00101 DEFINE_FWK_EVENTSETUP_SOURCE(XMLIdealGeometryESSource);
00102 
00103 

Generated on Tue Jun 9 17:37:35 2009 for CMSSW by  doxygen 1.5.4