11 #if defined(OS_LINUX) && !defined(OS_DARWIN)
15 #define R__bswap_constant_32(x) \
16 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
17 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
33 if(bankname != std::string(
"TRB0")){
34 uint32_t* fData =
reinterpret_cast<uint32_t*
>(pdata);
38 if(type == 1) bklen /= 4;
42 if(!((fData[3] & 0x1) == 1 && (fData[3] & 0x80000000) == 0)){
44 for(
int i = 0; i < bklen; i++){
45 #if defined(OS_LINUX) && !defined(OS_DARWIN)
46 fData[i] = __bswap_32 (fData[i]);
59 int size_subevent = fData[2]/4;
69 uint32_t fpgaWord = 0, headerWord = 0;
74 bool finished =
false;
76 uint32_t word = fData[pointer];
78 if((word & 0x0000ffff) == 0x00000100 ||
79 (word & 0x0000ffff) == 0x00000101 ||
80 (word & 0x0000ffff) == 0x00000102 ||
81 (word & 0x0000ffff) == 0x00000103 ){
84 int nwords_subevent = ((word & 0xffff0000) >> 16);
90 headerWord = fData[pointer];
92 uint32_t epochWord = 0;
94 for(
int i = 0; i < nwords_subevent; i++){
96 uint32_t word = fData[pointer];
98 if((word & 0xe0000000) == 0x60000000)
101 if((word & 0xe0000000) == 0x80000000){
102 uint32_t tdcWord = fData[pointer];
104 if((fpgaWord & 0xf) > 3 ){
105 std::cout <<
"TDC FPGA ID > 3? Not possible... " << std::hex << fpgaWord <<
" " << headerWord
106 <<
" " << tdcWord <<
" " << pointer <<
" " << size_subevent << std::dec << std::endl;
107 for(
int i = 0; i < 6 ; i++)
108 std::cout << i <<
" 0x"<<std::hex
109 << fData[i] << std::dec << std::endl;
114 epochWord, tdcWord));
130 int end_packet = 2+ size_subevent -1;
131 if( fData[end_packet-1] != 0x15555){
132 std::cout <<
"TRB3 sub-event ID trailer word = " << fData[end_packet-1] <<
"; not expected 0x15555; bank decoding error!!!" << std::endl;
141 uint32_t* fData =
reinterpret_cast<uint32_t*
>(pdata);
153 uint32_t fpgaWord = 0, headerWord = 0;
155 for(
int pointer = 7; pointer < bklen; pointer++){
157 uint32_t word = fData[pointer];
161 if((word & 0xfff0ffff) == 0x00000100 ||
162 (word & 0xfff0ffff) == 0x00000101 ||
163 (word & 0xfff0ffff) == 0x00000102 ||
164 (word & 0xfff0ffff) == 0x00000103 ){
168 headerWord = fData[pointer];
174 if((word & 0xe0000000) == 0x60000000){
175 uint32_t epochWord = word;
177 uint32_t tdcWord = fData[pointer];
181 if((tdcWord & 0xe0000000) == 0x80000000){
183 epochWord, tdcWord));
#define R__bswap_constant_32(x)
void UseTRB3LinearCalibration(bool uselinear)
bool useLinearCalibration
void SetTRB3LinearCalibrationConstants(float low_value, float high_value)
std::vector< TrbTdcMeas > fMeasurements
Vector of TDC Measurements.
TrbDecoder(int bklen, void *pdata, std::string bankname, int type)
Constructor.
Decoder for individual hits from GSI TFB3 FPGA-TDC.