00001 #include <iostream> 00002 #include "EventFilter/CSCRawToDigi/src/bitset_append.h" 00003 00004 00008 template <class T> 00009 bool cscPackerCompare(const T & t1, const T & t2) 00010 { 00011 bool result = true; 00012 if(t1 != t2) { 00013 std::cerr << "Mismatch:\n"<< t1 << "\n" << t2 << std::endl; 00014 result = false; 00015 } 00016 return result; 00017 } 00018 00019 00020 template <class T> 00021 T cscPackAndUnpack(T & t) 00022 { 00023 boost::dynamic_bitset<> firstPack = t.pack(); 00024 unsigned char data[10000]; 00025 bitset_utilities::bitsetToChar(firstPack, data); 00026 return T((unsigned short int *)data); 00027 } 00028 00029 00030 // packs a class, then unpacks, packs again, and compares 00031 template <class T> 00032 bool cscClassPackerCompare(T & t) 00033 { 00034 boost::dynamic_bitset<> firstPack = t.pack(); 00035 unsigned char data[1000]; 00036 bitset_utilities::bitsetToChar(firstPack, data); 00037 T newObject((unsigned short int *)data); 00038 boost::dynamic_bitset<> secondPack = newObject.pack(); 00039 if(firstPack != secondPack) 00040 { 00041 std::cerr << "Mismatch in " << typeid(t).name() << "\n"; 00042 bitset_utilities::printWords(firstPack); 00043 bitset_utilities::printWords(secondPack); 00044 return false; 00045 } 00046 return true; 00047 } 00048