// // $Id: build_geometry.cpp,v 1.6 2000/05/12 20:29:54 hobbs Exp $ // // File: build_geometry.cpp // Purpose: // Created: 21-FEB-1998 John Hobbs // // $Revision: 1.6 $ // // // Include files #include #include "../base/BaseGeometry.hpp" #include #include #include // RCP stuff #include #include #include using namespace std; using edm::RCPManager; using edm::RCP; int main(int argc, char **argv) // // Purpose: Instantiate a base geometry and if a file name is given on the // command line, save the geometry to that file. In both cases, // the text dump method is invoked // Returns: 0 = no errors // 1 = errors // { d0om_init("GeometrySaver"); char* ftype="DSPACK"; // Proper argument count? if( argc<1 || argc >4 ) { cerr << "Usage: build_geometry [-d] [-z] [output_file_name]" << endl; return(1); } // Command line parsing... bool dump=false; string geofile(""); for( int i=1 ; i base; try { RCP DefaultRCP = rcpman->extract("d0_geometry","BaseGeometry"); cout << DefaultRCP << endl; base = BaseGeometry::build_default(&DefaultRCP); } catch(runtime_error mistake) { cerr << "Caught error: " << mistake.what() << endl; return(1); } if( base.ptr() == 0 ) { cerr << "Null geometry pointer from BaseGeometry::build_default" << endl; return(1); } else { cout << "Default detector geometry created" << endl; if( dump ) cout << *base << endl; } // Do optional save to file here... if( argc >= 2 ) { // Initialize d0om and open output d0StreamFactory* theFactory = d0StreamFactory::locateStreamFactory(); d0Stream* out = theFactory->make_d0Stream(geofile,ftype,ios::out); if( !out ) { cerr << "Error opening output file" << endl; return(1); } // Write it out and close... out->write(*base); out->close(); } return 0; }