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 :
NULL);
148 cmHists_.initialise(iConfig,pDebugStream);
157 prevMedians_[fedId][iCh] = std::pair<uint16_t,uint16_t>(0,0);
163 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
183 cmHists_.bookTopLevelHistograms(ibooker);
214 FEDErrors lFedErrors;
223 lFedErrors.initialiseFED(fedId,
cabling_,tTopo);
227 bool lDataExist = lFedErrors.checkDataPresent(fedData);
232 std::auto_ptr<const sistrip::FEDBuffer> buffer;
234 if (!lFedErrors.fillFatalFEDErrors(fedData,0)) {
240 bool channelLengthsOK = buffer->checkChannelLengthsMatchBufferLength();
241 bool channelPacketCodesOK = buffer->checkChannelPacketCodes();
242 bool feLengthsOK = buffer->checkFEUnitLengths();
243 if ( !channelLengthsOK ||
244 !channelPacketCodesOK ||
250 std::ostringstream infoStream;
254 infoStream <<
" --- Processing FED #" << fedId << std::endl;
258 std::vector<CMHistograms::CMvalues>
values;
260 for (
unsigned int iCh = 0;
273 uint32_t lDetId = lConnection.
detId();
274 unsigned short nChInModule = lConnection.
nApvPairs();
278 bool lFailUnpackerChannelCheck = !buffer->channelGood(iCh) && connected;
280 if (lFailUnpackerChannelCheck) {
309 std::ostringstream lMode;
310 lMode << buffer->readoutMode();
312 std::cout <<
"Readout mode: " << lMode.str() << std::endl;
316 std::pair<uint16_t,uint16_t> medians = std::pair<uint16_t,uint16_t>(0,0);
318 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));
320 CMHistograms::CMvalues lVal;
321 lVal.ChannelID = iCh;
322 lVal.Medians = std::pair<uint16_t,uint16_t>(medians.first,medians.second);
333 if (lChannel.
length() > 7) {
334 infoStream <<
"Medians for channel #" << iCh <<
" (length " << lChannel.
length() <<
"): " << medians.first <<
", " << medians.second << std::endl;
338 values.push_back(lVal);
341 fillMaps(lDetId,nChInModule,medians);
343 prevMedians_[fedId][iCh] = std::pair<uint16_t,uint16_t>(medians.first,medians.second);
351 lTime =
static_cast<float>(iEvent.
id().
event());
356 lTime =
static_cast<float>(
evt_);
362 cmHists_.fillHistograms(values,lTime,fedId);
455 std::pair<std::map<unsigned int,Statistics>::iterator,
bool> alreadyThere[2];
458 lStat.
Mean = (aMedians.first+aMedians.second)*1./(2*aChInModule);
459 lStat.
Rms = (aMedians.first+aMedians.second)*(aMedians.first+aMedians.second)*1./(4*aChInModule);
460 lStat.
Counter = 1./aChInModule;
462 alreadyThere[0] =
CommonModes_.insert(std::pair<unsigned int,Statistics>(aDetId,lStat));
463 if (!alreadyThere[0].
second) {
464 ((alreadyThere[0].first)->second).Mean += (aMedians.first+aMedians.second)*1./(2*aChInModule);
465 ((alreadyThere[0].first)->second).Rms += (aMedians.first+aMedians.second)*(aMedians.first+aMedians.second)*1./(4*aChInModule);
466 ((alreadyThere[0].first)->second).Counter += 1./aChInModule;
469 lStat.
Mean = (aMedians.first-aMedians.second)*1./aChInModule;
470 lStat.
Rms = (aMedians.first-aMedians.second)*(aMedians.first-aMedians.second)*1./aChInModule;
471 lStat.
Counter = 1./aChInModule;
474 if (!alreadyThere[1].second) {
475 ((alreadyThere[1].first)->second).Mean += (aMedians.first-aMedians.second)*1./aChInModule;
476 ((alreadyThere[1].first)->second).Rms += (aMedians.first-aMedians.second)*(aMedians.first-aMedians.second)*1./aChInModule;
477 ((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]
virtual 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_
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...
~SiStripCMMonitorPlugin()
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_