File indexing completed on 2024-04-06 12:10:22
0001 #ifndef EventFilter_CSCRawToDigi_CSCPACKERCOMPARE_H
0002 #define EventFilter_CSCRawToDigi_CSCPACKERCOMPARE_H
0003
0004 #include <iostream>
0005 #include <typeinfo>
0006 #include "EventFilter/CSCRawToDigi/interface/bitset_append.h"
0007
0008
0009
0010
0011 template <class T>
0012 bool cscPackerCompare(const T &t1, const T &t2) {
0013 bool result = true;
0014 if (t1 != t2) {
0015 std::cerr << "Mismatch:\n" << t1 << "\n" << t2 << std::endl;
0016 result = false;
0017 }
0018 return result;
0019 }
0020
0021 template <class T>
0022 T cscPackAndUnpack(T &t) {
0023 boost::dynamic_bitset<> firstPack = t.pack();
0024 unsigned char data[10000];
0025 bitset_utilities::bitsetToChar(firstPack, data);
0026 return T((unsigned short int *)data);
0027 }
0028
0029
0030 template <class T>
0031 bool cscClassPackerCompare(T &t) {
0032 boost::dynamic_bitset<> firstPack = t.pack();
0033 unsigned char data[1000];
0034 bitset_utilities::bitsetToChar(firstPack, data);
0035 T newObject((unsigned short int *)data);
0036 boost::dynamic_bitset<> secondPack = newObject.pack();
0037 if (firstPack != secondPack) {
0038 std::cerr << "Mismatch in " << typeid(t).name() << "\n";
0039 bitset_utilities::printWords(firstPack);
0040 bitset_utilities::printWords(secondPack);
0041 return false;
0042 }
0043 return true;
0044 }
0045
0046 #endif