// // $Id: extract_geometry.cpp,v 1.2 2001/09/21 19:37:47 hobbs Exp $ // // File: extract_geometry.cpp // Purpose: Copy the geometry from one subdetector into a file by itself // Created: 3-FEB-2001 John D. Hobbs // // $Revision: 1.2 $ // // // Include files #include #include #include #include #include "d0_geometry/base/BaseGeometry.hpp" #include "d0_geometry/base/d0StandaloneGeometry.hpp" #include "d0stream/d0StreamFactory.hpp" #include "d0stream/d0Stream.hpp" #include "silicon_geometry/base/SiBaseGeometry.hpp" #include "cft_geometry/base/CftBaseGeometry.hpp" #include "cps_geometry/base/CpsBaseGeometry.hpp" #include "fps_geometry/base/FPSBaseGeometry.hpp" #include "calorimeter_geometry/base/CalBaseGeometry.hpp" #include "muon_geometry/base/MuoBaseGeometry.hpp" // Global definitions using namespace std; int main(int argc, char **argv) { // Always gotta' initialize d0om d0om_init("Extractor"); // Get the geometry d0StandaloneGeometry d0geom(argc,argv); d0_Ref d0 = d0geom.get_geometry(); if( d0.is_null() ) { cout << "Error getting geometry using " << d0geom.get_file_name(); return 1; } // Get the unused elements of the command line. The first is assumed to // be argv[0], the executable name. The next is the desired subdetector // text name (SMT, CFT, CPS, FPS, CAL, MUO) and the last is the output // file name. vector rest; d0geom.get_modified_args(rest); if( rest.size() != 3 ) { cout << "Wrong number of command strings. Expect subdet and filename" << endl; return 2; } string detname(rest[1]); // Do I know the requested subdet? vector subdets; subdets.push_back("SMT"); subdets.push_back("CFT"); subdets.push_back("CPS"); subdets.push_back("FPS"); subdets.push_back("CAL"); subdets.push_back("MUO"); if( find(subdets.begin(),subdets.end(),rest[1]) == subdets.end() ) { cout << "Unknown subdetector: " << rest[1] << endl; return 3; } // Open the output file and write the requested subdetector d0StreamFactory *dsf = d0StreamFactory::locateStreamFactory(); d0Stream* os = dsf->make_d0Stream(rest[2],"EVPACK",ios::out); if( !os ) { cout << "Error opening output file " << rest[2] << endl; return 4; } if( detname == string("SMT") ) { d0_Ref smt = d0->get_mutable_silicon(); os->write(*smt); } if( detname == string("CFT") ) { d0_Ref cft = d0->get_mutable_cft(); os->write(*cft); } if( detname == string("CPS") ) { d0_Ref cps = d0->get_mutable_cps(); os->write(*cps); } if( detname == string("FPS") ) { d0_Ref fps = d0->get_mutable_fps(); os->write(*fps); } if( detname == string("CAL") ) { d0_Ref cal = d0->get_mutable_calorimeter(); os->write(*cal); } if( detname == string("MUO") ) { d0_Ref muo = d0->get_mutable_muon(); os->write(*muo); } os->close(); // Bye bye return 0; }