// // $Id: smt_local_to_global.cpp,v 1.2 2005/04/03 15:36:37 shfu Exp $ // // File: local_to_global.cpp // Purpose: Shell giving command line conversion of hits from local to global // coordinates. Uses default geometry and reads from standard input // Created: 02-JUN-1998 John Hobbs // // Jan 24, 2005 by Shaohua Fu // added Layer0 // SFL0_Jan_2005 // // $Revision: 1.2 $ // // // Include files #include #include "d0om/d0_Ref.hpp" #include "geometry_system/components/CartesianCoordinate.hpp" #include #include "silicon_geometry/base/SiGeometer.hpp" #include "silicon_geometry/base/SiBaseGeometry.hpp" #include "silicon_geometry/utils/smt_build_default.hpp" using namespace std; using namespace dgs; int main() // // Purpose: // // Arguements: // // Returns: // { // Instantiate the detector d0_Ref theDetector = smt_build_default(); SiGeometer* theGeometer = SiGeometer::get_instance(); // and process user inputs int barrelID,layerID,ladderID; int dettype; // added SFL0_Jan_2005 double xlocal, zlocal; cout << "Usage: input dettype barrel layer ladder xlocal zlocal" << endl; // added SFL0_Jan_2005 cout << " -1 -1 0 0 0 0 to stop" << endl; // added SFL0_Jan_2005 //cin >> barrelID >> layerID >> ladderID >> xlocal >> zlocal; // cmt.out SFL0_Jan_2005 cin >> dettype >> barrelID >> layerID >> ladderID >> xlocal >> zlocal; // added SFL0_Jan_2005 std::cout.setf(ios::fixed|ios::showpoint,ios::scientific); //while( !cin.eof() && barrelID != (-1) ) { // Two ways to end processing... // cmt.out SFL0_Jan_2005 while( !cin.eof() && barrelID != (-1) && dettype != (-1) ) { // added SFL0_Jan_2005 if (dettype == 1) { // added SFL0_Jan_2005 //const SiLadder* theLadder = theGeometer->get_ladder(barrelID,layerID,ladderID); // cmt.out SFL0_Jan_2005 const SiLadder* theLadder = theGeometer->get_ladder(0,barrelID,layerID,ladderID); // added SFL0_Jan_2005 if( theLadder ) { CartesianCoordinate local(xlocal,0.0,zlocal); SpacePoint g = theLadder->local_to_global(local); std::cout << "Local(barrel,layer,ladder: " << barrelID << "," << layerID << "," << ladderID << ") (" << xlocal << "," << zlocal << ") gives global (" << setw(8) << setprecision(3) << g.x() << "," << setw(8) << setprecision(3) << g.y() << "," << setw(8) << setprecision(3) << g.z() << ")" << endl; } else std::cerr << "Error getting (barrel,layer,ladder) = (" << barrelID << "," << layerID << "," << ladderID << ")" << endl; } // added SFL0_Jan_2005 // added SFL0_Jan_2005 else if (dettype == 0) { const SiLadder* theLadder = theGeometer->get_ladder(3,barrelID,layerID,ladderID); if( theLadder ) { CartesianCoordinate local(xlocal,0.0,zlocal); SpacePoint g = theLadder->local_to_global(local); std::cout << "Local layer0 (barrel,layer,ladder: " << barrelID << "," << layerID << "," << ladderID << ") (" << xlocal << "," << zlocal << ") gives global (" << setw(8) << setprecision(3) << g.x() << "," << setw(8) << setprecision(3) << g.y() << "," << setw(8) << setprecision(3) << g.z() << ")" << endl; } else std::cerr << "Error getting layer0 (barrel,layer,ladder) = (" << barrelID << "," << layerID << "," << ladderID << ")" << endl; } // end of SFL0_Jan_2005 //cin >> barrelID >> layerID >> ladderID >> xlocal >> zlocal; // cmt.out SFL0_Jan_2005 cin >> dettype >> barrelID >> layerID >> ladderID >> xlocal >> zlocal; // added SFL0_Jan_2005 } return 0; }