// // $Id: CftMaterialGeometer_t.cpp,v 1.8 2000/12/05 16:52:19 hobbs Exp $ // // File: CftMaterialGeometer_t.cc // Purpose: Test CftMaterialGeometer class // Created: 10-OCT-1997 Harry L. Melanson // // $Revision: 1.8 $ // // // Include files #include #include #include #include "rcp/RCPManager.hpp" #include "rcp/RCP.hpp" #include "cft_util/CFTDetector.hpp" #include "cft_geometry/base/CftGeometerDecoupler.hpp" #include "cft_geometry/base/CftGeometer.hpp" #include "cft_geometry/base/CftBaseGeometry.hpp" #include "cft_geometry/base/CftBarrelSurface.hpp" #include "cft_geometry/base/CftDoubletSurface.hpp" #include "cft_geometry/material/CftMaterialGeometer.hpp" #include "geometry_system/management/HandleSystem.hpp" #include "material/Material.hpp" #include "thinshells/CylindricalShell.hpp" using namespace std; using edm::RCPManager; using edm::RCP; using namespace dgs; using namespace D0Material; int main() { cout << "Testing CftMaterialGeometer class..." << endl; //////////////////////////////////////////////////////////////////////// // // Make sure assert is enabled. // //////////////////////////////////////////////////////////////////////// bool assert_flag = false; assert ( ( assert_flag = true, assert_flag ) ); if ( ! assert_flag ) { cerr << "Assert is disabled" << endl; return 1; } //////////////////////////////////////////////////////////////////////// // // Build default CftBaseGeometry // //////////////////////////////////////////////////////////////////////// d0_Ref cft; RCPManager* rcpman = RCPManager::instance(); try { RCP rcp = rcpman->extract("cft_geometry","CftBaseGeometry"); cft = CftBaseGeometry::build_default(&rcp); } catch(runtime_error mistake) { cerr << "ERROR: " << mistake.what() << endl; return(1); } //////////////////////////////////////////////////////////////////////// // // Tell CftGeometer about CftBaseGeometry // //////////////////////////////////////////////////////////////////////// d0_Ref const_cft; const_cft = D0_CONST_REFCONV((CftBaseGeometry)) (cft); CftGeometer* cftgm = CftGeometer::get_instance(); cftgm->refresh(const_cft); assert ( cftgm->get_doublet_count() == 16); cout << "CftBaseGeometry built." << endl; //////////////////////////////////////////////////////////////////////// // // Get CftMaterialGeometer and build geometry // //////////////////////////////////////////////////////////////////////// CftMaterialGeometer* cftMatGM = CftMaterialGeometer::get_instance(); assert ( cftMatGM != NULL ); cout << "CftMaterialGeometer::get_instance() successful." << endl; RCP rcpMat = rcpman->extract("cft_geometry","CftMaterialGeometry"); cftMatGM->absRefresh(&rcpMat); //////////////////////////////////////////////////////////////////////// // // Loop over each doublet // //////////////////////////////////////////////////////////////////////// CFTDoubletList cftlist = CFTDetector::all_doublets(); CFTDoubletList::const_iterator idblt; map shells; map > surfs; for (idblt = cftlist.begin(); idblt != cftlist.end(); ++idblt) { CFTDoublet dblt = *idblt; // Get this doublet's thin shell cout << endl; cout << "Doublet " << CFTDetector::name(dblt) << " : get_doublet_shell..." << endl << endl; shells[dblt] = cftMatGM->get_doublet_shell(dblt); assert ( shells[dblt] != NULL ); // Exercise access methods cout << " Exercise access methods:" << endl; const Material* mat = shells[dblt]->get_Material(); float frac = shells[dblt]->get_X0_frac(); float thick = shells[dblt]->get_Thickness(); Handle surf = shells[dblt]->get_Surface(); surfs[dblt] = surf; cout << " get_Material() = " << *mat << endl; cout << " get_X0_frac() = " << frac << endl; cout << " get_Thickness() = " << thick << endl; cout << " get_Surface() = " << *surf << endl; } //////////////////////////////////////////////////////////////////////// // // Now try a new base geometry to see if Handles to surfaces work // //////////////////////////////////////////////////////////////////////// // Move the entire CFT to new origin (1,2,3) cout << endl; cout << "Now make a new base geometry, moved to origin (1,2,3)" << endl; float dx = 1.0; float dy = 2.0; float dz = 3.0; GeometryXform neworigin = GeometryXform(dx, dy, dz, 0.0, 0.0, 0.0); cft->move(neworigin); // Remake const version of new geometry d0_Ref const_cft2; const_cft2 = D0_CONST_REFCONV((CftBaseGeometry)) (cft); // and refresh Geometer's using Decoupler. cout << "Refresh using CftGeometerDecoupler." << endl; CftGeometerDecoupler* cftDecoupler = new CftGeometerDecoupler; cftDecoupler->refresh(const_cft2); // Check that the move worked in base geometry. cout << "Doublet 1: " << *(cftgm->get_doublet(1)) << endl; assert ( ((cftgm->get_doublet(1))->get_position())[0] == dx ); // x origin assert ( ((cftgm->get_doublet(1))->get_position())[1] == dy ); // y origin assert ( ((cftgm->get_doublet(1))->get_position())[2] == dz ); // z origin // Go through the shells and check that they also moved. for (idblt = cftlist.begin(); idblt != cftlist.end(); ++idblt) { CFTDoublet dblt = *idblt; cout << endl; cout << "Doublet " << CFTDetector::name(dblt) << endl << endl; const Material* mat = shells[dblt]->get_Material(); float frac = shells[dblt]->get_X0_frac(); float thick = shells[dblt]->get_Thickness(); Handle surf = shells[dblt]->get_Surface(); cout << " get_Material() = " << *mat << endl; cout << " get_X0_frac() = " << frac << endl; cout << " get_Thickness() = " << thick << endl; cout << " get_Surface() = " << *surf << endl; cout << " Surface(w/ Handle) = " << *surfs[dblt] << endl; assert ( (surf->get_position())[0] == dx ); // x origin assert ( (surf->get_position())[1] == dy ); // y origin assert ( (surf->get_position())[2] == dz ); // z origin assert ( (surfs[dblt]->get_position())[0] == dx ); // x origin assert ( (surfs[dblt]->get_position())[1] == dy ); // y origin assert ( (surfs[dblt]->get_position())[2] == dz ); // z origin } return 0; }