00001 #include "CondCore/IdealGeometryPlugins/interface/IdealGeometryProxy.h" 00002 #include "DetectorDescription/PersistentDDDObjects/interface/DDPersToDDDFactory.h" 00003 00004 //TEMPORARY!!! 00005 //#include "DetectorDescription/Core/interface/DDExpandedView.h" 00006 //END TEMPORARY!!! 00007 00008 00009 DataProxy<IdealGeometryRecord, DDCompactView>::DataProxy( cond::Connection* connection 00010 , std::map<std::string,std::string>::iterator& pDatumToToken ) 00011 : m_connection(connection), m_pDatumToToken(pDatumToToken) 00012 { 00013 // std::cout<<"IdealGeometry DataProxy constructor"<<std::endl; 00014 edm::eventsetup::DataKey::makeTypeTag<DDCompactView>(); 00015 // std::cout<<"IdealGeometry DataProxy constructor "<<m_pProxyToToken->second<<std::endl; 00016 } 00017 00018 DataProxy<IdealGeometryRecord, DDCompactView>::~DataProxy() { } 00019 00020 const DDCompactView* DataProxy<IdealGeometryRecord, DDCompactView>::make(const IdealGeometryRecord& 00021 , const edm::eventsetup::DataKey&) 00022 { 00023 PIdealGeometry* result = 0; 00024 DDCompactView* returnValue = 0; 00025 std::cout << " ENTER IdealGeometryProxy make " << std::endl << std::flush; 00026 // try{ 00027 std::cout<<"IdealGeometryProxy make "<<std::endl; 00028 cond::PoolTransaction& pooldb=m_connection->poolTransaction(); 00029 pooldb.start(true); 00030 pool::Ref<PIdealGeometry> mydata (&(pooldb.poolDataSvc()),m_pDatumToToken->second); 00031 result=mydata.ptr(); 00032 m_data.copyShallow(mydata); 00033 //cond::TypedRef<PIdealGeometry>(m_pooldb->poolTransaction(),m_pProxyToToken->second); 00034 // *m_data; 00035 pooldb.commit(); 00036 // }catch( const cond::Exception& er ){ 00037 // std::cout << "caught a cond::Exception" << std::endl; 00038 // throw er; 00039 // }catch( const std::exception& er ){ 00040 // std::cout << "caught a cond::exception" << std::endl; 00041 // throw cond::Exception( er.what() ); 00042 // }catch( ... ){ 00043 // std::cout << "caught a non-cond exception." << std::endl; 00044 // throw cond::Exception( "Unknown error" ); 00045 // } 00046 00047 // Make the DDCompactView from PIdealGeometry 00048 00049 // std::cout<<"ref belongs to container "<< m_data.containerName()<<std::endl; 00050 // std::cout << "(*m_data).pStrings.size() is " << (*m_data).pStrings.size() << std::endl; 00051 if (!result) { 00052 throw cond::Exception("IdealGeometryProxy specialization of DataProxy::make: null result"); 00053 } else { 00054 DDPersToDDDFactory ddFact(&((*m_data).pStrings)); 00055 for(std::vector<PRotation>::const_iterator rit = (*m_data).pRotations.begin(); 00056 rit != (*m_data).pRotations.end(); ++rit) { 00057 ddFact.rotation( *rit ); 00058 } 00059 // std::cout << "about to do Materials" << std::endl; 00060 for(std::vector<PMaterial>::const_iterator mit = (*m_data).pMaterials.begin(); 00061 mit != (*m_data).pMaterials.end(); ++mit) { 00062 ddFact.material( *mit ); 00063 } 00064 // std::cout << "about to do Solids" << std::endl; 00065 for(std::vector<PSolid>::const_iterator sit = (*m_data).pSolids.begin(); 00066 sit != (*m_data).pSolids.end(); ++sit) { 00067 ddFact.solid( *sit ); 00068 } 00069 // std::cout << "about to do LogicalParts" << std::endl; 00070 for(std::vector<PLogicalPart>::const_iterator lit = (*m_data).pLogicalParts.begin(); 00071 lit != (*m_data).pLogicalParts.end(); ++lit) { 00072 // std::cout << "making part " << lit->pName << std::endl; 00073 DDLogicalPart lp = ddFact.logicalPart ( *lit ); 00074 // std::cout << lp << std::endl; 00075 } 00076 00077 // std::cout << "about to setRoot to " << (*m_data).pStartNode << std::endl; 00078 ddFact.setRoot( (*m_data).pStartNode ); 00079 // std::cout << "about to do PosParts" << std::endl; 00080 for(std::vector<PPosPart>::const_iterator pit = (*m_data).pPosParts.begin(); 00081 pit != (*m_data).pPosParts.end(); ++pit) { 00082 ddFact.position( *pit ); 00083 } 00084 00085 // std::cout << "about to do SpecPars" << std::endl; 00086 for(std::vector<PSpecPar>::const_iterator spit = (*m_data).pSpecPars.begin(); 00087 spit != (*m_data).pSpecPars.end(); ++spit) { 00088 ddFact.specPar( *spit ); 00089 } 00090 00091 // HOW TO DO THIS? for now just return the plain old DDCompactView 00092 /* if ( (*m_data).pStartNode == "MagneticFieldVolumes:MAGF" ){ 00093 setWhatProduced(this, &PoolDBESSource::produceMagField, 00094 edm::es::Label(pset.getParameter<std::string>("@module_label"))); 00095 findingRecord<IdealMagneticFieldRecord>(); 00096 } else { 00097 setWhatProduced(this, &PoolDBESSource::produceGeom ); 00098 findingRecord<IdealGeometryRecord>(); 00099 } 00100 */ 00101 // DDCompactView global; 00102 DDName ddRoot((*m_data).pStartNode); 00103 DDLogicalPart rootNode(ddRoot); 00104 if(! rootNode.isValid()){ 00105 throw cms::Exception("Geometry")<<"There is no valid node named \"" 00106 <<(*m_data).pStartNode<<"\""; 00107 } 00108 returnValue = new DDCompactView(rootNode); 00109 DDCompactView globalOne; 00110 returnValue->writeableGraph() = globalOne.graph(); 00111 } 00112 00113 return returnValue; 00114 } 00115 00116 void DataProxy<IdealGeometryRecord, DDCompactView>::invalidateCache() { 00117 m_data.clear(); 00118 }