45 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh"
46 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
53 #include "DQM/SiStripMonitorHardware/interface/CMHistograms.hh"
78 void fillMaps(uint32_t aDetId,
unsigned short aChInModule, std::pair<uint16_t, uint16_t> aMedians);
118 iConfig.getUntrackedParameter<
std::
string>(
"HistogramFolderName",
"SiStrip/ReadoutView/CMMonitoring")),
119 fedIdVec_(iConfig.getUntrackedParameter<
std::
vector<unsigned
int> >(
"FedIdVec")),
120 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<
bool>(
"FillAllDetailedHistograms",
false)),
121 fillWithEvtNum_(iConfig.getUntrackedParameter<
bool>(
"FillWithEventNumber",
false)),
122 fillWithLocalEvtNum_(iConfig.getUntrackedParameter<
bool>(
"FillWithLocalEventNumber",
false)),
123 printDebug_(iConfig.getUntrackedParameter<unsigned
int>(
"PrintDebugMessages", 1)),
129 std::ostringstream debugStream;
131 debugStream <<
"[SiStripCMMonitorPlugin]Configuration for SiStripCMMonitorPlugin: " << std::endl
132 <<
"[SiStripCMMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
133 <<
"[SiStripCMMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
134 <<
"[SiStripCMMonitorPlugin]\tFillAllDetailedHistograms? "
136 <<
"[SiStripCMMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
137 <<
"[SiStripCMMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl;
140 std::ostringstream* pDebugStream = (
printDebug_ > 1 ? &debugStream :
nullptr);
142 cmHists_.initialise(iConfig, pDebugStream);
156 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
176 cmHists_.bookTopLevelHistograms(ibooker, tkDetMap);
179 cmHists_.bookAllFEDHistograms(ibooker);
200 FEDErrors lFedErrors;
212 bool lDataExist = lFedErrors.checkDataPresent(fedData);
217 std::unique_ptr<const sistrip::FEDBuffer>
buffer;
219 if (!lFedErrors.fillFatalFEDErrors(fedData, 0)) {
225 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
227 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
228 tmp_buffer->findChannels();
230 bool channelLengthsOK =
buffer->checkChannelLengthsMatchBufferLength();
231 bool channelPacketCodesOK =
buffer->checkChannelPacketCodes();
232 bool feLengthsOK =
buffer->checkFEUnitLengths();
233 if (!channelLengthsOK || !channelPacketCodesOK || !feLengthsOK) {
238 std::ostringstream infoStream;
241 infoStream <<
" --- Processing FED #" <<
fedId << std::endl;
244 std::vector<CMHistograms::CMvalues>
values;
257 uint32_t lDetId = lConnection.
detId();
258 unsigned short nChInModule = lConnection.
nApvPairs();
263 bool lFailUnpackerChannelCheck = !
buffer->channelGood(iCh,
true) && connected;
265 if (lFailUnpackerChannelCheck) {
293 std::ostringstream lMode;
294 lMode <<
buffer->readoutMode();
296 std::cout <<
"Readout mode: " << lMode.str() << std::endl;
299 std::pair<uint16_t, uint16_t> medians = std::pair<uint16_t, uint16_t>(0, 0);
301 if (lMode.str().find(
"Zero suppressed") != lMode.str().npos && lMode.str().find(
"lite") == lMode.str().npos)
302 medians = std::pair<uint16_t, uint16_t>(lChannel.
cmMedian(0), lChannel.
cmMedian(1));
304 CMHistograms::CMvalues lVal;
305 lVal.ChannelID = iCh;
306 lVal.Medians = std::pair<uint16_t, uint16_t>(medians.first, medians.second);
317 if (lChannel.
length() > 7) {
318 infoStream <<
"Medians for channel #" << iCh <<
" (length " << lChannel.
length() <<
"): " << medians.first
319 <<
", " << medians.second << std::endl;
326 fillMaps(lDetId, nChInModule, medians);
328 prevMedians_[
fedId][iCh] = std::pair<uint16_t, uint16_t>(medians.first, medians.second);
336 lTime = static_cast<float>(
iEvent.id().event());
341 lTime = static_cast<float>(
evt_);
343 lTime =
iEvent.orbitNumber() / 11223.;
432 unsigned short aChInModule,
433 std::pair<uint16_t, uint16_t> aMedians) {
435 std::pair<std::map<unsigned int, Statistics>::iterator,
bool> alreadyThere[2];
438 lStat.
Mean = (aMedians.first + aMedians.second) * 1. / (2 * aChInModule);
439 lStat.
Rms = (aMedians.first + aMedians.second) * (aMedians.first + aMedians.second) * 1. / (4 * aChInModule);
440 lStat.
Counter = 1. / aChInModule;
442 alreadyThere[0] =
CommonModes_.insert(std::pair<unsigned int, Statistics>(aDetId, lStat));
443 if (!alreadyThere[0].
second) {
444 ((alreadyThere[0].first)->
second).Mean += (aMedians.first + aMedians.second) * 1. / (2 * aChInModule);
445 ((alreadyThere[0].first)->
second).Rms +=
446 (aMedians.first + aMedians.second) * (aMedians.first + aMedians.second) * 1. / (4 * aChInModule);
447 ((alreadyThere[0].first)->
second).Counter += 1. / aChInModule;
450 lStat.
Mean = (aMedians.first - aMedians.second) * 1. / aChInModule;
451 lStat.
Rms = (aMedians.first - aMedians.second) * (aMedians.first - aMedians.second) * 1. / aChInModule;
452 lStat.
Counter = 1. / aChInModule;
455 if (!alreadyThere[1].
second) {
456 ((alreadyThere[1].first)->
second).Mean += (aMedians.first - aMedians.second) * 1. / aChInModule;
457 ((alreadyThere[1].first)->
second).Rms +=
458 (aMedians.first - aMedians.second) * (aMedians.first - aMedians.second) * 1. / aChInModule;
459 ((alreadyThere[1].first)->
second).Counter += 1. / aChInModule;