44 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
68 inline void fillPresent(
unsigned int fedId,
bool present);
120 : rawDataTag_(iConfig.getParameter<edm::
InputTag>(
"RawDataTag")),
121 dirName_(iConfig.getUntrackedParameter<std::
string>(
"DirName",
"SiStrip/FEDIntegrity/")),
122 printDebug_(iConfig.getUntrackedParameter<bool>(
"PrintDebugMessages",
false)),
123 doPLOTfedsPresent_(iConfig.getParameter<bool>(
"doPLOTfedsPresent")),
124 doPLOTfedFatalErrors_(iConfig.getParameter<bool>(
"doPLOTfedFatalErrors")),
125 doPLOTfedNonFatalErrors_(iConfig.getParameter<bool>(
"doPLOTfedNonFatalErrors")),
126 doPLOTnFEDinVsLS_(iConfig.getParameter<bool>(
"doPLOTnFEDinVsLS")),
127 doPLOTnFEDinWdataVsLS_(iConfig.getParameter<bool>(
"doPLOTnFEDinWdataVsLS")),
128 fedsPresent_(nullptr),
129 fedFatalErrors_(nullptr),
130 fedNonFatalErrors_(nullptr),
131 nFEDinVsLS_(nullptr),
132 nFEDinWdataVsLS_(nullptr),
133 updateFrequency_(iConfig.getUntrackedParameter<unsigned int>(
"HistogramUpdateFrequency", 0)),
134 fedsPresentBinContents_(
FEDNumbering::MAXSiStripFEDID + 1, 0),
135 fedFatalErrorBinContents_(
FEDNumbering::MAXSiStripFEDID + 1, 0),
136 fedNonFatalErrorBinContents_(
FEDNumbering::MAXSiStripFEDID + 1, 0),
138 doPayloadChecks_(iConfig.getUntrackedParameter<bool>(
"DoPayloadChecks",
true)),
139 checkChannelLengths_(iConfig.getUntrackedParameter<bool>(
"CheckChannelLengths",
true)),
140 checkPacketCodes_(iConfig.getUntrackedParameter<bool>(
"CheckChannelPacketCodes",
true)),
141 checkFELengths_(iConfig.getUntrackedParameter<bool>(
"CheckFELengths",
true)),
142 checkChannelStatusBits_(iConfig.getUntrackedParameter<bool>(
"CheckChannelStatus",
true)),
143 verbose_(iConfig.getUntrackedParameter<bool>(
"verbose",
false)),
149 std::stringstream
ss;
150 ss <<
"Payload checks are disabled but individual payload checks have been enabled. The following payload checks "
153 ss <<
"Channel length check, ";
155 ss <<
"Channel packet code check, ";
157 ss <<
"Cabled channel status bits checks, ";
159 ss <<
"FE Unit legnth check";
184 std::cout <<
"[SiStripFEDCheckPlugin::analyze] gotData ? " << (gotData ?
"YES" :
"NOPE") << std::endl;
192 FEDErrors lFedErrors;
196 size_t nFEDinWdata = 0;
205 if (!fedData.
size() || !fedData.
data()) {
214 std::cout <<
" fedData.data(): " << fedData.
data() << std::endl;
217 if (fedData.
size() && fedData.
data())
225 bool hasFatalErrors =
false;
226 float rateNonFatal = 0;
228 std::unique_ptr<const sistrip::FEDBuffer>
buffer;
230 if (!lFedErrors.fillFatalFEDErrors(fedData, 0)) {
231 hasFatalErrors =
true;
237 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
239 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
240 tmp_buffer->findChannels();
243 bool channelLengthsOK =
checkChannelLengths_ ? buffer->checkChannelLengthsMatchBufferLength() :
true;
244 bool channelPacketCodesOK =
checkPacketCodes_ ? buffer->checkChannelPacketCodes() :
true;
245 bool feLengthsOK =
checkFELengths_ ? buffer->checkFEUnitLengths() :
true;
246 if (!channelLengthsOK || !channelPacketCodesOK || !feLengthsOK) {
247 hasFatalErrors =
true;
251 rateNonFatal = lFedErrors.fillNonFatalFEDErrors(buffer.get(),
cabling_);
255 if (hasFatalErrors) {
261 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
263 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
264 tmp_buffer->findChannels();
267 edm::LogInfo(
"SiStripFEDCheck") <<
"Fatal error with FED ID " << fedId <<
". Check summary: " << std::endl
268 << buffer->checkSummary() << std::endl;
269 std::stringstream
ss;
281 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
283 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
284 tmp_buffer->findChannels();
287 edm::LogInfo(
"SiStripFEDCheck") <<
"Non-fatal error with FED ID " << fedId <<
" for " << rateNonFatal
288 <<
" of the channels. Check summary: " << std::endl
289 << buffer->checkSummary() << std::endl;
290 std::stringstream
ss;
297 std::cout <<
"nFEDin: " << nFEDin <<
" nFEDinWdata: " << nFEDinWdata << std::endl;
312 double xFEDmin = siStripFedIdMin_ - 0.5;
320 ibooker.
book1D(
"FEDEntries",
"Number of times FED buffer is present in data", nFED, xFEDmin, xFEDmax);
325 fedFatalErrors_ = ibooker.
book1D(
"FEDFatal",
"Number of fatal errors in FED buffer", nFED, xFEDmin, xFEDmax);
331 ibooker.
book1D(
"FEDNonFatal",
"Number of non fatal errors in FED buffer", nFED, xFEDmin, xFEDmax);
341 ibooker.
bookProfile(
"nFEDinVsLS",
"number of FED in Vs LS", LSBin, LSMin, LSMax, nFED, xFEDmin, xFEDmax);
348 "nFEDinWdataVsLS",
"number of FED in (with data) Vs LS", LSBin, LSMin, LSMax, nFED, xFEDmin, xFEDmax);
384 if (nonFatalError > 0)
387 if (nonFatalError > 0)
404 unsigned int entriesFedsPresent = 0;
405 unsigned int entriesFatalErrors = 0;
406 unsigned int entriesNonFatalErrors = 0;
411 entriesFedsPresent += fedsPresentBin;
415 entriesFatalErrors += fedFatalErrorsBin;
419 entriesNonFatalErrors += fedNonFatalErrorsBin;
438 desc.
addUntracked<
unsigned int>(
"HistogramUpdateFrequency", 1000);
441 desc.
add<
bool>(
"doPLOTfedsPresent",
true);
442 desc.
add<
bool>(
"doPLOTfedFatalErrors",
true);
443 desc.
add<
bool>(
"doPLOTfedNonFatalErrors",
true);
444 desc.
add<
bool>(
"doPLOTnFEDinVsLS",
false);
445 desc.
add<
bool>(
"doPLOTnFEDinWdataVsLS",
false);
453 desc.
addUntracked<
bool>(
"CheckChannelPacketCodes",
true);
458 desc.
add<
int>(
"LSBin", 5000);
459 desc.
add<
double>(
"LSMin", 0.5);
460 desc.
add<
double>(
"LSMax", 5000.5);
bool doPLOTnFEDinWdataVsLS_
void dqmEndRun(edm::Run const &, edm::EventSetup const &) override
MonitorElement * nFEDinWdataVsLS_
bool checkChannelLengths_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
example_stream int eventCount_
void fillFatalError(unsigned int fedId, bool fatalError)
edm::InputTag rawDataTag_
bool doPLOTfedNonFatalErrors_
virtual void setCurrentFolder(std::string const &fullpath)
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
unsigned int siStripFedIdMax_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const SiStripFedCabling * cabling_
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
#define DEFINE_FWK_MODULE(type)
bool hasNonFatalError(const FEDRawData &fedData, unsigned int fedId) const
MonitorElement * fedNonFatalErrors_
LuminosityBlockNumber_t luminosityBlock() const
size_t size() const
Lenght of the data buffer in bytes.
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
bool getData(T &iHolder) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void addDefault(ParameterSetDescription const &psetDescription)
unsigned int updateFrequency_
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
void updateCabling(const SiStripFedCablingRcd &cablingRcd)
void analyze(const edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~SiStripFEDCheckPlugin() override
Log< level::Info, false > LogInfo
std::vector< unsigned int > fedFatalErrorBinContents_
std::vector< unsigned int > fedsPresentBinContents_
unsigned int siStripFedIdMin_
Constants and enumerated types for FED/FEC systems.
MonitorElement * nFEDinVsLS_
bool hasFatalError(const FEDRawData &fedData, unsigned int fedId) const
T getParameter(std::string const &) const
bool doPLOTfedFatalErrors_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
bool check(const edm::EventSetup &iSetup)
SiStripFEDCheckPlugin(const edm::ParameterSet &)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
FEDBufferStatusCode preconstructCheckFEDBuffer(const FEDRawData &fedBuffer, bool allowBadBuffer=false)
MonitorElement * fedFatalErrors_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
MonitorElement * fedsPresent_
bool checkChannelStatusBits_
void fillNonFatalError(unsigned int fedId, float nonFatalError)
std::vector< unsigned int > fedNonFatalErrorBinContents_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void fillPresent(unsigned int fedId, bool present)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)