CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripSpyMonitorModule Class Reference
Inheritance diagram for SiStripSpyMonitorModule:
DQMEDAnalyzer edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiStripSpyMonitorModule (const edm::ParameterSet &)
 
 ~SiStripSpyMonitorModule () override
 
- Public Member Functions inherited from DQMEDAnalyzer
void beginRun (edm::Run const &, edm::EventSetup const &) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
void dqmBeginRun (const edm::Run &, const edm::EventSetup &) override
 
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator findTwoConsecutive (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
 
bool hasNegativePedSubtr (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, uint16_t aPair)
 
bool identifyTickmarks (const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
 

Private Attributes

edm::EventNumber_t evt_
 
bool fillAllDetailedHistograms_
 
bool fillWithEvtNum_
 
bool fillWithLocalEvtNum_
 
uint16_t firstHeaderBit_
 
uint16_t firstTrailerBit_
 
std::string folderName_
 
sistrip::SpyUtilities::FrameQuality frameQuality_
 
SPYHistograms histManager_
 
uint32_t maxDigiRange_
 
uint32_t maxDigitalHigh_
 
uint32_t maxDigitalLow_
 
uint32_t minDigiRange_
 
uint32_t minDigitalHigh_
 
uint32_t minDigitalLow_
 
std::ofstream outfile_ [20]
 
std::map< std::string, unsigned int > outfileMap_
 
std::vector< std::string > outfileNames_
 
edm::InputTag spyAPVeTag_
 
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
 
edm::InputTag spyL1Tag_
 
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
 
edm::InputTag spyPedSubtrDigisTag_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
 
edm::InputTag spyScopeRawDigisTag_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
 
edm::InputTag spyTotCountTag_
 
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
 
sistrip::SpyUtilities utility_
 
bool writeCabling_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr< dqmDetails::NoCacheglobalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr< dqmDetails::NoCacheglobalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 51 of file SiStripSpyMonitorModule.cc.

Constructor & Destructor Documentation

SiStripSpyMonitorModule::SiStripSpyMonitorModule ( const edm::ParameterSet iConfig)
explicit

Definition at line 137 of file SiStripSpyMonitorModule.cc.

References evt_, frameQuality_, edm::ParameterSet::getUntrackedParameter(), histManager_, mps_fire::i, SPYHistograms::initialise(), simpleEdmComparison::lName, sistrip::SpyUtilities::FrameQuality::maxDigiRange, sistrip::SpyUtilities::FrameQuality::maxTickHeight, sistrip::SpyUtilities::FrameQuality::maxZeroLight, sistrip::SpyUtilities::FrameQuality::minDigiRange, sistrip::SpyUtilities::FrameQuality::minTickHeight, sistrip::SpyUtilities::FrameQuality::minZeroLight, cmsBatch::nFiles, MillePedeFileConverter_cfg::out, outfile_, outfileMap_, outfileNames_, spyAPVeTag_, spyAPVeToken_, spyL1Tag_, spyL1Token_, spyPedSubtrDigisTag_, spyPedSubtrDigisToken_, spyScopeRawDigisTag_, spyScopeRawDigisToken_, spyTotCountTag_, and spyTotCountToken_.

138  : spyScopeRawDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyScopeRawDigisTag",edm::InputTag("SiStripSpyUnpacker","ScopeRawDigis"))),
139  spyPedSubtrDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyPedSubtrDigisTag",edm::InputTag("SiStripFEDEmulator",""))),
140  spyL1Tag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyL1Tag",edm::InputTag("SiStripSpyDigiConverter","L1ACount"))),
141  spyTotCountTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyTotalEventCountTag",edm::InputTag("SiStripSpyDigiConverter","TotalEventCount"))),
142  spyAPVeTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyAPVeTag",edm::InputTag("SiStripSpyDigiConverter","APVAddress"))),
143  folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/SpyMonitoringSummary")),
144  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)),
145  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)),
146  fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithLocalEventNumber",false)),
147  firstHeaderBit_(0),
148  firstTrailerBit_(0),
149  outfileNames_(iConfig.getUntrackedParameter<std::vector<std::string> >("OutputErrors")),
150  writeCabling_(iConfig.getUntrackedParameter<bool>("WriteCabling",false))
151 {
152 
153  spyScopeRawDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyScopeRawDigisTag_);
154  spyPedSubtrDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyPedSubtrDigisTag_);
155 
156  spyL1Token_ = consumes<std::vector<uint32_t> >(spyL1Tag_);
157  spyTotCountToken_ = consumes<std::vector<uint32_t> >(spyTotCountTag_);
158  spyAPVeToken_ = consumes<std::vector<uint32_t> >(spyAPVeTag_);
159 
160  evt_ = 0;
161  std::ostringstream pDebugStream;
162  histManager_.initialise(iConfig,&pDebugStream);
163  const unsigned int nFiles = outfileNames_.size();
164 
165  for (unsigned int i(0); i<nFiles; i++){
166  std::ostringstream lName;
167  lName << outfileNames_.at(i) << ".out";
168  if (i<20) outfile_[i].open(lName.str().c_str(),std::ios::out);
169  outfileMap_[outfileNames_.at(i)] = i;
170  }
171 
172  frameQuality_.minDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinDigiRange",100));
173  frameQuality_.maxDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxDigiRange",1024));
174  frameQuality_.minZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinZeroLight",0));
175  frameQuality_.maxZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxZeroLight",1024));
176  frameQuality_.minTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinTickHeight",0));
177  frameQuality_.maxTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxTickHeight",1024));
178 
179 }
T getUntrackedParameter(std::string const &, T const &) const
void initialise(const edm::ParameterSet &iConfig, std::ostringstream *pDebugStream) override
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
std::map< std::string, unsigned int > outfileMap_
sistrip::SpyUtilities::FrameQuality frameQuality_
std::vector< std::string > outfileNames_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
SiStripSpyMonitorModule::~SiStripSpyMonitorModule ( )
override

Definition at line 181 of file SiStripSpyMonitorModule.cc.

References mps_fire::i, cmsBatch::nFiles, outfile_, outfileMap_, and outfileNames_.

182 {
183  const unsigned int nFiles = outfileNames_.size();
184  for (unsigned int i(0); i<nFiles; i++){
185  outfile_[i].close();
186  }
187 
188  outfileMap_.clear();
189  outfileNames_.clear();
190 
191 }
std::map< std::string, unsigned int > outfileMap_
std::vector< std::string > outfileNames_

Member Function Documentation

void SiStripSpyMonitorModule::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 223 of file SiStripSpyMonitorModule.cc.

References sistrip::SpyUtilities::Frame::apvAddress, sistrip::SpyUtilities::Frame::apvErrorBit, FedChannelConnection::apvPairNumber(), FedChannelConnection::detId(), sistrip::SpyUtilities::Frame::digitalHigh, sistrip::SpyUtilities::Frame::digitalLow, MillePedeFileConverter_cfg::e, edm::DetSetVector< T >::end(), edm::EventID::event(), evt_, sistrip::SpyUtilities::extractFrameInfo(), sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, sistrip::FEDCH_PER_FED, SiStripFedCabling::fedConnection(), SPYHistograms::fillCountersHistograms(), SPYHistograms::fillDetailedHistograms(), SPYHistograms::fillFEDHistograms(), fillWithLocalEvtNum_, edm::DetSetVector< T >::find(), sistrip::SpyUtilities::Frame::firstHeaderBit, firstHeaderBit_, sistrip::SpyUtilities::Frame::firstTrailerBit, firstTrailerBit_, frameQuality_, edm::Event::getByToken(), sistrip::SpyUtilities::getCabling(), sistrip::SpyUtilities::getMajorityHeader(), SPYHistograms::Errors::hasAPVAddressError0, SPYHistograms::Errors::hasAPVAddressError1, SPYHistograms::Errors::hasErrorBit0, SPYHistograms::Errors::hasErrorBit1, SPYHistograms::Errors::hasHighPb, SPYHistograms::Errors::hasHighRange, SPYHistograms::Errors::hasLowPb, SPYHistograms::Errors::hasLowRange, SPYHistograms::Errors::hasMaxSat, SPYHistograms::Errors::hasMinZero, hasNegativePedSubtr(), SPYHistograms::Errors::hasNegPeds, SPYHistograms::Errors::hasNoData, SPYHistograms::Errors::hasOOS, SPYHistograms::Errors::hasOtherPbs, histManager_, mps_fire::i, edm::EventBase::id(), identifyTickmarks(), FedChannelConnection::isConnected(), LogDebug, sistrip::SpyUtilities::FrameQuality::maxDigiRange, sistrip::SpyUtilities::FrameQuality::maxTickHeight, sistrip::SpyUtilities::FrameQuality::maxZeroLight, sistrip::SpyUtilities::FrameQuality::minDigiRange, sistrip::SpyUtilities::FrameQuality::minTickHeight, sistrip::SpyUtilities::FrameQuality::minZeroLight, SPYHistograms::ErrorCounters::nAPVAddressError, SPYHistograms::ErrorCounters::nAPVError, cmsBatch::nFiles, SPYHistograms::ErrorCounters::nHighPb, SPYHistograms::ErrorCounters::nHighRange, SPYHistograms::ErrorCounters::nLowPb, SPYHistograms::ErrorCounters::nLowRange, SPYHistograms::ErrorCounters::nMaxSat, SPYHistograms::ErrorCounters::nMinZero, SPYHistograms::ErrorCounters::nNegPeds, SPYHistograms::ErrorCounters::nNoData, SPYHistograms::ErrorCounters::nOOS, SPYHistograms::ErrorCounters::nOtherPbs, MillePedeFileConverter_cfg::out, outfile_, outfileMap_, outfileNames_, edm::Handle< T >::product(), sistrip::SpyUtilities::range(), sistrip::SPY_SAMPLES_PER_CHANNEL, spyAPVeToken_, spyL1Token_, spyPedSubtrDigisToken_, spyScopeRawDigisToken_, spyTotCountToken_, sistrip::STRIPS_PER_FEDCH, sistrip::SpyUtilities::threshold(), utility_, cms::Exception::what(), and writeCabling_.

225 {
226 
227  //update cabling and pedestals
228  const SiStripFedCabling* lCabling = utility_.getCabling( iSetup );
229  if (evt_ == 0 && writeCabling_){
230  std::ofstream lOutCabling;
231  lOutCabling.open("trackerDetId_FEDIdChNum_list.txt",std::ios::out);
232  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) {//loop on feds
233  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++){//loop on channels
234  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
235  if (!lConnection.isConnected()) continue;
236  uint32_t lDetId = lConnection.detId();
237  lOutCabling << "FED ID = " << lFedId
238  << ", Channel = " << lFedChannel
239  << ",fedkey = " << sistrip::FEDCH_PER_FED*lFedId + lFedChannel
240  << ", detId = " << lDetId
241  << std::endl;
242  }
243  }
244  lOutCabling.close();
245  }
246 
247  //For spy data
248  //get map of TotalEventCount and L1ID, indexed by fedId, and APVaddress indexed by fedIndex.
249  edm::Handle<std::vector<uint32_t> > lSpyL1IDHandle,lSpyTotCountHandle,lSpyAPVeHandle;
250  try {
251  iEvent.getByToken(spyL1Token_,lSpyL1IDHandle);
252  iEvent.getByToken(spyTotCountToken_,lSpyTotCountHandle);
253  iEvent.getByToken(spyAPVeToken_,lSpyAPVeHandle);
254  }
255  catch (const cms::Exception& e) {
256  LogError("SiStripSpyMonitorModule") << e.what() ;
257  return;
258  }
259  //const std::map<uint32_t,uint32_t> & lSpyMaxCountMap = *lSpyL1IDHandle;
260  //const std::map<uint32_t,uint32_t> & lSpyMinCountMap = *lSpyTotCountHandle;
261  const std::vector<uint32_t> & lSpyAPVeVec = *lSpyAPVeHandle;
262 
263  //retrieve the scope digis
265  try {
266  iEvent.getByToken(spyScopeRawDigisToken_, digisHandle);
267  }
268  catch (const cms::Exception& e) {
269  LogError("SiStripSpyMonitorModule") << e.what() ;
270  return;
271  }
272  const edm::DetSetVector<SiStripRawDigi> * lInputDigis = digisHandle.product();
273 
274  //retrieve the reordered payload digis
276  try {
277  iEvent.getByToken(spyPedSubtrDigisToken_, payloadHandle);
278  }
279  catch (const cms::Exception& e) {
280  LogError("SiStripSpyMonitorModule") << e.what() ;
281  return;
282  }
283  const edm::DetSetVector<SiStripRawDigi> * lPayloadDigis = payloadHandle.product();
284 
285 
286  //for first event only
287  //loop first on channels to calculate majority value of when the first header bit is found.
288  //output info message to give the value found
289  //should currently be 6 but may vary in the futur
290  //then we can check firstTrailerBit is +256+24 after
291 
292  if (evt_ == 0){
295  }
296 
297  //initialise some counters, filled in histos eventually
299  lCounters.nNoData = 0;
300  lCounters.nLowRange = 0;
301  lCounters.nHighRange = 0;
302  lCounters.nMinZero = 0;
303  lCounters.nMaxSat = 0;
304  lCounters.nLowPb = 0;
305  lCounters.nHighPb = 0;
306  lCounters.nOOS = 0;
307  lCounters.nOtherPbs = 0;
308  lCounters.nAPVError = 0;
309  lCounters.nAPVAddressError = 0;
310  lCounters.nNegPeds = 0;
311 
312 
313 
314  //fill event number for output text files
315  const unsigned int nFiles = outfileNames_.size();
316  for (unsigned int i(0); i<nFiles; i++){
317  outfile_[i] << "**** evt "<< iEvent.id().event() << " ****" << std::endl ;
318  }
319 
320 
321  //loop over all FEDs and channels
322 
323  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) {//loop on feds
324 
325  SPYHistograms::Errors lFEDErrors;
326  lFEDErrors.hasNoData = false;
327  lFEDErrors.hasLowRange = false;
328  lFEDErrors.hasHighRange = false;
329  lFEDErrors.hasMinZero = false;
330  lFEDErrors.hasMaxSat = false;
331  lFEDErrors.hasLowPb = false;
332  lFEDErrors.hasHighPb = false;
333  lFEDErrors.hasOOS = false;
334  lFEDErrors.hasOtherPbs = false;
335  lFEDErrors.hasErrorBit0 = false;
336  lFEDErrors.hasErrorBit1 = false;
337  lFEDErrors.hasAPVAddressError0 = false;
338  lFEDErrors.hasAPVAddressError1 = false;
339  lFEDErrors.hasNegPeds = false;
340 
341  uint32_t lAPVAddrRef = lSpyAPVeVec.at(lFedId);
342 
343  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++){//loop on channels
344 
345  uint32_t lFedIndex = sistrip::FEDCH_PER_FED*lFedId + lFedChannel;
346 
347  const FedChannelConnection & lConnection = lCabling->fedConnection(lFedId,lFedChannel);
348 
349  if (!lConnection.isConnected()) continue;
350 
351  uint32_t lDetId = lConnection.detId();
352  //uint16_t lNPairs = lConnection.nApvPairs();
353  uint16_t lPair = lConnection.apvPairNumber();
354 
355  edm::DetSetVector<SiStripRawDigi>::const_iterator lDigis = lInputDigis->find(lFedIndex);
356 
357  //pedsubtr digis
358  edm::DetSetVector<SiStripRawDigi>::const_iterator lPayload = lPayloadDigis->find(lDetId);
359 
360  //no digis found, continue.
361  if (lDigis == lInputDigis->end()) {
362  LogDebug("SiStripSpyMonitorModule") << " -- digis not found in ScopeRawDigis map for FEDID "
363  << lFedId << " and FED channel " << lFedChannel << std::endl;
364  continue;
365  }
366 
368 
369  SPYHistograms::Errors lErrors;
370  lErrors.hasNoData = false;
371  lErrors.hasLowRange = false;
372  lErrors.hasHighRange = false;
373  lErrors.hasMinZero = false;
374  lErrors.hasMaxSat = false;
375  lErrors.hasLowPb = false;
376  lErrors.hasHighPb = false;
377  lErrors.hasOOS = false;
378  lErrors.hasOtherPbs = false;
379  lErrors.hasErrorBit0 = false;
380  lErrors.hasErrorBit1 = false;
381  lErrors.hasAPVAddressError0 = false;
382  lErrors.hasAPVAddressError1 = false;
383  lErrors.hasNegPeds = false;
384 
385  uint16_t lRange = sistrip::SpyUtilities::range(lFrame);
386  uint16_t lThreshold = sistrip::SpyUtilities::threshold(lFrame);
387 
388  if (lRange == 0) {
389  lCounters.nNoData++;
390  lErrors.hasNoData = true;
391  lFEDErrors.hasNoData = true;
392  if (outfileMap_.find("NoData") != outfileMap_.end()) outfile_[outfileMap_["NoData"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
393  }
394  else if (lFrame.digitalLow == 0 && lRange > 0) {
395  lCounters.nMinZero++;
396  lErrors.hasMinZero = true;
397  lFEDErrors.hasMinZero = true;
398  if (outfileMap_.find("MinZero") != outfileMap_.end()) outfile_[outfileMap_["MinZero"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
399  }
400  else if (lFrame.digitalHigh >= 1023){
401  lCounters.nMaxSat++;
402  lErrors.hasMaxSat = true;
403  lFEDErrors.hasMaxSat = true;
404  if (outfileMap_.find("MaxSat") != outfileMap_.end()) outfile_[outfileMap_["MaxSat"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
405  }
406  else if (lRange > 0 && lRange < frameQuality_.minDigiRange) {
407  lCounters.nLowRange++;
408  lErrors.hasLowRange = true;
409  lFEDErrors.hasLowRange = true;
410  if (outfileMap_.find("LowRange") != outfileMap_.end()) outfile_[outfileMap_["LowRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
411  }
412  else if (lRange > frameQuality_.maxDigiRange) {
413  lCounters.nHighRange++;
414  lErrors.hasHighRange = true;
415  lFEDErrors.hasHighRange = true;
416  if (outfileMap_.find("HighRange") != outfileMap_.end()) outfile_[outfileMap_["HighRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
417  }
419  lCounters.nLowPb++;
420  lErrors.hasLowPb = true;
421  lFEDErrors.hasLowPb = true;
422  if (outfileMap_.find("LowPb") != outfileMap_.end()) outfile_[outfileMap_["LowPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
423  }
425  lCounters.nHighPb++;
426  lErrors.hasHighPb = true;
427  lFEDErrors.hasHighPb = true;
428  if (outfileMap_.find("HighPb") != outfileMap_.end()) outfile_[outfileMap_["HighPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
429  }
430  else if ( lFrame.firstHeaderBit != firstHeaderBit_ && //header in wrong position
431  ( (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //header and
432  lFrame.firstTrailerBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //trailer found
433  lFrame.firstTrailerBit-lFrame.firstHeaderBit == 280) || //+ right distance between them
434  (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && // or header found
435  lFrame.firstTrailerBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // and trailer not found
436  lFrame.firstHeaderBit > 16 ) || // corresponding to back-to-back frame late enough
437  (lFrame.firstHeaderBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // or header not found
438  identifyTickmarks(*lDigis,lThreshold) ) // but such that tickmark compatible with OOS frame
439  )
440  ){
441  lCounters.nOOS++;
442  lErrors.hasOOS = true;
443  lFEDErrors.hasOOS = true;
444  if (outfileMap_.find("OOS") != outfileMap_.end()) outfile_[outfileMap_["OOS"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
445  }
446  else if ( !(lFrame.firstHeaderBit == firstHeaderBit_ && lFrame.firstTrailerBit == firstTrailerBit_) ){
447  lCounters.nOtherPbs++;
448  lErrors.hasOtherPbs = true;
449  lFEDErrors.hasOtherPbs = true;
450  if (outfileMap_.find("OtherPbs") != outfileMap_.end()) outfile_[outfileMap_["OtherPbs"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
451  }
452  else if (lFrame.apvErrorBit.first || lFrame.apvErrorBit.second) {
453  if (lFrame.apvErrorBit.first) {
454  lCounters.nAPVError++;
455  lErrors.hasErrorBit0 = true;
456  lFEDErrors.hasErrorBit0 = true;
457  }
458  if (lFrame.apvErrorBit.second) {
459  lCounters.nAPVError++;
460  lErrors.hasErrorBit1 = true;
461  lFEDErrors.hasErrorBit1 = true;
462  }
463  if (outfileMap_.find("APVError") != outfileMap_.end()) {
464  outfile_[outfileMap_["APVError"]] << lFedId << " " << lFedChannel << " " << lDetId ;
465  if (lFrame.apvErrorBit.first) outfile_[outfileMap_["APVError"]] << " APV0" << std::endl;
466  if (lFrame.apvErrorBit.second) outfile_[outfileMap_["APVError"]] << " APV1" << std::endl;
467  }
468  }
469  else if ( lFrame.apvAddress.first != lAPVAddrRef ||
470  lFrame.apvAddress.second != lAPVAddrRef ) {
471  if (lFrame.apvAddress.first != lAPVAddrRef){
472  lCounters.nAPVAddressError++;
473  lErrors.hasAPVAddressError0 = true;
474  lFEDErrors.hasAPVAddressError0 = true;
475  }
476  if (lFrame.apvAddress.second != lAPVAddrRef){
477  lCounters.nAPVAddressError++;
478  lErrors.hasAPVAddressError1 = true;
479  lFEDErrors.hasAPVAddressError1 = true;
480  }
481  if (outfileMap_.find("APVAddressError") != outfileMap_.end()){
482  outfile_[outfileMap_["APVAddressError"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
483  if (lFrame.apvAddress.first != lAPVAddrRef) outfile_[outfileMap_["APVAddressError"]] << " APV0" << std::endl;
484  if (lFrame.apvAddress.second != lAPVAddrRef) outfile_[outfileMap_["APVAddressError"]] << " APV1" << std::endl;
485  }
486  }
487  else if (lPayload != lPayloadDigis->end() && hasNegativePedSubtr(*lPayload,lPair)){
488  lCounters.nNegPeds++;
489  lErrors.hasNegPeds = true;
490  lFEDErrors.hasNegPeds = true;
491  if (outfileMap_.find("NegPeds") != outfileMap_.end()) outfile_[outfileMap_["NegPeds"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
492  }
493 
494  histManager_.fillDetailedHistograms(lErrors,lFrame,lFedId,lFedChannel);
495 
496  }//loop on channels
497 
498 
499  histManager_.fillFEDHistograms(lFEDErrors,lFedId);
500 
501  }//loop on feds
502 
503  double lTime;
504  //if (fillWithEvtNum_)
505  //lTime = iEvent.id().event();
506  //else if (fillWithLocalEvtNum_) lTime = evt_;
507  //no orbit number for spy data !!
508  //else lTime = iEvent.orbitNumber()/11223.;
509  if (fillWithLocalEvtNum_) {
510  // casting from unsigned long long to a double here
511  // doing it explicitely
512  lTime = static_cast<double>(evt_);
513  } else {
514  // casting from unsigned long long to a double here
515  // doing it explicitely
516  lTime = static_cast<double>(iEvent.id().event());
517  }
518 
519  histManager_.fillCountersHistograms(lCounters,lTime);
520 
521 
522  //used to fill histo vs time with local event number....
523  evt_++;
524 
525 }//analyze method
#define LogDebug(id)
EventNumber_t event() const
Definition: EventID.h:41
static const uint16_t FED_ID_MIN
iterator find(det_id_type id)
Definition: DetSetVector.h:290
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
uint16_t apvPairNumber() const
bool identifyTickmarks(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
static const uint16_t SPY_SAMPLES_PER_CHANNEL
char const * what() const override
Definition: Exception.cc:141
std::pair< uint8_t, uint8_t > apvAddress
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)
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...
sistrip::SpyUtilities::FrameQuality frameQuality_
static const uint16_t range(const Frame &aFrame)
std::vector< std::string > outfileNames_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
static const uint16_t threshold(const Frame &aFrame)
static const uint16_t STRIPS_PER_FEDCH
T const * product() const
Definition: Handle.h:81
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
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
edm::EventID id() const
Definition: EventBase.h:60
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)
static const uint16_t FED_ID_MAX
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:104
sistrip::SpyUtilities utility_
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
void SiStripSpyMonitorModule::bookHistograms ( DQMStore::IBooker ,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprivatevirtual

Implements DQMEDAnalyzer.

Definition at line 200 of file SiStripSpyMonitorModule.cc.

References SPYHistograms::bookAllFEDHistograms(), SPYHistograms::bookFEDHistograms(), SPYHistograms::bookTopLevelHistograms(), sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, fillAllDetailedHistograms_, folderName_, histManager_, DQMStore::IBooker::pwd(), and DQMStore::IBooker::setCurrentFolder().

201 {
202  ibooker.setCurrentFolder(folderName_);
203 
204  LogInfo("SiStripSpyMonitorModule") << " Histograms will be written in "
205  << folderName_
206  << ". Current folder is : "
207  << ibooker.pwd()
208  << std::endl;
209 
210  //this propagates dqm_ to the histoclass, must be called !
212 
214 
215  //dummy error object
216  SPYHistograms::Errors lError;
217  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId)
218  histManager_.bookFEDHistograms(ibooker , lFedId , lError , true);
219 }
static const uint16_t FED_ID_MIN
void bookTopLevelHistograms(DQMStore::IBooker &)
void bookAllFEDHistograms(DQMStore::IBooker &)
void bookFEDHistograms(DQMStore::IBooker &, const unsigned int fedId, const Errors &aErr, bool doAll=false)
static const uint16_t FED_ID_MAX
void SiStripSpyMonitorModule::dqmBeginRun ( const edm::Run r,
const edm::EventSetup c 
)
overrideprivate

Definition at line 193 of file SiStripSpyMonitorModule.cc.

References evt_, firstHeaderBit_, and firstTrailerBit_.

194 {
195  evt_ = 0;
196  firstHeaderBit_ = 0;
197  firstTrailerBit_ = 0;
198 }
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator SiStripSpyMonitorModule::findTwoConsecutive ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold,
uint16_t &  aCounter 
)
private

Definition at line 579 of file SiStripSpyMonitorModule.cc.

References edm::DetSet< T >::begin(), DEFINE_FWK_MODULE, edm::DetSet< T >::end(), sistrip::SPY_SAMPLES_PER_CHANNEL, and electronIdCutBased_cfi::threshold.

Referenced by identifyTickmarks().

582 {
583  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
584  edm::DetSetVector<SiStripRawDigi>::detset::const_iterator lStart = channelDigis.begin()+aCounter;
585 
586  bool foundTrailer = false;
587  // Loop over digis looking for last two above threshold
588  uint8_t aboveThreshold = 0;
589 
590  for (; lStart != endChannelDigis; ++lStart) {
591  if ( lStart->adc() > threshold) {
592  aboveThreshold++;
593  }
594  else {
595  aboveThreshold = 0;
596  }
597  if (aboveThreshold == 2) {foundTrailer = true; break; }
598  aCounter++;
599  }//end of loop over digis
600 
601  if (foundTrailer) return lStart;
602  else {
604  return endChannelDigis;
605  }
606 }
iterator end()
Definition: DetSet.h:60
static const uint16_t SPY_SAMPLES_PER_CHANNEL
iterator begin()
Definition: DetSet.h:59
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
bool SiStripSpyMonitorModule::hasNegativePedSubtr ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
uint16_t  aPair 
)
private

Definition at line 527 of file SiStripSpyMonitorModule.cc.

References edm::DetSet< T >::begin(), KineDebug3::count(), edm::DetSet< T >::end(), sistrip::STRIPS_PER_FEDCH, and heppy_batch::val.

Referenced by analyze().

529 {
531  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
532 
533  uint32_t count = 0;
534  for (; iDigi != endChannelDigis; ++iDigi) {
535  const uint16_t val = iDigi->adc();
536  uint16_t lPair = static_cast<uint16_t>(count/sistrip::STRIPS_PER_FEDCH);
537  if (val == 0 && lPair == aPair) return true;
538  count++;
539  }
540 
541  return false;
542 
543 }
iterator end()
Definition: DetSet.h:60
iterator begin()
Definition: DetSet.h:59
static const uint16_t STRIPS_PER_FEDCH
collection_type::const_iterator const_iterator
Definition: DetSet.h:33
bool SiStripSpyMonitorModule::identifyTickmarks ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold 
)
private

Definition at line 545 of file SiStripSpyMonitorModule.cc.

References KineDebug3::count(), edm::DetSet< T >::detId(), edm::DetSet< T >::end(), evt_, findTwoConsecutive(), LogDebug, and sistrip::SPY_SAMPLES_PER_CHANNEL.

Referenced by analyze().

547 {
548 
549  //start from the end
551  uint16_t lastPos = sistrip::SPY_SAMPLES_PER_CHANNEL;
552  uint16_t nTrailers = 0;
554 
555  for ( ; count == 0; count--){
556  iDigi = findTwoConsecutive(channelDigis,threshold,count);
557  //if found, in different position = 70 before than previous value, go and look 70 before
558  if (iDigi != channelDigis.end() &&
559  (lastPos == sistrip::SPY_SAMPLES_PER_CHANNEL || count == lastPos+1-70)) {
560  nTrailers++;
561  lastPos = count-1;
562  count -= 70;
563  }
564  //else keep looking
565  else count--;
566  }
567 
568  if (nTrailers > 1) LogDebug("SiStripSpyMonitorModule") << " -- Found "
569  << nTrailers << " trailers every 70 clock cycles for channel "
570  << channelDigis.detId()
571  << ", evt " << evt_
572  << std::endl;
573  //if only one found, should be < 280 otherwise header should have been found and this method would not be called
574  return (nTrailers > 1) || (nTrailers == 1 && lastPos < 280);
575 
576 }
#define LogDebug(id)
iterator end()
Definition: DetSet.h:60
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator findTwoConsecutive(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
det_id_type detId() const
Definition: DetSet.h:72
static const uint16_t SPY_SAMPLES_PER_CHANNEL
collection_type::const_iterator const_iterator
Definition: DetSet.h:33

Member Data Documentation

edm::EventNumber_t SiStripSpyMonitorModule::evt_
private
bool SiStripSpyMonitorModule::fillAllDetailedHistograms_
private

Definition at line 108 of file SiStripSpyMonitorModule.cc.

Referenced by bookHistograms().

bool SiStripSpyMonitorModule::fillWithEvtNum_
private

Definition at line 110 of file SiStripSpyMonitorModule.cc.

bool SiStripSpyMonitorModule::fillWithLocalEvtNum_
private

Definition at line 111 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

uint16_t SiStripSpyMonitorModule::firstHeaderBit_
private

Definition at line 114 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and dqmBeginRun().

uint16_t SiStripSpyMonitorModule::firstTrailerBit_
private

Definition at line 115 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and dqmBeginRun().

std::string SiStripSpyMonitorModule::folderName_
private

Definition at line 106 of file SiStripSpyMonitorModule.cc.

Referenced by bookHistograms().

sistrip::SpyUtilities::FrameQuality SiStripSpyMonitorModule::frameQuality_
private

Definition at line 118 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

SPYHistograms SiStripSpyMonitorModule::histManager_
private

Definition at line 113 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), bookHistograms(), and SiStripSpyMonitorModule().

uint32_t SiStripSpyMonitorModule::maxDigiRange_
private

Definition at line 97 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::maxDigitalHigh_
private

Definition at line 101 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::maxDigitalLow_
private

Definition at line 99 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigiRange_
private

Definition at line 96 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigitalHigh_
private

Definition at line 100 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigitalLow_
private

Definition at line 98 of file SiStripSpyMonitorModule.cc.

std::ofstream SiStripSpyMonitorModule::outfile_[20]
private
std::map<std::string,unsigned int> SiStripSpyMonitorModule::outfileMap_
private
std::vector<std::string> SiStripSpyMonitorModule::outfileNames_
private
edm::InputTag SiStripSpyMonitorModule::spyAPVeTag_
private

Definition at line 89 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<std::vector<uint32_t> > SiStripSpyMonitorModule::spyAPVeToken_
private

Definition at line 93 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyL1Tag_
private

Definition at line 87 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<std::vector<uint32_t> > SiStripSpyMonitorModule::spyL1Token_
private

Definition at line 91 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyPedSubtrDigisTag_
private

Definition at line 80 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripSpyMonitorModule::spyPedSubtrDigisToken_
private

Definition at line 83 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyScopeRawDigisTag_
private

Definition at line 79 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripSpyMonitorModule::spyScopeRawDigisToken_
private

Definition at line 82 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

edm::InputTag SiStripSpyMonitorModule::spyTotCountTag_
private

Definition at line 88 of file SiStripSpyMonitorModule.cc.

Referenced by SiStripSpyMonitorModule().

edm::EDGetTokenT<std::vector<uint32_t> > SiStripSpyMonitorModule::spyTotCountToken_
private

Definition at line 92 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

sistrip::SpyUtilities SiStripSpyMonitorModule::utility_
private

Definition at line 117 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

bool SiStripSpyMonitorModule::writeCabling_
private

Definition at line 124 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().