From 1148b3afc2a6caba1a74e33a68fb119ef5f8e560 Mon Sep 17 00:00:00 2001 From: Andrew Brinkerhoff Date: Mon, 1 Feb 2016 19:03:30 +0100 Subject: [PATCH] v1 of EMTF unpacking, continued --- DataFormats/L1TMuon/interface/EMTF/ME.h | 12 +-- DataFormats/L1TMuon/interface/EMTF/SP.h | 70 ++++++++--------- .../EMTFBlockCounters.cc | 14 ++-- .../EMTFBlockHeaders.cc | 75 +++++++++++++------ .../src/implementations_stage2/EMTFBlockME.cc | 52 +++++++------ .../src/implementations_stage2/EMTFBlockSP.cc | 63 ++++++++++------ .../EMTFBlockTrailers.cc | 70 ++++++++++------- .../src/implementations_stage2/EMTFSetup.cc | 2 +- .../EMTFUnpackerTools.h | 39 ++++++---- 9 files changed, 240 insertions(+), 157 deletions(-) diff --git a/DataFormats/L1TMuon/interface/EMTF/ME.h b/DataFormats/L1TMuon/interface/EMTF/ME.h index a09fc710aadb0..9880558c704c7 100644 --- a/DataFormats/L1TMuon/interface/EMTF/ME.h +++ b/DataFormats/L1TMuon/interface/EMTF/ME.h @@ -13,11 +13,11 @@ namespace l1t { explicit ME(uint64_t dataword); ME() : - me_bxn(-99), key_wire_group(-99), clct_key_half_strip(-99), quality(-99), clct_pattern(-99), id(-99), epc(-99), station(-99), tbin_num(-99), bc0(-99), bxe(-99), lr(-99), afff(-99), cik(-99), nit(-99), afef(-99), se(-99), sm(-99), af(-99), vp(-99), dataword(-99) + me_bxn(-99), key_wire_group(-99), clct_key_half_strip(-99), quality(-99), clct_pattern(-99), csc_ID(-99), epc(-99), station(-99), tbin_num(-99), bc0(-99), bxe(-99), lr(-99), afff(-99), cik(-99), nit(-99), afef(-99), se(-99), sm(-99), af(-99), vp(-99), dataword(-99) {}; - ME(int int_me_bxn, int int_key_wire_group, int int_clct_key_half_strip, int int_quality, int int_clct_pattern, int int_id, int int_epc, int int_station, int int_tbin_num, int int_bc0, int int_bxe, int int_lr, int int_afff, int int_cik, int int_nit, int int_afef, int int_se, int int_sm, int int_af, int int_vp) : - me_bxn(int_me_bxn), key_wire_group(int_key_wire_group), clct_key_half_strip(int_clct_key_half_strip), quality(int_quality), clct_pattern(int_clct_pattern), id(int_id), epc(int_epc), station(int_station), tbin_num(int_tbin_num), bc0(int_bc0), bxe(int_bxe), lr(int_lr), afff(int_afff), cik(int_cik), nit(int_nit), afef(int_afef), se(int_se), sm(int_sm), af(int_af), vp(int_vp), dataword(-99) + ME(int int_me_bxn, int int_key_wire_group, int int_clct_key_half_strip, int int_quality, int int_clct_pattern, int int_csc_ID, int int_epc, int int_station, int int_tbin_num, int int_bc0, int int_bxe, int int_lr, int int_afff, int int_cik, int int_nit, int int_afef, int int_se, int int_sm, int int_af, int int_vp) : + me_bxn(int_me_bxn), key_wire_group(int_key_wire_group), clct_key_half_strip(int_clct_key_half_strip), quality(int_quality), clct_pattern(int_clct_pattern), csc_ID(int_csc_ID), epc(int_epc), station(int_station), tbin_num(int_tbin_num), bc0(int_bc0), bxe(int_bxe), lr(int_lr), afff(int_afff), cik(int_cik), nit(int_nit), afef(int_afef), se(int_se), sm(int_sm), af(int_af), vp(int_vp), dataword(-99) {}; virtual ~ME() {}; @@ -27,7 +27,7 @@ namespace l1t { void set_clct_key_half_strip(int bits) { clct_key_half_strip = bits; }; void set_quality(int bits) { quality = bits; }; void set_clct_pattern(int bits) { clct_pattern = bits; }; - void set_id(int bits) { id = bits; }; + void set_csc_ID(int bits) { csc_ID = bits; }; void set_epc(int bits) { epc = bits; }; void set_station(int bits) { station = bits; }; void set_tbin_num(int bits) { tbin_num = bits; }; @@ -49,7 +49,7 @@ namespace l1t { const int CLCT_key_half_strip() const { return clct_key_half_strip ; }; const int Quality() const { return quality ; }; const int CLCT_pattern() const { return clct_pattern ; }; - const int ID() const { return id ; }; + const int CSC_ID() const { return csc_ID ; }; const int EPC() const { return epc ; }; const int Station() const { return station ; }; const int Tbin_num() const { return tbin_num ; }; @@ -72,7 +72,7 @@ namespace l1t { int clct_key_half_strip; int quality; int clct_pattern; - int id; + int csc_ID; int epc; int station; int tbin_num; diff --git a/DataFormats/L1TMuon/interface/EMTF/SP.h b/DataFormats/L1TMuon/interface/EMTF/SP.h index 9d390d5650a1d..66354f6c27879 100644 --- a/DataFormats/L1TMuon/interface/EMTF/SP.h +++ b/DataFormats/L1TMuon/interface/EMTF/SP.h @@ -13,31 +13,31 @@ namespace l1t { explicit SP(uint64_t dataword); SP() : - pt_lut_address(-99), phi_full(-99), phi_gmt(-99), eta(-99), pt(-99), quality(-99), bx(-99), me4_id(-99), me3_id(-99), me2_id(-99), me1_id(-99), me4_tbin(-99), me3_tbin(-99), me2_tbin(-99), me1_tbin(-99), tbin_num(-99), hl(-99), c(-99), vc(-99), vt(-99), se(-99), bc0(-99), dataword(-99) + pt_lut_address(-99), phi_full(-99), phi_GMT(-99), eta_GMT(-99), pt(-99), quality(-99), bx(-99), me4_ID(-99), me3_ID(-99), me2_ID(-99), me1_ID(-99), me4_TBIN(-99), me3_TBIN(-99), me2_TBIN(-99), me1_TBIN(-99), tbin_num(-99), hl(-99), c(-99), vc(-99), vt(-99), se(-99), bc0(-99), dataword(-99) {}; - SP(int int_pt_lut_address, int int_phi_full, int int_phi_gmt, int int_eta, int int_pt, int int_quality, int int_bx, int int_me4_id, int int_me3_id, int int_me2_id, int int_me1_id, int int_me4_tbin, int int_me3_tbin, int int_me2_tbin, int int_me1_tbin, int int_tbin_num, int int_hl, int int_c, int int_vc, int int_vt, int int_se, int int_bc0) : - pt_lut_address(int_pt_lut_address), phi_full(int_phi_full), phi_gmt(int_phi_gmt), eta(int_eta), pt(int_pt), quality(int_quality), bx(int_bx), me4_id(int_me4_id), me3_id(int_me3_id), me2_id(int_me2_id), me1_id(int_me1_id), me4_tbin(int_me4_tbin), me3_tbin(int_me3_tbin), me2_tbin(int_me2_tbin), me1_tbin(int_me1_tbin), tbin_num(int_tbin_num), hl(int_hl), c(int_c), vc(int_vc), vt(int_vt), se(int_se), bc0(int_bc0), dataword(-99) + SP(int int_pt_lut_address, int int_phi_full, int int_phi_GMT, int int_eta_GMT, int int_pt, int int_quality, int int_bx, int int_me4_ID, int int_me3_ID, int int_me2_ID, int int_me1_ID, int int_me4_TBIN, int int_me3_TBIN, int int_me2_TBIN, int int_me1_TBIN, int int_TBIN_num, int int_hl, int int_c, int int_vc, int int_vt, int int_se, int int_bc0) : + pt_lut_address(int_pt_lut_address), phi_full(int_phi_full), phi_GMT(int_phi_GMT), eta_GMT(int_eta_GMT), pt(int_pt), quality(int_quality), bx(int_bx), me4_ID(int_me4_ID), me3_ID(int_me3_ID), me2_ID(int_me2_ID), me1_ID(int_me1_ID), me4_TBIN(int_me4_TBIN), me3_TBIN(int_me3_TBIN), me2_TBIN(int_me2_TBIN), me1_TBIN(int_me1_TBIN), tbin_num(int_TBIN_num), hl(int_hl), c(int_c), vc(int_vc), vt(int_vt), se(int_se), bc0(int_bc0), dataword(-99) {}; virtual ~SP() {}; void set_pt_lut_address(int bits) { pt_lut_address= bits; }; void set_phi_full (int bits) { phi_full = bits; }; - void set_phi_gmt (int bits) { phi_gmt = bits; }; - void set_eta (int bits) { eta = bits; }; + void set_phi_GMT (int bits) { phi_GMT = bits; }; + void set_eta_GMT (int bits) { eta_GMT = bits; }; void set_pt (int bits) { pt = bits; }; void set_quality (int bits) { quality = bits; }; void set_bx (int bits) { bx = bits; }; - void set_me4_id (int bits) { me4_id = bits; }; - void set_me3_id (int bits) { me3_id = bits; }; - void set_me2_id (int bits) { me2_id = bits; }; - void set_me1_id (int bits) { me1_id = bits; }; - void set_me4_tbin (int bits) { me4_tbin = bits; }; - void set_me3_tbin (int bits) { me3_tbin = bits; }; - void set_me2_tbin (int bits) { me2_tbin = bits; }; - void set_me1_tbin (int bits) { me1_tbin = bits; }; - void set_tbin_num (int bits) { tbin_num = bits; }; + void set_me4_ID (int bits) { me4_ID = bits; }; + void set_me3_ID (int bits) { me3_ID = bits; }; + void set_me2_ID (int bits) { me2_ID = bits; }; + void set_me1_ID (int bits) { me1_ID = bits; }; + void set_me4_TBIN (int bits) { me4_TBIN = bits; }; + void set_me3_TBIN (int bits) { me3_TBIN = bits; }; + void set_me2_TBIN (int bits) { me2_TBIN = bits; }; + void set_me1_TBIN (int bits) { me1_TBIN = bits; }; + void set_TBIN_num (int bits) { tbin_num = bits; }; void set_hl (int bits) { hl = bits; }; void set_c (int bits) { c = bits; }; void set_vc (int bits) { vc = bits; }; @@ -48,20 +48,20 @@ namespace l1t { const int Pt_lut_address() const { return pt_lut_address; }; const int Phi_full() const { return phi_full ; }; - const int Phi_gmt() const { return phi_gmt ; }; - const int Eta() const { return eta ; }; + const int Phi_GMT() const { return phi_GMT ; }; + const int Eta_GMT() const { return eta_GMT ; }; const int Pt() const { return pt ; }; const int Quality() const { return quality ; }; const int BX() const { return bx ; }; - const int ME4_id() const { return me4_id ; }; - const int ME3_id() const { return me3_id ; }; - const int ME2_id() const { return me2_id ; }; - const int ME1_id() const { return me1_id ; }; - const int ME4_tbin() const { return me4_tbin ; }; - const int ME3_tbin() const { return me3_tbin ; }; - const int ME2_tbin() const { return me2_tbin ; }; - const int ME1_tbin() const { return me1_tbin ; }; - const int Tbin_num() const { return tbin_num ; }; + const int ME4_ID() const { return me4_ID ; }; + const int ME3_ID() const { return me3_ID ; }; + const int ME2_ID() const { return me2_ID ; }; + const int ME1_ID() const { return me1_ID ; }; + const int ME4_TBIN() const { return me4_TBIN ; }; + const int ME3_TBIN() const { return me3_TBIN ; }; + const int ME2_TBIN() const { return me2_TBIN ; }; + const int ME1_TBIN() const { return me1_TBIN ; }; + const int TBIN_num() const { return tbin_num ; }; const int HL() const { return hl ; }; const int C() const { return c ; }; const int VC() const { return vc ; }; @@ -74,19 +74,19 @@ namespace l1t { private: int pt_lut_address; int phi_full ; - int phi_gmt ; - int eta ; + int phi_GMT ; + int eta_GMT ; int pt ; int quality ; int bx ; - int me4_id ; - int me3_id ; - int me2_id ; - int me1_id ; - int me4_tbin ; - int me3_tbin ; - int me2_tbin ; - int me1_tbin ; + int me4_ID ; + int me3_ID ; + int me2_ID ; + int me1_ID ; + int me4_TBIN ; + int me3_TBIN ; + int me2_TBIN ; + int me1_TBIN ; int tbin_num ; int hl ; int c ; diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockCounters.cc b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockCounters.cc index e15bde96a6b51..395a964063a2d 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockCounters.cc +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockCounters.cc @@ -29,8 +29,6 @@ namespace l1t { namespace stage2 { namespace emtf { - EMTFUnpackerTools tools2; - bool CountersBlockUnpacker::unpack(const Block& block, UnpackerCollections *coll) { // Get the payload for this block, made up of 16-bit words (0xffff) @@ -42,6 +40,12 @@ namespace l1t { // for (uint iWord = 0; iWord < payload.size(); iWord++) // std::cout << std::hex << std::setw(8) << std::setfill('0') << payload[iWord] << std::dec << std::endl; + // Assign payload to 16-bit words + uint16_t BCa = payload[0]; + uint16_t BCb = payload[1]; + uint16_t BCc = payload[2]; + uint16_t BCd = payload[3]; + // res is a pointer to a collection of EMTFOutput class objects // There is one EMTFOutput for each MTF7 (60 deg. sector) in the event EMTFOutputCollection* res; @@ -56,9 +60,9 @@ namespace l1t { std::cout << "Why is there already an Counters?" << std::endl; l1t::emtf::Counters Counters_; - // Counters_.set_track_counter( tools2.GetHexBits(payload[], , ) ); - // Counters_.set_orbit_counter( tools2.GetHexBits(payload[], , ) ); - // Counters_.set_rpc_counter( tools2.GetHexBits(payload[], , ) ); + Counters_.set_track_counter( GetHexBits(BCa, 0, 14, BCb, 0, 14) ); + Counters_.set_orbit_counter( GetHexBits(BCc, 0, 14, BCd, 0, 14) ); + // Counters_.set_rpc_counter( GetHexBits(payload[], , ) ); // Counters_.set_dataword(uint64_t bits) { dataword = bits; }; (res->at(iOut)).set_Counters(Counters_); diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockHeaders.cc b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockHeaders.cc index 5bcfc173f3fe3..7035ff43e204f 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockHeaders.cc +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockHeaders.cc @@ -29,8 +29,6 @@ namespace l1t { namespace stage2 { namespace emtf { - EMTFUnpackerTools tools1; - bool HeadersBlockUnpacker::unpack(const Block& block, UnpackerCollections *coll) { // Get the payload for this block, made up of 16-bit words (0xffff) @@ -38,9 +36,39 @@ namespace l1t { // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc. auto payload = block.payload(); + // TODO: Proper error handling for payload size check (also in other Block functions) // std::cout << "This payload has " << payload.size() << " 16-bit words" << std::endl; - // for (uint iWord = 0; iWord < payload.size(); iWord++) - // std::cout << std::hex << std::setw(8) << std::setfill('0') << payload[iWord] << std::dec << std::endl; + if (payload.size() != 12) { + std::cout << "Critical error in EMTFBlockHeaders.cc: payload.size() = " + << payload.size() << ", not 12!!!" << std::endl; + // return 0; + } + + // TODO: Proper error handling for > 16-bit words (also in other Block functions) + for (uint iWord = 0; iWord < payload.size(); iWord++) { + // std::cout << std::hex << std::setw(4) << std::setfill('0') << payload[iWord] << std::dec << std::endl; + if ( (payload[iWord] >> 16) > 0 ) { + std::cout << "Critical error: payload[" << iWord << "] = " << std::hex << payload[iWord] + << std::dec << ", more than 16 bits!!!" << std::dec << std::endl; + // return 0; + } + } + + // Assign payload to 16-bit words + uint16_t HD1a = payload[0]; + uint16_t HD1b = payload[1]; + // uint16_t HD1c = payload[2]; + uint16_t HD1d = payload[3]; + // uint16_t HD2a = payload[4]; + uint16_t HD2b = payload[5]; + uint16_t HD2c = payload[6]; + uint16_t HD2d = payload[7]; + uint16_t HD3a = payload[8]; + uint16_t HD3b = payload[9]; + uint16_t HD3c = payload[10]; + uint16_t HD3d = payload[11]; + + // TODO: Proper checks for Event Record Header format (also in other Block functions) // res is a pointer to a collection of EMTFOutput class objects // There is one EMTFOutput for each MTF7 (60 deg. sector) in the event @@ -52,7 +80,6 @@ namespace l1t { res->push_back(EMTFOutput_); int iOut = res->size() - 1; - ////////////////////////////////////// // Unpack the AMC13 header information ////////////////////////////////////// @@ -107,25 +134,25 @@ namespace l1t { std::cout << "Why is there already an EventHeader?" << std::endl; l1t::emtf::EventHeader EventHeader_; - // EventHeader_.set_l1a( tools1.GetHexBits(payload[], , ) ) { l1a = bits; }; - EventHeader_.set_l1a_bxn ( tools1.GetHexBits(payload[3], 0, 11) ); - EventHeader_.set_sp_ts ( tools1.GetHexBits(payload[5], 8, 11) ); - EventHeader_.set_sp_ersv ( tools1.GetHexBits(payload[5], 5, 7) ); - EventHeader_.set_sp_addr ( tools1.GetHexBits(payload[5], 0, 4) ); - EventHeader_.set_tbin ( tools1.GetHexBits(payload[6], 8, 10) ); - EventHeader_.set_ddm ( tools1.GetHexBits(payload[6], 7, 7) ); - EventHeader_.set_spa ( tools1.GetHexBits(payload[6], 6, 6) ); - EventHeader_.set_rpca ( tools1.GetHexBits(payload[6], 5, 5) ); - EventHeader_.set_skip ( tools1.GetHexBits(payload[6], 4, 4) ); - EventHeader_.set_rdy ( tools1.GetHexBits(payload[6], 3, 3) ); - EventHeader_.set_bsy ( tools1.GetHexBits(payload[6], 2, 2) ); - EventHeader_.set_osy ( tools1.GetHexBits(payload[6], 1, 1) ); - EventHeader_.set_wof ( tools1.GetHexBits(payload[6], 0, 0) ); - EventHeader_.set_me1a ( tools1.GetHexBits(payload[7], 0, 11) ); - EventHeader_.set_me1b ( tools1.GetHexBits(payload[8], 0, 8) ); - EventHeader_.set_me2 ( tools1.GetHexBits(payload[9], 0, 10) ); - EventHeader_.set_me3 ( tools1.GetHexBits(payload[10], 0, 10) ); - EventHeader_.set_me4 ( tools1.GetHexBits(payload[11], 0, 10) ); + EventHeader_.set_l1a ( GetHexBits(HD1a, 0, 11, HD1b, 0, 11) ); + EventHeader_.set_l1a_bxn ( GetHexBits(HD1d, 0, 11) ); + EventHeader_.set_sp_ts ( GetHexBits(HD2b, 8, 11) ); + EventHeader_.set_sp_ersv ( GetHexBits(HD2b, 5, 7) ); + EventHeader_.set_sp_addr ( GetHexBits(HD2b, 0, 4) ); + EventHeader_.set_tbin ( GetHexBits(HD2c, 8, 10) ); + EventHeader_.set_ddm ( GetHexBits(HD2c, 7, 7) ); + EventHeader_.set_spa ( GetHexBits(HD2c, 6, 6) ); + EventHeader_.set_rpca ( GetHexBits(HD2c, 5, 5) ); + EventHeader_.set_skip ( GetHexBits(HD2c, 4, 4) ); + EventHeader_.set_rdy ( GetHexBits(HD2c, 3, 3) ); + EventHeader_.set_bsy ( GetHexBits(HD2c, 2, 2) ); + EventHeader_.set_osy ( GetHexBits(HD2c, 1, 1) ); + EventHeader_.set_wof ( GetHexBits(HD2c, 0, 0) ); + EventHeader_.set_me1a ( GetHexBits(HD2d, 0, 11) ); + EventHeader_.set_me1b ( GetHexBits(HD3a, 0, 8) ); + EventHeader_.set_me2 ( GetHexBits(HD3b, 0, 10) ); + EventHeader_.set_me3 ( GetHexBits(HD3c, 0, 10) ); + EventHeader_.set_me4 ( GetHexBits(HD3d, 0, 10) ); // EventHeader_.set_dataword(uint64_t bits) { dataword = bits; }; (res->at(iOut)).set_EventHeader(EventHeader_); diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockME.cc b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockME.cc index ca66757d9c5e8..8e1fb958d62a4 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockME.cc +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockME.cc @@ -29,8 +29,6 @@ namespace l1t { namespace stage2 { namespace emtf { - EMTFUnpackerTools tools3; - bool MEBlockUnpacker::unpack(const Block& block, UnpackerCollections *coll) { // Get the payload for this block, made up of 16-bit words (0xffff) @@ -38,6 +36,12 @@ namespace l1t { // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc. auto payload = block.payload(); + // Assign payload to 16-bit words + uint16_t MEa = payload[0]; + uint16_t MEb = payload[1]; + uint16_t MEc = payload[2]; + uint16_t MEd = payload[3]; + // std::cout << "This payload has " << payload.size() << " 16-bit words" << std::endl; // for (uint iWord = 0; iWord < payload.size(); iWord++) // std::cout << std::hex << std::setw(8) << std::setfill('0') << payload[iWord] << std::dec << std::endl; @@ -54,26 +58,30 @@ namespace l1t { l1t::emtf::ME ME_; - ME_.set_me_bxn ( tools3.GetHexBits(payload[2], 0, 11) ); - ME_.set_key_wire_group ( tools3.GetHexBits(payload[0], 8, 14) ); - ME_.set_clct_key_half_strip ( tools3.GetHexBits(payload[1], 0, 7) ); - // ME_.set_quality ( tools3.GetHexBits(payload[], , ) ); - ME_.set_clct_pattern ( tools3.GetHexBits(payload[0], 0, 3) ); - ME_.set_id ( tools3.GetHexBits(payload[1], 8, 10) ); - // ME_.set_epc ( tools3.GetHexBits(payload[], , ) ); - ME_.set_station ( tools3.GetHexBits(payload[3], 4, 6) ); - // ME_.set_tbin_num ( tools3.GetHexBits(payload[], , ) ); - ME_.set_bc0 ( tools3.GetHexBits(payload[1], 14, 14) ); - ME_.set_bxe ( tools3.GetHexBits(payload[1], 13, 13) ); - ME_.set_lr ( tools3.GetHexBits(payload[1], 12, 12) ); - // ME_.set_afff ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_cik ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_nit ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_afef ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_se ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_sm ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_af ( tools3.GetHexBits(payload[], , ) ); - // ME_.set_vp ( tools3.GetHexBits(payload[], , ) ); + ME_.set_clct_pattern ( GetHexBits(MEa, 0, 3) ); + ME_.set_quality ( GetHexBits(MEa, 4, 7) ); + ME_.set_key_wire_group ( GetHexBits(MEa, 8, 14) ); + + ME_.set_clct_key_half_strip ( GetHexBits(MEb, 0, 7) ); + ME_.set_csc_ID ( GetHexBits(MEb, 8, 11) ); + ME_.set_lr ( GetHexBits(MEb, 12, 12) ); + ME_.set_bxe ( GetHexBits(MEb, 13, 13) ); + ME_.set_bc0 ( GetHexBits(MEb, 14, 14) ); + + ME_.set_me_bxn ( GetHexBits(MEc, 0, 11) ); + ME_.set_nit ( GetHexBits(MEc, 12, 12) ); + ME_.set_cik ( GetHexBits(MEc, 13, 13) ); + ME_.set_afff ( GetHexBits(MEc, 14, 14) ); + + ME_.set_tbin_num ( GetHexBits(MEd, 0, 2) ); + ME_.set_vp ( GetHexBits(MEd, 3, 3) ); + ME_.set_station ( GetHexBits(MEd, 4, 6) ); + ME_.set_af ( GetHexBits(MEd, 7, 7) ); + ME_.set_epc ( GetHexBits(MEd, 8, 11) ); + ME_.set_sm ( GetHexBits(MEd, 12, 12) ); + ME_.set_se ( GetHexBits(MEd, 13, 13) ); + ME_.set_afef ( GetHexBits(MEd, 14, 14) ); + // ME_.set_dataword ( uint64_t dataword); (res->at(iOut)).push_ME(ME_); diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockSP.cc b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockSP.cc index 1ecfd8fab71f1..3eb0830039c30 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockSP.cc +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockSP.cc @@ -29,8 +29,6 @@ namespace l1t { namespace stage2 { namespace emtf { - EMTFUnpackerTools tools4; - bool SPBlockUnpacker::unpack(const Block& block, UnpackerCollections *coll) { // Get the payload for this block, made up of 16-bit words (0xffff) @@ -38,6 +36,16 @@ namespace l1t { // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc. auto payload = block.payload(); + // Assign payload to 16-bit words + uint16_t SP1a = payload[0]; + uint16_t SP1b = payload[1]; + uint16_t SP1c = payload[2]; + uint16_t SP1d = payload[3]; + uint16_t SP2a = payload[4]; + uint16_t SP2b = payload[5]; + uint16_t SP2c = payload[6]; + uint16_t SP2d = payload[7]; + // std::cout << "This payload has " << payload.size() << " 16-bit words" << std::endl; // for (uint iWord = 0; iWord < payload.size(); iWord++) // std::cout << std::hex << std::setw(8) << std::setfill('0') << payload[iWord] << std::dec << std::endl; @@ -54,28 +62,35 @@ namespace l1t { l1t::emtf::SP SP_; - // SP_.set_pt_lut_address ( tools4.GetHexBits(payload[], , ) ); - SP_.set_phi_full ( tools4.GetHexBits(payload[0], 0, 11) ); - SP_.set_phi_gmt ( tools4.GetHexBits(payload[1], 0, 7) ); - SP_.set_eta ( tools4.GetHexBits(payload[2], 0, 8) ); - SP_.set_pt ( tools4.GetHexBits(payload[3], 0, 8) ); - SP_.set_quality ( tools4.GetHexBits(payload[2], 9, 12) ); - SP_.set_bx ( tools4.GetHexBits(payload[2], 13, 14) ); - SP_.set_me4_id ( tools4.GetHexBits(payload[4], 10, 14) ); - SP_.set_me3_id ( tools4.GetHexBits(payload[4], 5, 9) ); - SP_.set_me2_id ( tools4.GetHexBits(payload[4], 0, 4) ); - SP_.set_me1_id ( tools4.GetHexBits(payload[3], 9, 14) ); - // SP_.set_me4_tbin ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_me3_tbin ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_me2_tbin ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_me1_tbin ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_tbin_num ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_hl ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_c ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_vc ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_vt ( tools4.GetHexBits(payload[], , ) ); - // SP_.set_se ( tools4.GetHexBits(payload[], , ) ); - SP_.set_bc0 ( tools4.GetHexBits(payload[1], 12, 12) ); + SP_.set_phi_full ( GetHexBits(SP1a, 0, 11) ); + SP_.set_vc ( GetHexBits(SP1a, 12, 12) ); + SP_.set_c ( GetHexBits(SP1a, 13, 13) ); + SP_.set_hl ( GetHexBits(SP1a, 14, 14) ); + + SP_.set_phi_GMT ( GetHexBits(SP1b, 0, 7) ); + SP_.set_bc0 ( GetHexBits(SP1b, 12, 12) ); + SP_.set_se ( GetHexBits(SP1b, 13, 13) ); + SP_.set_vt ( GetHexBits(SP1b, 14, 14) ); + + SP_.set_eta_GMT ( GetHexBits(SP1c, 0, 8) ); + SP_.set_quality ( GetHexBits(SP1c, 9, 12) ); + SP_.set_bx ( GetHexBits(SP1c, 13, 14) ); + + SP_.set_pt ( GetHexBits(SP1d, 0, 8) ); + SP_.set_me1_ID ( GetHexBits(SP1d, 9, 14) ); + + SP_.set_me2_ID ( GetHexBits(SP2a, 0, 4) ); + SP_.set_me3_ID ( GetHexBits(SP2a, 5, 9) ); + SP_.set_me4_ID ( GetHexBits(SP2a, 10, 14) ); + + SP_.set_me1_TBIN ( GetHexBits(SP2b, 0, 2) ); + SP_.set_me2_TBIN ( GetHexBits(SP2b, 3, 5) ); + SP_.set_me3_TBIN ( GetHexBits(SP2b, 6, 8) ); + SP_.set_me4_TBIN ( GetHexBits(SP2b, 9, 11) ); + SP_.set_TBIN_num ( GetHexBits(SP2b, 12, 14) ); + + SP_.set_pt_lut_address ( GetHexBits(SP2c, 0, 14, SP2d, 0, 14) ); + // SP.set_dataword ( uint64_t dataword ); (res->at(iOut)).push_SP(SP_); diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockTrailers.cc b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockTrailers.cc index 6133e5990ab11..d2c7054b58ef4 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockTrailers.cc +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFBlockTrailers.cc @@ -29,8 +29,6 @@ namespace l1t { namespace stage2 { namespace emtf { - EMTFUnpackerTools tools5; - bool TrailersBlockUnpacker::unpack(const Block& block, UnpackerCollections *coll) { // Get the payload for this block, made up of 16-bit words (0xffff) @@ -38,6 +36,16 @@ namespace l1t { // payload[0] = bits 0-15, payload[1] = 16-31, payload[3] = 32-47, etc. auto payload = block.payload(); + // Assign payload to 16-bit words + uint16_t TR1a = payload[0]; + uint16_t TR1b = payload[1]; + uint16_t TR1c = payload[2]; + uint16_t TR1d = payload[3]; + uint16_t TR2a = payload[4]; + uint16_t TR2b = payload[5]; + uint16_t TR2c = payload[6]; + uint16_t TR2d = payload[7]; + // std::cout << "This payload has " << payload.size() << " 16-bit words" << std::endl; // for (uint iWord = 0; iWord < payload.size(); iWord++) // std::cout << std::hex << std::setw(8) << std::setfill('0') << payload[iWord] << std::dec << std::endl; @@ -56,19 +64,29 @@ namespace l1t { std::cout << "Why is there already an EventTrailer?" << std::endl; l1t::emtf::EventTrailer EventTrailer_; - // EventTrailer_.set_crc22 ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_ddcsr_bid ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_ddcsr_lf ( tools5.GetHexBits(payload[], , ) ); - EventTrailer_.set_spcsr_scc ( tools5.GetHexBits(payload[3], 0, 11) ); - EventTrailer_.set_l1a ( tools5.GetHexBits(payload[0], 0, 7) ); - // EventTrailer_.set_yy ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_mm ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_dd ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_sp_ladr ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_sp_ersv ( tools5.GetHexBits(payload[], , ) ); - // EventTrailer_.set_sp_padr ( tools5.GetHexBits(payload[], , ) ); - EventTrailer_.set_lfff ( tools5.GetHexBits(payload[1], 7, 7) ); - // EventTrailer_.set_bb ( tools5.GetHexBits(payload[], , ) ); + EventTrailer_.set_l1a ( GetHexBits(TR1a, 0, 7) ); + EventTrailer_.set_ddcsr_lf ( GetHexBits(TR1a, 8, 11, TR1b, 8, 11) ); + + EventTrailer_.set_lfff ( GetHexBits(TR1b, 7, 7) ); + + // EventTrailer_.set_ddcsr_bid ( GetHexBits(TR2a, 0, 4, TR1c, 0, 8) ); // Probably incorrect + EventTrailer_.set_mm ( GetHexBits(TR1c, 0, 3) ); + EventTrailer_.set_yy ( GetHexBits(TR1c, 4, 7) ); + EventTrailer_.set_bb ( GetHexBits(TR1c, 8, 8) ); + + EventTrailer_.set_spcsr_scc ( GetHexBits(TR1d, 0, 11) ); + + EventTrailer_.set_dd ( GetHexBits(TR2a, 0, 4) ); + + EventTrailer_.set_sp_padr ( GetHexBits(TR2b, 0, 4) ); + EventTrailer_.set_sp_ersv ( GetHexBits(TR2b, 5, 7) ); + EventTrailer_.set_sp_ladr ( GetHexBits(TR2b, 8, 11) ); + + EventTrailer_.set_crc22 ( GetHexBits(TR2c, 0, 10, TR2d, 0, 10) ); + // TODO: Put in DataFormats/L1TMuon/interface/EMTF/EventTrailer.h + // EventTrailer_.set_lp ( GetHexBits(TR2c, 11, 11) ); + // EventTrailer_.set_hp ( GetHexBits(TR2d, 11, 11) ); + // EventTrailer_.set_dataword(uint64_t bits) { dataword = bits; }; (res->at(iOut)).set_EventTrailer(EventTrailer_); @@ -82,9 +100,9 @@ namespace l1t { l1t::emtf::MTF7Trailer MTF7Trailer_; // // AMC trailer info defined in interface/AMCSpec.h ... but not implemented in interface/Block.h? - // MTF7Trailer_.set_crc_32( tools5.GetHexBits(payload[], , ) ); - // MTF7Trailer_.set_lv1_id( tools5.GetHexBits(payload[], , ) ); - // MTF7Trailer_.set_data_length( tools5.GetHexBits(payload[], , ) ); + // MTF7Trailer_.set_crc_32( GetHexBits(payload[], , ) ); + // MTF7Trailer_.set_lv1_id( GetHexBits(payload[], , ) ); + // MTF7Trailer_.set_data_length( GetHexBits(payload[], , ) ); // MTF7Trailer_.set_dataword(uint64_t bits) { dataword = bits; }; (res->at(iOut)).set_MTF7Trailer(MTF7Trailer_); @@ -100,14 +118,14 @@ namespace l1t { // TODO: Write functions in interface/AMC13Spec.h (as in AMCSpec.h) to extract all AMC13 header and trailer info // TODO: Edit interface/Block.h to have a amc13() function similar to amc() - // AMC13Trailer_.set_evt_lgth( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_crc16( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_evt_stat( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_tts( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_c( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_f( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_t( tools5.GetHexBits(payload[], , ) ); - // AMC13Trailer_.set_r( tools5.GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_evt_lgth( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_crc16( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_evt_stat( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_tts( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_c( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_f( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_t( GetHexBits(payload[], , ) ); + // AMC13Trailer_.set_r( GetHexBits(payload[], , ) ); // AMC13Trailer_.set_dataword(uint64_t bits) { dataword = bits; }; (res->at(iOut)).set_AMC13Trailer(AMC13Trailer_); diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFSetup.cc b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFSetup.cc index 951a4cc59ce08..765d43b8e1b59 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFSetup.cc +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFSetup.cc @@ -63,7 +63,7 @@ namespace l1t { auto emtf_headers_unp = UnpackerFactory::get()->make("stage2::emtf::HeadersBlockUnpacker"); // Unpack "AMC data header" and "Event Record Header" auto emtf_counters_unp = UnpackerFactory::get()->make("stage2::emtf::CountersBlockUnpacker"); // Unpack "Block of Counters" auto emtf_me_unp = UnpackerFactory::get()->make("stage2::emtf::MEBlockUnpacker"); // Unpack "ME Data Record" - // auto emtf_rpc_unp = UnpackerFactory::get()->make("stage2::emtf::RPCBlockUnpacker"); // Unpack "RPC Data Record" + // auto emtf_rpc_unp = UnpackerFactory::get()->make("stage2::emtf::RPCBlockUnpacker"); // // Unpack "RPC Data Record" auto emtf_sp_unp = UnpackerFactory::get()->make("stage2::emtf::SPBlockUnpacker"); // Unpack "SP Output Data Record" auto emtf_trailers_unp = UnpackerFactory::get()->make("stage2::emtf::TrailersBlockUnpacker"); // Unpack "Event Record Trailer" diff --git a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFUnpackerTools.h b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFUnpackerTools.h index 7f9c511fe1e00..ef228db176c24 100644 --- a/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFUnpackerTools.h +++ b/EventFilter/L1TRawToDigi/src/implementations_stage2/EMTFUnpackerTools.h @@ -1,5 +1,8 @@ // Tools for unpacking and packing EMTF data +#ifndef EMTFUnpackerTools_h +#define EMTFUnpackerTools_h + // Generally useful includes #include #include // For things like std::setw @@ -8,21 +11,29 @@ namespace l1t { namespace stage2 { namespace emtf { - class EMTFUnpackerTools { - public: - - int powInt(int base, int exp) { - if (exp == 0) return 1; - if (exp == 1) return base; - return base * powInt(base, exp-1); - } - - int GetHexBits(uint64_t word, int lowBit, int highBit) { - return ( (word >> lowBit) & (powInt(2, (1 + highBit - lowBit)) - 1) ); - } - - }; // End class EMTFUnpackerTools + inline int PowInt(int base, int exp) { + if (exp == 0) return 1; + if (exp == 1) return base; + return base * PowInt(base, exp-1); + } + + inline uint16_t GetHexBits(uint16_t word, uint16_t lowBit, uint16_t highBit) { + return ( (word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1) ); + } + + inline uint32_t GetHexBits(uint32_t word, uint32_t lowBit, uint32_t highBit) { + return ( (word >> lowBit) & (PowInt(2, (1 + highBit - lowBit)) - 1) ); + } + + inline uint32_t GetHexBits(uint16_t word1, uint16_t lowBit1, uint16_t highBit1, + uint16_t word2, uint16_t lowBit2, uint16_t highBit2) { + uint16_t word1_sel = (word1 >> lowBit1) & (PowInt(2, (1 + highBit1 - lowBit1)) - 1); + uint16_t word2_sel = (word2 >> lowBit2) & (PowInt(2, (1 + highBit2 - lowBit2)) - 1); + return ( (word2_sel << (1 + highBit1 - lowBit1)) | word1_sel ); + } } // End namespace emtf } // End namespace stage2 } // End namespace l1t + +#endif /* define EMTFUnpackerTools_h */