#include #include #include #include #include "COMETGeomId.hxx" #include "COMETGeomIdDef.hxx" #include "ICOMETLog.hxx" #include "IOARuntimeParameters.hxx" //Make everything in the test class public so we can test at lesure. //Evil has its uses. #define private public #define protected public #include "IGeometryDatabase.hxx" #undef private #undef protected namespace tut { struct TGeometryDatabase_base { TGeometryDatabase_base() { //run before each test //Hide the log message when initialising IOARuntimeParameters COMET::ICOMETLog::LogPriority lp = COMET::ICOMETLog::GetLogLevel(); COMET::ICOMETLog::SetLogLevel(COMET::ICOMETLog::QuietLevel); COMET::IOARuntimeParameters::Get(); COMET::ICOMETLog::SetLogLevel(lp); } ~TGeometryDatabase_base() { //run after each test } }; /* void geomdb_tfbmap_equiv_test_tagged(std::string tag, const COMET::ITFBChannelMap& tfb_map); */ //Declare the test group test_group TGeometryDatabase_group("IGeometryDatabase is OK"); //Specify tests typedef test_group::object test_TGeometryDatabase; //-------------------------------------------------------------------- template<> template<> void test_TGeometryDatabase::test<1>() { // test that the Subdet maps return the correct objects // also check the size of fChannelMaps is growing as expected // (must do this in first test because the object is a singleton) COMET::IGeometryDatabase& geomDB = COMET::IGeometryDatabase::Get(); /* const COMET::IChannelMap* p0d_map = &(geomDB.P0D()); ensure("P0D() returns a const IP0DChannelMap", typeid(*p0d_map) == typeid(const COMET::IP0DChannelMap)); ensure("fP0DMap non-null", geomDB.fP0DMap != 0x0); const COMET::IChannelMap* tpc_map = &(geomDB.TPC()); ensure("TPC() returns a const ITPCChannelMap", typeid(*tpc_map) == typeid(const COMET::ITPCChannelMap)); ensure("fTPCMap non-null", geomDB.fTPCMap != 0x0); const COMET::IChannelMap* fgd_map = &(geomDB.FGD()); ensure("FGD() returns a const IFGDChannelMap", typeid(*fgd_map) == typeid(const COMET::IFGDChannelMap)); ensure("fFGDMap non-null", geomDB.fFGDMap != 0x0); const COMET::IChannelMap* ecal_map = &(geomDB.ECal()); ensure("ECal() returns a const IECalChannelMap", typeid(*ecal_map) == typeid(const COMET::IECalChannelMap)); ensure("fECalMap non-null", geomDB.fECalMap != 0x0); const COMET::IChannelMap* smrd_map = &(geomDB.SMRD()); ensure("SMRD() returns a const ISMRDChannelMap", typeid(*smrd_map) == typeid(const COMET::ISMRDChannelMap)); ensure("fSMRDMap non-null", geomDB.fSMRDMap != 0x0); const COMET::IChannelMap* ingrid_map = &(geomDB.INGRID()); ensure("INGRID() returns a const TINGRIDCChannelMap", typeid(*ingrid_map) == typeid(const COMET::IINGRIDChannelMap)); ensure("fINGRIDMap non-null", geomDB.fINGRIDMap != 0x0); */ } //-------------------------------------------------------------------- template<> template<> void test_TGeometryDatabase::test<2>() { // test that the Subdet maps are not affected when other maps are requested COMET::IGeometryDatabase& geomDB = COMET::IGeometryDatabase::Get(); /* const COMET::IChannelMap* ecal_map = &(geomDB.ECal()); const COMET::IChannelMap* smrd_map = &(geomDB.SMRD()); const COMET::IChannelMap* ingrid_map = &(geomDB.INGRID()); const COMET::IChannelMap* p0d_map = &(geomDB.P0D()); const COMET::IChannelMap* tpc_map = &(geomDB.TPC()); const COMET::IChannelMap* fgd_map = &(geomDB.FGD()); */ ensure("Geom DB is unique", &geomDB == &(COMET::IGeometryDatabase::Get())); /* ensure("ECal map not disturbed", ecal_map == &(geomDB.ECal())); ensure("SMRD map not disturbed", smrd_map == &(geomDB.SMRD())); ensure("INGRID map not disturbed", ingrid_map == &(geomDB.INGRID())); ensure("P0D map not disturbed", p0d_map == &(geomDB.P0D())); ensure("TPC map not disturbed", tpc_map == &(geomDB.TPC())); ensure("FGD map not disturbed", fgd_map == &(geomDB.FGD())); */ } //-------------------------------------------------------------------- template<> template<> void test_TGeometryDatabase::test<3>() { // ensure access through GeometryDatabase or P0DChannelMap // gives same results /* const COMET::IP0DChannelMap& p0d_map = COMET::IGeometryDatabase::Get().P0D(); geomdb_tfbmap_equiv_test_tagged("P0D", p0d_map); */ } //-------------------------------------------------------------------- template<> template<> void test_TGeometryDatabase::test<4>() { // ensure access through GeometryDatabase or ECalChannelMap // gives same results /* const COMET::IECalChannelMap& ecal_map = COMET::IGeometryDatabase::Get().ECal(); geomdb_tfbmap_equiv_test_tagged("ECal", ecal_map); */ } //-------------------------------------------------------------------- template<> template<> void test_TGeometryDatabase::test<5>() { // ensure access through GeometryDatabase or SMRDChannelMap // gives same results /* const COMET::ISMRDChannelMap& smrd_map = COMET::IGeometryDatabase::Get().SMRD(); geomdb_tfbmap_equiv_test_tagged("SMRD", smrd_map); */ } //-------------------------------------------------------------------- template<> template<> void test_TGeometryDatabase::test<6>() { // ensure access through GeometryDatabase or INGRIDChannelMap // gives same results /* const COMET::IINGRIDChannelMap& i_map = COMET::IGeometryDatabase::Get().INGRID(); geomdb_tfbmap_equiv_test_tagged("INGRID", i_map); */ } //---------------------------------------------------------------------- template<>template<> void test_TGeometryDatabase::test<7>() { // endure acess through GeometryDatabase of FGDChannelMap give // same results. Also check the methods that don't have analogues // in the FGD channel map itself COMET::IGeometryDatabase& geomDB = COMET::IGeometryDatabase::Get(); /* typedef COMET::IFGDChannelMap::ChannelAttenuation FGDCA_t; const FGDCA_t high_att = COMET::IFGDChannelMap::kHighAttenuation; const FGDCA_t low_att = COMET::IFGDChannelMap::kLowAttenuation; namespace FGD = COMET::GeomId::FGD; const COMET::IFGDChannelMap& fgd_map = geomDB.FGD(); for (int fgd = 0; fgd < 2; ++fgd){ for (int mod = 0; mod < (fgd==0?15:7); ++mod){ for (int bar = 0; bar < 192; ++bar){ for (int orient =0; orient < 2; ++orient){ COMET::IGeometryId gid = FGD::Bar(fgd, mod, orient, bar); //check the channel lookup COMET::IFGDChannelId cid_h1; ensure("FGD: Get high chanid", fgd_map.GetChannelId(cid_h1, gid, high_att)); COMET::IFGDChannelId cid_h2; ensure("FGD: Get high chanid (2)", geomDB.GetFGDChannelId(cid_h2, gid, high_att)); ensure_equals("FGD: high chanid match", cid_h1, cid_h2); COMET::IFGDChannelId cid_l1; ensure("FGD: Get low chanid", fgd_map.GetChannelId(cid_l1, gid, low_att)); COMET::IFGDChannelId cid_l2; ensure("FGD: Get low chanid (2)", geomDB.GetFGDChannelId(cid_l2, gid, low_att)); ensure_equals("FGD: low chanid match", cid_l1, cid_l2); //Check the channel to channel mappings COMET::IFGDChannelId cid_tmp; ensure("FGD: c2c get chanid (hh)", geomDB.GetFGDChannelId(cid_tmp, cid_h1, high_att)); ensure_equals("FGD:c2c mapping (hh)", cid_tmp, cid_h1); ensure("FGD: c2c get chanid (hl)", geomDB.GetFGDChannelId(cid_tmp, cid_h1, low_att)); ensure_equals("FGD:c2c mapping (hl)", cid_tmp, cid_l1); ensure("FGD: c2c get chanid (lh)", geomDB.GetFGDChannelId(cid_tmp, cid_l1, high_att)); ensure_equals("FGD:c2c mapping (hh)", cid_tmp, cid_h1); ensure("FGD: c2c get chanid (ll)", geomDB.GetFGDChannelId(cid_tmp, cid_l1, low_att)); ensure_equals("FGD:c2c mapping (ll)", cid_tmp, cid_l1); //check the automatic attenuation lookup COMET::IFGDChannelId cid_auto; ensure("FGD: Get auto chanid", geomDB.GetChannelId(cid_auto, gid)); ensure("FGD: auto chanid match", cid_auto == cid_h1 || cid_auto == cid_l1); //check the return path COMET::IGeometryId gid_return; ensure("FGD: Re-get geomid (high)", geomDB.GetGeometryId(gid_return, cid_h1)); ensure_equals("FGD: gid match (high)", gid_return, gid); ensure("FGD: Re-get geomid (high)", geomDB.GetGeometryId(gid_return, cid_l1)); ensure_equals("FGD: gid match (high)", gid_return, gid); } //orient } //bar } //module } //fgd */ } }; //namespace tut /* //---------------------------------------------------------------------- // Helper functions //---------------------------------------------------------------------- void tut::geomdb_tfbmap_equiv_test_tagged(std::string tag, const COMET::ITFBChannelMap& tfb_map) { // ensure acess through GeometryDatabase or TFBChannelMap give same result COMET::IGeometryDatabase& geomDB = COMET::IGeometryDatabase::Get(); typedef const std::vector chanvec; typedef chanvec::const_iterator chaniter; typedef COMET::ITFBChannelMap::BarEnd BarEnd_t; chanvec& cvec = tfb_map.GetInstrumentedChannels(); for (chaniter citer = cvec.begin(); citer != cvec.end(); ++citer){ COMET::IGeometryId gid; BarEnd_t be; ensure(tag + ": Get geomid", tfb_map.GetGeometryId(gid, *citer)); ensure(tag + ": Get bar end", tfb_map.GetBarEnd(be, *citer)); COMET::IChannelId cid(*citer); COMET::IGeometryId db_gid; BarEnd_t db_be; ensure(tag + ": Get geomid (2)", geomDB.GetGeometryId(db_gid, cid)); ensure(tag + ": Get ECal bar end (2)", geomDB.GetTFBBarEnd(db_be, *citer)); ensure_equals((tag + ": geomid match").c_str(), db_gid, gid); ensure_equals((tag + ": bar end match").c_str(), db_be, be); if (db_be == COMET::ITFBChannelMap::kSingleEnded){ COMET::IChannelId cid_return; ensure(tag + ": Re-get chanid", geomDB.GetChannelId(cid_return, gid)); ensure_equals((tag + ": single chanid match").c_str(), cid_return, cid); } COMET::ITFBChannelId cid_tfb_return; ensure(tag + ": Re-get chanid (via TFB)", geomDB.GetTFBChannelId(cid_tfb_return, gid, be)); ensure_equals((tag + ": chanid match (via TFB)").c_str(), cid_tfb_return, cid); } } */