30 #include <fmt/printf.h> 37 void setBinLog(TAxis* axis) {
38 int bins = axis->GetNbins();
39 float from = axis->GetXmin();
40 float to = axis->GetXmax();
42 std::vector<float> new_bins(
bins + 1, 0);
43 for (
int i = 0;
i <=
bins;
i++) {
44 new_bins[
i] = TMath::Power(10, from +
i *
width);
46 axis->Set(
bins, new_bins.data());
49 void setBinLogX(TH1*
h) {
50 TAxis* axis =
h->GetXaxis();
53 void setBinLogY(TH1*
h) {
54 TAxis* axis =
h->GetYaxis();
58 template <
typename... Args>
60 auto h = std::make_unique<TH2I>(std::forward<Args>(
args)...);
65 const auto&
name =
h->GetName();
66 return ibook.book2I(
name,
h.release());
87 using MapToCodes = std::map<SiPixelFEDErrorCodes, std::string>;
89 const MapToCodes errorCodeToStringMap = {{k_FED25,
"FED25 error"},
90 {k_FED26,
"FED26 error"},
91 {k_FED27,
"FED27 error"},
92 {k_FED28,
"FED28 error"},
93 {k_FED29,
"FED29 error"},
94 {k_FED30,
"FED30 error"},
95 {k_FED31,
"FED31 error"}};
97 const MapToCodes errorCodeToTypeMap = {{k_FED25,
"ROC of 25"},
98 {k_FED26,
"Gap word"},
99 {k_FED27,
"Dummy word"},
100 {k_FED28,
"FIFO full"},
101 {k_FED29,
"Timeout"},
102 {k_FED30,
"TBM error trailer"},
103 {k_FED31,
"Event number"},
104 {k_FED32,
"Slink header"},
105 {k_FED33,
"Slink trailer"},
106 {k_FED34,
"Event size"},
107 {k_FED35,
"Invalid channel#"},
108 {k_FED36,
"ROC value"},
109 {k_FED37,
"Dcol or pixel value"},
110 {k_FED38,
"Readout order"}};
144 : pixelErrorSrcGPU_(iConfig.getParameter<
edm::
InputTag>(
"pixelErrorSrcGPU")),
145 pixelErrorSrcCPU_(iConfig.getParameter<
edm::
InputTag>(
"pixelErrorSrcCPU")),
148 topFolderName_(iConfig.getParameter<
std::
string>(
"topFolderName")) {}
154 std::map<int, int> countsOnCPU;
155 std::map<int, int> countsOnGPU;
157 std::array<std::array<int, nErrors>,
nFEDs> countsMatrixOnCPU;
158 std::array<std::array<int, nErrors>,
nFEDs> countsMatrixOnGPU;
163 countsMatrixOnCPU[
i][
j] = 0;
164 countsMatrixOnGPU[
i][
j] = 0;
169 for (
unsigned int j = k_FED25;
j <= k_FED31;
j++) {
180 <<
"the comparison will not run.";
189 <<
"the comparison will not run.";
195 for (
auto it = inputFromCPU->begin();
it != inputFromCPU->end(); ++
it) {
196 for (
auto& siPixelRawDataError : *
it) {
197 int fed = siPixelRawDataError.getFedId();
198 int type = siPixelRawDataError.getType();
202 countsOnCPU[
type] += 1;
205 LogDebug(
kName) <<
" (on cpu) FED: " << fed <<
" detid: " <<
id.rawId() <<
" type:" <<
type;
212 for (
auto it = inputFromGPU->begin();
it != inputFromGPU->end(); ++
it) {
213 for (
auto& siPixelRawDataError : *
it) {
214 int fed = siPixelRawDataError.getFedId();
215 int type = siPixelRawDataError.getType();
219 countsOnGPU[
type] += 1;
222 LogDebug(
kName) <<
" (on gpu) FED: " << fed <<
" detid: " <<
id.rawId() <<
" type:" <<
type;
227 LogDebug(
kName) <<
" on gpu found: " << errorsOnGPU <<
" on cpu found: " << errorsOnCPU;
232 for (
unsigned int j = k_FED25;
j <= k_FED31;
j++) {
240 if (countsMatrixOnGPU[
i][
j] != 0 || countsMatrixOnCPU[
i][
j] != 0) {
242 <<
" | GPU counts: " << countsMatrixOnGPU[
i][
j]
243 <<
" CPU counts:" << countsMatrixOnCPU[
i][
j];
261 iBook.
book2I(
"FEErrorVsFEDIdUnbalance",
262 "difference (GPU-CPU) of FED errors per FEDid per error type;;FED Id number;GPU counts - CPU counts",
278 "n. of total Pixel FEDErrors per event; CPU; GPU",
286 for (
const auto& element : errorCodeToStringMap) {
287 h_nFEDErrors_[element.first] = iBook.
book2I(fmt::sprintf(
"nFED%i_Errors", static_cast<int>(element.first)),
288 fmt::sprintf(
"n. of %ss per event; CPU; GPU", element.second),
301 ->setComment(
"input GPU SiPixel FED errors");
303 ->setComment(
"input CPU SiPixel FED errors");
304 desc.add<
std::string>(
"topFolderName",
"SiPixelHeterogeneous/PixelErrorCompareGPUvsCPU");
Log< level::Info, true > LogVerbatim
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::unordered_map< SiPixelFEDErrorCodes, MonitorElement * > h_nFEDErrors_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const std::string topFolderName_
virtual void setCurrentFolder(std::string const &fullpath)
const edm::EDGetTokenT< edm::DetSetVector< SiPixelRawDataError > > tokenErrorsGPU_
const edm::InputTag pixelErrorSrcCPU_
Log< level::Error, false > LogError
~SiPixelPhase1RawDataErrorComparator() override=default
const edm::InputTag pixelErrorSrcGPU_
MonitorElement * h_FEDerrorVsFEDIdUnbalance_
dqm::reco::DQMStore DQMStore
static constexpr int nFEDs
SiPixelPhase1RawDataErrorComparator(const edm::ParameterSet &)
static constexpr const char * kName
#define DEFINE_FWK_MODULE(type)
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * h_totFEDErrors_
static constexpr int nErrors
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
MonitorElement * book2I(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
const edm::EDGetTokenT< edm::DetSetVector< SiPixelRawDataError > > tokenErrorsCPU_
void bookHistograms(DQMStore::IBooker &ibooker, edm::Run const &iRun, edm::EventSetup const &iSetup) override
Pixel error – collection of errors and error information.
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override