CMS 3D CMS Logo

SiStripSpyMonitorModule.cc
Go to the documentation of this file.
1 // Original Author: Anne-Marie Magnan
2 // Created: 2010/01/11
3 //
4 
5 #include <sstream>
6 #include <memory>
7 #include <list>
8 #include <algorithm>
9 #include <cassert>
10 
21 
29 
34 
36 
37 // For plotting.
39 
43 
45 
46 //
47 // Class declaration
48 //
49 
51 public:
53  ~SiStripSpyMonitorModule() override;
54 
55 private:
56  void analyze(const edm::Event&, const edm::EventSetup&) override;
57  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
58  void dqmBeginRun(const edm::Run&, const edm::EventSetup&) override;
59 
60  //check if contains pedsubtr data = 0
61  bool hasNegativePedSubtr(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis, uint16_t aPair);
62 
63  bool identifyTickmarks(const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis, const uint16_t threshold);
64 
66  const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis, const uint16_t threshold, uint16_t& aCounter);
67 
68  //tag of spydata collection
71 
74 
75  //tag of l1A and apveAddress counters
79 
83 
84  uint32_t minDigiRange_;
85  uint32_t maxDigiRange_;
86  uint32_t minDigitalLow_;
87  uint32_t maxDigitalLow_;
88  uint32_t minDigitalHigh_;
89  uint32_t maxDigitalHigh_;
90 
92 
93  //folder name for histograms in DQMStore
95  //book detailed histograms even if they will be empty (for merging)
97  //do histos vs time with time=event number. Default time = orbit number (s)
100 
102  uint16_t firstHeaderBit_;
104 
106 
107  std::ofstream outfile_[20];
108  std::vector<std::string> outfileNames_;
109  std::map<std::string, unsigned int> outfileMap_;
110 
112 
117  void updateFedCabling(const SiStripFedCablingRcd& rcd);
118 };
119 
120 using edm::LogError;
121 using edm::LogInfo;
122 using edm::LogWarning;
123 //
124 // Constructors and destructor
125 //
126 
128  : spyScopeRawDigisTag_(iConfig.getUntrackedParameter<edm::InputTag>(
129  "SpyScopeRawDigisTag", edm::InputTag("SiStripSpyUnpacker", "ScopeRawDigis"))),
130  spyPedSubtrDigisTag_(
131  iConfig.getUntrackedParameter<edm::InputTag>("SpyPedSubtrDigisTag", edm::InputTag("SiStripFEDEmulator", ""))),
132  spyL1Tag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyL1Tag",
133  edm::InputTag("SiStripSpyDigiConverter", "L1ACount"))),
134  spyTotCountTag_(iConfig.getUntrackedParameter<edm::InputTag>(
135  "SpyTotalEventCountTag", edm::InputTag("SiStripSpyDigiConverter", "TotalEventCount"))),
136  spyAPVeTag_(iConfig.getUntrackedParameter<edm::InputTag>("SpyAPVeTag",
137  edm::InputTag("SiStripSpyDigiConverter", "APVAddress"))),
138  folderName_(iConfig.getUntrackedParameter<std::string>("HistogramFolderName",
139  "SiStrip/ReadoutView/SpyMonitoringSummary")),
140  fillAllDetailedHistograms_(iConfig.getUntrackedParameter<bool>("FillAllDetailedHistograms", false)),
141  fillWithEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithEventNumber", false)),
142  fillWithLocalEvtNum_(iConfig.getUntrackedParameter<bool>("FillWithLocalEventNumber", false)),
143  firstHeaderBit_(0),
144  firstTrailerBit_(0),
145  outfileNames_(iConfig.getUntrackedParameter<std::vector<std::string> >("OutputErrors")),
146  writeCabling_(iConfig.getUntrackedParameter<bool>("WriteCabling", false)),
147  tkDetMapToken_(esConsumes<edm::Transition::BeginRun>()),
148  fedCablingToken_(esConsumes<>()),
149  cablingWatcher_(this, &SiStripSpyMonitorModule::updateFedCabling) {
150  spyScopeRawDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyScopeRawDigisTag_);
151  spyPedSubtrDigisToken_ = consumes<edm::DetSetVector<SiStripRawDigi> >(spyPedSubtrDigisTag_);
152 
153  spyL1Token_ = consumes<std::vector<uint32_t> >(spyL1Tag_);
154  spyTotCountToken_ = consumes<std::vector<uint32_t> >(spyTotCountTag_);
155  spyAPVeToken_ = consumes<std::vector<uint32_t> >(spyAPVeTag_);
156 
157  evt_ = 0;
158  std::ostringstream pDebugStream;
159  histManager_.initialise(iConfig, &pDebugStream);
160  const unsigned int nFiles = outfileNames_.size();
161 
162  for (unsigned int i(0); i < nFiles; i++) {
163  std::ostringstream lName;
164  lName << outfileNames_.at(i) << ".out";
165  if (i < 20)
166  outfile_[i].open(lName.str().c_str(), std::ios::out);
167  outfileMap_[outfileNames_.at(i)] = i;
168  }
169 
170  frameQuality_.minDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinDigiRange", 100));
171  frameQuality_.maxDigiRange = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxDigiRange", 1024));
172  frameQuality_.minZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinZeroLight", 0));
173  frameQuality_.maxZeroLight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxZeroLight", 1024));
174  frameQuality_.minTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MinTickHeight", 0));
175  frameQuality_.maxTickHeight = static_cast<uint16_t>(iConfig.getUntrackedParameter<uint32_t>("MaxTickHeight", 1024));
176 }
177 
179  const unsigned int nFiles = outfileNames_.size();
180  for (unsigned int i(0); i < nFiles; i++) {
181  outfile_[i].close();
182  }
183 
184  outfileMap_.clear();
185  outfileNames_.clear();
186 }
187 
190 }
191 
193  evt_ = 0;
194  firstHeaderBit_ = 0;
195  firstTrailerBit_ = 0;
196 }
197 
199  const edm::Run& run,
200  const edm::EventSetup& eSetup) {
201  ibooker.setCurrentFolder(folderName_);
202 
203  LogInfo("SiStripSpyMonitorModule") << " Histograms will be written in " << folderName_
204  << ". Current folder is : " << ibooker.pwd() << std::endl;
205 
206  const auto tkDetMap = &eSetup.getData(tkDetMapToken_);
207  //this propagates dqm_ to the histoclass, must be called !
208  histManager_.bookTopLevelHistograms(ibooker, tkDetMap);
209 
212 
213  //dummy error object
214  SPYHistograms::Errors lError;
215  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId)
216  histManager_.bookFEDHistograms(ibooker, lFedId, lError, true);
217 }
218 
219 // ------------ method called to for each event ------------
221  //update cabling and pedestals
222  cablingWatcher_.check(iSetup);
223  if (evt_ == 0 && writeCabling_) {
224  std::ofstream lOutCabling;
225  lOutCabling.open("trackerDetId_FEDIdChNum_list.txt", std::ios::out);
226  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) { //loop on feds
227  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++) { //loop on channels
228  const FedChannelConnection& lConnection = fedCabling_->fedConnection(lFedId, lFedChannel);
229  if (!lConnection.isConnected())
230  continue;
231  uint32_t lDetId = lConnection.detId();
232  lOutCabling << "FED ID = " << lFedId << ", Channel = " << lFedChannel
233  << ",fedkey = " << sistrip::FEDCH_PER_FED * lFedId + lFedChannel << ", detId = " << lDetId
234  << std::endl;
235  }
236  }
237  lOutCabling.close();
238  }
239 
240  //For spy data
241  //get map of TotalEventCount and L1ID, indexed by fedId, and APVaddress indexed by fedIndex.
242  edm::Handle<std::vector<uint32_t> > lSpyL1IDHandle, lSpyTotCountHandle, lSpyAPVeHandle;
243  try {
244  iEvent.getByToken(spyL1Token_, lSpyL1IDHandle);
245  iEvent.getByToken(spyTotCountToken_, lSpyTotCountHandle);
246  iEvent.getByToken(spyAPVeToken_, lSpyAPVeHandle);
247  } catch (const cms::Exception& e) {
248  LogError("SiStripSpyMonitorModule") << e.what();
249  return;
250  }
251  //const std::map<uint32_t,uint32_t> & lSpyMaxCountMap = *lSpyL1IDHandle;
252  //const std::map<uint32_t,uint32_t> & lSpyMinCountMap = *lSpyTotCountHandle;
253  const std::vector<uint32_t>& lSpyAPVeVec = *lSpyAPVeHandle;
254 
255  //retrieve the scope digis
257  try {
258  iEvent.getByToken(spyScopeRawDigisToken_, digisHandle);
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.getByToken(spyPedSubtrDigisToken_, payloadHandle);
269  } catch (const cms::Exception& e) {
270  LogError("SiStripSpyMonitorModule") << e.what();
271  return;
272  }
273  const edm::DetSetVector<SiStripRawDigi>* lPayloadDigis = payloadHandle.product();
274 
275  //for first event only
276  //loop first on channels to calculate majority value of when the first header bit is found.
277  //output info message to give the value found
278  //should currently be 6 but may vary in the futur
279  //then we can check firstTrailerBit is +256+24 after
280 
281  if (evt_ == 0) {
284  }
285 
286  //initialise some counters, filled in histos eventually
288  lCounters.nNoData = 0;
289  lCounters.nLowRange = 0;
290  lCounters.nHighRange = 0;
291  lCounters.nMinZero = 0;
292  lCounters.nMaxSat = 0;
293  lCounters.nLowPb = 0;
294  lCounters.nHighPb = 0;
295  lCounters.nOOS = 0;
296  lCounters.nOtherPbs = 0;
297  lCounters.nAPVError = 0;
298  lCounters.nAPVAddressError = 0;
299  lCounters.nNegPeds = 0;
300 
301  //fill event number for output text files
302  const unsigned int nFiles = outfileNames_.size();
303  for (unsigned int i(0); i < nFiles; i++) {
304  outfile_[i] << "**** evt " << iEvent.id().event() << " ****" << std::endl;
305  }
306 
307  //loop over all FEDs and channels
308 
309  for (uint16_t lFedId = sistrip::FED_ID_MIN; lFedId <= sistrip::FED_ID_MAX; ++lFedId) { //loop on feds
310 
311  SPYHistograms::Errors lFEDErrors;
312  lFEDErrors.hasNoData = false;
313  lFEDErrors.hasLowRange = false;
314  lFEDErrors.hasHighRange = false;
315  lFEDErrors.hasMinZero = false;
316  lFEDErrors.hasMaxSat = false;
317  lFEDErrors.hasLowPb = false;
318  lFEDErrors.hasHighPb = false;
319  lFEDErrors.hasOOS = false;
320  lFEDErrors.hasOtherPbs = false;
321  lFEDErrors.hasErrorBit0 = false;
322  lFEDErrors.hasErrorBit1 = false;
323  lFEDErrors.hasAPVAddressError0 = false;
324  lFEDErrors.hasAPVAddressError1 = false;
325  lFEDErrors.hasNegPeds = false;
326 
327  uint32_t lAPVAddrRef = lSpyAPVeVec.at(lFedId);
328 
329  for (uint16_t lFedChannel = 0; lFedChannel < sistrip::FEDCH_PER_FED; lFedChannel++) { //loop on channels
330 
331  uint32_t lFedIndex = sistrip::FEDCH_PER_FED * lFedId + lFedChannel;
332 
333  const FedChannelConnection& lConnection = fedCabling_->fedConnection(lFedId, lFedChannel);
334 
335  if (!lConnection.isConnected())
336  continue;
337 
338  uint32_t lDetId = lConnection.detId();
339  //uint16_t lNPairs = lConnection.nApvPairs();
340  uint16_t lPair = lConnection.apvPairNumber();
341 
342  edm::DetSetVector<SiStripRawDigi>::const_iterator lDigis = lInputDigis->find(lFedIndex);
343 
344  //pedsubtr digis
345  edm::DetSetVector<SiStripRawDigi>::const_iterator lPayload = lPayloadDigis->find(lDetId);
346 
347  //no digis found, continue.
348  if (lDigis == lInputDigis->end()) {
349  LogDebug("SiStripSpyMonitorModule") << " -- digis not found in ScopeRawDigis map for FEDID " << lFedId
350  << " and FED channel " << lFedChannel << std::endl;
351  continue;
352  }
353 
355 
356  SPYHistograms::Errors lErrors;
357  lErrors.hasNoData = false;
358  lErrors.hasLowRange = false;
359  lErrors.hasHighRange = false;
360  lErrors.hasMinZero = false;
361  lErrors.hasMaxSat = false;
362  lErrors.hasLowPb = false;
363  lErrors.hasHighPb = false;
364  lErrors.hasOOS = false;
365  lErrors.hasOtherPbs = false;
366  lErrors.hasErrorBit0 = false;
367  lErrors.hasErrorBit1 = false;
368  lErrors.hasAPVAddressError0 = false;
369  lErrors.hasAPVAddressError1 = false;
370  lErrors.hasNegPeds = false;
371 
372  uint16_t lRange = sistrip::SpyUtilities::range(lFrame);
373  uint16_t lThreshold = sistrip::SpyUtilities::threshold(lFrame);
374 
375  if (lRange == 0) {
376  lCounters.nNoData++;
377  lErrors.hasNoData = true;
378  lFEDErrors.hasNoData = true;
379  if (outfileMap_.find("NoData") != outfileMap_.end())
380  outfile_[outfileMap_["NoData"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
381  } else if (lFrame.digitalLow == 0 && lRange > 0) {
382  lCounters.nMinZero++;
383  lErrors.hasMinZero = true;
384  lFEDErrors.hasMinZero = true;
385  if (outfileMap_.find("MinZero") != outfileMap_.end())
386  outfile_[outfileMap_["MinZero"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
387  } else if (lFrame.digitalHigh >= 1023) {
388  lCounters.nMaxSat++;
389  lErrors.hasMaxSat = true;
390  lFEDErrors.hasMaxSat = true;
391  if (outfileMap_.find("MaxSat") != outfileMap_.end())
392  outfile_[outfileMap_["MaxSat"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
393  } else if (lRange > 0 && lRange < frameQuality_.minDigiRange) {
394  lCounters.nLowRange++;
395  lErrors.hasLowRange = true;
396  lFEDErrors.hasLowRange = true;
397  if (outfileMap_.find("LowRange") != outfileMap_.end())
398  outfile_[outfileMap_["LowRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
399  } else if (lRange > frameQuality_.maxDigiRange) {
400  lCounters.nHighRange++;
401  lErrors.hasHighRange = true;
402  lFEDErrors.hasHighRange = true;
403  if (outfileMap_.find("HighRange") != outfileMap_.end())
404  outfile_[outfileMap_["HighRange"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
405  } else if (lFrame.digitalLow < frameQuality_.minZeroLight || lFrame.digitalLow > frameQuality_.maxZeroLight) {
406  lCounters.nLowPb++;
407  lErrors.hasLowPb = true;
408  lFEDErrors.hasLowPb = true;
409  if (outfileMap_.find("LowPb") != outfileMap_.end())
410  outfile_[outfileMap_["LowPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
412  lCounters.nHighPb++;
413  lErrors.hasHighPb = true;
414  lFEDErrors.hasHighPb = true;
415  if (outfileMap_.find("HighPb") != outfileMap_.end())
416  outfile_[outfileMap_["HighPb"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
417  } else if (lFrame.firstHeaderBit != firstHeaderBit_ && //header in wrong position
418  ((lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //header and
419  lFrame.firstTrailerBit != sistrip::SPY_SAMPLES_PER_CHANNEL && //trailer found
420  lFrame.firstTrailerBit - lFrame.firstHeaderBit == 280) || //+ right distance between them
421  (lFrame.firstHeaderBit != sistrip::SPY_SAMPLES_PER_CHANNEL && // or header found
422  lFrame.firstTrailerBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // and trailer not found
423  lFrame.firstHeaderBit > 16) || // corresponding to back-to-back frame late enough
424  (lFrame.firstHeaderBit == sistrip::SPY_SAMPLES_PER_CHANNEL && // or header not found
425  identifyTickmarks(*lDigis, lThreshold)) // but such that tickmark compatible with OOS frame
426  )) {
427  lCounters.nOOS++;
428  lErrors.hasOOS = true;
429  lFEDErrors.hasOOS = true;
430  if (outfileMap_.find("OOS") != outfileMap_.end())
431  outfile_[outfileMap_["OOS"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
432  } else if (!(lFrame.firstHeaderBit == firstHeaderBit_ && lFrame.firstTrailerBit == firstTrailerBit_)) {
433  lCounters.nOtherPbs++;
434  lErrors.hasOtherPbs = true;
435  lFEDErrors.hasOtherPbs = true;
436  if (outfileMap_.find("OtherPbs") != outfileMap_.end())
437  outfile_[outfileMap_["OtherPbs"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
438  } else if (lFrame.apvErrorBit.first || lFrame.apvErrorBit.second) {
439  if (lFrame.apvErrorBit.first) {
440  lCounters.nAPVError++;
441  lErrors.hasErrorBit0 = true;
442  lFEDErrors.hasErrorBit0 = true;
443  }
444  if (lFrame.apvErrorBit.second) {
445  lCounters.nAPVError++;
446  lErrors.hasErrorBit1 = true;
447  lFEDErrors.hasErrorBit1 = true;
448  }
449  if (outfileMap_.find("APVError") != outfileMap_.end()) {
450  outfile_[outfileMap_["APVError"]] << lFedId << " " << lFedChannel << " " << lDetId;
451  if (lFrame.apvErrorBit.first)
452  outfile_[outfileMap_["APVError"]] << " APV0" << std::endl;
453  if (lFrame.apvErrorBit.second)
454  outfile_[outfileMap_["APVError"]] << " APV1" << std::endl;
455  }
456  } else if (lFrame.apvAddress.first != lAPVAddrRef || lFrame.apvAddress.second != lAPVAddrRef) {
457  if (lFrame.apvAddress.first != lAPVAddrRef) {
458  lCounters.nAPVAddressError++;
459  lErrors.hasAPVAddressError0 = true;
460  lFEDErrors.hasAPVAddressError0 = true;
461  }
462  if (lFrame.apvAddress.second != lAPVAddrRef) {
463  lCounters.nAPVAddressError++;
464  lErrors.hasAPVAddressError1 = true;
465  lFEDErrors.hasAPVAddressError1 = true;
466  }
467  if (outfileMap_.find("APVAddressError") != outfileMap_.end()) {
468  outfile_[outfileMap_["APVAddressError"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
469  if (lFrame.apvAddress.first != lAPVAddrRef)
470  outfile_[outfileMap_["APVAddressError"]] << " APV0" << std::endl;
471  if (lFrame.apvAddress.second != lAPVAddrRef)
472  outfile_[outfileMap_["APVAddressError"]] << " APV1" << std::endl;
473  }
474  } else if (lPayload != lPayloadDigis->end() && hasNegativePedSubtr(*lPayload, lPair)) {
475  lCounters.nNegPeds++;
476  lErrors.hasNegPeds = true;
477  lFEDErrors.hasNegPeds = true;
478  if (outfileMap_.find("NegPeds") != outfileMap_.end())
479  outfile_[outfileMap_["NegPeds"]] << lFedId << " " << lFedChannel << " " << lDetId << std::endl;
480  }
481 
482  histManager_.fillDetailedHistograms(lErrors, lFrame, lFedId, lFedChannel);
483 
484  } //loop on channels
485 
486  histManager_.fillFEDHistograms(lFEDErrors, lFedId);
487 
488  } //loop on feds
489 
490  double lTime;
491  //if (fillWithEvtNum_)
492  //lTime = iEvent.id().event();
493  //else if (fillWithLocalEvtNum_) lTime = evt_;
494  //no orbit number for spy data !!
495  //else lTime = iEvent.orbitNumber()/11223.;
496  if (fillWithLocalEvtNum_) {
497  // casting from unsigned long long to a double here
498  // doing it explicitely
499  lTime = static_cast<double>(evt_);
500  } else {
501  // casting from unsigned long long to a double here
502  // doing it explicitely
503  lTime = static_cast<double>(iEvent.id().event());
504  }
505 
506  histManager_.fillCountersHistograms(lCounters, lTime);
507 
508  //used to fill histo vs time with local event number....
509  evt_++;
510 
511 } //analyze method
512 
514  uint16_t aPair) {
516  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
517 
518  uint32_t count = 0;
519  for (; iDigi != endChannelDigis; ++iDigi) {
520  const uint16_t val = iDigi->adc();
521  uint16_t lPair = static_cast<uint16_t>(count / sistrip::STRIPS_PER_FEDCH);
522  if (val == 0 && lPair == aPair)
523  return true;
524  count++;
525  }
526 
527  return false;
528 }
529 
531  const uint16_t threshold) {
532  //start from the end
534  uint16_t lastPos = sistrip::SPY_SAMPLES_PER_CHANNEL;
535  uint16_t nTrailers = 0;
537 
538  for (; count == 0; count--) {
539  iDigi = findTwoConsecutive(channelDigis, threshold, count);
540  //if found, in different position = 70 before than previous value, go and look 70 before
541  if (iDigi != channelDigis.end() && (lastPos == sistrip::SPY_SAMPLES_PER_CHANNEL || count == lastPos + 1 - 70)) {
542  nTrailers++;
543  lastPos = count - 1;
544  count -= 70;
545  }
546  //else keep looking
547  else
548  count--;
549  }
550 
551  if (nTrailers > 1)
552  LogDebug("SiStripSpyMonitorModule") << " -- Found " << nTrailers << " trailers every 70 clock cycles for channel "
553  << channelDigis.detId() << ", evt " << evt_ << std::endl;
554  //if only one found, should be < 280 otherwise header should have been found and this method would not be called
555  return (nTrailers > 1) || (nTrailers == 1 && lastPos < 280);
556 }
557 
559  const edm::DetSetVector<SiStripRawDigi>::detset& channelDigis, const uint16_t threshold, uint16_t& aCounter) {
560  const edm::DetSetVector<SiStripRawDigi>::detset::const_iterator endChannelDigis = channelDigis.end();
561  edm::DetSetVector<SiStripRawDigi>::detset::const_iterator lStart = channelDigis.begin() + aCounter;
562 
563  bool foundTrailer = false;
564  // Loop over digis looking for last two above threshold
565  uint8_t aboveThreshold = 0;
566 
567  for (; lStart != endChannelDigis; ++lStart) {
568  if (lStart->adc() > threshold) {
569  aboveThreshold++;
570  } else {
571  aboveThreshold = 0;
572  }
573  if (aboveThreshold == 2) {
574  foundTrailer = true;
575  break;
576  }
577  aCounter++;
578  } //end of loop over digis
579 
580  if (foundTrailer)
581  return lStart;
582  else {
584  return endChannelDigis;
585  }
586 }
587 
588 //
589 // Define as a plug-in
590 //
591 
SiStripSpyMonitorModule::spyL1Tag_
edm::InputTag spyL1Tag_
Definition: SiStripSpyMonitorModule.cc:76
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
FEDNumbering.h
edm::DetSetVector< SiStripRawDigi >
SiStripSpyMonitorModule::spyTotCountToken_
edm::EDGetTokenT< std::vector< uint32_t > > spyTotCountToken_
Definition: SiStripSpyMonitorModule.cc:81
SPYHistograms::ErrorCounters::nHighPb
unsigned int nHighPb
Definition: SPYHistograms.h:26
SPYHistograms::ErrorCounters::nOOS
unsigned int nOOS
Definition: SPYHistograms.h:27
sistrip::SpyUtilities::extractFrameInfo
const Frame extractFrameInfo(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, bool aPrintDebug=false)
Definition: SiStripSpyUtilities.cc:11
electrons_cff.bool
bool
Definition: electrons_cff.py:366
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
SiStripSpyMonitorModule::findTwoConsecutive
edm::DetSetVector< SiStripRawDigi >::detset::const_iterator findTwoConsecutive(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold, uint16_t &aCounter)
Definition: SiStripSpyMonitorModule.cc:558
funct::false
false
Definition: Factorize.h:29
sistrip::SpyUtilities::Frame::firstTrailerBit
uint16_t firstTrailerBit
Definition: SiStripSpyUtilities.h:25
SiStripSpyMonitorModule::tkDetMapToken_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
Definition: SiStripSpyMonitorModule.cc:113
edm::Handle::product
T const * product() const
Definition: Handle.h:70
SPYHistograms::Errors::hasAPVAddressError1
bool hasAPVAddressError1
Definition: SPYHistograms.h:50
edm::ESWatcher< SiStripFedCablingRcd >
edm::DetSetVector::end
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:325
sistrip::SpyUtilities::Frame::digitalLow
uint16_t digitalLow
Definition: SiStripSpyUtilities.h:22
SPYHistograms::ErrorCounters::nOtherPbs
unsigned int nOtherPbs
Definition: SPYHistograms.h:30
edm::DetSet
Definition: DetSet.h:23
SiStripSpyMonitorModule::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: SiStripSpyMonitorModule.cc:220
edm::Run
Definition: Run.h:45
SPYHistograms::ErrorCounters::nMaxSat
unsigned int nMaxSat
Definition: SPYHistograms.h:24
SiStripSpyMonitorModule::maxDigiRange_
uint32_t maxDigiRange_
Definition: SiStripSpyMonitorModule.cc:85
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripSpyMonitorModule::firstHeaderBit_
uint16_t firstHeaderBit_
Definition: SiStripSpyMonitorModule.cc:102
SiStripSpyMonitorModule::dqmBeginRun
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: SiStripSpyMonitorModule.cc:192
SiStripSpyMonitorModule::fillAllDetailedHistograms_
bool fillAllDetailedHistograms_
Definition: SiStripSpyMonitorModule.cc:96
SPYHistograms::ErrorCounters
Definition: SPYHistograms.h:19
SiStripRawDigi.h
SPYHistograms::ErrorCounters::nAPVError
unsigned int nAPVError
Definition: SPYHistograms.h:31
SiStripSpyMonitorModule::updateFedCabling
void updateFedCabling(const SiStripFedCablingRcd &rcd)
Definition: SiStripSpyMonitorModule.cc:188
sistrip::SpyUtilities::FrameQuality
Definition: SiStripSpyUtilities.h:31
edm::DetSet::begin
iterator begin()
Definition: DetSet.h:57
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
SiStripSpyMonitorModule::SiStripSpyMonitorModule
SiStripSpyMonitorModule(const edm::ParameterSet &)
Definition: SiStripSpyMonitorModule.cc:127
SiStripFedCabling.h
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
SiStripSpyMonitorModule::identifyTickmarks
bool identifyTickmarks(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, const uint16_t threshold)
Definition: SiStripSpyMonitorModule.cc:530
SiStripSpyMonitorModule::maxDigitalHigh_
uint32_t maxDigitalHigh_
Definition: SiStripSpyMonitorModule.cc:89
sistrip::SpyUtilities::Frame::apvAddress
std::pair< uint8_t, uint8_t > apvAddress
Definition: SiStripSpyUtilities.h:28
sistrip::SpyUtilities::getMajorityHeader
void getMajorityHeader(const edm::DetSetVector< SiStripRawDigi > *aInputDigis, uint16_t &firstHeaderBit, bool printResult=true)
Definition: SiStripSpyUtilities.cc:97
DQMStore.h
SPYHistograms::ErrorCounters::nAPVAddressError
unsigned int nAPVAddressError
Definition: SPYHistograms.h:32
SiStripFedCabling::fedConnection
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
Definition: SiStripFedCabling.cc:171
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
sistrip::FED_ID_MIN
static const uint16_t FED_ID_MIN
Definition: ConstantsForHardwareSystems.h:21
SPYHistograms::fillCountersHistograms
void fillCountersHistograms(const ErrorCounters &aCounter, const double aTime)
Definition: SPYHistograms.cc:86
SiStripSpyMonitorModule::minDigitalLow_
uint32_t minDigitalLow_
Definition: SiStripSpyMonitorModule.cc:86
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
ConstantsForHardwareSystems.h
Constants and enumerated types for FED/FEC systems.
SiStripFedCabling
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
Definition: SiStripFedCabling.h:25
FEDRawData.h
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SPYHistograms::Errors::hasAPVAddressError0
bool hasAPVAddressError0
Definition: SPYHistograms.h:49
SiStripSpyUtilities.h
SiStripSpyMonitorModule::fillWithEvtNum_
bool fillWithEvtNum_
Definition: SiStripSpyMonitorModule.cc:98
SPYHistograms::bookTopLevelHistograms
void bookTopLevelHistograms(DQMStore::IBooker &, const TkDetMap *)
Definition: SPYHistograms.cc:227
SiStripSpyMonitorModule::outfileMap_
std::map< std::string, unsigned int > outfileMap_
Definition: SiStripSpyMonitorModule.cc:109
SiStripSpyMonitorModule::spyAPVeToken_
edm::EDGetTokenT< std::vector< uint32_t > > spyAPVeToken_
Definition: SiStripSpyMonitorModule.cc:82
SiStripSpyMonitorModule::hasNegativePedSubtr
bool hasNegativePedSubtr(const edm::DetSetVector< SiStripRawDigi >::detset &channelDigis, uint16_t aPair)
Definition: SiStripSpyMonitorModule.cc:513
SPYHistograms::ErrorCounters::nLowRange
unsigned int nLowRange
Definition: SPYHistograms.h:21
SPYHistograms::Errors::hasNoData
bool hasNoData
Definition: SPYHistograms.h:38
MakerMacros.h
SiStripFedCablingRcd
Definition: SiStripCondDataRecords.h:22
SPYHistograms::Errors::hasNegPeds
bool hasNegPeds
Definition: SPYHistograms.h:51
SiStripSpyMonitorModule::minDigiRange_
uint32_t minDigiRange_
Definition: SiStripSpyMonitorModule.cc:84
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
sistrip::SPY_SAMPLES_PER_CHANNEL
static const uint16_t SPY_SAMPLES_PER_CHANNEL
Definition: SiStripFEDSpyBuffer.h:23
SPYHistograms::bookAllFEDHistograms
void bookAllFEDHistograms(DQMStore::IBooker &)
Definition: SPYHistograms.cc:680
SiStripSpyMonitorModule
Definition: SiStripSpyMonitorModule.cc:50
SiStripSpyMonitorModule::histManager_
SPYHistograms histManager_
Definition: SiStripSpyMonitorModule.cc:101
SiStripFEDBuffer.h
Service.h
SiStripSpyMonitorModule::spyPedSubtrDigisToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyPedSubtrDigisToken_
Definition: SiStripSpyMonitorModule.cc:73
SiStripSpyMonitorModule::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: SiStripSpyMonitorModule.cc:198
SiStripPedestalsRcd.h
SiStripSpyMonitorModule::maxDigitalLow_
uint32_t maxDigitalLow_
Definition: SiStripSpyMonitorModule.cc:87
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
SPYHistograms::Errors::hasLowPb
bool hasLowPb
Definition: SPYHistograms.h:43
SPYHistograms::Errors::hasOOS
bool hasOOS
Definition: SPYHistograms.h:45
SPYHistograms::Errors::hasHighPb
bool hasHighPb
Definition: SPYHistograms.h:44
EDGetToken.h
dqm::implementation::NavigatorBase::pwd
virtual std::string pwd()
Definition: DQMStore.cc:16
simpleEdmComparison.lName
lName
Definition: simpleEdmComparison.py:125
SPYHistograms::Errors
Definition: SPYHistograms.h:37
SPYHistograms::ErrorCounters::nLowPb
unsigned int nLowPb
Definition: SPYHistograms.h:25
SiStripSpyMonitorModule::outfileNames_
std::vector< std::string > outfileNames_
Definition: SiStripSpyMonitorModule.cc:108
DQMEDAnalyzer.h
SiStripSpyMonitorModule::frameQuality_
sistrip::SpyUtilities::FrameQuality frameQuality_
Definition: SiStripSpyMonitorModule.cc:105
SPYHistograms::Errors::hasMaxSat
bool hasMaxSat
Definition: SPYHistograms.h:42
SPYHistograms::Errors::hasErrorBit1
bool hasErrorBit1
Definition: SPYHistograms.h:48
DQMEDAnalyzer
Definition: DQMEDAnalyzer.py:1
FedChannelConnection
Class containning control, module, detector and connection information, at the level of a FED channel...
Definition: FedChannelConnection.h:26
SPYHistograms::fillDetailedHistograms
void fillDetailedHistograms(const Errors &aErr, const sistrip::SpyUtilities::Frame &aFrame, const unsigned int aFedId, const unsigned int aFedChannel)
Definition: SPYHistograms.cc:158
FedChannelConnection::isConnected
bool isConnected() const
Definition: FedChannelConnection.h:197
SPYHistograms::ErrorCounters::nMinZero
unsigned int nMinZero
Definition: SPYHistograms.h:23
FedChannelConnection::detId
const uint32_t & detId() const
Definition: FedChannelConnection.h:213
SiStripFedKey.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
SiStripSpyMonitorModule::spyScopeRawDigisToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > spyScopeRawDigisToken_
Definition: SiStripSpyMonitorModule.cc:72
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
Event.h
SiStripSpyMonitorModule::fedCablingToken_
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
Definition: SiStripSpyMonitorModule.cc:114
edm::DetSetVector::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSetVector.h:102
sistrip::STRIPS_PER_FEDCH
static const uint16_t STRIPS_PER_FEDCH
Definition: ConstantsForHardwareSystems.h:44
SPYHistograms::ErrorCounters::nNegPeds
unsigned int nNegPeds
Definition: SPYHistograms.h:33
SPYHistograms::ErrorCounters::nHighRange
unsigned int nHighRange
Definition: SPYHistograms.h:22
SiStripSpyMonitorModule::cablingWatcher_
edm::ESWatcher< SiStripFedCablingRcd > cablingWatcher_
Definition: SiStripSpyMonitorModule.cc:116
edm::DetSetVector::find
iterator find(det_id_type id)
Definition: DetSetVector.h:264
iEvent
int iEvent
Definition: GenABIO.cc:224
SiStripSpyMonitorModule::spyTotCountTag_
edm::InputTag spyTotCountTag_
Definition: SiStripSpyMonitorModule.cc:77
SPYHistograms::Errors::hasHighRange
bool hasHighRange
Definition: SPYHistograms.h:40
FEDRawDataCollection.h
SPYHistograms::ErrorCounters::nNoData
unsigned int nNoData
Definition: SPYHistograms.h:20
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
SPYHistograms.h
SiStripSpyMonitorModule::spyAPVeTag_
edm::InputTag spyAPVeTag_
Definition: SiStripSpyMonitorModule.cc:78
edm::EventSetup
Definition: EventSetup.h:58
edm::DetSet::detId
det_id_type detId() const
Definition: DetSet.h:74
DetSetVector.h
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
SiStripSpyMonitorModule::spyPedSubtrDigisTag_
edm::InputTag spyPedSubtrDigisTag_
Definition: SiStripSpyMonitorModule.cc:70
sistrip::SpyUtilities::FrameQuality::maxTickHeight
uint16_t maxTickHeight
Definition: SiStripSpyUtilities.h:37
edm::ESGetToken< TkDetMap, TrackerTopologyRcd >
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
sistrip::FED_ID_MAX
static const uint16_t FED_ID_MAX
Definition: ConstantsForHardwareSystems.h:22
sistrip::SpyUtilities::FrameQuality::minZeroLight
uint16_t minZeroLight
Definition: SiStripSpyUtilities.h:34
InputTag.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
alignCSCRings.r
r
Definition: alignCSCRings.py:93
SiStripSpyMonitorModule::~SiStripSpyMonitorModule
~SiStripSpyMonitorModule() override
Definition: SiStripSpyMonitorModule.cc:178
SiStripSpyMonitorModule::outfile_
std::ofstream outfile_[20]
Definition: SiStripSpyMonitorModule.cc:107
SiStripSpyMonitorModule::writeCabling_
bool writeCabling_
Definition: SiStripSpyMonitorModule.cc:111
SPYHistograms::Errors::hasLowRange
bool hasLowRange
Definition: SPYHistograms.h:39
sistrip::SpyUtilities::Frame::firstHeaderBit
uint16_t firstHeaderBit
Definition: SiStripSpyUtilities.h:24
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
sistrip::SpyUtilities::threshold
const uint16_t threshold(const Frame &aFrame)
Definition: SiStripSpyUtilities.cc:83
sistrip::SpyUtilities::FrameQuality::minDigiRange
uint16_t minDigiRange
Definition: SiStripSpyUtilities.h:32
Frameworkfwd.h
ESWatcher.h
SiStripSpyMonitorModule::folderName_
std::string folderName_
Definition: SiStripSpyMonitorModule.cc:94
SiStripSpyMonitorModule::evt_
edm::EventNumber_t evt_
Definition: SiStripSpyMonitorModule.cc:91
SPYHistograms::Errors::hasErrorBit0
bool hasErrorBit0
Definition: SPYHistograms.h:47
sistrip::SpyUtilities::Frame::digitalHigh
uint16_t digitalHigh
Definition: SiStripSpyUtilities.h:23
SiStripSpyMonitorModule::minDigitalHigh_
uint32_t minDigitalHigh_
Definition: SiStripSpyMonitorModule.cc:88
SiStripPedestals.h
cmsBatch.nFiles
nFiles
Definition: cmsBatch.py:308
SPYHistograms::fillFEDHistograms
void fillFEDHistograms(const Errors &aErr, const unsigned int aFedId)
Definition: SPYHistograms.cc:114
sistrip::SpyUtilities::Frame::apvErrorBit
std::pair< bool, bool > apvErrorBit
Definition: SiStripSpyUtilities.h:27
EventSetup.h
SiStripSpyMonitorModule::fillWithLocalEvtNum_
bool fillWithLocalEvtNum_
Definition: SiStripSpyMonitorModule.cc:99
Exception.h
SiStripFedCablingRcd.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
SPYHistograms::bookFEDHistograms
void bookFEDHistograms(DQMStore::IBooker &, const unsigned int fedId, const Errors &aErr, bool doAll=false)
Definition: SPYHistograms.cc:503
sistrip::FEDCH_PER_FED
static const uint16_t FEDCH_PER_FED
Definition: ConstantsForHardwareSystems.h:30
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
FedChannelConnection::apvPairNumber
uint16_t apvPairNumber() const
Definition: FedChannelConnection.h:230
edm::eventsetup::EventSetupRecordImplementation::get
PRODUCT const & get(ESGetToken< PRODUCT, T > const &iToken) const
Definition: EventSetupRecordImplementation.h:74
SPYHistograms::initialise
void initialise(const edm::ParameterSet &iConfig, std::ostringstream *pDebugStream) override
Definition: SPYHistograms.cc:17
cms::Exception
Definition: Exception.h:70
SiStripSpyMonitorModule::spyL1Token_
edm::EDGetTokenT< std::vector< uint32_t > > spyL1Token_
Definition: SiStripSpyMonitorModule.cc:80
edm::DetSet::end
iterator end()
Definition: DetSet.h:58
sistrip::SpyUtilities::Frame
Definition: SiStripSpyUtilities.h:20
ParameterSet.h
SiStripSpyMonitorModule::spyScopeRawDigisTag_
edm::InputTag spyScopeRawDigisTag_
Definition: SiStripSpyMonitorModule.cc:69
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
SPYHistograms
Definition: SPYHistograms.h:13
sistrip::SpyUtilities::FrameQuality::maxZeroLight
uint16_t maxZeroLight
Definition: SiStripSpyUtilities.h:35
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:430
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::Event
Definition: Event.h:73
sistrip::SpyUtilities::FrameQuality::maxDigiRange
uint16_t maxDigiRange
Definition: SiStripSpyUtilities.h:33
SiStripFEDSpyBuffer.h
SiStripSpyMonitorModule::fedCabling_
const SiStripFedCabling * fedCabling_
Definition: SiStripSpyMonitorModule.cc:115
SPYHistograms::Errors::hasMinZero
bool hasMinZero
Definition: SPYHistograms.h:41
SiStripSpyMonitorModule::firstTrailerBit_
uint16_t firstTrailerBit_
Definition: SiStripSpyMonitorModule.cc:103
edm::InputTag
Definition: InputTag.h:15
sistrip::SpyUtilities::FrameQuality::minTickHeight
uint16_t minTickHeight
Definition: SiStripSpyUtilities.h:36
SPYHistograms::Errors::hasOtherPbs
bool hasOtherPbs
Definition: SPYHistograms.h:46
sistrip::SpyUtilities::range
const uint16_t range(const Frame &aFrame)
Definition: SiStripSpyUtilities.cc:76
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::DetSet::const_iterator
collection_type::const_iterator const_iterator
Definition: DetSet.h:31