CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripSpyMonitorModule Class Reference
Inheritance diagram for SiStripSpyMonitorModule:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 SiStripSpyMonitorModule (const edm::ParameterSet &)
 
 ~SiStripSpyMonitorModule ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
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

DQMStoredqm_
 
std::string dqmStoreFileName_
 
unsigned int 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::InputTag spyL1Tag_
 
edm::InputTag spyPedSubtrDigisTag_
 
edm::InputTag spyScopeRawDigisTag_
 
edm::InputTag spyTotCountTag_
 
sistrip::SpyUtilities utility_
 
bool writeCabling_
 
bool writeDQMStore_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 50 of file SiStripSpyMonitorModule.cc.

Constructor & Destructor Documentation

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

Definition at line 131 of file SiStripSpyMonitorModule.cc.

References evt_, frameQuality_, edm::ParameterSet::getUntrackedParameter(), histManager_, i, SPYHistograms::initialise(), sistrip::SpyUtilities::FrameQuality::maxDigiRange, sistrip::SpyUtilities::FrameQuality::maxTickHeight, sistrip::SpyUtilities::FrameQuality::maxZeroLight, sistrip::SpyUtilities::FrameQuality::minDigiRange, sistrip::SpyUtilities::FrameQuality::minTickHeight, sistrip::SpyUtilities::FrameQuality::minZeroLight, dbtoconf::out, outfile_, outfileMap_, and outfileNames_.

132  : spyScopeRawDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyScopeRawDigisTag",edm::InputTag("SiStripSpyUnpacker","ScopeRawDigis"))),
133  spyPedSubtrDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyPedSubtrDigisTag",edm::InputTag("SiStripFEDEmulator",""))),
134  spyL1Tag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyL1Tag",edm::InputTag("SiStripSpyDigiConverter","L1ACount"))),
135  spyTotCountTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyTotalEventCountTag",edm::InputTag("SiStripSpyDigiConverter","TotalEventCount"))),
136  spyAPVeTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyAPVeTag",edm::InputTag("SiStripSpyDigiConverter","APVAddress"))),
137  dqm_(0),
138  folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName","SiStrip/ReadoutView/SpyMonitoringSummary")),
139  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms",false)),
140  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber",false)),
141  fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithLocalEventNumber",false)),
142  writeDQMStore_(iConfig.getUntrackedParameter<bool>("WriteDQMStore",false)),
143  dqmStoreFileName_(iConfig.getUntrackedParameter<std::string>("DQMStoreFileName","DQMStore.root")),
144  firstHeaderBit_(0),
145  firstTrailerBit_(0),
146  outfileNames_(iConfig.getUntrackedParameter<std::vector<std::string> >("OutputErrors")),
147  writeCabling_(iConfig.getUntrackedParameter<bool>("WriteCabling",false))
148 {
149 
150  evt_ = 0;
151  std::ostringstream pDebugStream;
152  histManager_.initialise(iConfig,&pDebugStream);
153  const unsigned int nFiles = outfileNames_.size();
154 
155  for (unsigned int i(0); i<nFiles; i++){
156  std::ostringstream lName;
157  lName << outfileNames_.at(i) << ".out";
158  if (i<20) outfile_[i].open(lName.str().c_str(),std::ios::out);
159  outfileMap_[outfileNames_.at(i)] = i;
160  }
161 
162  frameQuality_.minDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinDigiRange",100));
163  frameQuality_.maxDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxDigiRange",1024));
164  frameQuality_.minZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinZeroLight",0));
165  frameQuality_.maxZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxZeroLight",1024));
166  frameQuality_.minTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinTickHeight",0));
167  frameQuality_.maxTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxTickHeight",1024));
168 
169 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
void initialise(const edm::ParameterSet &iConfig, std::ostringstream *pDebugStream)
std::map< std::string, unsigned int > outfileMap_
sistrip::SpyUtilities::FrameQuality frameQuality_
std::vector< std::string > outfileNames_
tuple out
Definition: dbtoconf.py:99
SiStripSpyMonitorModule::~SiStripSpyMonitorModule ( )

Definition at line 171 of file SiStripSpyMonitorModule.cc.

References i, outfile_, outfileMap_, and outfileNames_.

172 {
173  const unsigned int nFiles = outfileNames_.size();
174  for (unsigned int i(0); i<nFiles; i++){
175  outfile_[i].close();
176  }
177 
178  outfileMap_.clear();
179  outfileNames_.clear();
180 
181 }
int i
Definition: DBlmapReader.cc:9
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 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 213 of file SiStripSpyMonitorModule.cc.

References sistrip::SpyUtilities::Frame::apvAddress, sistrip::SpyUtilities::Frame::apvErrorBit, FedChannelConnection::apvPairNumber(), SiStripFedCabling::connection(), FedChannelConnection::detId(), sistrip::SpyUtilities::Frame::digitalHigh, sistrip::SpyUtilities::Frame::digitalLow, alignCSCRings::e, edm::DetSetVector< T >::end(), edm::EventID::event(), evt_, sistrip::SpyUtilities::extractFrameInfo(), sistrip::FED_ID_MAX, sistrip::FED_ID_MIN, sistrip::FEDCH_PER_FED, SPYHistograms::fillCountersHistograms(), SPYHistograms::fillDetailedHistograms(), SPYHistograms::fillFEDHistograms(), fillWithLocalEvtNum_, edm::DetSetVector< T >::find(), create_complex_test_file0_cfg::firstEvent, sistrip::SpyUtilities::Frame::firstHeaderBit, firstHeaderBit_, sistrip::SpyUtilities::Frame::firstTrailerBit, firstTrailerBit_, frameQuality_, edm::Event::getByLabel(), 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_, 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, 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, dbtoconf::out, outfile_, outfileMap_, outfileNames_, edm::Handle< T >::product(), sistrip::SpyUtilities::range(), sistrip::SPY_SAMPLES_PER_CHANNEL, spyAPVeTag_, spyL1Tag_, spyPedSubtrDigisTag_, spyScopeRawDigisTag_, spyTotCountTag_, sistrip::STRIPS_PER_FEDCH, sistrip::SpyUtilities::threshold(), utility_, cms::Exception::what(), and writeCabling_.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 186 of file SiStripSpyMonitorModule.cc.

References SPYHistograms::bookAllFEDHistograms(), SPYHistograms::bookTopLevelHistograms(), dqm_, evt_, fillAllDetailedHistograms_, firstHeaderBit_, firstTrailerBit_, folderName_, histManager_, DQMStore::pwd(), and DQMStore::setCurrentFolder().

187 {
188 
189  //get DQM store
192 
193  LogInfo("SiStripSpyMonitorModule") << " Histograms will be written in "
194  << folderName_
195  << ". Current folder is : "
196  << dqm_->pwd()
197  << std::endl;
198 
199  //this propagates dqm_ to the histoclass, must be called !
201 
203 
204  evt_ = 0;
205  firstHeaderBit_ = 0;
206  firstTrailerBit_ = 0;
207 }
void bookAllFEDHistograms()
void bookTopLevelHistograms(DQMStore *dqm)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
const std::string & pwd(void) const
Definition: DQMStore.cc:406
void SiStripSpyMonitorModule::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 516 of file SiStripSpyMonitorModule.cc.

References dqm_, dqmStoreFileName_, i, outfile_, outfileMap_, outfileNames_, DQMStore::save(), and writeDQMStore_.

517 {
518 
519  LogInfo("SiStripSpyMonitorModule") << "WriteDQMStore ? " << writeDQMStore_
520  << " file name = " << dqmStoreFileName_
521  << std::endl;
523 
524  const unsigned int nFiles = outfileNames_.size();
525  for (unsigned int i(0); i<nFiles; i++){
526  outfile_[i].close();
527  }
528 
529  outfileMap_.clear();
530  outfileNames_.clear();
531 
532 }
int i
Definition: DBlmapReader.cc:9
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")
Definition: DQMStore.cc:2118
std::map< std::string, unsigned int > outfileMap_
std::vector< std::string > outfileNames_
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 588 of file SiStripSpyMonitorModule.cc.

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

Referenced by identifyTickmarks().

591 {
592  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
593  edm::DetSetVector<SiStripRawDigi>::detset::const_iterator lStart = channelDigis.begin()+aCounter;
594 
595  bool foundTrailer = false;
596  // Loop over digis looking for last two above threshold
597  uint8_t aboveThreshold = 0;
598 
599  for (; lStart != endChannelDigis; ++lStart) {
600  if ( lStart->adc() > threshold) {
601  aboveThreshold++;
602  }
603  else {
604  aboveThreshold = 0;
605  }
606  if (aboveThreshold == 2) {foundTrailer = true; break; }
607  aCounter++;
608  }//end of loop over digis
609 
610  if (foundTrailer) return lStart;
611  else {
613  return endChannelDigis;
614  }
615 }
iterator end()
Definition: DetSet.h:61
static const uint16_t SPY_SAMPLES_PER_CHANNEL
iterator begin()
Definition: DetSet.h:60
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
bool SiStripSpyMonitorModule::hasNegativePedSubtr ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
uint16_t  aPair 
)
private

Definition at line 536 of file SiStripSpyMonitorModule.cc.

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

Referenced by analyze().

538 {
540  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
541 
542  uint32_t count = 0;
543  for (; iDigi != endChannelDigis; ++iDigi) {
544  const uint16_t val = iDigi->adc();
545  uint16_t lPair = static_cast<uint16_t>(count/sistrip::STRIPS_PER_FEDCH);
546  if (val == 0 && lPair == aPair) return true;
547  count++;
548  }
549 
550  return false;
551 
552 }
iterator end()
Definition: DetSet.h:61
iterator begin()
Definition: DetSet.h:60
static const uint16_t STRIPS_PER_FEDCH
collection_type::const_iterator const_iterator
Definition: DetSet.h:34
bool SiStripSpyMonitorModule::identifyTickmarks ( const edm::DetSetVector< SiStripRawDigi >::detset &  channelDigis,
const uint16_t  threshold 
)
private

Definition at line 554 of file SiStripSpyMonitorModule.cc.

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

Referenced by analyze().

556 {
557 
558  //start from the end
560  uint16_t lastPos = sistrip::SPY_SAMPLES_PER_CHANNEL;
561  uint16_t nTrailers = 0;
563 
564  for ( ; count == 0; count--){
565  iDigi = findTwoConsecutive(channelDigis,threshold,count);
566  //if found, in different position = 70 before than previous value, go and look 70 before
567  if (iDigi != channelDigis.end() &&
568  (lastPos == sistrip::SPY_SAMPLES_PER_CHANNEL || count == lastPos+1-70)) {
569  nTrailers++;
570  lastPos = count-1;
571  count -= 70;
572  }
573  //else keep looking
574  else count--;
575  }
576 
577  if (nTrailers > 1) LogDebug("SiStripSpyMonitorModule") << " -- Found "
578  << nTrailers << " trailers every 70 clock cycles for channel "
579  << channelDigis.detId()
580  << ", evt " << evt_
581  << std::endl;
582  //if only one found, should be < 280 otherwise header should have been found and this method would not be called
583  return (nTrailers > 1) || (nTrailers == 1 && lastPos < 280);
584 
585 }
#define LogDebug(id)
iterator end()
Definition: DetSet.h:61
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:73
static const uint16_t SPY_SAMPLES_PER_CHANNEL
collection_type::const_iterator const_iterator
Definition: DetSet.h:34

Member Data Documentation

DQMStore* SiStripSpyMonitorModule::dqm_
private

Definition at line 95 of file SiStripSpyMonitorModule.cc.

Referenced by beginJob(), and endJob().

std::string SiStripSpyMonitorModule::dqmStoreFileName_
private

Definition at line 105 of file SiStripSpyMonitorModule.cc.

Referenced by endJob().

unsigned int SiStripSpyMonitorModule::evt_
private
bool SiStripSpyMonitorModule::fillAllDetailedHistograms_
private

Definition at line 99 of file SiStripSpyMonitorModule.cc.

Referenced by beginJob().

bool SiStripSpyMonitorModule::fillWithEvtNum_
private

Definition at line 101 of file SiStripSpyMonitorModule.cc.

bool SiStripSpyMonitorModule::fillWithLocalEvtNum_
private

Definition at line 102 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

uint16_t SiStripSpyMonitorModule::firstHeaderBit_
private

Definition at line 108 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and beginJob().

uint16_t SiStripSpyMonitorModule::firstTrailerBit_
private

Definition at line 109 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and beginJob().

std::string SiStripSpyMonitorModule::folderName_
private

Definition at line 97 of file SiStripSpyMonitorModule.cc.

Referenced by beginJob().

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

Definition at line 112 of file SiStripSpyMonitorModule.cc.

Referenced by analyze(), and SiStripSpyMonitorModule().

SPYHistograms SiStripSpyMonitorModule::histManager_
private

Definition at line 107 of file SiStripSpyMonitorModule.cc.

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

uint32_t SiStripSpyMonitorModule::maxDigiRange_
private

Definition at line 87 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::maxDigitalHigh_
private

Definition at line 91 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::maxDigitalLow_
private

Definition at line 89 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigiRange_
private

Definition at line 86 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigitalHigh_
private

Definition at line 90 of file SiStripSpyMonitorModule.cc.

uint32_t SiStripSpyMonitorModule::minDigitalLow_
private

Definition at line 88 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 84 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

edm::InputTag SiStripSpyMonitorModule::spyL1Tag_
private

Definition at line 82 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

edm::InputTag SiStripSpyMonitorModule::spyPedSubtrDigisTag_
private

Definition at line 79 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

edm::InputTag SiStripSpyMonitorModule::spyScopeRawDigisTag_
private

Definition at line 78 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

edm::InputTag SiStripSpyMonitorModule::spyTotCountTag_
private

Definition at line 83 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

sistrip::SpyUtilities SiStripSpyMonitorModule::utility_
private

Definition at line 111 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

bool SiStripSpyMonitorModule::writeCabling_
private

Definition at line 118 of file SiStripSpyMonitorModule.cc.

Referenced by analyze().

bool SiStripSpyMonitorModule::writeDQMStore_
private

Definition at line 104 of file SiStripSpyMonitorModule.cc.

Referenced by endJob().