45 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
69 inline void fillPresent(
unsigned int fedId,
bool present);
121 : rawDataTag_(iConfig.getParameter<edm::
InputTag>(
"RawDataTag")),
122 dirName_(iConfig.getUntrackedParameter<std::
string>(
"DirName",
"SiStrip/FEDIntegrity/")),
123 printDebug_(iConfig.getUntrackedParameter<bool>(
"PrintDebugMessages",
false)),
124 doPLOTfedsPresent_(iConfig.getParameter<bool>(
"doPLOTfedsPresent")),
125 doPLOTfedFatalErrors_(iConfig.getParameter<bool>(
"doPLOTfedFatalErrors")),
126 doPLOTfedNonFatalErrors_(iConfig.getParameter<bool>(
"doPLOTfedNonFatalErrors")),
127 doPLOTnFEDinVsLS_(iConfig.getParameter<bool>(
"doPLOTnFEDinVsLS")),
128 doPLOTnFEDinWdataVsLS_(iConfig.getParameter<bool>(
"doPLOTnFEDinWdataVsLS")),
129 fedsPresent_(nullptr),
130 fedFatalErrors_(nullptr),
131 fedNonFatalErrors_(nullptr),
132 nFEDinVsLS_(nullptr),
133 nFEDinWdataVsLS_(nullptr),
134 updateFrequency_(iConfig.getUntrackedParameter<unsigned int>(
"HistogramUpdateFrequency", 0)),
135 fedsPresentBinContents_(
FEDNumbering::MAXSiStripFEDID + 1, 0),
136 fedFatalErrorBinContents_(
FEDNumbering::MAXSiStripFEDID + 1, 0),
137 fedNonFatalErrorBinContents_(
FEDNumbering::MAXSiStripFEDID + 1, 0),
139 doPayloadChecks_(iConfig.getUntrackedParameter<bool>(
"DoPayloadChecks",
true)),
140 checkChannelLengths_(iConfig.getUntrackedParameter<bool>(
"CheckChannelLengths",
true)),
141 checkPacketCodes_(iConfig.getUntrackedParameter<bool>(
"CheckChannelPacketCodes",
true)),
142 checkFELengths_(iConfig.getUntrackedParameter<bool>(
"CheckFELengths",
true)),
143 checkChannelStatusBits_(iConfig.getUntrackedParameter<bool>(
"CheckChannelStatus",
true)),
144 verbose_(iConfig.getUntrackedParameter<bool>(
"verbose",
false)),
150 std::stringstream
ss;
151 ss <<
"Payload checks are disabled but individual payload checks have been enabled. The following payload checks "
154 ss <<
"Channel length check, ";
156 ss <<
"Channel packet code check, ";
158 ss <<
"Cabled channel status bits checks, ";
160 ss <<
"FE Unit legnth check";
185 std::cout <<
"[SiStripFEDCheckPlugin::analyze] gotData ? " << (gotData ?
"YES" :
"NOPE") << std::endl;
193 FEDErrors lFedErrors;
197 size_t nFEDinWdata = 0;
206 if (!fedData.
size() || !fedData.
data()) {
215 std::cout <<
" fedData.data(): " << fedData.
data() << std::endl;
218 if (fedData.
size() && fedData.
data())
226 bool hasFatalErrors =
false;
227 float rateNonFatal = 0;
229 std::unique_ptr<const sistrip::FEDBuffer>
buffer;
231 if (!lFedErrors.fillFatalFEDErrors(fedData, 0)) {
232 hasFatalErrors =
true;
238 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
240 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
241 tmp_buffer->findChannels();
244 bool channelLengthsOK =
checkChannelLengths_ ? buffer->checkChannelLengthsMatchBufferLength() :
true;
245 bool channelPacketCodesOK =
checkPacketCodes_ ? buffer->checkChannelPacketCodes() :
true;
246 bool feLengthsOK =
checkFELengths_ ? buffer->checkFEUnitLengths() :
true;
247 if (!channelLengthsOK || !channelPacketCodesOK || !feLengthsOK) {
248 hasFatalErrors =
true;
252 rateNonFatal = lFedErrors.fillNonFatalFEDErrors(buffer.get(),
cabling_);
256 if (hasFatalErrors) {
262 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
264 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
265 tmp_buffer->findChannels();
268 edm::LogInfo(
"SiStripFEDCheck") <<
"Fatal error with FED ID " << fedId <<
". Check summary: " << std::endl
269 << buffer->checkSummary() << std::endl;
270 std::stringstream
ss;
282 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
284 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
285 tmp_buffer->findChannels();
288 edm::LogInfo(
"SiStripFEDCheck") <<
"Non-fatal error with FED ID " << fedId <<
" for " << rateNonFatal
289 <<
" of the channels. Check summary: " << std::endl
290 << buffer->checkSummary() << std::endl;
291 std::stringstream
ss;
298 std::cout <<
"nFEDin: " << nFEDin <<
" nFEDinWdata: " << nFEDinWdata << std::endl;
313 double xFEDmin = siStripFedIdMin_ - 0.5;
321 ibooker.
book1D(
"FEDEntries",
"Number of times FED buffer is present in data", nFED, xFEDmin, xFEDmax);
326 fedFatalErrors_ = ibooker.
book1D(
"FEDFatal",
"Number of fatal errors in FED buffer", nFED, xFEDmin, xFEDmax);
332 ibooker.
book1D(
"FEDNonFatal",
"Number of non fatal errors in FED buffer", nFED, xFEDmin, xFEDmax);
342 ibooker.
bookProfile(
"nFEDinVsLS",
"number of FED in Vs LS", LSBin, LSMin, LSMax, nFED, xFEDmin, xFEDmax);
349 "nFEDinWdataVsLS",
"number of FED in (with data) Vs LS", LSBin, LSMin, LSMax, nFED, xFEDmin, xFEDmax);
385 if (nonFatalError > 0)
388 if (nonFatalError > 0)
405 unsigned int entriesFedsPresent = 0;
406 unsigned int entriesFatalErrors = 0;
407 unsigned int entriesNonFatalErrors = 0;
412 entriesFedsPresent += fedsPresentBin;
416 entriesFatalErrors += fedFatalErrorsBin;
420 entriesNonFatalErrors += fedNonFatalErrorsBin;
439 desc.
addUntracked<
unsigned int>(
"HistogramUpdateFrequency", 1000);
442 desc.
add<
bool>(
"doPLOTfedsPresent",
true);
443 desc.
add<
bool>(
"doPLOTfedFatalErrors",
true);
444 desc.
add<
bool>(
"doPLOTfedNonFatalErrors",
true);
445 desc.
add<
bool>(
"doPLOTnFEDinVsLS",
false);
446 desc.
add<
bool>(
"doPLOTnFEDinWdataVsLS",
false);
454 desc.
addUntracked<
bool>(
"CheckChannelPacketCodes",
true);
459 desc.
add<
int>(
"LSBin", 5000);
460 desc.
add<
double>(
"LSMin", 0.5);
461 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)