Skip to content

Commit

Permalink
v1 of EMTF unpacking, continued
Browse files Browse the repository at this point in the history
  • Loading branch information
abrinke1 committed Feb 1, 2016
1 parent 7c40315 commit 1148b3a
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 157 deletions.
12 changes: 6 additions & 6 deletions DataFormats/L1TMuon/interface/EMTF/ME.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {};
Expand All @@ -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; };
Expand All @@ -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 ; };
Expand All @@ -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;
Expand Down
70 changes: 35 additions & 35 deletions DataFormats/L1TMuon/interface/EMTF/SP.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; };
Expand All @@ -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 ; };
Expand All @@ -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 ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand All @@ -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_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,46 @@ 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)
// Format defined in MTF7Payload::getBlock() in src/Block.cc
// 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
Expand All @@ -52,7 +80,6 @@ namespace l1t {
res->push_back(EMTFOutput_);
int iOut = res->size() - 1;


//////////////////////////////////////
// Unpack the AMC13 header information
//////////////////////////////////////
Expand Down Expand Up @@ -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_);
Expand Down
Loading

0 comments on commit 1148b3a

Please sign in to comment.