46 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh" 47 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh" 54 #include "DQM/SiStripMonitorHardware/interface/CMHistograms.hh" 84 void fillMaps(uint32_t aDetId,
unsigned short aChInModule, std::pair<uint16_t,uint16_t> aMedians);
124 :
rawDataTag_(iConfig.getUntrackedParameter<
edm::InputTag>(
"RawDataTag",
edm::InputTag(
"source",
""))),
125 folderName_(iConfig.getUntrackedParameter<
std::
string>(
"HistogramFolderName",
"SiStrip/ReadoutView/CMMonitoring")),
126 fedIdVec_(iConfig.getUntrackedParameter<
std::vector<unsigned
int> >(
"FedIdVec")),
130 printDebug_(iConfig.getUntrackedParameter<unsigned
int>(
"PrintDebugMessages",1)),
136 std::ostringstream debugStream;
138 debugStream <<
"[SiStripCMMonitorPlugin]Configuration for SiStripCMMonitorPlugin: " << std::endl
139 <<
"[SiStripCMMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
140 <<
"[SiStripCMMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
142 <<
"[SiStripCMMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
143 <<
"[SiStripCMMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl;
146 std::ostringstream* pDebugStream = (
printDebug_>1 ? &debugStream :
nullptr);
148 cmHists_.initialise(iConfig,pDebugStream);
163 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
187 cmHists_.bookTopLevelHistograms(ibooker, tkDetMap);
218 FEDErrors lFedErrors;
231 bool lDataExist = lFedErrors.checkDataPresent(fedData);
236 std::auto_ptr<const sistrip::FEDBuffer>
buffer;
238 if (!lFedErrors.fillFatalFEDErrors(fedData,0)) {
244 bool channelLengthsOK = buffer->checkChannelLengthsMatchBufferLength();
245 bool channelPacketCodesOK = buffer->checkChannelPacketCodes();
246 bool feLengthsOK = buffer->checkFEUnitLengths();
247 if ( !channelLengthsOK ||
248 !channelPacketCodesOK ||
254 std::ostringstream infoStream;
258 infoStream <<
" --- Processing FED #" <<
fedId << std::endl;
262 std::vector<CMHistograms::CMvalues>
values;
264 for (
unsigned int iCh = 0;
277 uint32_t lDetId = lConnection.
detId();
278 unsigned short nChInModule = lConnection.
nApvPairs();
282 bool lFailUnpackerChannelCheck = !buffer->channelGood(iCh,
true) && connected;
284 if (lFailUnpackerChannelCheck) {
313 std::ostringstream lMode;
314 lMode << buffer->readoutMode();
316 std::cout <<
"Readout mode: " << lMode.str() << std::endl;
320 std::pair<uint16_t,uint16_t> medians = std::pair<uint16_t,uint16_t>(0,0);
322 if (lMode.str().find(
"Zero suppressed") != lMode.str().npos && lMode.str().find(
"lite") == lMode.str().npos) medians = std::pair<uint16_t,uint16_t>(lChannel.
cmMedian(0),lChannel.
cmMedian(1));
324 CMHistograms::CMvalues lVal;
325 lVal.ChannelID = iCh;
326 lVal.Medians = std::pair<uint16_t,uint16_t>(medians.first,medians.second);
337 if (lChannel.
length() > 7) {
338 infoStream <<
"Medians for channel #" << iCh <<
" (length " << lChannel.
length() <<
"): " << medians.first <<
", " << medians.second << std::endl;
342 values.push_back(lVal);
345 fillMaps(lDetId,nChInModule,medians);
347 prevMedians_[
fedId][iCh] = std::pair<uint16_t,uint16_t>(medians.first,medians.second);
355 lTime =
static_cast<float>(iEvent.
id().
event());
360 lTime =
static_cast<float>(
evt_);
459 std::pair<std::map<unsigned int,Statistics>::iterator,
bool> alreadyThere[2];
462 lStat.
Mean = (aMedians.first+aMedians.second)*1./(2*aChInModule);
463 lStat.
Rms = (aMedians.first+aMedians.second)*(aMedians.first+aMedians.second)*1./(4*aChInModule);
464 lStat.
Counter = 1./aChInModule;
466 alreadyThere[0] =
CommonModes_.insert(std::pair<unsigned int,Statistics>(aDetId,lStat));
467 if (!alreadyThere[0].
second) {
468 ((alreadyThere[0].first)->second).Mean += (aMedians.first+aMedians.second)*1./(2*aChInModule);
469 ((alreadyThere[0].first)->second).Rms += (aMedians.first+aMedians.second)*(aMedians.first+aMedians.second)*1./(4*aChInModule);
470 ((alreadyThere[0].first)->second).Counter += 1./aChInModule;
473 lStat.
Mean = (aMedians.first-aMedians.second)*1./aChInModule;
474 lStat.
Rms = (aMedians.first-aMedians.second)*(aMedians.first-aMedians.second)*1./aChInModule;
475 lStat.
Counter = 1./aChInModule;
478 if (!alreadyThere[1].second) {
479 ((alreadyThere[1].first)->second).Mean += (aMedians.first-aMedians.second)*1./aChInModule;
480 ((alreadyThere[1].first)->second).Rms += (aMedians.first-aMedians.second)*(aMedians.first-aMedians.second)*1./aChInModule;
481 ((alreadyThere[1].first)->second).Counter += 1./aChInModule;
EventNumber_t event() const
std::pair< uint16_t, uint16_t > prevMedians_[FEDNumbering::MAXSiStripFEDID+1][sistrip::FEDCH_PER_FED]
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_
#define DEFINE_FWK_MODULE(type)
void fillMaps(uint32_t aDetId, unsigned short aChInModule, std::pair< uint16_t, uint16_t > aMedians)
unsigned long long EventNumber_t
std::vector< unsigned int > fedIdVec_
std::map< unsigned int, Statistics > CommonModesAPV0minusAPV1_
size_t size() const
Lenght of the data buffer in bytes.
U second(std::pair< T, U > const &p)
uint16_t cmMedian(const uint8_t apvIndex) const
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_
void setCurrentFolder(const std::string &fullpath)
std::map< unsigned int, Statistics > CommonModes_
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_