Skip to content

Commit

Permalink
Merge pull request #38255 from yeckang/GEMRawToDigi_GEMChMap_12_4_X
Browse files Browse the repository at this point in the history
[Backport] Turning on GE21 digis to be unpacked for monitoring [12_4_X]
  • Loading branch information
cmsbuild authored Jun 9, 2022
2 parents 5407acc + a657129 commit 68b5dcc
Show file tree
Hide file tree
Showing 15 changed files with 293 additions and 159 deletions.
4 changes: 2 additions & 2 deletions CondFormats/GEMObjects/interface/GEMChMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ class GEMChMap {

const std::vector<uint16_t> getVfats(const int type) const { return chamVfats_.at(type); }
void add(int type, uint16_t d) {
if (std::find(chamVfats_[type].begin(), chamVfats_[type].end(), d) != chamVfats_[type].end())
if (std::find(chamVfats_[type].begin(), chamVfats_[type].end(), d) == chamVfats_[type].end())
chamVfats_[type].push_back(d);
}

const std::vector<int> getIEtas(int chamberType, uint16_t vfatAdd) const {
return chamIEtas_.at({chamberType, vfatAdd});
}
void add(vfatEC d, int iEta) {
if (std::find(chamIEtas_[d].begin(), chamIEtas_[d].end(), iEta) != chamIEtas_[d].end())
if (std::find(chamIEtas_[d].begin(), chamIEtas_[d].end(), iEta) == chamIEtas_[d].end())
chamIEtas_[d].push_back(iEta);
}

Expand Down
9 changes: 3 additions & 6 deletions DQM/GEM/interface/GEMDAQStatusSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@

#include "Validation/MuonGEMHits/interface/GEMValidationUtils.h"

#include "CondFormats/DataRecord/interface/GEMeMapRcd.h"
#include "CondFormats/GEMObjects/interface/GEMeMap.h"
#include "CondFormats/GEMObjects/interface/GEMROMapping.h"
#include "CondFormats/DataRecord/interface/GEMChMapRcd.h"
#include "CondFormats/GEMObjects/interface/GEMChMap.h"
#include "DataFormats/GEMDigi/interface/GEMDigiCollection.h"
#include "DataFormats/GEMDigi/interface/GEMVFATStatusCollection.h"
#include "DataFormats/GEMDigi/interface/GEMOHStatusCollection.h"
Expand Down Expand Up @@ -70,9 +69,7 @@ class GEMDAQStatusSource : public GEMDQMBase {
void SetLabelOHStatus(MonitorElement *h2Status);
void SetLabelVFATStatus(MonitorElement *h2Status);

edm::ESGetToken<GEMeMap, GEMeMapRcd> gemEMapToken_;
//std::shared_ptr<GEMROMapping> gemROMap_;
const GEMeMap *gemEMap_;
const edm::ESGetToken<GEMChMap, GEMChMapRcd> gemChMapToken_;

edm::EDGetToken tagVFAT_;
edm::EDGetToken tagOH_;
Expand Down
51 changes: 25 additions & 26 deletions DQM/GEM/plugins/GEMDAQStatusSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
using namespace std;
using namespace edm;

GEMDAQStatusSource::GEMDAQStatusSource(const edm::ParameterSet &cfg) : GEMDQMBase(cfg) {
GEMDAQStatusSource::GEMDAQStatusSource(const edm::ParameterSet &cfg)
: GEMDQMBase(cfg), gemChMapToken_(esConsumes<GEMChMap, GEMChMapRcd, edm::Transition::BeginRun>()) {
tagVFAT_ = consumes<GEMVFATStatusCollection>(cfg.getParameter<edm::InputTag>("VFATInputLabel"));
tagOH_ = consumes<GEMOHStatusCollection>(cfg.getParameter<edm::InputTag>("OHInputLabel"));
tagAMC_ = consumes<GEMAMCStatusCollection>(cfg.getParameter<edm::InputTag>("AMCInputLabel"));
tagAMC13_ = consumes<GEMAMC13StatusCollection>(cfg.getParameter<edm::InputTag>("AMC13InputLabel"));

nAMCSlots_ = cfg.getParameter<Int_t>("AMCSlots");
gemEMapToken_ = esConsumes<GEMeMap, GEMeMapRcd, edm::Transition::BeginRun>();
}

void GEMDAQStatusSource::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
Expand All @@ -28,36 +28,35 @@ void GEMDAQStatusSource::fillDescriptions(edm::ConfigurationDescriptions &descri
}

void GEMDAQStatusSource::LoadROMap(edm::EventSetup const &iSetup) {
auto gemROMap = std::make_shared<GEMROMapping>();
//if (useDBEMap_)
if (true) {
const auto &eMap = iSetup.getData(gemEMapToken_);
auto gemEMap = std::make_unique<GEMeMap>(eMap);
gemEMap->convert(*gemROMap);

for (auto imap : gemEMap->theChamberMap_) {
int nNumChamber = (int)imap.fedId.size();
for (int i = 0; i < nNumChamber; i++) {
unsigned int fedId = imap.fedId[i];
uint8_t amcNum = imap.amcNum[i];
uint8_t gebId = imap.gebId[i];
GEMROMapping::chamEC geb_ec{fedId, amcNum, gebId};
GEMROMapping::chamDC geb_dc = gemROMap->chamberPos(geb_ec);
GEMDetId gemChId = geb_dc.detId;

mapFEDIdToRe_[fedId] = gemChId.region();
mapAMC13ToListChamber_[fedId].push_back(gemChId);
mapAMCToListChamber_[{fedId, amcNum}].push_back(gemChId);
}
const auto &chMap = iSetup.getData(gemChMapToken_);
auto gemChMap = std::make_unique<GEMChMap>(chMap);

for (auto const &[ec, dc] : gemChMap->chamberMap()) {
unsigned int fedId = ec.fedId;
uint8_t amcNum = ec.amcNum;
GEMDetId gemChId(dc.detId);

mapFEDIdToRe_[fedId] = gemChId.region();
mapAMC13ToListChamber_[fedId].push_back(gemChId);
mapAMCToListChamber_[{fedId, amcNum}].push_back(gemChId);
}

gemEMap.reset();
} else {
// no EMap in DB, using dummy
// FIXME: How to add mapFEDIdToRe_ and mapDetIdToAMC_??
auto gemEMap = std::make_unique<GEMeMap>();
gemEMap->convertDummy(*gemROMap);
gemEMap.reset();
auto gemChMap = std::make_unique<GEMChMap>();
gemChMap->setDummy();

for (auto const &[ec, dc] : gemChMap->chamberMap()) {
unsigned int fedId = ec.fedId;
uint8_t amcNum = ec.amcNum;
GEMDetId gemChId(dc.detId);

mapFEDIdToRe_[fedId] = gemChId.region();
mapAMC13ToListChamber_[fedId].push_back(gemChId);
mapAMCToListChamber_[{fedId, amcNum}].push_back(gemChId);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion DQM/L1TMonitor/python/L1TdeGEMTPG_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
monitorDir = cms.string("L1TEMU/L1TdeGEMTPG"),
verbose = cms.bool(False),
## when multiple chambers are enabled, order them by station number!
chambers = cms.vstring("GE11"),
chambers = cms.vstring("GE11", "GE21"),
dataEmul = cms.vstring("data","emul"),
clusterVars = cms.vstring("size", "pad", "bx"),
clusterNBin = cms.vuint32(20,384,10),
Expand Down
74 changes: 66 additions & 8 deletions DataFormats/GEMDigi/interface/GEMAMC.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class GEMAMC {
};
union AMCheader2 {
uint64_t word;
// v301 dataformat
struct {
uint64_t boardID : 16; // 8bit long GLIB serial number
uint64_t orbitNum : 16; // Orbit number, Reset by EC0
Expand All @@ -26,14 +27,22 @@ class GEMAMC {
uint64_t runType : 4; // run types like physics, cosmics, threshold scan, latency scan, etc..
uint64_t formatVer : 4; // Current format version = 0x0
};
// v302 dataformat
struct {
uint64_t softSrcId : 12; // FED ID - Configruation Error if does not match with CDF header
uint64_t softSlot : 4; // AMC slot number - Configuation Error if does not match with AMC13 AHn header
uint64_t orbitNumV302 : 32; // Orbit counter, Reset by EC0 - Error if does not match AMC BH header
uint64_t : 12; // unused
uint64_t FVv302 : 4; // Current version = 0x1
};
};
union AMCTrailer {
uint64_t word;
struct {
uint64_t dataLength : 20; // Number of 64bit words in this event
uint64_t : 4;
uint64_t l1AID : 8; // L1A number (first 8 bits)
uint64_t crc : 32; // CRC added by the AMC13
uint64_t : 4; // unused
uint64_t l1AID : 8; // L1A number (first 8 bits)
uint64_t crc : 32; // CRC added by the AMC13
};
};
union EventHeader {
Expand All @@ -51,6 +60,7 @@ class GEMAMC {
};
union EventTrailer {
uint64_t word;
// v301 dataformat
struct {
uint64_t BCL : 4; // 1st bit, BC0 locked - If 0, this is a bad condition indicating a
// problem in the clock or TTC command stream (critical condition)
Expand All @@ -62,6 +72,25 @@ class GEMAMC {
// different chambers in this event (1 bit)
uint64_t linkTo : 24; // Link timeout flags (one bit for each link indicating timeout condition)
};
// v302 dataformat
struct {
uint64_t L1aNF : 1; // L1A FIFO near full - Warning
uint64_t L1aF : 1; // L1A FIFO full - Error
uint64_t : 1; // unused
uint64_t BCLv302 : 1; // BC0 locked - If 0, this is a bad condition indicating a
// problem in the clock or TTC command stream (critical condition)
uint64_t DRv302 : 1; // DAQ Ready - If 0, this means that AMC13 is not ready to take data (critical condition)
uint64_t CLv302 : 1; // DAQ clock locked- If 0, this indicates a problem in the DAQ clock (critical condition)
uint64_t MLv302 : 1; // MMCM locked - Should always be 1
uint64_t BPv302 : 1; // Backpressure - If this is 1, it means that we are receiving backpressure from AMC13
uint64_t param3 : 8; // RunPar - Controlled by software, normally used only for calibrations
uint64_t param2 : 8; // RunPar - Controlled by software, normally used only for calibrations
uint64_t param1 : 8; // RunPar - Controlled by software, normally used only for calibrations
uint64_t runType : 4; // Type of Run - Controlled by software, “physics” is assigned 0x1,
// hits from events with other run types should be discarded
uint64_t : 4; // unused
uint64_t linkToV302 : 24; // Link timeout flags (one bit for each link indicating timeout condition)
};
};

GEMAMC() : amch1_(0), amch2_(0), amct_(0), eh_(0), et_(0){};
Expand All @@ -87,17 +116,39 @@ class GEMAMC {
void setGEMeventTrailer(uint64_t word) { et_ = word; }
uint64_t getGEMeventTrailer() const { return et_; }

// v301
uint32_t dataLength() const { return AMCTrailer{amct_}.dataLength; }
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 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; }
uint32_t orbitNumber() const {
if (formatVer() == 0)
return AMCheader2{amch2_}.orbitNum;
return AMCheader2{amch2_}.orbitNumV302;
}
uint8_t param3() const {
if (formatVer() == 0)
return AMCheader2{amch2_}.param3;
return EventTrailer{et_}.param3;
}
uint8_t param2() const {
if (formatVer() == 0)
return AMCheader2{amch2_}.param2;
return EventTrailer{et_}.param2;
}
uint8_t param1() const {
if (formatVer() == 0)
return AMCheader2{amch2_}.param1;
return EventTrailer{et_}.param1;
}
uint8_t runType() const {
if (formatVer() == 0)
return AMCheader2{amch2_}.runType;
return EventTrailer{et_}.runType;
}
// SAME in V301 and V302
uint8_t formatVer() const { return AMCheader2{amch2_}.formatVer; }

uint8_t lv1Idt() const { return AMCTrailer{amct_}.l1AID; }
Expand All @@ -116,6 +167,13 @@ class GEMAMC {
uint8_t oosGlib() const { return EventTrailer{et_}.oosGlib; }
uint32_t linkTo() const { return EventTrailer{et_}.linkTo; }

// v302
uint16_t softSrcId() const { return AMCheader2{amch2_}.softSrcId; }
uint8_t softSlot() const { return AMCheader2{amch2_}.softSlot; }

uint8_t l1aNF() const { return EventTrailer{et_}.L1aNF; }
uint8_t l1aF() const { return EventTrailer{et_}.L1aF; }

//!Adds GEB data to vector
void addGEB(GEMOptoHybrid g) { gebd_.push_back(g); }
//!Returns a vector of GEB data
Expand Down
16 changes: 13 additions & 3 deletions DataFormats/GEMDigi/interface/GEMAMCStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ class GEMAMCStatus {
uint16_t DAQclocklocked : 1;
uint16_t DAQnotReday : 1;
uint16_t BC0locked : 1;
uint16_t badFEDId : 1;
uint16_t L1AFull : 1;
};
};
union Warnings {
uint8_t wcodes;
struct {
uint8_t InValidOH : 1;
uint8_t backPressure : 1;
uint8_t L1ANearFull : 1;
};
};

Expand All @@ -38,17 +41,24 @@ class GEMAMCStatus {
error.badBC = !((amc13->bunchCrossing() == amc.bunchCrossing()) ||
(amc13->bunchCrossing() == 0 && amc.bunchCrossing() == GEMAMC13::lastBC));
error.badRunType = amc.runType() != 0x1;
// Last OC in AMC13 is different to TCDS, AMC, and VFAT
error.badOC = !((uint16_t(amc13->orbitNumber()) == amc.orbitNumber()) ||
(amc13->bunchCrossing() == 0 && uint16_t(amc.orbitNumber() + 1) == uint16_t(amc13->orbitNumber())));
if (amc.formatVer() == 0)
// Last OC in AMC13 is different to TCDS, AMC, and VFAT
error.badOC =
!((uint16_t(amc13->orbitNumber()) == amc.orbitNumber()) ||
(amc13->bunchCrossing() == 0 && uint16_t(amc.orbitNumber() + 1) == uint16_t(amc13->orbitNumber())));
else
error.badOC = (amc13->orbitNumber() != amc.orbitNumber());
error.MMCMlocked = !amc.mmcmLocked();
error.DAQclocklocked = !amc.daqClockLocked();
error.DAQnotReday = !amc.daqReady();
error.BC0locked = !amc.bc0locked();
error.badFEDId = (amc13->sourceId() != amc.softSrcId() and amc.formatVer() != 0);
error.L1AFull = (amc.l1aF() and amc.formatVer() != 0);
errors_ = error.ecodes;

Warnings warn{0};
warn.backPressure = amc.backPressure();
warn.L1ANearFull = (amc.l1aNF() and amc.formatVer() != 0);
warnings_ = warn.wcodes;
}

Expand Down
4 changes: 2 additions & 2 deletions DataFormats/GEMDigi/interface/GEMOHStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GEMOHStatus {
Errors error{0};
error.EvtF = oh.evtF();
error.InF = oh.inF();
error.L1aF = oh.l1aF();
error.L1aF = (oh.l1aF() and (oh.version() == 0));
error.EvtSzOFW = oh.evtSzOFW();
error.Inv = oh.inv();
error.OOScAvV = oh.oOScAvV();
Expand All @@ -53,7 +53,7 @@ class GEMOHStatus {
Warnings warn{0};
warn.EvtNF = oh.evtNF();
warn.InNF = oh.inNF();
warn.L1aNF = oh.l1aNF();
warn.L1aNF = (oh.l1aNF() and (oh.version() == 0));
warn.EvtSzW = oh.evtSzW();
warnings_ = warn.wcodes;
}
Expand Down
Loading

0 comments on commit 68b5dcc

Please sign in to comment.