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

[13_0_x] PPS suppress LogErrors in Pixel unpacker #42307

Merged
merged 3 commits into from
Jul 31, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
#include "EventFilter/CTPPSRawToDigi/interface/ElectronicIndex.h"
#include "FWCore/Utilities/interface/typedefs.h"

#include "EventFilter/CTPPSRawToDigi/interface/CTPPSPixelErrorSummary.h"

#include <cstdint>
#include <vector>
#include <map>
Expand All @@ -65,7 +67,7 @@ class CTPPSPixelDataFormatter {

typedef std::unordered_map<cms_uint32_t, DetDigis> Digis;

CTPPSPixelDataFormatter(std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> const& mapping);
CTPPSPixelDataFormatter(std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> const& mapping, CTPPSPixelErrorSummary&);

void setErrorStatus(bool theErrorStatus);

Expand Down Expand Up @@ -94,6 +96,8 @@ class CTPPSPixelDataFormatter {
return a.id < b.id || (a.id == b.id && a.roc < b.roc);
}

void printErrorSummary() const { m_ErrorSummary.printSummary(); }

private:
int m_WordCounter;

Expand All @@ -113,6 +117,7 @@ class CTPPSPixelDataFormatter {
int m_allDetDigis;
int m_hasDetDigis;
CTPPSPixelIndices m_Indices;
CTPPSPixelErrorSummary& m_ErrorSummary;
};

#endif
21 changes: 21 additions & 0 deletions EventFilter/CTPPSRawToDigi/interface/CTPPSPixelErrorSummary.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef EventFilter_CTPPSRawToDigi_CTPPSPixelErrorSummary
#define EventFilter_CTPPSRawToDigi_CTPPSPixelErrorSummary

#include <string>
#include <map>

class CTPPSPixelErrorSummary {
public:
CTPPSPixelErrorSummary(const std::string& category, const std::string& name, bool debug = false)
: m_debug(debug), m_category(category), m_name(name) {}

void add(const std::string& message, const std::string& details = "");
void printSummary() const;

private:
bool m_debug;
std::string m_category;
std::string m_name;
std::map<std::string, std::size_t> m_errors;
};
#endif
5 changes: 5 additions & 0 deletions EventFilter/CTPPSRawToDigi/interface/CTPPSPixelRawToDigi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
#include "EventFilter/CTPPSRawToDigi/interface/CTPPSPixelErrorSummary.h"

#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
Expand All @@ -30,6 +31,8 @@ class CTPPSPixelRawToDigi : public edm::stream::EDProducer<> {
/// get data, convert to digis attach againe to Event
void produce(edm::Event&, const edm::EventSetup&) override;

void endStream() override;

private:
edm::ParameterSet config_;

Expand All @@ -43,6 +46,8 @@ class CTPPSPixelRawToDigi : public edm::stream::EDProducer<> {

std::string mappingLabel_;

CTPPSPixelErrorSummary eSummary_;

bool includeErrors_;
bool isRun3_;
};
Expand Down
7 changes: 5 additions & 2 deletions EventFilter/CTPPSRawToDigi/plugins/CTPPSPixelDigiToRaw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Description: [one line class summary]
#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/PPSObjects/interface/CTPPSPixelFramePosition.h"
#include "EventFilter/CTPPSRawToDigi/interface/CTPPSPixelErrorSummary.h"

#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"
Expand Down Expand Up @@ -82,6 +83,7 @@ class CTPPSPixelDigiToRaw : public edm::stream::EDProducer<> {
edm::ESGetToken<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd> tCTPPSPixelDAQMapping_;
std::vector<CTPPSPixelDataFormatter::PPSPixelIndex> v_iDdet2fed_;
CTPPSPixelFramePosition fPos_;
CTPPSPixelErrorSummary eSummary_;
bool isRun3_;
};

Expand All @@ -101,7 +103,8 @@ CTPPSPixelDigiToRaw::CTPPSPixelDigiToRaw(const edm::ParameterSet& iConfig)
allDigiCounter_(0),
allWordCounter_(0),
debug_(false),
mappingLabel_(iConfig.getParameter<std::string>("mappingLabel")) {
mappingLabel_(iConfig.getParameter<std::string>("mappingLabel")),
eSummary_("CTPPSPixelDataFormatter", "[ctppsPixelRawToDigi]", false) {
//register your products
tCTPPSPixelDigi_ = consumes<edm::DetSetVector<CTPPSPixelDigi>>(iConfig.getParameter<edm::InputTag>("InputLabel"));
tCTPPSPixelDAQMapping_ = esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>();
Expand Down Expand Up @@ -145,7 +148,7 @@ void CTPPSPixelDigiToRaw::produce(edm::Event& iEvent, const edm::EventSetup& iSe
p.second.iD, p.second.roc, p.first.getROC(), p.first.getFEDId(), p.first.getChannelIdx()});
fedIds_ = mapping->fedIds();

CTPPSPixelDataFormatter formatter(mapping->ROCMapping);
CTPPSPixelDataFormatter formatter(mapping->ROCMapping, eSummary_);

// create product (raw data)
auto buffers = std::make_unique<FEDRawDataCollection>();
Expand Down
7 changes: 5 additions & 2 deletions EventFilter/CTPPSRawToDigi/plugins/CTPPSPixelRawToDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
using namespace std;

CTPPSPixelRawToDigi::CTPPSPixelRawToDigi(const edm::ParameterSet& conf)
: config_(conf)
: config_(conf),
eSummary_("CTPPSPixelDataFormatter", "[ctppsPixelRawToDigi]", edm::isDebugEnabled())

{
FEDRawDataCollection_ = consumes<FEDRawDataCollection>(config_.getParameter<edm::InputTag>("inputLabel"));
Expand Down Expand Up @@ -76,7 +77,7 @@ void CTPPSPixelRawToDigi::produce(edm::Event& ev, const edm::EventSetup& es) {

fedIds_ = mapping->fedIds();

CTPPSPixelDataFormatter formatter(mapping->ROCMapping);
CTPPSPixelDataFormatter formatter(mapping->ROCMapping, eSummary_);
formatter.setErrorStatus(includeErrors_);

bool errorsInEvent = false;
Expand Down Expand Up @@ -121,4 +122,6 @@ void CTPPSPixelRawToDigi::produce(edm::Event& ev, const edm::EventSetup& es) {
}
}

void CTPPSPixelRawToDigi::endStream() { eSummary_.printSummary(); }

DEFINE_FWK_MODULE(CTPPSPixelRawToDigi);
46 changes: 33 additions & 13 deletions EventFilter/CTPPSRawToDigi/src/CTPPSPixelDataFormatter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@ namespace {

} // namespace

CTPPSPixelDataFormatter::CTPPSPixelDataFormatter(std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> const& mapping)
: m_WordCounter(0), m_Mapping(mapping) {
CTPPSPixelDataFormatter::CTPPSPixelDataFormatter(std::map<CTPPSPixelFramePosition, CTPPSPixelROCInfo> const& mapping,
CTPPSPixelErrorSummary& eSummary)
: m_WordCounter(0),
m_Mapping(mapping),
m_ErrorSummary(eSummary)

{
int s32 = sizeof(Word32);
int s64 = sizeof(Word64);
int s8 = sizeof(char);
Expand Down Expand Up @@ -166,14 +171,16 @@ void CTPPSPixelDataFormatter::interpretRawData(
if (mit == m_Mapping.end()) {
if (nlink >= maxLinkIndex) {
m_ErrorCheck.conversionError(fedId, iD, InvalidLinkId, ww, errors);
edm::LogError("CTPPSPixelDataFormatter") << " Invalid linkId ";

m_ErrorSummary.add("Invalid linkId", "");
} else if ((nroc - 1) >= maxRocIndex) {
m_ErrorCheck.conversionError(fedId, iD, InvalidROCId, ww, errors);
edm::LogError("CTPPSPixelDataFormatter")
<< " Invalid ROC Id " << convroc << " in nlink " << nlink << " of FED " << fedId << " in DetId " << iD;
m_ErrorSummary.add("Invalid ROC",
fmt::format("Id {0}, in link {1}, of FED {2} in DetId {3}", convroc, nlink, fedId, iD));

} else {
m_ErrorCheck.conversionError(fedId, iD, Unknown, ww, errors);
edm::LogError("CTPPSPixelDataFormatter") << " Error unknown ";
m_ErrorSummary.add("Error unknown");
}
skipROC = true; // skipping roc due to mapping errors
continue;
Expand Down Expand Up @@ -201,19 +208,32 @@ void CTPPSPixelDataFormatter::interpretRawData(
int row = (ww >> m_ROW_shift) & m_ROW_mask;

if (!isRun3 && (dcol < min_Dcol || dcol > max_Dcol || pxid < min_Pixid || pxid > max_Pixid)) {
edm::LogError("CTPPSPixelDataFormatter")
<< " unphysical dcol and/or pxid "
<< "fedId=" << fedId << " nllink=" << nlink << " convroc=" << convroc << " adc=" << adc << " dcol=" << dcol
<< " pxid=" << pxid << " detId=" << iD;
m_ErrorSummary.add(
"unphysical dcol and/or pxid",
fmt::format("fedId= {0}, nllink= {1}, convroc= {2}, adc= {3}, dcol= {4}, pxid= {5}, detId= {6}",
fedId,
nlink,
convroc,
adc,
dcol,
pxid,
iD));

m_ErrorCheck.conversionError(fedId, iD, InvalidPixelId, ww, errors);

continue;
}
if (isRun3 && (col < min_COL || col > max_COL || row < min_ROW || row > max_ROW)) {
edm::LogError("CTPPSPixelDataFormatter") << " unphysical col and/or row "
<< "fedId=" << fedId << " nllink=" << nlink << " convroc=" << convroc
<< " adc=" << adc << " col=" << col << " row=" << row << " detId=" << iD;
m_ErrorSummary.add("unphysical col and/or row",
fmt::format("fedId= {0}, nllink= {1}, convroc= {2}, adc= {3}, col= {4}, row= {5}, detId= {6}",
fedId,
nlink,
convroc,
adc,
col,
row,
iD));

m_ErrorCheck.conversionError(fedId, iD, InvalidPixelId, ww, errors);

continue;
Expand Down
31 changes: 31 additions & 0 deletions EventFilter/CTPPSRawToDigi/src/CTPPSPixelErrorSummary.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "EventFilter/CTPPSRawToDigi/interface/CTPPSPixelErrorSummary.h"
#include <iostream>
#include <algorithm>

void CTPPSPixelErrorSummary::add(const std::string& message, const std::string& details) {
const auto eIt = m_errors.find(message);
if (eIt == m_errors.end()) {
m_errors.emplace(message, 1);
edm::LogError(m_category) << message << ": " << details
<< (m_debug ? ""
: "\nNote: further warnings of this type will be suppressed (this can be "
"changed by enabling debugging printout)");
} else {
++(eIt->second);
if (m_debug) {
edm::LogError(m_category) << message << ": " << details;
}
}
}

void CTPPSPixelErrorSummary::printSummary() const {
if (!m_errors.empty()) {
std::stringstream message;
message << m_name << " errors:";
for (const auto& warnAndCount : m_errors) {
message << std::endl << warnAndCount.first << " (" << warnAndCount.second << ")";
}
edm::LogError(m_category) << message.str();
}
}