7 bool unpackError =
false;
9 if( (buf[0]&0xF000) != 0x9000 || (buf[1]&0xF000) != 0x9000 || (buf[2]&0xF000) != 0x9000 || (buf[3]&0xF000) != 0x9000 ||
10 (buf[4]&0xF000) != 0xA000 || (buf[5]&0xF000) != 0xA000 || (buf[6]&0xF000) != 0xA000 || (buf[7]&0xF000) != 0xA000 )
13 unpackError |= header_.unpack(buf);
15 if( !header_.empty() ){
17 if( header_.format_version() )
18 unpackError |= counters_.unpack(buf);
20 if( header_.format_version()<3 || !header_.suppression() ){
21 for(
unsigned short tbin=0; tbin<header_.nTBINs(); tbin++)
22 unpackError |= record_[tbin].
unpack(buf,header_.active(),header_.suppression(),tbin);
25 for(
unsigned short tbin=0, actual_tbin = (buf[7] >> 8) & 0x7; tbin<header_.nTBINs(); tbin++){
26 bzero(&(record_[tbin]),
sizeof(record_[tbin]));
28 if( (buf[0]&0xF000)==0xF000 && (buf[1]&0xF000)==0xF000 && (buf[2]&0xF000)==0xF000 && (buf[3]&0xF000)==0xF000 &&
29 (buf[4]&0xF000)==0xE000 && (buf[5]&0xF000)==0xE000 && (buf[6]&0xF000)==0xE000 && (buf[7]&0xF000)==0xE000 )
break;
31 if( tbin+1 != actual_tbin )
continue;
33 unpackError |= record_[tbin].unpack(buf,header_.active(),header_.suppression(),tbin);
34 actual_tbin = (buf[7] >> 8) & 0x7;
39 for(
unsigned short tbin=0; tbin<header_.nTBINs(); tbin++){
40 for(
unsigned short trk=0; trk<3; trk++){
44 int second_earliest_lct_delay = -1;
45 if( track.
mode() != 15 && track.
mode() != 11 ){
47 std::map< int, std::list<int> > timeline;
52 if( track.
MB_id() ) timeline[track.
MB_tbin() ].push_back(5);
53 int earliest_lct_delay = -1;
55 for(
int delay=7; delay>=0 && second_earliest_lct_delay==-1; delay--){
56 std::list<int>::const_iterator iter = timeline[delay].begin();
57 while( iter != timeline[delay].
end() && second_earliest_lct_delay==-1 ){
58 if( earliest_lct_delay==-1 ) earliest_lct_delay=delay;
59 else if( second_earliest_lct_delay==-1 ) second_earliest_lct_delay=delay;
63 }
else second_earliest_lct_delay = 0;
68 unsigned int mpc = ( track.
ME1_id()>3 ? 1 : 0 );
69 int ME1_tbin = tbin + second_earliest_lct_delay - track.
ME1_tbin();
71 if( ME1_tbin>=0 && ME1_tbin<7 ) {
72 std::vector<CSCSP_MEblock> lcts = record_[ME1_tbin].LCTs(mpc);
73 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
76 if( ((lct->spInput()-1)%3+1)==(mpc?track.
ME1_id()-3:track.
ME1_id()) ){
83 int ME2_tbin = tbin + second_earliest_lct_delay - track.
ME2_tbin();
85 if( ME2_tbin>=0 && ME2_tbin<7 ) {
86 std::vector<CSCSP_MEblock> lcts = record_[ME2_tbin].LCTs(2);
87 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
90 if( ((lct->spInput()-1)%3+1)==track.
ME2_id() ){
97 int ME3_tbin = tbin + second_earliest_lct_delay - track.
ME3_tbin();
99 if( ME3_tbin>=0 && ME3_tbin<7 ) {
100 std::vector<CSCSP_MEblock> lcts = record_[ME3_tbin].LCTs(3);
101 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
104 if( ((lct->spInput()-1)%3+1)==track.
ME3_id() ){
105 track.
lct_[2] = *lct;
111 int ME4_tbin = tbin + second_earliest_lct_delay - track.
ME4_tbin();
113 if( ME4_tbin>=0 && ME4_tbin<7 ) {
114 std::vector<CSCSP_MEblock> lcts = record_[ME4_tbin].LCTs(4);
115 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++)
118 if( ((lct->spInput()-1)%3+1)==track.
ME4_id() ){
119 track.
lct_[3] = *lct;
125 int MB_tbin = tbin + second_earliest_lct_delay - track.
MB_tbin();
127 if( MB_tbin>=0 && MB_tbin<7 ) {
128 std::vector<CSCSP_MBblock> stubs = record_[MB_tbin].mbStubs();
129 for(std::vector<CSCSP_MBblock>::const_iterator stub=stubs.begin(); stub!=stubs.end(); stub++)
130 if( (stub->id()==1 && track.
MB_id()%2==1) || (stub->id()==2 && track.
MB_id()%2==0) ){
139 unpackError |= trailer_.unpack(buf);
unsigned int MB_tbin(void) const
unsigned int ME4_tbin(void) const
bool unpack(const unsigned short *&buf)
unsigned int MB_id(void) const
unsigned int mode(void) const
unsigned int ME3_id(void) const
unsigned int ME3_tbin(void) const
unsigned int ME2_tbin(void) const
unsigned int ME1_id(void) const
unsigned int ME1_tbin(void) const
unsigned int ME2_id(void) const
unsigned int ME4_id(void) const