Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] [GEM] Unpacker update for the vfat masking information [12_5_X] #39488

Merged
merged 3 commits into from Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions DQM/GEM/plugins/GEMDAQStatusSource.cc
Expand Up @@ -506,7 +506,7 @@ void GEMDAQStatusSource::analyze(edm::Event const &event, edm::EventSetup const
const GEMVFATStatusCollection::Range &range = (*vfatIt).second;

for (auto vfatStat = range.first; vfatStat != range.second; ++vfatStat) {
Int_t nIdxVFAT = getVFATNumber(gid.station(), gid.ieta(), vfatStat->vfatPosition());
Int_t nIdxVFAT = vfatStat->vfatPosition();

GEMVFATStatus::Warnings warnings{vfatStat->warnings()};
if (warnings.basicOFW)
Expand All @@ -515,7 +515,8 @@ void GEMDAQStatusSource::analyze(edm::Event const &event, edm::EventSetup const
mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 3);

GEMVFATStatus::Errors errors{(uint8_t)vfatStat->errors()};
mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 4);
if (errors.vc)
mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 4);
if (errors.InValidHeader)
mapStatusVFATPerCh_.Fill(key4Ch, nIdxVFAT, 5);
if (errors.EC)
Expand Down
14 changes: 14 additions & 0 deletions DataFormats/GEMDigi/interface/GEMOHStatus.h
Expand Up @@ -31,6 +31,7 @@ class GEMOHStatus {
uint8_t L1aNF : 1; // L1A FIFO near full
uint8_t EvtSzW : 1; // Event size warning
uint8_t InValidVFAT : 1;
uint8_t missingVFAT : 1;
};
};

Expand All @@ -51,10 +52,15 @@ class GEMOHStatus {
errors_ = error.codes;

Warnings warn{0};
existVFATs_ = oh.existVFATs();
vfatMask_ = oh.vfatMask();
zsMask_ = oh.zsMask();
missingVFATs_ = (existVFATs_ ^ 0xffffff) & (vfatMask_ & (zsMask_ ^ 0xffffff));
warn.EvtNF = oh.evtNF();
warn.InNF = oh.inNF();
warn.L1aNF = (oh.l1aNF() and (oh.version() == 0));
warn.EvtSzW = oh.evtSzW();
warn.missingVFAT = (oh.version() != 0) and (missingVFATs_ != 0);
warnings_ = warn.wcodes;
}

Expand All @@ -67,10 +73,18 @@ class GEMOHStatus {
bool isBad() const { return errors_ != 0; }
uint16_t errors() const { return errors_; }
uint8_t warnings() const { return warnings_; }
uint32_t missingVFATs() const { return missingVFATs_; }
uint32_t vfatMask() const { return vfatMask_; }
uint32_t zsMask() const { return zsMask_; }
uint32_t existVFATs() const { return existVFATs_; }

private:
uint16_t errors_;
uint8_t warnings_;
uint32_t missingVFATs_;
uint32_t vfatMask_;
uint32_t zsMask_;
uint32_t existVFATs_;
};

inline std::ostream& operator<<(std::ostream& out, const GEMOHStatus& status) {
Expand Down
10 changes: 8 additions & 2 deletions DataFormats/GEMDigi/interface/GEMOptoHybrid.h
Expand Up @@ -73,7 +73,7 @@ class GEMOptoHybrid {
};
};

GEMOptoHybrid() : ch_(0), ct_(0){};
GEMOptoHybrid() : ch_(0), ct_(0), existVFATs_(0){};
~GEMOptoHybrid() { vfatd_.clear(); }

void setVersion(uint8_t i) { ver_ = i; }
Expand Down Expand Up @@ -147,9 +147,13 @@ class GEMOptoHybrid {
uint32_t zsMask() const { return GEBchamberTrailer{ct_}.ZSMask; }

//!Adds VFAT data to the vector
void addVFAT(GEMVFAT v) { vfatd_.push_back(v); }
void addVFAT(GEMVFAT v) {
existVFATs_ = existVFATs_ | (0x1 << v.vfatId());
vfatd_.push_back(v);
}
//!Returns the vector of VFAT data
const std::vector<GEMVFAT>* vFATs() const { return &vfatd_; }
uint32_t existVFATs() const { return existVFATs_; }
//!Clear the vector rof VFAT data
void clearVFATs() { vfatd_.clear(); }

Expand All @@ -161,6 +165,8 @@ class GEMOptoHybrid {
uint64_t ch_; // GEBchamberHeader
uint64_t ct_; // GEBchamberTrailer

uint32_t existVFATs_;

std::vector<GEMVFAT> vfatd_;
};
#endif
20 changes: 14 additions & 6 deletions DataFormats/GEMDigi/interface/GEMVFATStatus.h
@@ -1,6 +1,7 @@
#ifndef DataFormats_GEMDigi_GEMVFATStatus_h
#define DataFormats_GEMDigi_GEMVFATStatus_h
#include "GEMAMC.h"
#include "GEMOptoHybrid.h"
#include "GEMVFAT.h"
#include <bitset>
#include <ostream>
Expand All @@ -12,8 +13,10 @@ class GEMVFATStatus {
struct {
uint8_t vc : 1; // VFAT CRC error
uint8_t InValidHeader : 1;
uint8_t EC : 1; // does not match AMC EC
uint8_t BC : 1; // does not match AMC BC
uint8_t EC : 1; // does not match AMC EC
uint8_t BC : 1; // does not match AMC BC
uint8_t vfatMask : 1; // VFAT mask error
uint8_t zsMask : 1; // Zero Suppression mask error
};
};
union Warnings {
Expand All @@ -25,14 +28,19 @@ class GEMVFATStatus {
};

GEMVFATStatus() {}
GEMVFATStatus(const GEMAMC& amc, const GEMVFAT& vfat, uint16_t position, bool readMultiBX) {
GEMVFATStatus(const GEMAMC& amc, const GEMOptoHybrid& oh, const GEMVFAT& vfat, bool readMultiBX) {
Errors error{0};
Warnings warn{0};

error.EC = vfat.ec() != amc.lv1Idt();
if (!readMultiBX)
error.BC = vfat.bc() != amc.bunchCrossing();

if (oh.version() != 0) {
error.vfatMask = (oh.vfatMask() >> vfat.vfatId()) ^ 0x1;
error.zsMask = (oh.zsMask() >> vfat.vfatId()) & 0x1;
}

if (vfat.version() > 2) {
error.vc = vfat.vc();
if (vfat.header() == 0x1E)
Expand All @@ -46,20 +54,20 @@ class GEMVFATStatus {
else
error.InValidHeader = 1;
}
vfatPosition_ = position;
vfatPosition_ = vfat.vfatId();

errors_ = error.codes;
warnings_ = warn.wcodes;
}

uint16_t vfatPosition() const { return vfatPosition_; }
bool isBad() const { return errors_ != 0; }
uint16_t errors() const { return errors_; }
uint8_t errors() const { return errors_; }
uint8_t warnings() const { return warnings_; }

private:
uint16_t vfatPosition_;
uint16_t errors_;
uint8_t errors_;
uint8_t warnings_;
};

Expand Down
6 changes: 4 additions & 2 deletions DataFormats/GEMDigi/src/classes_def.xml
Expand Up @@ -61,17 +61,19 @@
<class name="MuonDigiCollection<uint16_t,GEMAMCStatus>"/>
<class name="edm::Wrapper<MuonDigiCollection<uint16_t,GEMAMCStatus> >" splitLevel="0"/>

<class name="GEMOHStatus" ClassVersion="3">
<class name="GEMOHStatus" ClassVersion="4">
<version ClassVersion="3" checksum="1715607020"/>
<version ClassVersion="4" checksum="442197271"/>
</class>
<class name="std::vector<GEMOHStatus>"/>
<class name="std::map<GEMDetId,std::vector<GEMOHStatus> >"/>
<class name="std::pair<GEMDetId,std::vector<GEMOHStatus> >"/>
<class name="MuonDigiCollection<GEMDetId,GEMOHStatus>"/>
<class name="edm::Wrapper<MuonDigiCollection<GEMDetId,GEMOHStatus> >" splitLevel="0"/>

<class name="GEMVFATStatus" ClassVersion="3">
<class name="GEMVFATStatus" ClassVersion="4">
<version ClassVersion="3" checksum="2994917778"/>
<version ClassVersion="4" checksum="2298275534"/>
</class>
<class name="std::vector<GEMVFATStatus>"/>
<class name="std::map<GEMDetId,std::vector<GEMVFATStatus> >"/>
Expand Down
3 changes: 2 additions & 1 deletion EventFilter/GEMRawToDigi/plugins/GEMRawToDigiModule.cc
Expand Up @@ -178,6 +178,7 @@ void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event& iEvent, edm::Eve
if (keepDAQStatus_) {
outOHStatus.get()->insertDigi(cId, st_oh);
}
continue;
}

//Read vfat data
Expand All @@ -194,7 +195,7 @@ void GEMRawToDigiModule::produce(edm::StreamID iID, edm::Event& iEvent, edm::Eve
continue;
}

GEMVFATStatus st_vfat(amc, vfat, vfat.phi(), readMultiBX_);
GEMVFATStatus st_vfat(amc, optoHybrid, vfat, readMultiBX_);
if (st_vfat.isBad()) {
LogDebug("GEMRawToDigiModule") << st_vfat;
if (keepDAQStatus_) {
Expand Down