![]() |
![]() |
#include <EventFilter/CSCTFRawToDigi/src/CSCSPEvent.h>
Public Member Functions | |
const CSCSPCounters & | counters (void) const throw () |
CSCSPEvent (void) | |
const CSCSPHeader & | header (void) const throw () |
const CSCSPRecord & | record (unsigned int tbin) const throw () |
const CSCSPTrailer & | trailer (void) const throw () |
bool | unpack (const unsigned short *&buf) throw () |
Private Attributes | |
CSCSPCounters | counters_ |
CSCSPHeader | header_ |
CSCSPRecord | record_ [7] |
CSCSPTrailer | trailer_ |
Definition at line 9 of file CSCSPEvent.h.
CSCSPEvent::CSCSPEvent | ( | void | ) | [inline] |
const CSCSPCounters& CSCSPEvent::counters | ( | void | ) | const throw () [inline] |
Definition at line 18 of file CSCSPEvent.h.
References counters_.
Referenced by CSCTFUnpacker::produce().
00018 { return counters_; }
const CSCSPHeader& CSCSPEvent::header | ( | void | ) | const throw () [inline] |
Definition at line 17 of file CSCSPEvent.h.
References header_.
Referenced by CSCTFUnpacker::produce().
00017 { return header_; }
const CSCSPRecord& CSCSPEvent::record | ( | unsigned int | tbin | ) | const throw () [inline] |
Definition at line 21 of file CSCSPEvent.h.
References record_.
Referenced by CSCTFUnpacker::produce().
00021 { return record_[tbin]; }
const CSCSPTrailer& CSCSPEvent::trailer | ( | void | ) | const throw () [inline] |
bool CSCSPEvent::unpack | ( | const unsigned short *& | buf | ) | throw () |
Definition at line 5 of file CSCSPEvent.cc.
References CSCSP_SPblock::dt_, CSCSP_SPblock::dtFilled, end, iter, CSCSP_SPblock::lct_, CSCSP_SPblock::lctFilled, CSCSP_SPblock::MB_id(), CSCSP_SPblock::MB_tbin(), CSCSP_SPblock::ME1_id(), CSCSP_SPblock::ME1_tbin(), CSCSP_SPblock::ME2_id(), CSCSP_SPblock::ME2_tbin(), CSCSP_SPblock::ME3_id(), CSCSP_SPblock::ME3_tbin(), CSCSP_SPblock::ME4_id(), CSCSP_SPblock::ME4_tbin(), track, and HcalUnpacker_impl::unpack().
00005 { 00006 bool unpackError = false; 00007 00008 if( (buf[0]&0xF000) != 0x9000 || (buf[1]&0xF000) != 0x9000 || (buf[2]&0xF000) != 0x9000 || (buf[3]&0xF000) != 0x9000 || 00009 (buf[4]&0xF000) != 0xA000 || (buf[5]&0xF000) != 0xA000 || (buf[6]&0xF000) != 0xA000 || (buf[7]&0xF000) != 0xA000 ) 00010 return true; 00011 else 00012 unpackError |= header_.unpack(buf); 00013 00014 if( !header_.empty() ){ 00015 // Block of Counters is added in format version 4.3 (dated by 05/27/2007) 00016 if( header_.format_version() ) 00017 unpackError |= counters_.unpack(buf); 00018 00019 for(unsigned short tbin=0; tbin<header_.nTBINs(); tbin++) 00020 unpackError |= record_[tbin].unpack(buf,header_.active(),header_.suppression(),tbin); 00021 00022 // Set LCTs for each track in each time bin 00023 for(unsigned short tbin=0; tbin<header_.nTBINs(); tbin++){ 00024 for(unsigned short trk=0; trk<3; trk++){ 00025 CSCSP_SPblock &track = record_[tbin].sp[trk]; 00026 if( track.ME1_id()==0 && track.ME2_id()==0 && track.ME3_id()==0 && track.ME4_id()==0 && track.MB_id()==0 ) continue; 00027 // BXA algorithm is not trivial: first let's order all delays (MEx_tbin) aligning LCTs to one BX 00028 std::map< int, std::list<int> > timeline; 00029 if( track.ME1_id() ) timeline[track.ME1_tbin()].push_back(1); 00030 if( track.ME2_id() ) timeline[track.ME2_tbin()].push_back(2); 00031 if( track.ME3_id() ) timeline[track.ME3_tbin()].push_back(3); 00032 if( track.ME4_id() ) timeline[track.ME4_tbin()].push_back(4); 00033 int earliest_tbin=0, second_earliest_tbin=0; 00034 for(int bx=7; bx>=0; bx--){ 00035 std::list<int>::const_iterator iter = timeline[bx].begin(); 00036 while( iter != timeline[bx].end() ){ 00037 if( earliest_tbin==0 ) earliest_tbin=bx; 00038 else if( second_earliest_tbin==0 ) second_earliest_tbin=bx; 00039 iter++; 00040 } 00041 } 00042 // MEx_tbin are LCTs delays shifting all of them to the bx of last LCT used to build a track 00043 // let's convert delays to TBINs keeping in mind that tbin = some_shift - second_earliest_tbin 00044 if( track.ME1_id() ){ // if track contains LCT from first station 00045 unsigned int mpc = ( track.ME1_id()>3 ? 1 : 0 ); 00046 int ME1_tbin = tbin - track.ME1_tbin() + second_earliest_tbin; 00047 if( ME1_tbin<0 || ME1_tbin>7 ) unpackError |= true; 00048 else { 00049 std::vector<CSCSP_MEblock> lcts = record_[ME1_tbin].LCTs(mpc); 00050 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++) 00051 // Due to old MPC firmware link information was not accessible for some data: 00052 //if( lct->link()==(mpc?track.ME1_id()-3:track.ME1_id()) ){ 00053 if( ((lct->spInput()-1)%3+1)==(mpc?track.ME1_id()-3:track.ME1_id()) ){ 00054 track.lct_[0] = *lct; 00055 track.lctFilled[0] = true; 00056 } 00057 } 00058 } 00059 if( track.ME2_id() ){ // ... second station 00060 int ME2_tbin = tbin - track.ME2_tbin() + second_earliest_tbin; 00061 if( ME2_tbin<0 || ME2_tbin>7 ) unpackError |= true; 00062 else { 00063 std::vector<CSCSP_MEblock> lcts = record_[ME2_tbin].LCTs(2); 00064 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++) 00065 // Due to old MPC firmware link information was not accessible for some data: 00066 //if( lct->link()==track.ME2_id() ){ 00067 if( ((lct->spInput()-1)%3+1)==track.ME2_id() ){ 00068 track.lct_[1] = *lct; 00069 track.lctFilled[1] = true; 00070 } 00071 } 00072 } 00073 if( track.ME3_id() ){ // ... third station 00074 int ME3_tbin = tbin - track.ME3_tbin() + second_earliest_tbin; 00075 if( ME3_tbin<0 || ME3_tbin>7 ) unpackError |= true; 00076 else { 00077 std::vector<CSCSP_MEblock> lcts = record_[ME3_tbin].LCTs(3); 00078 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++) 00079 // Due to old MPC firmware link information was not accessible for some data: 00080 //if( lct->link()==track.ME3_id() ){ 00081 if( ((lct->spInput()-1)%3+1)==track.ME3_id() ){ 00082 track.lct_[2] = *lct; 00083 track.lctFilled[2] = true; 00084 } 00085 } 00086 } 00087 if( track.ME4_id() ){ // ... fourth station 00088 int ME4_tbin = tbin - track.ME4_tbin() + second_earliest_tbin; 00089 if( ME4_tbin<0 || ME4_tbin>7 ) unpackError |= true; 00090 else { 00091 std::vector<CSCSP_MEblock> lcts = record_[ME4_tbin].LCTs(4); 00092 for(std::vector<CSCSP_MEblock>::const_iterator lct=lcts.begin(); lct!=lcts.end(); lct++) 00093 // Due to old MPC firmware link information was not accessible for some data: 00094 //if( lct->link()==track.ME4_id() ){ 00095 if( ((lct->spInput()-1)%3+1)==track.ME4_id() ){ 00096 track.lct_[3] = *lct; 00097 track.lctFilled[3] = true; 00098 } 00099 } 00100 } 00101 if( track.MB_id() ){ // ... barrel 00102 if( (tbin==0 && track.MB_tbin()) || (tbin==6 && track.MB_id()%2==0) ) unpackError |= true; 00103 else { 00104 std::vector<CSCSP_MBblock> stubs = ( track.MB_id()%2==0 ? record_[tbin+1].mbStubs() : record_[tbin].mbStubs() ); 00105 for(std::vector<CSCSP_MBblock>::const_iterator stub=stubs.begin(); stub!=stubs.end(); stub++) 00106 if( (stub->id()==1 && track.MB_id()<=2) || (stub->id()==2 && track.MB_id()>2) ){ 00107 track.dt_ = *stub; 00108 track.dtFilled = true; 00109 } 00110 if( !track.dtFilled ) unpackError |= true; 00111 } 00112 } 00113 00114 } 00115 } 00116 } 00117 00118 unpackError |= trailer_.unpack(buf); 00119 00120 return unpackError; 00121 }
CSCSPCounters CSCSPEvent::counters_ [private] |
CSCSPHeader CSCSPEvent::header_ [private] |
CSCSPRecord CSCSPEvent::record_[7] [private] |
CSCSPTrailer CSCSPEvent::trailer_ [private] |