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);
122 iConfig.getUntrackedParameter<
std::
string>(
"HistogramFolderName",
"SiStrip/ReadoutView/CMMonitoring")),
123 fedIdVec_(iConfig.getUntrackedParameter<
std::
vector<unsigned
int> >(
"FedIdVec")),
124 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<
bool>(
"FillAllDetailedHistograms",
false)),
125 fillWithEvtNum_(iConfig.getUntrackedParameter<
bool>(
"FillWithEventNumber",
false)),
126 fillWithLocalEvtNum_(iConfig.getUntrackedParameter<
bool>(
"FillWithLocalEventNumber",
false)),
127 printDebug_(iConfig.getUntrackedParameter<unsigned
int>(
"PrintDebugMessages", 1)),
134 std::ostringstream debugStream;
136 debugStream <<
"[SiStripCMMonitorPlugin]Configuration for SiStripCMMonitorPlugin: " << std::endl
137 <<
"[SiStripCMMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
138 <<
"[SiStripCMMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
139 <<
"[SiStripCMMonitorPlugin]\tFillAllDetailedHistograms? " 141 <<
"[SiStripCMMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
142 <<
"[SiStripCMMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl;
145 std::ostringstream* pDebugStream = (
printDebug_ > 1 ? &debugStream :
nullptr);
147 cmHists_.initialise(iConfig, pDebugStream);
161 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
178 cmHists_.bookTopLevelHistograms(ibooker, tkDetMap);
181 cmHists_.bookAllFEDHistograms(ibooker);
199 FEDErrors lFedErrors;
211 bool lDataExist = lFedErrors.checkDataPresent(fedData);
216 std::unique_ptr<const sistrip::FEDBuffer>
buffer;
218 if (!lFedErrors.fillFatalFEDErrors(fedData, 0)) {
224 throw cms::Exception(
"FEDBuffer") << st_buffer <<
" (check debug output for more details)";
226 auto tmp_buffer = std::make_unique<sistrip::FEDBuffer>(fedData,
true);
227 tmp_buffer->findChannels();
229 bool channelLengthsOK =
buffer->checkChannelLengthsMatchBufferLength();
230 bool channelPacketCodesOK =
buffer->checkChannelPacketCodes();
231 bool feLengthsOK =
buffer->checkFEUnitLengths();
232 if (!channelLengthsOK || !channelPacketCodesOK || !feLengthsOK) {
237 std::ostringstream infoStream;
240 infoStream <<
" --- Processing FED #" <<
fedId << std::endl;
243 std::vector<CMHistograms::CMvalues>
values;
256 uint32_t lDetId = lConnection.
detId();
257 unsigned short nChInModule = lConnection.
nApvPairs();
262 bool lFailUnpackerChannelCheck = !
buffer->channelGood(iCh,
true) && connected;
264 if (lFailUnpackerChannelCheck) {
292 std::ostringstream lMode;
293 lMode <<
buffer->readoutMode();
295 std::cout <<
"Readout mode: " << lMode.str() << std::endl;
298 std::pair<uint16_t, uint16_t> medians = std::pair<uint16_t, uint16_t>(0, 0);
300 if (lMode.str().find(
"Zero suppressed") != lMode.str().npos && lMode.str().find(
"lite") == lMode.str().npos)
301 medians = std::pair<uint16_t, uint16_t>(lChannel.
cmMedian(0), lChannel.
cmMedian(1));
303 CMHistograms::CMvalues lVal;
304 lVal.ChannelID = iCh;
305 lVal.Medians = std::pair<uint16_t, uint16_t>(medians.first, medians.second);
316 if (lChannel.
length() > 7) {
317 infoStream <<
"Medians for channel #" << iCh <<
" (length " << lChannel.
length() <<
"): " << medians.first
318 <<
", " << medians.second << std::endl;
325 fillMaps(lDetId, nChInModule, medians);
327 prevMedians_[
fedId][iCh] = std::pair<uint16_t, uint16_t>(medians.first, medians.second);
335 lTime =
static_cast<float>(
iEvent.id().event());
340 lTime =
static_cast<float>(
evt_);
342 lTime =
iEvent.orbitNumber() / 11223.;
425 unsigned short aChInModule,
426 std::pair<uint16_t, uint16_t> aMedians) {
428 std::pair<std::map<unsigned int, Statistics>::iterator,
bool> alreadyThere[2];
431 lStat.
Mean = (aMedians.first + aMedians.second) * 1. / (2 * aChInModule);
432 lStat.
Rms = (aMedians.first + aMedians.second) * (aMedians.first + aMedians.second) * 1. / (4 * aChInModule);
433 lStat.
Counter = 1. / aChInModule;
435 alreadyThere[0] =
CommonModes_.insert(std::pair<unsigned int, Statistics>(aDetId, lStat));
436 if (!alreadyThere[0].
second) {
437 ((alreadyThere[0].first)->
second).Mean += (aMedians.first + aMedians.second) * 1. / (2 * aChInModule);
438 ((alreadyThere[0].first)->
second).Rms +=
439 (aMedians.first + aMedians.second) * (aMedians.first + aMedians.second) * 1. / (4 * aChInModule);
440 ((alreadyThere[0].first)->
second).Counter += 1. / aChInModule;
443 lStat.
Mean = (aMedians.first - aMedians.second) * 1. / aChInModule;
444 lStat.
Rms = (aMedians.first - aMedians.second) * (aMedians.first - aMedians.second) * 1. / aChInModule;
445 lStat.
Counter = 1. / aChInModule;
448 if (!alreadyThere[1].
second) {
449 ((alreadyThere[1].first)->
second).Mean += (aMedians.first - aMedians.second) * 1. / aChInModule;
450 ((alreadyThere[1].first)->
second).Rms +=
451 (aMedians.first - aMedians.second) * (aMedians.first - aMedians.second) * 1. / aChInModule;
452 ((alreadyThere[1].first)->
second).Counter += 1. / aChInModule;
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
virtual void setCurrentFolder(std::string const &fullpath)
edm::InputTag rawDataTag_
edm::ESWatcher< SiStripFedCablingRcd > fedCablingWatcher_
static const uint32_t invalid32_
#define DEFINE_FWK_MODULE(type)
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
void fillMaps(uint32_t aDetId, unsigned short aChInModule, std::pair< uint16_t, uint16_t > aMedians)
unsigned long long EventNumber_t
std::map< unsigned int, Statistics > CommonModes_
std::vector< unsigned int > fedIdVec_
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > tTopoToken_
std::pair< uint16_t, uint16_t > prevMedians_[FEDNumbering::MAXSiStripFEDID+1][sistrip::FEDCH_PER_FED]
U second(std::pair< T, U > const &p)
SiStripCMMonitorPlugin(const edm::ParameterSet &)
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Class containning control, module, detector and connection information, at the level of a FED channel...
void updateCabling(const SiStripFedCablingRcd &cablingRcd)
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
bool getData(T &iHolder) const
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const uint32_t & detId() const
~SiStripCMMonitorPlugin() override
uint16_t cmMedian(const uint8_t apvIndex) const
bool fillAllDetailedHistograms_
std::map< unsigned int, Statistics > CommonModesAPV0minusAPV1_
const uint16_t & nApvPairs() const
const SiStripFedCabling * cabling_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
bool check(const edm::EventSetup &iSetup)
static const uint16_t FEDCH_PER_FED
FEDBufferStatusCode preconstructCheckFEDBuffer(const FEDRawData &fedBuffer, bool allowBadBuffer=false)
bool fillWithLocalEvtNum_