1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#ifndef EventFilter_CSCRawToDigi_CSCPACKERCOMPARE_H
#define EventFilter_CSCRawToDigi_CSCPACKERCOMPARE_H
#include <iostream>
#include <typeinfo>
#include "EventFilter/CSCRawToDigi/interface/bitset_append.h"
/** Compares two objects, and prints them out if they differ
*/
template <class T>
bool cscPackerCompare(const T &t1, const T &t2) {
bool result = true;
if (t1 != t2) {
std::cerr << "Mismatch:\n" << t1 << "\n" << t2 << std::endl;
result = false;
}
return result;
}
template <class T>
T cscPackAndUnpack(T &t) {
boost::dynamic_bitset<> firstPack = t.pack();
unsigned char data[10000];
bitset_utilities::bitsetToChar(firstPack, data);
return T((unsigned short int *)data);
}
// packs a class, then unpacks, packs again, and compares
template <class T>
bool cscClassPackerCompare(T &t) {
boost::dynamic_bitset<> firstPack = t.pack();
unsigned char data[1000];
bitset_utilities::bitsetToChar(firstPack, data);
T newObject((unsigned short int *)data);
boost::dynamic_bitset<> secondPack = newObject.pack();
if (firstPack != secondPack) {
std::cerr << "Mismatch in " << typeid(t).name() << "\n";
bitset_utilities::printWords(firstPack);
bitset_utilities::printWords(secondPack);
return false;
}
return true;
}
#endif
|