Skip to content

Commit

Permalink
Merge pull request #34504 from jshlee/GEM-newDAQStatus-12_0_0_pre3
Browse files Browse the repository at this point in the history
GEM unpacker - updated DAQ dataformat and new DAQ status collections
  • Loading branch information
cmsbuild authored Jul 22, 2021
2 parents d94fd01 + 508f5dd commit 887ac84
Show file tree
Hide file tree
Showing 26 changed files with 790 additions and 169 deletions.
39 changes: 31 additions & 8 deletions CondFormats/GEMObjects/interface/GEMROMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,25 @@
#include "DataFormats/MuonDetId/interface/GEMDetId.h"
#include <map>
#include <vector>
#include <algorithm>

class GEMROMapping {
// EC electronics corrdinate
// DC GEMDetId corrdinate
// geb = GEM electronics board == OptoHybrid
public:
struct sectorEC {
unsigned int fedId;
uint8_t amcNum;
bool operator==(const sectorEC& r) const {
if (fedId == r.fedId) {
return amcNum == r.amcNum;
} else {
return false;
}
}
};

struct chamEC {
unsigned int fedId;
uint8_t amcNum;
Expand Down Expand Up @@ -82,17 +98,21 @@ class GEMROMapping {

GEMROMapping(){};

bool isValidChipID(const vfatEC& r) const { return vMapED_.find(r) != vMapED_.end(); }
bool isValidChamber(const chamEC& r) const { return chamED_.find(r) != chamED_.end(); }
bool isValidChipID(const vfatEC& r) const { return vfatMap_.find(r) != vfatMap_.end(); }
bool isValidChamber(const chamEC& r) const { return chamberMap_.find(r) != chamberMap_.end(); }

bool isValidAMC(const sectorEC& r) const { return std::find(amcVec_.begin(), amcVec_.end(), r) != amcVec_.end(); }

const chamDC& chamberPos(const chamEC& r) const { return chamED_.at(r); }
void add(chamEC e, chamDC d) { chamED_[e] = d; }
void add(sectorEC e) { amcVec_.push_back(e); }

const chamDC& chamberPos(const chamEC& r) const { return chamberMap_.at(r); }
void add(chamEC e, chamDC d) { chamberMap_[e] = d; }

const std::vector<vfatEC> getVfats(const GEMDetId& r) const { return chamVfats_.at(r); }
void add(GEMDetId e, vfatEC d) { chamVfats_[e].push_back(d); }

const vfatDC& vfatPos(const vfatEC& r) const { return vMapED_.at(r); }
void add(vfatEC e, vfatDC d) { vMapED_[e] = d; }
const vfatDC& vfatPos(const vfatEC& r) const { return vfatMap_.at(r); }
void add(vfatEC e, vfatDC d) { vfatMap_[e] = d; }

const channelNum& hitPos(const stripNum& s) const { return stChMap_.at(s); }
const stripNum& hitPos(const channelNum& c) const { return chStMap_.at(c); }
Expand All @@ -101,11 +121,14 @@ class GEMROMapping {
void add(stripNum s, channelNum c) { stChMap_[s] = c; }

private:
std::map<chamEC, chamDC> chamED_;
std::vector<sectorEC> amcVec_;

// electronics map to GEMDetId chamber
std::map<chamEC, chamDC> chamberMap_;

std::map<GEMDetId, std::vector<vfatEC>> chamVfats_;

std::map<vfatEC, vfatDC> vMapED_;
std::map<vfatEC, vfatDC> vfatMap_;

std::map<channelNum, stripNum> chStMap_;
std::map<stripNum, channelNum> stChMap_;
Expand Down
3 changes: 3 additions & 0 deletions CondFormats/GEMObjects/interface/GEMeMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ class GEMeMap {
static const int maxVFatGE0_ = 12; // vFat per eta partition, not known yet for ME0
static const int maxVFatGE11_ = 3; // vFat per eta partition in GE11
static const int maxVFatGE21_ = 6; // vFat per eta partition in GE21
static const int maxiEtaIdGE0_ = 8; // no. eta partitions for GE0
static const int maxiEtaIdGE11_ = 8; // no. eta partitions for GE11
static const int maxiEtaIdGE21_ = 16; // no. eta partitions for GE21
static const int maxChan_ = 128; // channels per vFat
};
#endif // GEMeMap_H
21 changes: 14 additions & 7 deletions CondFormats/GEMObjects/src/GEMeMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ void GEMeMap::convert(GEMROMapping& romap) {
// fed->amc->geb mapping to GEMDetId
for (auto imap : theChamberMap_) {
for (unsigned int ix = 0; ix < imap.fedId.size(); ix++) {
GEMROMapping::chamEC ec;
ec.fedId = imap.fedId[ix];
ec.amcNum = imap.amcNum[ix];
ec.gebId = imap.gebId[ix];

GEMROMapping::chamEC ec{imap.fedId[ix], imap.amcNum[ix], imap.gebId[ix]};
GEMROMapping::chamDC dc;
dc.detId = GEMDetId((imap.gemNum[ix] > 0) ? 1 : -1,
1,
Expand All @@ -29,6 +25,9 @@ void GEMeMap::convert(GEMROMapping& romap) {
0);
dc.vfatVer = imap.vfatVer[ix];
romap.add(ec, dc);
GEMROMapping::sectorEC amcEC = {imap.fedId[ix], imap.amcNum[ix]};
if (!romap.isValidAMC(amcEC))
romap.add(amcEC);
}
}

Expand Down Expand Up @@ -82,16 +81,20 @@ void GEMeMap::convertDummy(GEMROMapping& romap) {
uint8_t gebId = 0;
int maxVFat = 0;
int maxLayerId = GEMDetId::maxLayerId;
int maxiEtaId = 0;
if (st == 0) {
maxVFat = maxVFatGE0_;
fedId = (re == 1 ? FEDNumbering::MINGE0FEDID + 1 : FEDNumbering::MINGE0FEDID);
maxLayerId = GEMDetId::maxLayerId0;
maxiEtaId = maxiEtaIdGE0_;
} else if (st == 1) {
maxVFat = maxVFatGE11_;
fedId = (re == 1 ? FEDNumbering::MINGEMFEDID + 1 : FEDNumbering::MINGEMFEDID);
maxiEtaId = maxiEtaIdGE11_;
} else if (st == 2) {
maxVFat = maxVFatGE21_;
fedId = (re == 1 ? FEDNumbering::MINGE21FEDID + 1 : FEDNumbering::MINGE21FEDID);
maxiEtaId = maxiEtaIdGE21_;
}

for (int ch = 1; ch <= GEMDetId::maxChamberId; ++ch) {
Expand All @@ -108,16 +111,20 @@ void GEMeMap::convertDummy(GEMROMapping& romap) {
dc.vfatVer = vfatVerV3_;
romap.add(ec, dc);

GEMROMapping::sectorEC amcEC = {fedId, amcNum};
if (!romap.isValidAMC(amcEC))
romap.add(amcEC);

uint16_t chipPos = 0;
for (int lphi = 0; lphi < maxVFat; ++lphi) {
for (int roll = 1; roll <= GEMDetId::maxRollId; ++roll) {
for (int ieta = 1; ieta <= maxiEtaId; ++ieta) {
GEMROMapping::vfatEC vec;
vec.vfatAdd = chipPos;
vec.detId = gemId;

GEMROMapping::vfatDC vdc;
vdc.vfatType = vfatTypeV3_; // > 10 is vfat v3
vdc.detId = GEMDetId(re, 1, st, ly, ch, roll);
vdc.detId = GEMDetId(re, 1, st, ly, ch, ieta);
vdc.localPhi = lphi;

romap.add(vec, vdc);
Expand Down
10 changes: 6 additions & 4 deletions DataFormats/GEMDigi/interface/AMC13Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace gem {
uint64_t bxIdT : 12; // bx id
uint64_t lv1IdT : 8; // level 1 id
uint64_t blkN : 8; // block number
uint64_t crc32 : 36; // Overall CRC (first 32 bits)
uint64_t : 4;
uint64_t crc32 : 32; // Overall CRC
};
};
union CDFTrailer {
Expand Down Expand Up @@ -89,22 +90,23 @@ namespace gem {
void setCDFTrailer(uint32_t EvtLength);
uint64_t getCDFTrailer() const { return cdft_; }
uint32_t fragmentLength() const { return CDFTrailer{cdft_}.evtLength; }
uint16_t crc() const { return CDFTrailer{cdft_}.crcCDF; }
uint8_t evtStatus() const { return CDFTrailer{cdft_}.evtStat; }
uint8_t ttsBits() const { return CDFTrailer{cdft_}.tts; }

int bxId() const { return (int8_t)CDFHeader{cdfh_}.bxId; }
uint16_t bunchCrossing() const { return CDFHeader{cdfh_}.bxId; }
uint32_t lv1Id() const { return CDFHeader{cdfh_}.lv1Id; }
uint16_t sourceId() const { return CDFHeader{cdfh_}.sourceId; }

int orbitNumber() const { return AMC13Header{amc13h_}.orbitN; }
uint16_t orbitNumber() const { return AMC13Header{amc13h_}.orbitN; }
uint8_t nAMC() const { return AMC13Header{amc13h_}.nAMC; }

const std::vector<uint64_t>* getAMCheaders() const { return &amcHeaders_; }
uint32_t getAMCsize(int i) const { return AMCHeader{amcHeaders_.at(i)}.amcSize; }
void addAMCheader(uint64_t word);
void addAMCheader(uint32_t AMC_size, uint8_t Blk_No, uint8_t AMC_No, uint16_t BoardID);

uint32_t crc() const { return AMC13Trailer{amc13t_}.crc32; }

const std::vector<AMCdata>* getAMCpayloads() const { return &amcs_; }
void addAMCpayload(const AMCdata& a) { amcs_.push_back(a); }
void clearAMCpayloads() { amcs_.clear(); }
Expand Down
16 changes: 11 additions & 5 deletions DataFormats/GEMDigi/interface/AMCdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ namespace gem {
uint64_t word;
struct {
uint64_t dataLength : 20; // Number of 64bit words in this event
uint64_t l1AIDT : 12; // 8bit long GLIB serial number (first 8 bits)
uint64_t crc : 32; // CRC added by the AMC13
uint64_t : 4;
uint64_t l1AID : 8; // L1A number (first 8 bits)
uint64_t crc : 32; // CRC added by the AMC13
};
};
union EventHeader {
Expand Down Expand Up @@ -68,6 +69,8 @@ namespace gem {
AMCdata() : amch1_(0), amch2_(0), amct_(0), eh_(0), et_(0){};
~AMCdata() { gebd_.clear(); }

int status();

void setAMCheader1(uint64_t word) { amch1_ = word; }
void setAMCheader1(uint32_t dataLength, uint16_t bxID, uint32_t l1AID, uint8_t AMCnum);
uint64_t getAMCheader1() const { return amch1_; }
Expand All @@ -87,18 +90,21 @@ namespace gem {
uint64_t getGEMeventTrailer() const { return et_; }

uint32_t dataLength() const { return AMCTrailer{amct_}.dataLength; }
uint16_t bx() const { return AMCheader1{amch1_}.bxID; }
uint32_t l1A() const { return AMCheader1{amch1_}.l1AID; }
uint16_t bunchCrossing() const { return AMCheader1{amch1_}.bxID; }
uint32_t lv1Id() const { return AMCheader1{amch1_}.l1AID; }
uint8_t amcNum() const { return AMCheader1{amch1_}.AMCnum; }

uint16_t boardId() const { return AMCheader2{amch2_}.boardID; }
uint16_t orbitNum() const { return AMCheader2{amch2_}.orbitNum; }
uint16_t orbitNumber() const { return AMCheader2{amch2_}.orbitNum; }
uint8_t param3() const { return AMCheader2{amch2_}.param3; }
uint8_t param2() const { return AMCheader2{amch2_}.param2; }
uint8_t param1() const { return AMCheader2{amch2_}.param1; }
uint8_t runType() const { return AMCheader2{amch2_}.runType; }
uint8_t formatVer() const { return AMCheader2{amch2_}.formatVer; }

uint8_t lv1Idt() const { return AMCTrailer{amct_}.l1AID; }
uint32_t crc() const { return AMCTrailer{amct_}.crc; }

uint16_t ttsState() const { return EventHeader{eh_}.ttsState; }
uint8_t davCnt() const { return EventHeader{eh_}.davCnt; }
uint32_t buffState() const { return EventHeader{eh_}.buffState; }
Expand Down
94 changes: 46 additions & 48 deletions DataFormats/GEMDigi/interface/GEBdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@
#include <vector>

namespace gem {
// Input status 1 bit for each
// BX mismatch GLIB OH / BX mismatch GLIB VFAT / OOS GLIB OH / OOS GLIB VFAT / No VFAT marker
// Event size warn / L1AFIFO near full / InFIFO near full / EvtFIFO near full / Event size overflow
// L1AFIFO full / InFIFO full / EvtFIFO full

union GEBchamberHeader {
uint64_t word;
struct {
uint64_t BxmVvV : 11; // 1st bit BX mismatch VFAT vs VFAT
uint64_t BxmAvV : 1; // BX mismatch AMC vs VFAT
uint64_t OOScVvV : 1; // OOS (EC mismatch) VFAT vs VFAT
uint64_t OOScAvV : 1; // OOS (EC mismatch) AMC vs VFAT
uint64_t noVFAT : 1; // No VFAT marker
uint64_t EvtSzW : 1; // Event size warning
uint64_t L1aNF : 1; // L1A FIFO near full
uint64_t InNF : 1; // Input FIFO near full
uint64_t EvtNF : 1; // Event FIFO near full
uint64_t EvtSzOFW : 1; // Event size overflow
uint64_t L1aF : 1; // L1A FIFO full
uint64_t InF : 1; // Input FIFO full
uint64_t EvtF : 1; // Event FIFO full
uint64_t VfWdCnt : 12; // VFAT word count (in number of 64-bit words)
uint64_t inputID : 5; // Input link ID
uint64_t zeroSupWordsCnt : 24; // Number of zero suppressed VFAT 64bit words
uint64_t : 10; // unused
uint64_t BxmVvV : 1; // 1st bit BX mismatch VFAT vs VFAT
uint64_t BxmAvV : 1; // BX mismatch AMC vs VFAT
uint64_t OOScVvV : 1; // Out of Sync (EC mismatch) VFAT vs VFAT
uint64_t OOScAvV : 1; // Out of Sync (EC mismatch) AMC vs VFAT
uint64_t Inv : 1; // Invalid event
uint64_t EvtSzW : 1; // Event size warning
uint64_t L1aNF : 1; // L1A FIFO near full
uint64_t InNF : 1; // Input FIFO near full
uint64_t EvtNF : 1; // Event FIFO near full
uint64_t EvtSzOFW : 1; // Event size overflow
uint64_t L1aF : 1; // L1A FIFO full
uint64_t InF : 1; // Input FIFO full
uint64_t EvtF : 1; // Event FIFO full
uint64_t VfWdCnt : 12; // VFAT word count (in number of 64-bit words)
uint64_t InputID : 5; // Input link ID
uint64_t CALIB_CHAN : 7; // Calibration channel number
uint64_t : 17; // unused
};
};

union GEBchamberTrailer {
uint64_t word;
struct {
uint64_t ecOH : 20; // OH event counter
uint64_t bcOH : 13; // OH bunch crossing
uint64_t ecOH : 20; // NOT USED - OptoHybrid event counter
uint64_t bcOH : 13; // NOT USED - OptoHybrid bunch crossing
uint64_t InUfw : 1; // Input FIFO underflow
uint64_t SkD : 1; // Stuck data
uint64_t EvUfw : 1; // Event FIFO underflow
uint64_t SkD : 1; // NOT USED - Stuck data
uint64_t EvUfw : 1; // NOT USED - Event FIFO underflow
uint64_t VfWdCntT : 12; // VFAT word count (in number of 64-bit words)
uint64_t crc16 : 16; // CRC of OH data (currently not available – filled with 0)
uint64_t crc16 : 16; // CRC of OptoHybrid data (currently not available – filled with 0)
};
};

Expand All @@ -52,7 +52,7 @@ namespace gem {
void setChamberHeader(uint16_t vfatWordCnt, uint8_t inputID) {
GEBchamberHeader u{0};
u.VfWdCnt = vfatWordCnt;
u.inputID = inputID;
u.InputID = inputID;
ch_ = u.word;
}
uint64_t getChamberHeader() const { return ch_; }
Expand All @@ -68,30 +68,28 @@ namespace gem {
}
uint64_t getChamberTrailer() const { return ct_; }

uint16_t bxmVvV() const { return GEBchamberHeader{ch_}.BxmVvV; }
uint8_t bxmAvV() const { return GEBchamberHeader{ch_}.BxmAvV; }
uint8_t oOScVvV() const { return GEBchamberHeader{ch_}.OOScVvV; }
uint8_t oOScAvV() const { return GEBchamberHeader{ch_}.OOScAvV; }
uint8_t noVFAT() const { return GEBchamberHeader{ch_}.noVFAT; }
uint8_t evtSzW() const { return GEBchamberHeader{ch_}.EvtSzW; }
uint8_t l1aNF() const { return GEBchamberHeader{ch_}.L1aNF; }
uint8_t inNF() const { return GEBchamberHeader{ch_}.InNF; }
uint8_t evtNF() const { return GEBchamberHeader{ch_}.EvtNF; }
uint8_t evtSzOFW() const { return GEBchamberHeader{ch_}.EvtSzOFW; }
uint8_t l1aF() const { return GEBchamberHeader{ch_}.L1aF; }
uint8_t inF() const { return GEBchamberHeader{ch_}.InF; }
uint8_t evtF() const { return GEBchamberHeader{ch_}.EvtF; }
uint16_t vfatWordCnt() const { return GEBchamberHeader{ch_}.VfWdCnt; }
uint8_t inputID() const { return GEBchamberHeader{ch_}.inputID; }
uint32_t zeroSupWordsCnt() const { return GEBchamberHeader{ch_}.zeroSupWordsCnt; }

uint32_t ecOH() const { return GEBchamberTrailer{ct_}.ecOH; }
uint16_t bcOH() const { return GEBchamberTrailer{ct_}.bcOH; }
uint8_t inUfw() const { return GEBchamberTrailer{ct_}.InUfw; }
uint8_t stuckData() const { return GEBchamberTrailer{ct_}.SkD; }
uint8_t evUfw() const { return GEBchamberTrailer{ct_}.EvUfw; }
uint8_t inputID() const { return GEBchamberHeader{ch_}.InputID; }
uint16_t vfatWordCntT() const { return GEBchamberTrailer{ct_}.VfWdCntT; }
uint16_t crc() const { return GEBchamberTrailer{ct_}.crc16; }

bool bxmVvV() const { return GEBchamberHeader{ch_}.BxmVvV; }
bool bxmAvV() const { return GEBchamberHeader{ch_}.BxmAvV; }
bool oOScVvV() const { return GEBchamberHeader{ch_}.OOScVvV; }
bool oOScAvV() const { return GEBchamberHeader{ch_}.OOScAvV; }
bool inv() const { return GEBchamberHeader{ch_}.Inv; }
bool evtSzW() const { return GEBchamberHeader{ch_}.EvtSzW; }
bool l1aNF() const { return GEBchamberHeader{ch_}.L1aNF; }
bool inNF() const { return GEBchamberHeader{ch_}.InNF; }
bool evtNF() const { return GEBchamberHeader{ch_}.EvtNF; }
bool evtSzOFW() const { return GEBchamberHeader{ch_}.EvtSzOFW; }
bool l1aF() const { return GEBchamberHeader{ch_}.L1aF; }
bool inF() const { return GEBchamberHeader{ch_}.InF; }
bool evtF() const { return GEBchamberHeader{ch_}.EvtF; }
bool inUfw() const { return GEBchamberTrailer{ct_}.InUfw; }

bool noVFAT() const { return false; } // to be removed
bool stuckData() const { return false; } // to be removed
bool evUfw() const { return false; } // to be removed

//!Adds VFAT data to the vector
void addVFAT(VFATdata v) { vfatd_.push_back(v); }
Expand Down
Loading

0 comments on commit 887ac84

Please sign in to comment.