-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42307 from fabferro/issueLogErrors_13011
[13_0_x] PPS suppress LogErrors in Pixel unpacker
- Loading branch information
Showing
7 changed files
with
106 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
EventFilter/CTPPSRawToDigi/interface/CTPPSPixelErrorSummary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |