37 #include <fmt/printf.h> 44 void setBinLog(TAxis* axis) {
45 int bins = axis->GetNbins();
46 float from = axis->GetXmin();
47 float to = axis->GetXmax();
49 std::vector<float> new_bins(
bins + 1, 0);
50 for (
int i = 0;
i <=
bins;
i++) {
51 new_bins[
i] = TMath::Power(10, from +
i *
width);
53 axis->Set(
bins, new_bins.data());
56 void setBinLogX(TH1*
h) {
57 TAxis* axis =
h->GetXaxis();
60 void setBinLogY(TH1*
h) {
61 TAxis* axis =
h->GetYaxis();
65 template <
typename... Args>
67 auto h = std::make_unique<TH2I>(std::forward<Args>(
args)...);
72 const auto&
name =
h->GetName();
73 return ibook.book2I(
name,
h.release());
95 std::map<SiPixelFEDErrorCodes, std::string> errorCodeToStringMap = {{k_FED25,
"FED25 error"},
96 {k_FED26,
"FED26 error"},
97 {k_FED27,
"FED27 error"},
98 {k_FED28,
"FED28 error"},
99 {k_FED29,
"FED29 error"},
100 {k_FED30,
"FED30 error"},
101 {k_FED31,
"FED31 error"}};
103 std::map<SiPixelFEDErrorCodes, std::string> errorCodeToTypeMap = {{k_FED25,
"ROC of 25"},
104 {k_FED26,
"Gap word"},
105 {k_FED27,
"Dummy word"},
106 {k_FED28,
"FIFO full"},
107 {k_FED29,
"Timeout"},
108 {k_FED30,
"TBM error trailer"},
109 {k_FED31,
"Event number"},
110 {k_FED32,
"Slink header"},
111 {k_FED33,
"Slink trailer"},
112 {k_FED34,
"Event size"},
113 {k_FED35,
"Invalid channel#"},
114 {k_FED36,
"ROC value"},
115 {k_FED37,
"Dcol or pixel value"},
116 {k_FED38,
"Readout order"}};
138 static constexpr
int nErrors = k_FED38 - k_FED25;
149 topFolderName_(iConfig.getParameter<
std::
string>(
"topFolderName")) {}
155 std::map<int, int> countsOnCPU;
156 std::map<int, int> countsOnGPU;
158 std::array<std::array<int, nErrors>,
nFEDs> countsMatrixOnCPU;
159 std::array<std::array<int, nErrors>,
nFEDs> countsMatrixOnGPU;
164 countsMatrixOnCPU[
i][
j] = 0;
165 countsMatrixOnGPU[
i][
j] = 0;
170 for (
unsigned int j = k_FED25;
j <= k_FED31;
j++) {
178 edm::LogWarning(
"SiPixelCompareTrackSoA") <<
"reference (cpu) SiPixelRawDataErrors not found; \n" 179 <<
"the comparison will not run.";
184 for (
auto it = inputFromCPU->begin(); it != inputFromCPU->end(); ++it) {
185 for (
auto& siPixelRawDataError : *it) {
186 int fed = siPixelRawDataError.getFedId();
187 int type = siPixelRawDataError.getType();
188 DetId id = it->detId();
191 countsOnCPU[
type] += 1;
195 << __PRETTY_FUNCTION__ <<
" on cpu: FED: " << fed <<
" detid: " <<
id.rawId() <<
" type:" <<
type;
203 edm::LogWarning(
"SiPixelCompareTrackSoA") <<
"target (gpu) SiPixelRawDataErrors not found; \n" 204 <<
"the comparison will not run.";
209 for (
auto it = inputFromGPU->begin(); it != inputFromGPU->end(); ++it) {
210 for (
auto& siPixelRawDataError : *it) {
211 int fed = siPixelRawDataError.getFedId();
212 int type = siPixelRawDataError.getType();
213 DetId id = it->detId();
216 countsOnGPU[
type] += 1;
220 << __PRETTY_FUNCTION__ <<
" on gpu: FED: " << fed <<
" detid: " <<
id.rawId() <<
" type:" <<
type;
226 << __PRETTY_FUNCTION__ <<
" on gpu found: " << errorsOnGPU <<
" on cpu found: " << errorsOnCPU << std::endl;
231 for (
unsigned int j = k_FED25;
j <= k_FED31;
j++) {
239 if (countsMatrixOnGPU[
i][
j] != 0 || countsMatrixOnCPU[
i][
j] != 0) {
242 <<
" | GPU counts: " << countsMatrixOnGPU[
i][
j] <<
" CPU counts:" << countsMatrixOnCPU[
i][
j] << std::endl;
260 iBook.
book2I(
"FEErrorVsFEDIdUnbalance",
261 "difference (GPU-CPE) of FED errors per FEDid per error type;;FED Id number;GPU counts - CPU counts",
277 "n. of total Pixel FEDError per event; CPU; GPU",
285 for (
const auto& element : errorCodeToStringMap) {
287 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");
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_
~SiPixelPhase1RawDataErrorComparator() override=default
MonitorElement * h_FEDerrorVsFEDIdUnbalance_
dqm::reco::DQMStore DQMStore
static constexpr int nFEDs
SiPixelPhase1RawDataErrorComparator(const edm::ParameterSet &)
#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)
Log< level::Info, false > LogInfo
MonitorElement * h_totFEDErrors_
static constexpr int nErrors
Log< level::Warning, false > LogWarning
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