// // $Id: StandaloneGeometry.cpp,v 1.3 2005/12/16 21:34:27 snyder Exp $ // // File: smt_get_geometry.cpp // Purpose: // Created: 1-FEB-2001 John D. Hobbs // // $Revision: 1.3 $ // // // Include files #include #include #include "silicon_geometry/base/SiGeometer.hpp" #include "silicon_geometry/utils/StandaloneGeometry.hpp" using namespace std; StandaloneGeometry::StandaloneGeometry(const int argc, char **argv): _file(false), _ftype("EVPACK"), _fname("SiBaseGeometry") { // Stash the command line arguments for( int i=0 ; irefresh(_smtdet); } // and hand it off... return _smtdet; } void StandaloneGeometry::get_modified_args(vector &partialArgv) const { int i=0,iskip=0; partialArgv.clear(); // This loop relies on the entries in _used_args being sorted in increasing // order. This is guaranteed by the parser in the constructor. while( i<_argv.size() ) { if( iskip>=_used_args.size() || _used_args[iskip] != i ) partialArgv.push_back(_argv[i]); else if( iskip<_used_args.size() ) ++iskip; ++i; } } #include "rcp/RCP.hpp" #include "rcp/RCPManager.hpp" using namespace edm; void StandaloneGeometry::smt_build_default() const { cout << "Building the silicon geometry from RCP in " << _fname << endl; // Instantiate an RCP manager and read the silicon geometry RCP... RCPManager* rcpman = RCPManager::instance(); RCP SiDefaultRCP = rcpman->extract("silicon_geometry",_fname); // Instantiate a copy of the base geometry... _smtdet = SiBaseGeometry::build_default(&SiDefaultRCP); } #include "d0stream/d0StreamFactory.hpp" #include "d0stream/d0Stream.hpp" void StandaloneGeometry::smt_read_geometry() const { _smtdet = smt_read_geometry(_fname,_ftype); } d0_Ref StandaloneGeometry::smt_read_geometry(const string fname, const string ftype) { cout << "Reading the geoemtry from " << fname << endl; // Initialize d0om and open the input file d0om_init("d0Reader"); d0StreamFactory* theFactory = d0StreamFactory::locateStreamFactory(); d0Stream* geomfile = theFactory->make_d0Stream(fname.c_str(), ftype.c_str(),ios::in); if( !geomfile ) { cerr << "Error opening input file" << fname << endl; throw "Cannot open input file"; } // Read the geometry d0Key mykey("SiBaseGeometry"); d0_Ref_Any reader = geomfile->read(&mykey); if( !reader ) { cerr << "Fatal error reading from " << fname << endl; throw "Cannot read data"; } geomfile->close(); return d0om::refcast(reader); } ostream& operator <<(ostream& os, const StandaloneGeometry& me) { os << "[-f=] [-r=] [-d]" << endl; return os; }