62 virtual void endJob()
override;
74 const uint16_t threshold,
141 : spyScopeRawDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"SpyScopeRawDigisTag",edm::InputTag(
"SiStripSpyUnpacker",
"ScopeRawDigis"))),
142 spyPedSubtrDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"SpyPedSubtrDigisTag",edm::InputTag(
"SiStripFEDEmulator",
""))),
143 spyL1Tag_(iConfig.getUntrackedParameter<edm::InputTag>(
"SpyL1Tag",edm::InputTag(
"SiStripSpyDigiConverter",
"L1ACount"))),
144 spyTotCountTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"SpyTotalEventCountTag",edm::InputTag(
"SiStripSpyDigiConverter",
"TotalEventCount"))),
145 spyAPVeTag_(iConfig.getUntrackedParameter<edm::InputTag>(
"SpyAPVeTag",edm::InputTag(
"SiStripSpyDigiConverter",
"APVAddress"))),
147 folderName_(iConfig.getUntrackedParameter<std::
string>(
"HistogramFolderName",
"SiStrip/ReadoutView/SpyMonitoringSummary")),
148 fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>(
"FillAllDetailedHistograms",
false)),
149 fillWithEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithEventNumber",
false)),
150 fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>(
"FillWithLocalEventNumber",
false)),
151 writeDQMStore_(iConfig.getUntrackedParameter<bool>(
"WriteDQMStore",
false)),
152 dqmStoreFileName_(iConfig.getUntrackedParameter<std::
string>(
"DQMStoreFileName",
"DQMStore.root")),
155 outfileNames_(iConfig.getUntrackedParameter<std::vector<std::
string> >(
"OutputErrors")),
156 writeCabling_(iConfig.getUntrackedParameter<bool>(
"WriteCabling",
false))
167 std::ostringstream pDebugStream;
171 for (
unsigned int i(0);
i<nFiles;
i++){
172 std::ostringstream lName;
190 for (
unsigned int i(0);
i<nFiles;
i++){
209 LogInfo(
"SiStripSpyMonitorModule") <<
" Histograms will be written in "
211 <<
". Current folder is : "
237 std::ofstream lOutCabling;
238 lOutCabling.open(
"trackerDetId_FEDIdChNum_list.txt",
std::ios::out);
243 uint32_t lDetId = lConnection.
detId();
244 lOutCabling <<
"FED ID = " << lFedId
245 <<
", Channel = " << lFedChannel
246 <<
",fedkey = " << sistrip::FEDCH_PER_FED*lFedId + lFedChannel
247 <<
", detId = " << lDetId
273 const std::vector<uint32_t> & lSpyAPVeVec = *lSpyAPVeHandle;
330 for (
unsigned int i(0);
i<nFiles;
i++){
347 lFEDErrors.
hasOOS =
false;
355 uint32_t lAPVAddrRef = lSpyAPVeVec.at(lFedId);
359 uint32_t lFedIndex = sistrip::FEDCH_PER_FED*lFedId + lFedChannel;
365 uint32_t lDetId = lConnection.
detId();
375 if (lDigis == lInputDigis->
end()) {
376 LogDebug(
"SiStripSpyMonitorModule") <<
" -- digis not found in ScopeRawDigis map for FEDID "
377 << lFedId <<
" and FED channel " << lFedChannel << std::endl;
408 else if (lFrame.
digitalLow == 0 && lRange > 0) {
483 else if ( lFrame.
apvAddress.first != lAPVAddrRef ||
496 outfile_[
outfileMap_[
"APVAddressError"]] << lFedId <<
" " << lFedChannel <<
" " << lDetId << std::endl;
548 for (
unsigned int i(0);
i<nFiles;
i++){
566 for (; iDigi != endChannelDigis; ++iDigi) {
567 const uint16_t val = iDigi->adc();
569 if (val == 0 && lPair == aPair)
return true;
584 uint16_t nTrailers = 0;
587 for ( ; count == 0; count--){
590 if (iDigi != channelDigis.
end() &&
600 if (nTrailers > 1)
LogDebug(
"SiStripSpyMonitorModule") <<
" -- Found "
601 << nTrailers <<
" trailers every 70 clock cycles for channel "
602 << channelDigis.
detId()
606 return (nTrailers > 1) || (nTrailers == 1 && lastPos < 280);
618 bool foundTrailer =
false;
620 uint8_t aboveThreshold = 0;
622 for (; lStart != endChannelDigis; ++lStart) {
629 if (aboveThreshold == 2) {foundTrailer =
true;
break; }
633 if (foundTrailer)
return lStart;
636 return endChannelDigis;
unsigned int nAPVAddressError
virtual char const * what() const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
static const uint16_t FED_ID_MIN
iterator find(det_id_type id)
bool fillAllDetailedHistograms_
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator findTwoConsecutive(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
det_id_type detId() const
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
uint16_t apvPairNumber() const
SiStripSpyMonitorModule(const edm::ParameterSet &)
bool identifyTickmarks(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
static const uint16_t SPY_SAMPLES_PER_CHANNEL
std::pair< uint8_t, uint8_t > apvAddress
void initialise(const edm::ParameterSet &iConfig, std::ostringstream *pDebugStream)
bool hasNegativePedSubtr(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, uint16_t aPair)
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
void fillCountersHistograms(const ErrorCounters &aCounter, const double aTime)
SPYHistograms histManager_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
static const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
const uint32_t & detId() const
std::map< std::string, unsigned int > outfileMap_
Class containning control, module, detector and connection information, at the level of a FED channel...
void bookAllFEDHistograms()
virtual void endJob() override
std::string dqmStoreFileName_
sistrip::SpyUtilities::FrameQuality frameQuality_
static const uint16_t range(const Frame &aFrame)
std::vector< std::string > outfileNames_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
virtual void beginJob() override
iterator end()
Return the off-the-end iterator.
static const uint16_t threshold(const Frame &aFrame)
edm::InputTag spyTotCountTag_
edm::InputTag spyAPVeTag_
static const uint16_t STRIPS_PER_FEDCH
edm::InputTag spyPedSubtrDigisTag_
Constants and enumerated types for FED/FEC systems.
const SiStripFedCabling * getCabling(const edm::EventSetup &)
Updates the cabling object from the DB.
void fillFEDHistograms(const Errors &aErr, const unsigned int aFedId)
std::pair< bool, bool > apvErrorBit
T const * product() const
void bookTopLevelHistograms(DQMStore *dqm)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::ofstream outfile_[20]
bool fillWithLocalEvtNum_
static const uint16_t FEDCH_PER_FED
void fillDetailedHistograms(const Errors &aErr, const sistrip::SpyUtilities::Frame &aFrame, const unsigned int aFedId, const unsigned int aFedChannel)
static void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
~SiStripSpyMonitorModule()
edm::InputTag spyScopeRawDigisTag_
static const uint16_t FED_ID_MAX
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
volatile std::atomic< bool > shutdown_flag false
collection_type::const_iterator const_iterator
collection_type::const_iterator const_iterator
sistrip::SpyUtilities utility_
uint16_t firstTrailerBit_
void setCurrentFolder(const std::string &fullpath)
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
const std::string & pwd(void) const