#include #include "funcTChannelMap.hxx" #define private public #define protected public //#include "IFGDChannelMap.hxx" //#include "ITPCChannelMap.hxx" //#include "ITFBChannelMap.hxx" #undef private #undef protected //namespace tut{ namespace impl{ // Note: Because of the way templates instantiations are chosen, we // must provide the return type "(void) " when calling. template void num_elements_test(CHANNELMAP& map, int target_g2c_size, int target_c2g_size, int allowed_window, std::string tag); }; /* //---------------------------------------------------------------------- template void impl::num_elements_test(CHANNELMAP& map, int target_g2c_size, int target_c2g_size, int allowed_window, std::string tag) { using tut::ensure; using tut::ensure_distance; int distance = TMath::Abs(allowed_window)/2 ; if (distance == 0) distance = 1; //0 always fails. int g2c_size = map.fGeometryToChannelMap.size(); ensure_distance((tag + "Geometry IDs in default map").c_str(), g2c_size, target_g2c_size, distance); int c2g_size = map.fChannelToGeometryMap.size(); ensure_distance((tag + "Channel IDs in default map").c_str(), c2g_size, target_c2g_size, distance); } //---------------------------------------------------------------------- void tut::num_elements_test(const COMET::IFGDChannelMap& map, int target_g2c_size, int target_c2g_size, int allowed_window, std::string tag) { (void) impl::num_elements_test(map, target_g2c_size, target_c2g_size, allowed_window, tag); } //---------------------------------------------------------------------- void tut::num_elements_test(const COMET::ITPCChannelMap& map, int target_g2c_size, int target_c2g_size, int allowed_window, std::string tag) { (void) impl::num_elements_test(map, target_g2c_size, target_c2g_size, allowed_window, tag); } //---------------------------------------------------------------------- void tut::num_elements_test(const COMET::ITFBChannelMap& map, int target_g2c_size, int target_c2g_size, int allowed_window, std::string tag) { (void) impl::num_elements_test(map, target_g2c_size, target_c2g_size, allowed_window, tag); int c2g_size = map.fChannelToGeometryMap.size(); int nic = map.fInstrumentedChannels.size(); std::string s; s = "GeomId map exists for every instrumented channel"; ensure_equals(s.c_str(), c2g_size, nic); int c2b_size = map.fChannelToBarEndMap.size(); s = "Bar end map exists for ever instrumented channel"; ensure_equals(s.c_str(), c2b_size, nic); } //---------------------------------------------------------------------- void tut::geom_roundtrip_test(COMET::ITFBChannelMap& tfb_map) { //Check the round trip (geomId, End) => channelId => (geomId, End) using namespace COMET; //to shorten iterator declaraions using std::map; // ditto typedef COMET::ITFBChannelMap::BarEnd BarEnd_t; typedef map b2cMap_t; typedef map::iterator b2cIter_t; typedef map g2bcMap_t; typedef map::iterator g2bcIter_t; g2bcMap_t& geommap(tfb_map.fGeometryToChannelMap); for (g2bcIter_t it_g2bc = geommap.begin(); it_g2bc != geommap.end(); ++it_g2bc){ IGeometryId gid_start = it_g2bc->first; b2cMap_t& endmap(it_g2bc->second); for (b2cIter_t it_b2c = endmap.begin(); it_b2c != endmap.end(); ++it_b2c){ BarEnd_t be_start = it_b2c->first; ITFBChannelId cid; ensure("(gid) Channel ID lookup suceeds", tfb_map.GetChannelId(cid, gid_start, be_start)); IGeometryId gid_return; ensure("(gid) Geometry ID lookup suceeds", tfb_map.GetGeometryId(gid_return, cid)); ensure_equals("Geometry ID round trip", gid_return, gid_start); BarEnd_t be_return; ensure("(gid) BarEnd lookup suceeds", tfb_map.GetBarEnd(be_return, cid)); ensure_equals("BarEnd round trip", be_return, be_start); } //it_b2c } //it_g2bc } //---------------------------------------------------------------------- void tut::chan_roundtrip_test(COMET::ITFBChannelMap& tfb_map) { //Check the round trip channelId => (geomId, BarEnd) => channelId using namespace COMET; //to shorten iterator declaraions using std::map; // ditto typedef COMET::ITFBChannelMap::BarEnd BarEnd_t; typedef std::vector::iterator icIter_t; std::vector& chanlist = tfb_map.fInstrumentedChannels; for(icIter_t it_chan = chanlist.begin(); it_chan != chanlist.end(); ++it_chan){ ITFBChannelId cid_start = *it_chan; IGeometryId gid; ensure("(cid) Geometry ID lookup suceeds", tfb_map.GetGeometryId(gid, cid_start)); BarEnd_t be; ensure("(cid) BarEnd lookup suceeds", tfb_map.GetBarEnd(be,cid_start)); ITFBChannelId cid_return; ensure("(cid) Channel ID lookup suceeds", tfb_map.GetChannelId(cid_return, gid, be)); ensure_equals("Channel ID round trip", cid_return, cid_start); } } */