45 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh" 46 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh" 53 #include "DQM/SiStripMonitorHardware/interface/CMHistograms.hh" 80 void fillMaps(uint32_t aDetId,
unsigned short aChInModule, std::pair<uint16_t, uint16_t> aMedians);
120 iConfig.getUntrackedParameter<
std::
string>(
"HistogramFolderName",
"SiStrip/ReadoutView/CMMonitoring")),
121 fedIdVec_(iConfig.getUntrackedParameter<
std::vector<unsigned
int> >(
"FedIdVec")),
125 printDebug_(iConfig.getUntrackedParameter<unsigned
int>(
"PrintDebugMessages", 1)),
131 std::ostringstream debugStream;
133 debugStream <<
"[SiStripCMMonitorPlugin]Configuration for SiStripCMMonitorPlugin: " << std::endl
134 <<
"[SiStripCMMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
135 <<
"[SiStripCMMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
136 <<
"[SiStripCMMonitorPlugin]\tFillAllDetailedHistograms? " 138 <<
"[SiStripCMMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
139 <<
"[SiStripCMMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl;
142 std::ostringstream* pDebugStream = (
printDebug_ > 1 ? &debugStream :
nullptr);
144 cmHists_.initialise(iConfig, pDebugStream);
158 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
178 cmHists_.bookTopLevelHistograms(ibooker, tkDetMap);
181 cmHists_.bookAllFEDHistograms(ibooker);
204 FEDErrors lFedErrors;
216 bool lDataExist = lFedErrors.checkDataPresent(fedData);
221 std::unique_ptr<const sistrip::FEDBuffer>
buffer;
223 if (!lFedErrors.fillFatalFEDErrors(fedData, 0)) {
228 bool channelLengthsOK = buffer->checkChannelLengthsMatchBufferLength();
229 bool channelPacketCodesOK = buffer->checkChannelPacketCodes();
230 bool feLengthsOK = buffer->checkFEUnitLengths();
231 if (!channelLengthsOK || !channelPacketCodesOK || !feLengthsOK) {
236 std::ostringstream infoStream;
239 infoStream <<
" --- Processing FED #" <<
fedId << std::endl;
242 std::vector<CMHistograms::CMvalues>
values;
255 uint32_t lDetId = lConnection.
detId();
256 unsigned short nChInModule = lConnection.
nApvPairs();
261 bool lFailUnpackerChannelCheck = !buffer->channelGood(iCh,
true) && connected;
263 if (lFailUnpackerChannelCheck) {
291 std::ostringstream lMode;
292 lMode << buffer->readoutMode();
294 std::cout <<
"Readout mode: " << lMode.str() << std::endl;
297 std::pair<uint16_t, uint16_t> medians = std::pair<uint16_t, uint16_t>(0, 0);
299 if (lMode.str().find(
"Zero suppressed") != lMode.str().npos && lMode.str().find(
"lite") == lMode.str().npos)
300 medians = std::pair<uint16_t, uint16_t>(lChannel.
cmMedian(0), lChannel.
cmMedian(1));
302 CMHistograms::CMvalues lVal;
303 lVal.ChannelID = iCh;
304 lVal.Medians = std::pair<uint16_t, uint16_t>(medians.first, medians.second);
315 if (lChannel.
length() > 7) {
316 infoStream <<
"Medians for channel #" << iCh <<
" (length " << lChannel.
length() <<
"): " << medians.first
317 <<
", " << medians.second << std::endl;
321 values.push_back(lVal);
324 fillMaps(lDetId, nChInModule, medians);
326 prevMedians_[
fedId][iCh] = std::pair<uint16_t, uint16_t>(medians.first, medians.second);
334 lTime =
static_cast<float>(iEvent.
id().
event());
339 lTime =
static_cast<float>(
evt_);
430 unsigned short aChInModule,
431 std::pair<uint16_t, uint16_t> aMedians) {
433 std::pair<std::map<unsigned int, Statistics>::iterator,
bool> alreadyThere[2];
436 lStat.
Mean = (aMedians.first + aMedians.second) * 1. / (2 * aChInModule);
437 lStat.
Rms = (aMedians.first + aMedians.second) * (aMedians.first + aMedians.second) * 1. / (4 * aChInModule);
438 lStat.
Counter = 1. / aChInModule;
440 alreadyThere[0] =
CommonModes_.insert(std::pair<unsigned int, Statistics>(aDetId, lStat));
441 if (!alreadyThere[0].
second) {
442 ((alreadyThere[0].first)->second).Mean += (aMedians.first + aMedians.second) * 1. / (2 * aChInModule);
443 ((alreadyThere[0].first)->second).Rms +=
444 (aMedians.first + aMedians.second) * (aMedians.first + aMedians.second) * 1. / (4 * aChInModule);
445 ((alreadyThere[0].first)->second).Counter += 1. / aChInModule;
448 lStat.
Mean = (aMedians.first - aMedians.second) * 1. / aChInModule;
449 lStat.
Rms = (aMedians.first - aMedians.second) * (aMedians.first - aMedians.second) * 1. / aChInModule;
450 lStat.
Counter = 1. / aChInModule;
453 if (!alreadyThere[1].second) {
454 ((alreadyThere[1].first)->second).Mean += (aMedians.first - aMedians.second) * 1. / aChInModule;
455 ((alreadyThere[1].first)->second).Rms +=
456 (aMedians.first - aMedians.second) * (aMedians.first - aMedians.second) * 1. / aChInModule;
457 ((alreadyThere[1].first)->second).Counter += 1. / aChInModule;
EventNumber_t event() const
void analyze(const edm::Event &, const edm::EventSetup &) override
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
edm::InputTag rawDataTag_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static const uint32_t invalid32_
void setCurrentFolder(std::string const &fullpath)
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_
size_t size() const
Lenght of the data buffer in bytes.
std::pair< uint16_t, uint16_t > prevMedians_[FEDNumbering::MAXSiStripFEDID+1][sistrip::FEDCH_PER_FED]
U second(std::pair< T, U > const &p)
uint16_t cmMedian(const uint8_t apvIndex) const
#define DEFINE_FWK_MODULE(type)
SiStripCMMonitorPlugin(const edm::ParameterSet &)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void updateCabling(const edm::EventSetup &eventSetup)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
~SiStripCMMonitorPlugin() override
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...
static const uint16_t FEDCH_PER_FED
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
T const * product() const
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
bool fillWithLocalEvtNum_