7 bool unpackError =
false;
9 if ((
buf[0] & 0xF000) != 0x9000 || (
buf[1] & 0xF000) != 0x9000 || (
buf[2] & 0xF000) != 0x9000 ||
10 (
buf[3] & 0xF000) != 0x9000 || (
buf[4] & 0xF000) != 0xA000 || (
buf[5] & 0xF000) != 0xA000 ||
11 (
buf[6] & 0xF000) != 0xA000 || (
buf[7] & 0xF000) != 0xA000)
14 unpackError |= header_.unpack(
buf);
16 if (!header_.empty()) {
18 if (header_.format_version())
19 unpackError |= counters_.unpack(
buf);
21 if (header_.format_version() < 3 || !header_.suppression()) {
22 for (
unsigned short tbin = 0; tbin < header_.nTBINs(); tbin++)
23 unpackError |= record_[tbin].
unpack(
buf, header_.active(), header_.suppression(), tbin);
26 for (
unsigned short tbin = 0, actual_tbin = (
buf[7] >> 8) & 0x7; tbin < header_.nTBINs(); tbin++) {
27 bzero(&(record_[tbin]),
sizeof(record_[tbin]));
29 if ((
buf[0] & 0xF000) == 0xF000 && (
buf[1] & 0xF000) == 0xF000 && (
buf[2] & 0xF000) == 0xF000 &&
30 (
buf[3] & 0xF000) == 0xF000 && (
buf[4] & 0xF000) == 0xE000 && (
buf[5] & 0xF000) == 0xE000 &&
31 (
buf[6] & 0xF000) == 0xE000 && (
buf[7] & 0xF000) == 0xE000)
34 if (tbin + 1 != actual_tbin)
37 unpackError |= record_[tbin].unpack(
buf, header_.active(), header_.suppression(), tbin);
38 actual_tbin = (
buf[7] >> 8) & 0x7;
43 for (
unsigned short tbin = 0; tbin < header_.nTBINs(); tbin++) {
44 for (
unsigned short trk = 0; trk < 3; trk++) {
50 int second_earliest_lct_delay =
52 if (
track.mode() != 15 &&
track.mode() != 11) {
54 std::map<int, std::list<int> > timeline;
56 timeline[
track.ME1_tbin()].push_back(1);
58 timeline[
track.ME2_tbin()].push_back(2);
60 timeline[
track.ME3_tbin()].push_back(3);
62 timeline[
track.ME4_tbin()].push_back(4);
64 timeline[
track.MB_tbin()].push_back(5);
65 int earliest_lct_delay = -1;
67 for (
int delay = 7;
delay >= 0 && second_earliest_lct_delay == -1;
delay--) {
68 std::list<int>::const_iterator iter = timeline[
delay].begin();
69 while (iter != timeline[
delay].
end() && second_earliest_lct_delay == -1) {
70 if (earliest_lct_delay == -1)
71 earliest_lct_delay =
delay;
72 else if (second_earliest_lct_delay == -1)
73 second_earliest_lct_delay =
delay;
78 second_earliest_lct_delay = 0;
83 unsigned int mpc = (
track.ME1_id() > 3 ? 1 : 0);
84 int ME1_tbin = tbin + second_earliest_lct_delay -
track.ME1_tbin();
86 if (ME1_tbin >= 0 && ME1_tbin < 7) {
87 std::vector<CSCSP_MEblock> lcts = record_[ME1_tbin].LCTs(mpc);
88 for (std::vector<CSCSP_MEblock>::const_iterator lct = lcts.begin(); lct != lcts.end(); lct++)
91 if (((lct->spInput() - 1) % 3 + 1) == (mpc ?
track.ME1_id() - 3 :
track.ME1_id())) {
93 track.lctFilled[0] =
true;
98 int ME2_tbin = tbin + second_earliest_lct_delay -
track.ME2_tbin();
100 if (ME2_tbin >= 0 && ME2_tbin < 7) {
101 std::vector<CSCSP_MEblock> lcts = record_[ME2_tbin].LCTs(2);
102 for (std::vector<CSCSP_MEblock>::const_iterator lct = lcts.begin(); lct != lcts.end(); lct++)
105 if (((lct->spInput() - 1) % 3 + 1) ==
track.ME2_id()) {
106 track.lct_[1] = *lct;
107 track.lctFilled[1] =
true;
111 if (
track.ME3_id()) {
112 int ME3_tbin = tbin + second_earliest_lct_delay -
track.ME3_tbin();
114 if (ME3_tbin >= 0 && ME3_tbin < 7) {
115 std::vector<CSCSP_MEblock> lcts = record_[ME3_tbin].LCTs(3);
116 for (std::vector<CSCSP_MEblock>::const_iterator lct = lcts.begin(); lct != lcts.end(); lct++)
119 if (((lct->spInput() - 1) % 3 + 1) ==
track.ME3_id()) {
120 track.lct_[2] = *lct;
121 track.lctFilled[2] =
true;
125 if (
track.ME4_id()) {
126 int ME4_tbin = tbin + second_earliest_lct_delay -
track.ME4_tbin();
128 if (ME4_tbin >= 0 && ME4_tbin < 7) {
129 std::vector<CSCSP_MEblock> lcts = record_[ME4_tbin].LCTs(4);
130 for (std::vector<CSCSP_MEblock>::const_iterator lct = lcts.begin(); lct != lcts.end(); lct++)
133 if (((lct->spInput() - 1) % 3 + 1) ==
track.ME4_id()) {
134 track.lct_[3] = *lct;
135 track.lctFilled[3] =
true;
140 int MB_tbin = tbin + second_earliest_lct_delay -
track.MB_tbin();
142 if (MB_tbin >= 0 && MB_tbin < 7) {
143 std::vector<CSCSP_MBblock>
stubs = record_[MB_tbin].mbStubs();
144 for (std::vector<CSCSP_MBblock>::const_iterator stub =
stubs.begin(); stub !=
stubs.end(); stub++)
145 if ((stub->id() == 1 &&
track.MB_id() % 2 == 1) || (stub->id() == 2 &&
track.MB_id() % 2 == 0)) {
147 track.dtFilled =
true;
154 unpackError |= trailer_.unpack(
buf);
bool unpack(const unsigned short *&buf)