25int GetId(
int ncrate,
int nboard,
int channel)
27 assert(ncrate == 16 || ncrate == 18);
28 assert(nboard > 0 && nboard < 16);
33 station = (nboard < 6) ? 1 : 2;
34 nboardofstation = nboard - (station - 1) * 5;
37 station = (nboard < 6) ? 3 : (nboard < 11) ? 4 : 5;
38 nboardofstation = nboard - (station - 3) * 5;
44 : (channel < 16) ? 10 - channel
45 : (channel < 32) ? 42 - channel : (channel < 48) ? 74 - channel : 106 - channel;
46 strip += (nboardofstation - (direction ==
vertical ? 1 : 4)) * 64;
47 LOG(DEBUG) << ncrate <<
'\t' << nboard <<
'\t' << channel <<
'\t' << station <<
'\t' << strip <<
'\t'
48 << (direction ==
vertical ?
'V' :
'H');
49 return 10000 * station + 1000 * direction + strip;
53RPCUnpack::RPCUnpack() : fRawData(new TClonesArray(
"MuonTaggerHit")), fNHits(0), fNHitsTotal(0), fPartitionId(0x0B00) {}
79 LOG(DEBUG) <<
"RPCUnpack : Unpacking frame... size/bytes = " << size;
81 auto df =
reinterpret_cast<DataFrame *
>(data);
82 switch (df->header.frameTime) {
83 case SoS: LOG(INFO) <<
"RPCUnpack: SoS frame.";
return kTRUE;
84 case EoS: LOG(INFO) <<
"RPCUnpack: EoS frame.";
return kTRUE;
87 assert(df->header.size == size);
88 auto nhits = (size -
sizeof(
DataFrame)) / 12;
89 static_assert(
sizeof(
RawHit) == 12,
"Padding is off");
91 auto hits =
reinterpret_cast<unsigned char *
>(df->hits);
92 const int BYTES_PER_HITPATTERN = 8;
93 const int BYTES_PER_RECORD = 12;
94 for (
int i = 0; i < nhits; i++) {
95 auto hit = hits + i * BYTES_PER_RECORD;
96 auto crate = (
unsigned int)hit[0];
97 auto board = (
unsigned int)hit[1];
98 for (
int k = 1; k <= BYTES_PER_HITPATTERN; k++) {
102 for (
int j = 0; j < 8; j++) {
103 if (hit[index] & bitMask) {
104 auto channel = (BYTES_PER_HITPATTERN - k) * 8 + j;
105 if ((crate == 16 && (board == 5 || board == 10) && channel >= 48 && channel <= 53) ||
106 (crate == 16 && (board == 3 || board == 8) && channel >= 60 && channel <= 63) ||
107 (crate == 16 && (board == 4 || board == 9) && channel >= 10 && channel <= 15) ||
108 (crate == 16 && (board == 1 || board == 6) && channel >= 0 && channel <= 3) ||
109 (crate == 18 && (board == 5 || board == 10 || board == 15) && channel >= 48 && channel <= 53) ||
110 (crate == 18 && (board == 3 || board == 8 || board == 13) && channel >= 60 && channel <= 63) ||
111 (crate == 18 && (board == 4 || board == 9 || board == 14) && channel >= 10 && channel <= 15) ||
112 (crate == 18 && (board == 1 || board == 6 || board == 11) && channel >= 0 && channel <= 3)) {
117 MuonTaggerHit(
GetId(crate, board, channel), Float_t(df->header.frameTime) * 25);
126 LOG(WARNING) <<
"Skipped " << skipped <<
" hits on unconnected channels (probably noise).";