47 #include "DQM/SiStripMonitorHardware/interface/FEDHistograms.hh"
48 #include "DQM/SiStripMonitorHardware/interface/FEDErrors.hh"
57 #include "DQM/SiStripMonitorHardware/interface/CMHistograms.hh"
85 void fillMaps(uint32_t aDetId,
unsigned short aChInModule, std::pair<uint16_t,uint16_t> aMedians);
129 : rawDataTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"RawDataTag",edm::InputTag(
"source",
""))),
130 folderName_(iConfig.getUntrackedParameter<std::string>(
"HistogramFolderName",
"SiStrip/ReadoutView/CMMonitoring")),
131 fedIdVec_(iConfig.getUntrackedParameter<std::vector<unsigned int> >(
"FedIdVec")),
132 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>(
"FillAllDetailedHistograms",
false)),
133 fillWithEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithEventNumber",
false)),
134 fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithLocalEventNumber",
false)),
135 printDebug_(iConfig.getUntrackedParameter<unsigned int>(
"PrintDebugMessages",1)),
136 writeDQMStore_(iConfig.getUntrackedParameter<bool>(
"WriteDQMStore",
false)),
137 dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>(
"DQMStoreFileName",
"DQMStore.root")),
143 std::ostringstream debugStream;
145 debugStream <<
"[SiStripCMMonitorPlugin]Configuration for SiStripCMMonitorPlugin: " << std::endl
146 <<
"[SiStripCMMonitorPlugin]\tRawDataTag: " <<
rawDataTag_ << std::endl
147 <<
"[SiStripCMMonitorPlugin]\tHistogramFolderName: " <<
folderName_ << std::endl
149 <<
"[SiStripCMMonitorPlugin]\tFillWithEventNumber?" << (
fillWithEvtNum_ ?
"yes" :
"no") << std::endl
150 <<
"[SiStripCMMonitorPlugin]\tPrintDebugMessages? " << (
printDebug_ ?
"yes" :
"no") << std::endl
151 <<
"[SiStripCMMonitorPlugin]\tWriteDQMStore? " << (
writeDQMStore_ ?
"yes" :
"no") << std::endl;
155 std::ostringstream* pDebugStream = (
printDebug_>1 ? &debugStream :
NULL);
157 cmHists_.initialise(iConfig,pDebugStream);
166 prevMedians_[fedId][iCh] = std::pair<uint16_t,uint16_t>(0,0);
172 LogTrace(
"SiStripMonitorHardware") << debugStream.str();
205 FEDErrors lFedErrors;
214 lFedErrors.initialiseFED(fedId,
cabling_);
218 bool lDataExist = lFedErrors.checkDataPresent(fedData);
223 std::auto_ptr<const sistrip::FEDBuffer> buffer;
225 if (!lFedErrors.fillFatalFEDErrors(fedData,0)) {
231 bool channelLengthsOK = buffer->checkChannelLengthsMatchBufferLength();
232 bool channelPacketCodesOK = buffer->checkChannelPacketCodes();
233 bool feLengthsOK = buffer->checkFEUnitLengths();
234 if ( !channelLengthsOK ||
235 !channelPacketCodesOK ||
241 std::ostringstream infoStream;
245 infoStream <<
" --- Processing FED #" << fedId << std::endl;
249 std::vector<CMHistograms::CMvalues>
values;
251 for (
unsigned int iCh = 0;
264 uint32_t lDetId = lConnection.
detId();
265 unsigned short nChInModule = lConnection.
nApvPairs();
269 bool lFailUnpackerChannelCheck = !buffer->channelGood(iCh) && connected;
271 if (lFailUnpackerChannelCheck) {
300 std::ostringstream lMode;
301 lMode << buffer->readoutMode();
303 static bool lFirst =
true;
305 std::cout <<
"Readout mode: " << lMode.str() << std::endl;
312 std::pair<uint16_t,uint16_t> medians = std::pair<uint16_t,uint16_t>(0,0);
314 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));
316 CMHistograms::CMvalues lVal;
317 lVal.ChannelID = iCh;
318 lVal.Medians = std::pair<uint16_t,uint16_t>(medians.first,medians.second);
329 if (lChannel.
length() > 7) {
330 infoStream <<
"Medians for channel #" << iCh <<
" (length " << lChannel.
length() <<
"): " << medians.first <<
", " << medians.second << std::endl;
334 values.push_back(lVal);
337 fillMaps(lDetId,nChInModule,medians);
339 prevMedians_[fedId][iCh] = std::pair<uint16_t,uint16_t>(medians.first,medians.second);
348 cmHists_.fillHistograms(values,lTime,fedId);
384 std::map<unsigned int,Statistics>::iterator fracIter;
389 uint32_t
detid = fracIter->first;
404 message <<
"TkHistoMap CM: Detid " << detid <<
", mean = " << mean <<
", rms = " << rms <<
", counter = " << lStat.
Counter << std::endl;
412 uint32_t
detid = fracIter->first;
427 message <<
"TkHistoMap APV0minusAPV1: Detid " << detid <<
", mean = " << mean <<
", rms = " << rms <<
", counter = " << lStat.
Counter << std::endl;
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]
edm::InputTag rawDataTag_
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)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
const FedChannelConnection & connection(uint16_t fed_id, uint16_t fed_ch) const
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)
std::string dqmStoreFileName_
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)
const uint32_t & detId() const
Class containning control, module, detector and connection information, at the level of a FED channel...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool fillAllDetailedHistograms_
std::map< unsigned int, Statistics > CommonModes_
const uint16_t & nApvPairs() const
T const * product() 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.
void setCurrentFolder(const std::string &fullpath)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
bool fillWithLocalEvtNum_